| OLD | NEW | 
|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 296       "true;"); | 296       "true;"); | 
| 297   CHECK(!result.IsEmpty()); | 297   CHECK(!result.IsEmpty()); | 
| 298   // When stack tracer is invoked, the stack should look as follows: | 298   // When stack tracer is invoked, the stack should look as follows: | 
| 299   // script [JS] | 299   // script [JS] | 
| 300   //   JSTrace() [JS] | 300   //   JSTrace() [JS] | 
| 301   //     JSFuncDoTrace() [JS] [captures EBP value and encodes it as Smi] | 301   //     JSFuncDoTrace() [JS] [captures EBP value and encodes it as Smi] | 
| 302   //       trace(EBP) [native (extension)] | 302   //       trace(EBP) [native (extension)] | 
| 303   //         DoTrace(EBP) [native] | 303   //         DoTrace(EBP) [native] | 
| 304   //           StackTracer::Trace | 304   //           StackTracer::Trace | 
| 305 | 305 | 
| 306   // The VM state tracking keeps track of external callbacks and puts | 306   CHECK(sample.has_external_callback); | 
| 307   // them at the top of the sample stack. | 307   CHECK_EQ(FUNCTION_ADDR(TraceExtension::Trace), sample.external_callback); | 
| 308   int base = 0; |  | 
| 309   CHECK(sample.stack[0] == FUNCTION_ADDR(TraceExtension::Trace)); |  | 
| 310   base++; |  | 
| 311 | 308 | 
| 312   // Stack tracing will start from the first JS function, i.e. "JSFuncDoTrace" | 309   // Stack tracing will start from the first JS function, i.e. "JSFuncDoTrace" | 
|  | 310   int base = 0; | 
| 313   CHECK_GT(sample.frames_count, base + 1); | 311   CHECK_GT(sample.frames_count, base + 1); | 
| 314   CHECK(IsAddressWithinFuncCode("JSFuncDoTrace", sample.stack[base + 0])); | 312   CHECK(IsAddressWithinFuncCode("JSFuncDoTrace", sample.stack[base + 0])); | 
| 315   CHECK(IsAddressWithinFuncCode("JSTrace", sample.stack[base + 1])); | 313   CHECK(IsAddressWithinFuncCode("JSTrace", sample.stack[base + 1])); | 
| 316 } | 314 } | 
| 317 | 315 | 
| 318 | 316 | 
| 319 // This test verifies that stack tracing works when called during | 317 // This test verifies that stack tracing works when called during | 
| 320 // execution of JS code. However, as calling StackTracer requires | 318 // execution of JS code. However, as calling StackTracer requires | 
| 321 // entering native code, we can only emulate pure JS by erasing | 319 // entering native code, we can only emulate pure JS by erasing | 
| 322 // Isolate::c_entry_fp value. In this case, StackTracer uses passed frame | 320 // Isolate::c_entry_fp value. In this case, StackTracer uses passed frame | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
| 347   // When stack tracer is invoked, the stack should look as follows: | 345   // When stack tracer is invoked, the stack should look as follows: | 
| 348   // script [JS] | 346   // script [JS] | 
| 349   //   OuterJSTrace() [JS] | 347   //   OuterJSTrace() [JS] | 
| 350   //     JSTrace() [JS] | 348   //     JSTrace() [JS] | 
| 351   //       JSFuncDoTrace() [JS] | 349   //       JSFuncDoTrace() [JS] | 
| 352   //         js_trace(EBP) [native (extension)] | 350   //         js_trace(EBP) [native (extension)] | 
| 353   //           DoTraceHideCEntryFPAddress(EBP) [native] | 351   //           DoTraceHideCEntryFPAddress(EBP) [native] | 
| 354   //             StackTracer::Trace | 352   //             StackTracer::Trace | 
| 355   // | 353   // | 
| 356 | 354 | 
| 357   // The VM state tracking keeps track of external callbacks and puts | 355   CHECK(sample.has_external_callback); | 
| 358   // them at the top of the sample stack. | 356   CHECK_EQ(FUNCTION_ADDR(TraceExtension::JSTrace), sample.external_callback); | 
| 359   int base = 0; |  | 
| 360   CHECK(sample.stack[0] == FUNCTION_ADDR(TraceExtension::JSTrace)); |  | 
| 361   base++; |  | 
| 362 | 357 | 
| 363   // Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace" | 358   // Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace" | 
|  | 359   int base = 0; | 
| 364   CHECK_GT(sample.frames_count, base + 1); | 360   CHECK_GT(sample.frames_count, base + 1); | 
| 365   CHECK(IsAddressWithinFuncCode("JSTrace", sample.stack[base + 0])); | 361   CHECK(IsAddressWithinFuncCode("JSTrace", sample.stack[base + 0])); | 
| 366   CHECK(IsAddressWithinFuncCode("OuterJSTrace", sample.stack[base + 1])); | 362   CHECK(IsAddressWithinFuncCode("OuterJSTrace", sample.stack[base + 1])); | 
| 367 } | 363 } | 
| 368 | 364 | 
| 369 | 365 | 
| 370 static void CFuncDoTrace(byte dummy_parameter) { | 366 static void CFuncDoTrace(byte dummy_parameter) { | 
| 371   Address fp; | 367   Address fp; | 
| 372 #ifdef __GNUC__ | 368 #ifdef __GNUC__ | 
| 373   fp = reinterpret_cast<Address>(__builtin_frame_address(0)); | 369   fp = reinterpret_cast<Address>(__builtin_frame_address(0)); | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 410   CHECK_EQ(0, GetJsEntrySp()); | 406   CHECK_EQ(0, GetJsEntrySp()); | 
| 411   CompileRun("a = 1; b = a + 1;"); | 407   CompileRun("a = 1; b = a + 1;"); | 
| 412   CHECK_EQ(0, GetJsEntrySp()); | 408   CHECK_EQ(0, GetJsEntrySp()); | 
| 413   CompileRun("js_entry_sp();"); | 409   CompileRun("js_entry_sp();"); | 
| 414   CHECK_EQ(0, GetJsEntrySp()); | 410   CHECK_EQ(0, GetJsEntrySp()); | 
| 415   CompileRun("js_entry_sp_level2();"); | 411   CompileRun("js_entry_sp_level2();"); | 
| 416   CHECK_EQ(0, GetJsEntrySp()); | 412   CHECK_EQ(0, GetJsEntrySp()); | 
| 417 } | 413 } | 
| 418 | 414 | 
| 419 #endif  // ENABLE_LOGGING_AND_PROFILING | 415 #endif  // ENABLE_LOGGING_AND_PROFILING | 
| OLD | NEW | 
|---|