OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // | 2 // |
3 // Tests of profiler-related functions from log.h | 3 // Tests of profiler-related functions from log.h |
4 | 4 |
5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "v8.h" | 9 #include "v8.h" |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 static void InitTraceEnv(StackTracer* tracer, TickSample* sample) { | 37 static void InitTraceEnv(StackTracer* tracer, TickSample* sample) { |
38 trace_env.tracer = tracer; | 38 trace_env.tracer = tracer; |
39 trace_env.sample = sample; | 39 trace_env.sample = sample; |
40 } | 40 } |
41 | 41 |
42 | 42 |
43 static void DoTrace(unsigned int fp) { | 43 static void DoTrace(unsigned int fp) { |
44 trace_env.sample->fp = fp; | 44 trace_env.sample->fp = fp; |
45 // something that is less than fp | 45 // something that is less than fp |
46 trace_env.sample->sp = trace_env.sample->fp - sizeof(unsigned int); | 46 trace_env.sample->sp = trace_env.sample->fp - 100; |
47 trace_env.tracer->Trace(trace_env.sample); | 47 trace_env.tracer->Trace(trace_env.sample); |
48 } | 48 } |
49 | 49 |
50 | 50 |
51 static void CFuncDoTrace() { | 51 static void CFuncDoTrace() { |
52 unsigned int fp; | 52 unsigned int fp; |
53 #ifdef __GNUC__ | 53 #ifdef __GNUC__ |
54 fp = reinterpret_cast<unsigned int>(__builtin_frame_address(0)); | 54 fp = reinterpret_cast<unsigned int>(__builtin_frame_address(0)); |
55 #elif defined _MSC_VER | 55 #elif defined _MSC_VER |
56 __asm mov [fp], ebp // NOLINT | 56 __asm mov [fp], ebp // NOLINT |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 call_trace_code->instruction_size(), | 210 call_trace_code->instruction_size(), |
211 original, patch, sizeof(patch))); | 211 original, patch, sizeof(patch))); |
212 | 212 |
213 SetGlobalProperty("JSFuncDoTrace", v8::ToApi<Value>(call_trace)); | 213 SetGlobalProperty("JSFuncDoTrace", v8::ToApi<Value>(call_trace)); |
214 | 214 |
215 CompileRun( | 215 CompileRun( |
216 "function JSTrace() {" | 216 "function JSTrace() {" |
217 " JSFuncDoTrace();" | 217 " JSFuncDoTrace();" |
218 "};\n" | 218 "};\n" |
219 "JSTrace();"); | 219 "JSTrace();"); |
| 220 CHECK_NE(0, *(sample.stack)); |
| 221 CheckRetAddrIsInFunction( |
| 222 reinterpret_cast<unsigned int>(sample.stack[0]), |
| 223 reinterpret_cast<unsigned int>(call_trace_code->instruction_start()), |
| 224 call_trace_code->instruction_size()); |
220 Handle<JSFunction> js_trace(JSFunction::cast(*(v8::Utils::OpenHandle( | 225 Handle<JSFunction> js_trace(JSFunction::cast(*(v8::Utils::OpenHandle( |
221 *GetGlobalProperty("JSTrace"))))); | 226 *GetGlobalProperty("JSTrace"))))); |
222 v8::internal::Code* js_trace_code = js_trace->code(); | 227 v8::internal::Code* js_trace_code = js_trace->code(); |
223 CheckRetAddrIsInFunction( | 228 CheckRetAddrIsInFunction( |
224 reinterpret_cast<unsigned int>(sample.stack[0]), | 229 reinterpret_cast<unsigned int>(sample.stack[1]), |
225 reinterpret_cast<unsigned int>(js_trace_code->instruction_start()), | 230 reinterpret_cast<unsigned int>(js_trace_code->instruction_start()), |
226 js_trace_code->instruction_size()); | 231 js_trace_code->instruction_size()); |
227 CHECK_EQ(0, sample.stack[1]); | |
228 } | 232 } |
229 | 233 |
230 #endif // ENABLE_LOGGING_AND_PROFILING | 234 #endif // ENABLE_LOGGING_AND_PROFILING |
231 | |
OLD | NEW |