OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "test/cctest/compiler/function-tester.h" | 7 #include "test/cctest/compiler/function-tester.h" |
8 | 8 |
9 #if V8_TURBOFAN_TARGET | 9 #if V8_TURBOFAN_TARGET |
10 | 10 |
11 using namespace v8::internal; | 11 using namespace v8::internal; |
12 using namespace v8::internal::compiler; | 12 using namespace v8::internal::compiler; |
13 | 13 |
14 // Helper to determine inline count via JavaScriptFrame::GetInlineCount. | 14 // Helper to determine inline count via JavaScriptFrame::GetInlineCount. |
15 // Note that a count of 1 indicates that no inlining has occured. | 15 // Note that a count of 1 indicates that no inlining has occured. |
16 static void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) { | 16 static void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) { |
17 StackTraceFrameIterator it(CcTest::i_isolate()); | 17 StackTraceFrameIterator it(CcTest::i_isolate()); |
18 int frames_seen = 0; | 18 int frames_seen = 0; |
19 JavaScriptFrame* topmost = it.frame(); | 19 JavaScriptFrame* topmost = it.frame(); |
20 while (!it.done()) { | 20 while (!it.done()) { |
21 JavaScriptFrame* frame = it.frame(); | 21 JavaScriptFrame* frame = it.frame(); |
22 PrintF("%d %s, inline count: %d\n", frames_seen, | 22 PrintF("%d %s, inline count: %d\n", frames_seen, |
23 frame->function()->shared()->DebugName()->ToCString().get(), | 23 frame->function()->shared()->DebugName()->ToCString().get(), |
24 frame->GetInlineCount()); | 24 frame->GetInlineCount()); |
25 frames_seen++; | 25 frames_seen++; |
26 it.Advance(); | 26 it.Advance(); |
27 } | 27 } |
28 CHECK_EQ(args[0]->ToInt32()->Value(), topmost->GetInlineCount()); | 28 CHECK_EQ(args[0]->ToInt32(args.GetIsolate())->Value(), |
| 29 topmost->GetInlineCount()); |
29 } | 30 } |
30 | 31 |
31 | 32 |
32 static void InstallAssertInlineCountHelper(v8::Isolate* isolate) { | 33 static void InstallAssertInlineCountHelper(v8::Isolate* isolate) { |
33 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 34 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
34 v8::Local<v8::FunctionTemplate> t = | 35 v8::Local<v8::FunctionTemplate> t = |
35 v8::FunctionTemplate::New(isolate, AssertInlineCount); | 36 v8::FunctionTemplate::New(isolate, AssertInlineCount); |
36 context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction()); | 37 context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction()); |
37 } | 38 } |
38 | 39 |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 " function bar() { return foo(13, 14, 15); };" | 431 " function bar() { return foo(13, 14, 15); };" |
431 " return bar;" | 432 " return bar;" |
432 "})();", | 433 "})();", |
433 kInlineFlags); | 434 kInlineFlags); |
434 | 435 |
435 InstallAssertInlineCountHelper(CcTest::isolate()); | 436 InstallAssertInlineCountHelper(CcTest::isolate()); |
436 T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); | 437 T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); |
437 } | 438 } |
438 | 439 |
439 #endif // V8_TURBOFAN_TARGET | 440 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |