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 11 matching lines...) Expand all Loading... |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 // | 27 // |
28 // Tests of profiler-related functions from log.h | 28 // Tests of profiler-related functions from log.h |
29 | 29 |
30 #include <stdlib.h> | 30 #include <stdlib.h> |
31 | 31 |
32 #include "src/v8.h" | 32 #include "include/v8-profiler.h" |
33 | |
34 #include "src/api.h" | 33 #include "src/api.h" |
35 #include "src/codegen.h" | 34 #include "src/codegen.h" |
36 #include "src/disassembler.h" | 35 #include "src/disassembler.h" |
37 #include "src/isolate.h" | 36 #include "src/isolate.h" |
38 #include "src/log.h" | 37 #include "src/log.h" |
39 #include "src/profiler/tick-sample.h" | 38 #include "src/v8.h" |
40 #include "src/vm-state-inl.h" | 39 #include "src/vm-state-inl.h" |
41 #include "test/cctest/cctest.h" | 40 #include "test/cctest/cctest.h" |
42 #include "test/cctest/trace-extension.h" | 41 #include "test/cctest/trace-extension.h" |
43 | 42 |
44 using v8::Function; | 43 using v8::Function; |
45 using v8::Local; | 44 using v8::Local; |
46 using v8::Object; | 45 using v8::Object; |
47 using v8::Script; | 46 using v8::Script; |
48 using v8::String; | 47 using v8::String; |
| 48 using v8::TickSample; |
49 using v8::Value; | 49 using v8::Value; |
50 | 50 |
51 using v8::internal::byte; | 51 using v8::internal::byte; |
52 using v8::internal::Address; | 52 using v8::internal::Address; |
53 using v8::internal::Handle; | 53 using v8::internal::Handle; |
54 using v8::internal::Isolate; | 54 using v8::internal::Isolate; |
55 using v8::internal::JSFunction; | 55 using v8::internal::JSFunction; |
56 using v8::internal::TickSample; | |
57 | 56 |
58 | 57 static bool IsAddressWithinFuncCode(JSFunction* function, void* addr) { |
59 static bool IsAddressWithinFuncCode(JSFunction* function, Address addr) { | 58 Address address = reinterpret_cast<Address>(addr); |
60 i::AbstractCode* code = function->abstract_code(); | 59 i::AbstractCode* code = function->abstract_code(); |
61 return code->contains(addr); | 60 return code->contains(address); |
62 } | 61 } |
63 | 62 |
64 | |
65 static bool IsAddressWithinFuncCode(v8::Local<v8::Context> context, | 63 static bool IsAddressWithinFuncCode(v8::Local<v8::Context> context, |
66 const char* func_name, | 64 const char* func_name, void* addr) { |
67 Address addr) { | |
68 v8::Local<v8::Value> func = | 65 v8::Local<v8::Value> func = |
69 context->Global()->Get(context, v8_str(func_name)).ToLocalChecked(); | 66 context->Global()->Get(context, v8_str(func_name)).ToLocalChecked(); |
70 CHECK(func->IsFunction()); | 67 CHECK(func->IsFunction()); |
71 JSFunction* js_func = JSFunction::cast(*v8::Utils::OpenHandle(*func)); | 68 JSFunction* js_func = JSFunction::cast(*v8::Utils::OpenHandle(*func)); |
72 return IsAddressWithinFuncCode(js_func, addr); | 69 return IsAddressWithinFuncCode(js_func, addr); |
73 } | 70 } |
74 | 71 |
75 | 72 |
76 // This C++ function is called as a constructor, to grab the frame pointer | 73 // This C++ function is called as a constructor, to grab the frame pointer |
77 // from the calling function. When this function runs, the stack contains | 74 // from the calling function. When this function runs, the stack contains |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION); | 288 v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION); |
292 v8::Context::Scope context_scope(context); | 289 v8::Context::Scope context_scope(context); |
293 CHECK(!i::TraceExtension::GetJsEntrySp()); | 290 CHECK(!i::TraceExtension::GetJsEntrySp()); |
294 CompileRun("a = 1; b = a + 1;"); | 291 CompileRun("a = 1; b = a + 1;"); |
295 CHECK(!i::TraceExtension::GetJsEntrySp()); | 292 CHECK(!i::TraceExtension::GetJsEntrySp()); |
296 CompileRun("js_entry_sp();"); | 293 CompileRun("js_entry_sp();"); |
297 CHECK(!i::TraceExtension::GetJsEntrySp()); | 294 CHECK(!i::TraceExtension::GetJsEntrySp()); |
298 CompileRun("js_entry_sp_level2();"); | 295 CompileRun("js_entry_sp_level2();"); |
299 CHECK(!i::TraceExtension::GetJsEntrySp()); | 296 CHECK(!i::TraceExtension::GetJsEntrySp()); |
300 } | 297 } |
OLD | NEW |