| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 return i::Factory::NewStringFromAscii(i::CStrVector(s)); | 209 return i::Factory::NewStringFromAscii(i::CStrVector(s)); |
| 210 } | 210 } |
| 211 | 211 |
| 212 | 212 |
| 213 namespace v8 { | 213 namespace v8 { |
| 214 namespace internal { | 214 namespace internal { |
| 215 | 215 |
| 216 class CodeGeneratorPatcher { | 216 class CodeGeneratorPatcher { |
| 217 public: | 217 public: |
| 218 CodeGeneratorPatcher() { | 218 CodeGeneratorPatcher() { |
| 219 CodeGenerator::InlineRuntimeLUT genGetFramePointer = | 219 CodeGenerator::InlineRuntimeLUT gen_get_frame_pointer = |
| 220 {&CodeGenerator::GenerateGetFramePointer, "_GetFramePointer", 0}; | 220 {&CodeGenerator::GenerateGetFramePointer, "_GetFramePointer", 0}; |
| 221 // _RandomHeapNumber is just used as a dummy function that has zero | 221 // _RandomHeapNumber is just used as a dummy function that has zero |
| 222 // arguments, the same as the _GetFramePointer function we actually patch | 222 // arguments, the same as the _GetFramePointer function we actually patch |
| 223 // in. | 223 // in. |
| 224 bool result = CodeGenerator::PatchInlineRuntimeEntry( | 224 bool result = CodeGenerator::PatchInlineRuntimeEntry( |
| 225 NewString("_RandomHeapNumber"), | 225 NewString("_RandomHeapNumber"), |
| 226 genGetFramePointer, &oldInlineEntry); | 226 gen_get_frame_pointer, &old_inline_entry); |
| 227 CHECK(result); | 227 CHECK(result); |
| 228 } | 228 } |
| 229 | 229 |
| 230 ~CodeGeneratorPatcher() { | 230 ~CodeGeneratorPatcher() { |
| 231 CHECK(CodeGenerator::PatchInlineRuntimeEntry( | 231 CHECK(CodeGenerator::PatchInlineRuntimeEntry( |
| 232 NewString("_GetFramePointer"), | 232 NewString("_GetFramePointer"), |
| 233 oldInlineEntry, NULL)); | 233 old_inline_entry, NULL)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 private: | 236 private: |
| 237 CodeGenerator::InlineRuntimeLUT oldInlineEntry; | 237 CodeGenerator::InlineRuntimeLUT old_inline_entry; |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 } } // namespace v8::internal | 240 } } // namespace v8::internal |
| 241 | 241 |
| 242 | 242 |
| 243 // Creates a global function named 'func_name' that calls the tracing | 243 // Creates a global function named 'func_name' that calls the tracing |
| 244 // function 'trace_func_name' with an actual EBP register value, | 244 // function 'trace_func_name' with an actual EBP register value, |
| 245 // shifted right to be presented as Smi. | 245 // shifted right to be presented as Smi. |
| 246 static void CreateTraceCallerFunction(const char* func_name, | 246 static void CreateTraceCallerFunction(const char* func_name, |
| 247 const char* trace_func_name) { | 247 const char* trace_func_name) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 266 SetGlobalProperty(func_name, v8::ToApi<Value>(func)); | 266 SetGlobalProperty(func_name, v8::ToApi<Value>(func)); |
| 267 CHECK_EQ(*func, *GetGlobalJSFunction(func_name)); | 267 CHECK_EQ(*func, *GetGlobalJSFunction(func_name)); |
| 268 } | 268 } |
| 269 | 269 |
| 270 | 270 |
| 271 // This test verifies that stack tracing works when called during | 271 // This test verifies that stack tracing works when called during |
| 272 // execution of a native function called from JS code. In this case, | 272 // execution of a native function called from JS code. In this case, |
| 273 // StackTracer uses Top::c_entry_fp as a starting point for stack | 273 // StackTracer uses Top::c_entry_fp as a starting point for stack |
| 274 // walking. | 274 // walking. |
| 275 TEST(CFromJSStackTrace) { | 275 TEST(CFromJSStackTrace) { |
| 276 // TODO(711) The hack of replacing the inline runtime function | 276 // TODO(711): The hack of replacing the inline runtime function |
| 277 // RandomHeapNumber with GetFrameNumber does not work with the way the full | 277 // RandomHeapNumber with GetFrameNumber does not work with the way |
| 278 // compiler generates inline runtime calls. | 278 // the full compiler generates inline runtime calls. |
| 279 i::FLAG_full_compiler = false; |
| 279 i::FLAG_always_full_compiler = false; | 280 i::FLAG_always_full_compiler = false; |
| 280 | 281 |
| 281 TickSample sample; | 282 TickSample sample; |
| 282 InitTraceEnv(&sample); | 283 InitTraceEnv(&sample); |
| 283 | 284 |
| 284 InitializeVM(); | 285 InitializeVM(); |
| 285 v8::HandleScope scope; | 286 v8::HandleScope scope; |
| 286 // Create global function JSFuncDoTrace which calls | 287 // Create global function JSFuncDoTrace which calls |
| 287 // extension function trace() with the current frame pointer value. | 288 // extension function trace() with the current frame pointer value. |
| 288 CreateTraceCallerFunction("JSFuncDoTrace", "trace"); | 289 CreateTraceCallerFunction("JSFuncDoTrace", "trace"); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 306 CheckObjectIsJSFunction("JSTrace", sample.stack[1]); | 307 CheckObjectIsJSFunction("JSTrace", sample.stack[1]); |
| 307 } | 308 } |
| 308 | 309 |
| 309 | 310 |
| 310 // This test verifies that stack tracing works when called during | 311 // This test verifies that stack tracing works when called during |
| 311 // execution of JS code. However, as calling StackTracer requires | 312 // execution of JS code. However, as calling StackTracer requires |
| 312 // entering native code, we can only emulate pure JS by erasing | 313 // entering native code, we can only emulate pure JS by erasing |
| 313 // Top::c_entry_fp value. In this case, StackTracer uses passed frame | 314 // Top::c_entry_fp value. In this case, StackTracer uses passed frame |
| 314 // pointer value as a starting point for stack walking. | 315 // pointer value as a starting point for stack walking. |
| 315 TEST(PureJSStackTrace) { | 316 TEST(PureJSStackTrace) { |
| 316 // TODO(711) The hack of replacing the inline runtime function | 317 // TODO(711): The hack of replacing the inline runtime function |
| 317 // RandomHeapNumber with GetFrameNumber does not work with the way the full | 318 // RandomHeapNumber with GetFrameNumber does not work with the way |
| 318 // compiler generates inline runtime calls. | 319 // the full compiler generates inline runtime calls. |
| 320 i::FLAG_full_compiler = false; |
| 319 i::FLAG_always_full_compiler = false; | 321 i::FLAG_always_full_compiler = false; |
| 320 | 322 |
| 321 TickSample sample; | 323 TickSample sample; |
| 322 InitTraceEnv(&sample); | 324 InitTraceEnv(&sample); |
| 323 | 325 |
| 324 InitializeVM(); | 326 InitializeVM(); |
| 325 v8::HandleScope scope; | 327 v8::HandleScope scope; |
| 326 // Create global function JSFuncDoTrace which calls | 328 // Create global function JSFuncDoTrace which calls |
| 327 // extension function js_trace() with the current frame pointer value. | 329 // extension function js_trace() with the current frame pointer value. |
| 328 CreateTraceCallerFunction("JSFuncDoTrace", "js_trace"); | 330 CreateTraceCallerFunction("JSFuncDoTrace", "js_trace"); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 CHECK_EQ(0, GetJsEntrySp()); | 400 CHECK_EQ(0, GetJsEntrySp()); |
| 399 CompileRun("a = 1; b = a + 1;"); | 401 CompileRun("a = 1; b = a + 1;"); |
| 400 CHECK_EQ(0, GetJsEntrySp()); | 402 CHECK_EQ(0, GetJsEntrySp()); |
| 401 CompileRun("js_entry_sp();"); | 403 CompileRun("js_entry_sp();"); |
| 402 CHECK_EQ(0, GetJsEntrySp()); | 404 CHECK_EQ(0, GetJsEntrySp()); |
| 403 CompileRun("js_entry_sp_level2();"); | 405 CompileRun("js_entry_sp_level2();"); |
| 404 CHECK_EQ(0, GetJsEntrySp()); | 406 CHECK_EQ(0, GetJsEntrySp()); |
| 405 } | 407 } |
| 406 | 408 |
| 407 #endif // ENABLE_LOGGING_AND_PROFILING | 409 #endif // ENABLE_LOGGING_AND_PROFILING |
| OLD | NEW |