| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 trace_env.sample = sample; | 65 trace_env.sample = sample; |
| 66 } | 66 } |
| 67 | 67 |
| 68 | 68 |
| 69 static void DoTrace(Address fp) { | 69 static void DoTrace(Address fp) { |
| 70 RegisterState regs; | 70 RegisterState regs; |
| 71 regs.fp = fp; | 71 regs.fp = fp; |
| 72 // sp is only used to define stack high bound | 72 // sp is only used to define stack high bound |
| 73 regs.sp = | 73 regs.sp = |
| 74 reinterpret_cast<Address>(trace_env.sample) - 10240; | 74 reinterpret_cast<Address>(trace_env.sample) - 10240; |
| 75 trace_env.sample->Init(Isolate::Current(), regs); | 75 trace_env.sample->Init(CcTest::i_isolate(), regs); |
| 76 } | 76 } |
| 77 | 77 |
| 78 | 78 |
| 79 // Hide c_entry_fp to emulate situation when sampling is done while | 79 // Hide c_entry_fp to emulate situation when sampling is done while |
| 80 // pure JS code is being executed | 80 // pure JS code is being executed |
| 81 static void DoTraceHideCEntryFPAddress(Address fp) { | 81 static void DoTraceHideCEntryFPAddress(Address fp) { |
| 82 v8::internal::Address saved_c_frame_fp = | 82 v8::internal::Address saved_c_frame_fp = |
| 83 *(Isolate::Current()->c_entry_fp_address()); | 83 *(CcTest::i_isolate()->c_entry_fp_address()); |
| 84 CHECK(saved_c_frame_fp); | 84 CHECK(saved_c_frame_fp); |
| 85 *(Isolate::Current()->c_entry_fp_address()) = 0; | 85 *(CcTest::i_isolate()->c_entry_fp_address()) = 0; |
| 86 DoTrace(fp); | 86 DoTrace(fp); |
| 87 *(Isolate::Current()->c_entry_fp_address()) = saved_c_frame_fp; | 87 *(CcTest::i_isolate()->c_entry_fp_address()) = saved_c_frame_fp; |
| 88 } | 88 } |
| 89 | 89 |
| 90 | 90 |
| 91 // --- T r a c e E x t e n s i o n --- | 91 // --- T r a c e E x t e n s i o n --- |
| 92 | 92 |
| 93 class TraceExtension : public v8::Extension { | 93 class TraceExtension : public v8::Extension { |
| 94 public: | 94 public: |
| 95 TraceExtension() : v8::Extension("v8/trace", kSource) { } | 95 TraceExtension() : v8::Extension("v8/trace", kSource) { } |
| 96 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 96 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
| 97 v8::Handle<String> name); | 97 v8::Handle<String> name); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 DoTrace(GetFP(args)); | 149 DoTrace(GetFP(args)); |
| 150 } | 150 } |
| 151 | 151 |
| 152 | 152 |
| 153 void TraceExtension::JSTrace(const v8::FunctionCallbackInfo<v8::Value>& args) { | 153 void TraceExtension::JSTrace(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 154 DoTraceHideCEntryFPAddress(GetFP(args)); | 154 DoTraceHideCEntryFPAddress(GetFP(args)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 | 157 |
| 158 static Address GetJsEntrySp() { | 158 static Address GetJsEntrySp() { |
| 159 CHECK_NE(NULL, i::Isolate::Current()->thread_local_top()); | 159 CHECK_NE(NULL, CcTest::i_isolate()->thread_local_top()); |
| 160 return i::Isolate::Current()->js_entry_sp(); | 160 return CcTest::i_isolate()->js_entry_sp(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 | 163 |
| 164 void TraceExtension::JSEntrySP( | 164 void TraceExtension::JSEntrySP( |
| 165 const v8::FunctionCallbackInfo<v8::Value>& args) { | 165 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 166 CHECK_NE(0, GetJsEntrySp()); | 166 CHECK_NE(0, GetJsEntrySp()); |
| 167 } | 167 } |
| 168 | 168 |
| 169 | 169 |
| 170 void TraceExtension::JSEntrySPLevel2( | 170 void TraceExtension::JSEntrySPLevel2( |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 CcTest::InitializeVM(TRACE_EXTENSION); | 389 CcTest::InitializeVM(TRACE_EXTENSION); |
| 390 v8::HandleScope scope(CcTest::isolate()); | 390 v8::HandleScope scope(CcTest::isolate()); |
| 391 CHECK_EQ(0, GetJsEntrySp()); | 391 CHECK_EQ(0, GetJsEntrySp()); |
| 392 CompileRun("a = 1; b = a + 1;"); | 392 CompileRun("a = 1; b = a + 1;"); |
| 393 CHECK_EQ(0, GetJsEntrySp()); | 393 CHECK_EQ(0, GetJsEntrySp()); |
| 394 CompileRun("js_entry_sp();"); | 394 CompileRun("js_entry_sp();"); |
| 395 CHECK_EQ(0, GetJsEntrySp()); | 395 CHECK_EQ(0, GetJsEntrySp()); |
| 396 CompileRun("js_entry_sp_level2();"); | 396 CompileRun("js_entry_sp_level2();"); |
| 397 CHECK_EQ(0, GetJsEntrySp()); | 397 CHECK_EQ(0, GetJsEntrySp()); |
| 398 } | 398 } |
| OLD | NEW |