| 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 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // Helper to determine inline count via JavaScriptFrame::GetInlineCount. | 16 // Helper to determine inline count via JavaScriptFrame::GetFunctions. |
| 17 // Note that a count of 1 indicates that no inlining has occured. | 17 // Note that a count of 1 indicates that no inlining has occured. |
| 18 void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) { | 18 void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 19 StackTraceFrameIterator it(CcTest::i_isolate()); | 19 StackTraceFrameIterator it(CcTest::i_isolate()); |
| 20 int frames_seen = 0; | 20 int frames_seen = 0; |
| 21 JavaScriptFrame* topmost = it.frame(); | 21 JavaScriptFrame* topmost = it.frame(); |
| 22 while (!it.done()) { | 22 while (!it.done()) { |
| 23 JavaScriptFrame* frame = it.frame(); | 23 JavaScriptFrame* frame = it.frame(); |
| 24 List<JSFunction*> functions(2); |
| 25 frame->GetFunctions(&functions); |
| 24 PrintF("%d %s, inline count: %d\n", frames_seen, | 26 PrintF("%d %s, inline count: %d\n", frames_seen, |
| 25 frame->function()->shared()->DebugName()->ToCString().get(), | 27 frame->function()->shared()->DebugName()->ToCString().get(), |
| 26 frame->GetInlineCount()); | 28 functions.length()); |
| 27 frames_seen++; | 29 frames_seen++; |
| 28 it.Advance(); | 30 it.Advance(); |
| 29 } | 31 } |
| 30 CHECK_EQ(args[0]->ToInt32(args.GetIsolate())->Value(), | 32 List<JSFunction*> functions(2); |
| 31 topmost->GetInlineCount()); | 33 topmost->GetFunctions(&functions); |
| 34 CHECK_EQ(args[0]->ToInt32(args.GetIsolate())->Value(), functions.length()); |
| 32 } | 35 } |
| 33 | 36 |
| 34 | 37 |
| 35 void InstallAssertInlineCountHelper(v8::Isolate* isolate) { | 38 void InstallAssertInlineCountHelper(v8::Isolate* isolate) { |
| 36 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 39 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 37 v8::Local<v8::FunctionTemplate> t = | 40 v8::Local<v8::FunctionTemplate> t = |
| 38 v8::FunctionTemplate::New(isolate, AssertInlineCount); | 41 v8::FunctionTemplate::New(isolate, AssertInlineCount); |
| 39 context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction()); | 42 context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction()); |
| 40 } | 43 } |
| 41 | 44 |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 " 'use strong';" | 535 " 'use strong';" |
| 533 " function foo(x, y) { return x; }" | 536 " function foo(x, y) { return x; }" |
| 534 " function bar(x, y) { return foo(x); }" | 537 " function bar(x, y) { return foo(x); }" |
| 535 " return bar;" | 538 " return bar;" |
| 536 "})();", | 539 "})();", |
| 537 kInlineFlags); | 540 kInlineFlags); |
| 538 T.CheckThrows(T.undefined(), T.undefined()); | 541 T.CheckThrows(T.undefined(), T.undefined()); |
| 539 } | 542 } |
| 540 | 543 |
| 541 #endif // V8_TURBOFAN_TARGET | 544 #endif // V8_TURBOFAN_TARGET |
| OLD | NEW |