| 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 "OuterJSTrace();"); | 322 "OuterJSTrace();"); |
| 323 CHECK_GT(sample.frames_count, 1); | 323 CHECK_GT(sample.frames_count, 1); |
| 324 // Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace" | 324 // Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace" |
| 325 CheckRetAddrIsInJSFunction("JSTrace", | 325 CheckRetAddrIsInJSFunction("JSTrace", |
| 326 sample.stack[0]); | 326 sample.stack[0]); |
| 327 CheckRetAddrIsInJSFunction("OuterJSTrace", | 327 CheckRetAddrIsInJSFunction("OuterJSTrace", |
| 328 sample.stack[1]); | 328 sample.stack[1]); |
| 329 } | 329 } |
| 330 | 330 |
| 331 | 331 |
| 332 static void CFuncDoTrace() { | 332 static void CFuncDoTrace(byte dummy_parameter) { |
| 333 Address fp; | 333 Address fp; |
| 334 #ifdef __GNUC__ | 334 #ifdef __GNUC__ |
| 335 fp = reinterpret_cast<Address>(__builtin_frame_address(0)); | 335 fp = reinterpret_cast<Address>(__builtin_frame_address(0)); |
| 336 #elif defined _MSC_VER && defined V8_TARGET_ARCH_IA32 | 336 #elif defined _MSC_VER |
| 337 __asm mov [fp], ebp // NOLINT | 337 // Approximate a frame pointer address. We compile without base pointers, |
| 338 #elif defined _MSC_VER && defined V8_TARGET_ARCH_X64 | 338 // so we can't trust ebp/rbp. |
| 339 // TODO(X64): __asm extension is not supported by the Microsoft Visual C++ | 339 fp = &dummy_parameter - 2 * sizeof(void*); |
| 340 // 64-bit compiler. | 340 #else |
| 341 fp = 0; | 341 #error Unexpected platform. |
| 342 UNIMPLEMENTED(); | |
| 343 #endif | 342 #endif |
| 344 DoTrace(fp); | 343 DoTrace(fp); |
| 345 } | 344 } |
| 346 | 345 |
| 347 | 346 |
| 348 static int CFunc(int depth) { | 347 static int CFunc(int depth) { |
| 349 if (depth <= 0) { | 348 if (depth <= 0) { |
| 350 CFuncDoTrace(); | 349 CFuncDoTrace(0); |
| 351 return 0; | 350 return 0; |
| 352 } else { | 351 } else { |
| 353 return CFunc(depth - 1) + 1; | 352 return CFunc(depth - 1) + 1; |
| 354 } | 353 } |
| 355 } | 354 } |
| 356 | 355 |
| 357 | 356 |
| 358 TEST(PureCStackTrace) { | 357 TEST(PureCStackTrace) { |
| 359 TickSample sample; | 358 TickSample sample; |
| 360 InitTraceEnv(&sample); | 359 InitTraceEnv(&sample); |
| 361 // Check that sampler doesn't crash | 360 // Check that sampler doesn't crash |
| 362 CHECK_EQ(10, CFunc(10)); | 361 CHECK_EQ(10, CFunc(10)); |
| 363 } | 362 } |
| 364 | 363 |
| 365 | 364 |
| 366 TEST(JsEntrySp) { | 365 TEST(JsEntrySp) { |
| 367 InitializeVM(); | 366 InitializeVM(); |
| 368 v8::HandleScope scope; | 367 v8::HandleScope scope; |
| 369 CHECK_EQ(0, GetJsEntrySp()); | 368 CHECK_EQ(0, GetJsEntrySp()); |
| 370 CompileRun("a = 1; b = a + 1;"); | 369 CompileRun("a = 1; b = a + 1;"); |
| 371 CHECK_EQ(0, GetJsEntrySp()); | 370 CHECK_EQ(0, GetJsEntrySp()); |
| 372 CompileRun("js_entry_sp();"); | 371 CompileRun("js_entry_sp();"); |
| 373 CHECK_EQ(0, GetJsEntrySp()); | 372 CHECK_EQ(0, GetJsEntrySp()); |
| 374 CompileRun("js_entry_sp_level2();"); | 373 CompileRun("js_entry_sp_level2();"); |
| 375 CHECK_EQ(0, GetJsEntrySp()); | 374 CHECK_EQ(0, GetJsEntrySp()); |
| 376 } | 375 } |
| 377 | 376 |
| 378 #endif // ENABLE_LOGGING_AND_PROFILING | 377 #endif // ENABLE_LOGGING_AND_PROFILING |
| OLD | NEW |