63 } trace_env = {
NULL };
72 trace_env.sample->fp =
fp;
74 trace_env.sample->sp =
75 reinterpret_cast<Address>(trace_env.sample) - 10240;
76 StackTracer::Trace(Isolate::Current(), trace_env.sample);
82 static void DoTraceHideCEntryFPAddress(
Address fp) {
84 *(Isolate::Current()->c_entry_fp_address());
85 CHECK(saved_c_frame_fp);
86 *(Isolate::Current()->c_entry_fp_address()) = 0;
88 *(Isolate::Current()->c_entry_fp_address()) = saved_c_frame_fp;
105 static const char* kSource;
109 const char* TraceExtension::kSource =
110 "native function trace();"
111 "native function js_trace();"
112 "native function js_entry_sp();"
113 "native function js_entry_sp_level2();";
117 if (name->
Equals(String::New(
"trace"))) {
119 }
else if (name->
Equals(String::New(
"js_trace"))) {
121 }
else if (name->
Equals(String::New(
"js_entry_sp"))) {
123 }
else if (name->
Equals(String::New(
"js_entry_sp_level2"))) {
135 #if defined(V8_HOST_ARCH_32_BIT)
137 #elif defined(V8_HOST_ARCH_64_BIT)
138 int64_t low_bits = *
reinterpret_cast<uint64_t*
>(*args[0]) >> 32;
139 int64_t high_bits = *
reinterpret_cast<uint64_t*
>(*args[1]);
142 #error Host architecture is neither 32-bit nor 64-bit.
144 printf(
"Trace: %p\n", fp);
150 DoTrace(GetFP(args));
156 DoTraceHideCEntryFPAddress(GetFP(args));
161 static Address GetJsEntrySp() {
162 CHECK_NE(
NULL, i::Isolate::Current()->thread_local_top());
163 return Isolate::js_entry_sp(i::Isolate::Current()->thread_local_top());
176 const Address js_entry_sp = GetJsEntrySp();
178 CompileRun(
"js_entry_sp();");
179 CHECK_EQ(js_entry_sp, GetJsEntrySp());
188 static void InitializeVM() {
191 const char* extensions[] = {
"v8/trace" };
205 static bool IsAddressWithinFuncCode(
const char* func_name,
Address addr) {
208 JSFunction* js_func = JSFunction::cast(*v8::Utils::OpenHandle(*func));
209 return IsAddressWithinFuncCode(js_func, addr);
217 i::StackFrameIterator frame_iterator;
218 CHECK(frame_iterator.frame()->is_exit());
219 frame_iterator.Advance();
220 CHECK(frame_iterator.frame()->is_construct());
221 frame_iterator.Advance();
223 CHECK(calling_frame->is_java_script());
225 #if defined(V8_HOST_ARCH_32_BIT)
226 int32_t low_bits =
reinterpret_cast<int32_t>(calling_frame->fp());
227 args.
This()->Set(v8_str(
"low_bits"), v8_num(low_bits >> 1));
228 #elif defined(V8_HOST_ARCH_64_BIT)
229 uint64_t fp =
reinterpret_cast<uint64_t
>(calling_frame->fp());
232 args.
This()->Set(v8_str(
"low_bits"), v8_num(low_bits));
233 args.
This()->Set(v8_str(
"high_bits"), v8_num(high_bits));
235 #error Host architecture is neither 32-bit nor 64-bit.
245 constructor_template->
SetClassName(v8_str(
"FPGrabber"));
247 env->Global()->Set(v8_str(constructor_name), fun);
254 static void CreateTraceCallerFunction(
const char* func_name,
255 const char* trace_func_name) {
259 " fp = new FPGrabber();"
260 " %s(fp.low_bits, fp.high_bits);"
262 func_name, trace_func_name);
269 CompileRun(trace_call_buf.
start());
279 i::FLAG_use_inlining =
false;
282 InitTraceEnv(&sample);
288 CreateTraceCallerFunction(
"JSFuncDoTrace",
"trace");
290 "function JSTrace() {"
311 CHECK(IsAddressWithinFuncCode(
"JSFuncDoTrace", sample.
stack[base + 0]));
312 CHECK(IsAddressWithinFuncCode(
"JSTrace", sample.
stack[base + 1]));
324 i::FLAG_use_inlining =
false;
327 InitTraceEnv(&sample);
333 CreateTraceCallerFunction(
"JSFuncDoTrace",
"js_trace");
335 "function JSTrace() {"
338 "function OuterJSTrace() {"
360 CHECK(IsAddressWithinFuncCode(
"JSTrace", sample.
stack[base + 0]));
361 CHECK(IsAddressWithinFuncCode(
"OuterJSTrace", sample.
stack[base + 1]));
365 static void CFuncDoTrace(
byte dummy_parameter) {
368 fp =
reinterpret_cast<Address>(__builtin_frame_address(0));
369 #elif defined _MSC_VER
372 fp = &dummy_parameter - 2 *
sizeof(
void*);
374 #error Unexpected platform.
380 static int CFunc(
int depth) {
385 return CFunc(depth - 1) + 1;
395 InitTraceEnv(&sample);
406 CompileRun(
"a = 1; b = a + 1;");
408 CompileRun(
"js_entry_sp();");
410 CompileRun(
"js_entry_sp_level2();");
Address external_callback
#define CHECK_EQ(expected, value)
static Local< FunctionTemplate > New(InvocationCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >())
Extension(const char *name, const char *source=0, int dep_count=0, const char **deps=0, int source_length=-1)
virtual v8::Handle< v8::FunctionTemplate > GetNativeFunction(v8::Handle< String > name)
static v8::Handle< v8::Value > Trace(const v8::Arguments &args)
void CreateFramePointerGrabberConstructor(const char *constructor_name)
Address stack[kMaxFramesCount]
V8EXPORT bool Equals(Handle< Value > that) const
void SetClassName(Handle< String > name)
HANDLE HANDLE LPSTACKFRAME64 StackFrame
static v8::Handle< v8::Value > JSEntrySP(const v8::Arguments &args)
const char * name() const
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
V8EXPORT bool IsFunction() const
#define CHECK_NE(unexpected, value)
Local< Object > This() const
static int SNPrintF(Vector< char > str, const char *format,...)
Local< Function > GetFunction()
static v8::Handle< v8::Value > JSTrace(const v8::Arguments &args)
static v8::Handle< v8::Value > JSEntrySPLevel2(const v8::Arguments &args)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
Handle< Primitive > V8EXPORT Undefined()
static Persistent< Context > New(ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
bool has_external_callback