| 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 // TODO(jochen): Remove this after the setting is turned on globally. |
| 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
| 7 |
| 5 #include "src/v8.h" | 8 #include "src/v8.h" |
| 6 | 9 |
| 7 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
| 8 #include "test/cctest/compiler/function-tester.h" | 11 #include "test/cctest/compiler/function-tester.h" |
| 9 | 12 |
| 10 using namespace v8::internal; | 13 using namespace v8::internal; |
| 11 using namespace v8::internal::compiler; | 14 using namespace v8::internal::compiler; |
| 12 | 15 |
| 13 namespace { | 16 namespace { |
| 14 | 17 |
| 15 // Helper to determine inline count via JavaScriptFrame::GetFunctions. | 18 // Helper to determine inline count via JavaScriptFrame::GetFunctions. |
| 16 // Note that a count of 1 indicates that no inlining has occured. | 19 // Note that a count of 1 indicates that no inlining has occured. |
| 17 void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) { | 20 void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 18 StackTraceFrameIterator it(CcTest::i_isolate()); | 21 StackTraceFrameIterator it(CcTest::i_isolate()); |
| 19 int frames_seen = 0; | 22 int frames_seen = 0; |
| 20 JavaScriptFrame* topmost = it.frame(); | 23 JavaScriptFrame* topmost = it.frame(); |
| 21 while (!it.done()) { | 24 while (!it.done()) { |
| 22 JavaScriptFrame* frame = it.frame(); | 25 JavaScriptFrame* frame = it.frame(); |
| 23 List<JSFunction*> functions(2); | 26 List<JSFunction*> functions(2); |
| 24 frame->GetFunctions(&functions); | 27 frame->GetFunctions(&functions); |
| 25 PrintF("%d %s, inline count: %d\n", frames_seen, | 28 PrintF("%d %s, inline count: %d\n", frames_seen, |
| 26 frame->function()->shared()->DebugName()->ToCString().get(), | 29 frame->function()->shared()->DebugName()->ToCString().get(), |
| 27 functions.length()); | 30 functions.length()); |
| 28 frames_seen++; | 31 frames_seen++; |
| 29 it.Advance(); | 32 it.Advance(); |
| 30 } | 33 } |
| 31 List<JSFunction*> functions(2); | 34 List<JSFunction*> functions(2); |
| 32 topmost->GetFunctions(&functions); | 35 topmost->GetFunctions(&functions); |
| 33 CHECK_EQ(args[0]->ToInt32(args.GetIsolate())->Value(), functions.length()); | 36 CHECK_EQ(args[0] |
| 37 ->ToInt32(args.GetIsolate()->GetCurrentContext()) |
| 38 .ToLocalChecked() |
| 39 ->Value(), |
| 40 functions.length()); |
| 34 } | 41 } |
| 35 | 42 |
| 36 | 43 |
| 37 void InstallAssertInlineCountHelper(v8::Isolate* isolate) { | 44 void InstallAssertInlineCountHelper(v8::Isolate* isolate) { |
| 38 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 45 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 39 v8::Local<v8::FunctionTemplate> t = | 46 v8::Local<v8::FunctionTemplate> t = |
| 40 v8::FunctionTemplate::New(isolate, AssertInlineCount); | 47 v8::FunctionTemplate::New(isolate, AssertInlineCount); |
| 41 context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction()); | 48 CHECK(context->Global() |
| 49 ->Set(context, v8_str("AssertInlineCount"), |
| 50 t->GetFunction(context).ToLocalChecked()) |
| 51 .FromJust()); |
| 42 } | 52 } |
| 43 | 53 |
| 44 | 54 |
| 45 const uint32_t kRestrictedInliningFlags = | 55 const uint32_t kRestrictedInliningFlags = |
| 46 CompilationInfo::kFunctionContextSpecializing | | 56 CompilationInfo::kFunctionContextSpecializing | |
| 47 CompilationInfo::kTypingEnabled; | 57 CompilationInfo::kTypingEnabled; |
| 48 | 58 |
| 49 const uint32_t kInlineFlags = CompilationInfo::kInliningEnabled | | 59 const uint32_t kInlineFlags = CompilationInfo::kInliningEnabled | |
| 50 CompilationInfo::kFunctionContextSpecializing | | 60 CompilationInfo::kFunctionContextSpecializing | |
| 51 CompilationInfo::kTypingEnabled; | 61 CompilationInfo::kTypingEnabled; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 " if (x == 1) return bar(42);" | 598 " if (x == 1) return bar(42);" |
| 589 " return x;" | 599 " return x;" |
| 590 " }" | 600 " }" |
| 591 " return foo;" | 601 " return foo;" |
| 592 "})();", | 602 "})();", |
| 593 kInlineFlags); | 603 kInlineFlags); |
| 594 | 604 |
| 595 InstallAssertInlineCountHelper(CcTest::isolate()); | 605 InstallAssertInlineCountHelper(CcTest::isolate()); |
| 596 T.CheckCall(T.Val(42), T.Val(1)); | 606 T.CheckCall(T.Val(42), T.Val(1)); |
| 597 } | 607 } |
| OLD | NEW |