Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: test/cctest/compiler/test-run-inlining.cc

Issue 993473002: [turbofan] Add support for inlining of builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 {
15
14 // Helper to determine inline count via JavaScriptFrame::GetInlineCount. 16 // Helper to determine inline count via JavaScriptFrame::GetInlineCount.
15 // 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.
16 static void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) { 18 void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) {
17 StackTraceFrameIterator it(CcTest::i_isolate()); 19 StackTraceFrameIterator it(CcTest::i_isolate());
18 int frames_seen = 0; 20 int frames_seen = 0;
19 JavaScriptFrame* topmost = it.frame(); 21 JavaScriptFrame* topmost = it.frame();
20 while (!it.done()) { 22 while (!it.done()) {
21 JavaScriptFrame* frame = it.frame(); 23 JavaScriptFrame* frame = it.frame();
22 PrintF("%d %s, inline count: %d\n", frames_seen, 24 PrintF("%d %s, inline count: %d\n", frames_seen,
23 frame->function()->shared()->DebugName()->ToCString().get(), 25 frame->function()->shared()->DebugName()->ToCString().get(),
24 frame->GetInlineCount()); 26 frame->GetInlineCount());
25 frames_seen++; 27 frames_seen++;
26 it.Advance(); 28 it.Advance();
27 } 29 }
28 CHECK_EQ(args[0]->ToInt32(args.GetIsolate())->Value(), 30 CHECK_EQ(args[0]->ToInt32(args.GetIsolate())->Value(),
29 topmost->GetInlineCount()); 31 topmost->GetInlineCount());
30 } 32 }
31 33
32 34
33 static void InstallAssertInlineCountHelper(v8::Isolate* isolate) { 35 void InstallAssertInlineCountHelper(v8::Isolate* isolate) {
34 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 36 v8::Local<v8::Context> context = isolate->GetCurrentContext();
35 v8::Local<v8::FunctionTemplate> t = 37 v8::Local<v8::FunctionTemplate> t =
36 v8::FunctionTemplate::New(isolate, AssertInlineCount); 38 v8::FunctionTemplate::New(isolate, AssertInlineCount);
37 context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction()); 39 context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction());
38 } 40 }
39 41
40 42
41 static uint32_t kInlineFlags = CompilationInfo::kInliningEnabled | 43 const uint32_t kBuiltinInlineFlags = CompilationInfo::kBuiltinInliningEnabled |
42 CompilationInfo::kContextSpecializing | 44 CompilationInfo::kContextSpecializing |
43 CompilationInfo::kTypingEnabled; 45 CompilationInfo::kTypingEnabled;
46
47 const uint32_t kInlineFlags = CompilationInfo::kInliningEnabled |
48 CompilationInfo::kContextSpecializing |
49 CompilationInfo::kTypingEnabled;
50
51 } // namespace
44 52
45 53
46 TEST(SimpleInlining) { 54 TEST(SimpleInlining) {
47 FLAG_turbo_deoptimization = true; 55 FLAG_turbo_deoptimization = true;
48 FunctionTester T( 56 FunctionTester T(
49 "(function(){" 57 "(function(){"
50 " function foo(s) { AssertInlineCount(2); return s; };" 58 " function foo(s) { AssertInlineCount(2); return s; };"
51 " function bar(s, t) { return foo(s); };" 59 " function bar(s, t) { return foo(s); };"
52 " return bar;" 60 " return bar;"
53 "})();", 61 "})();",
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 " }" 485 " }"
478 " function bar() { return foo(13, 14, 15); };" 486 " function bar() { return foo(13, 14, 15); };"
479 " return bar;" 487 " return bar;"
480 "})();", 488 "})();",
481 kInlineFlags); 489 kInlineFlags);
482 490
483 InstallAssertInlineCountHelper(CcTest::isolate()); 491 InstallAssertInlineCountHelper(CcTest::isolate());
484 T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); 492 T.CheckCall(T.true_value(), T.Val(12), T.Val(14));
485 } 493 }
486 494
495
496 TEST(InlineBuiltin) {
497 FLAG_turbo_deoptimization = true;
498 FunctionTester T(
499 "(function () {"
500 " function foo(s,t,u) { AssertInlineCount(2); return true; }"
501 " function bar() { return foo(); };"
502 " %SetInlineBuiltinFlag(foo);"
503 " return bar;"
504 "})();",
505 kBuiltinInlineFlags);
506
507 InstallAssertInlineCountHelper(CcTest::isolate());
508 T.CheckCall(T.true_value());
509 }
510
487 #endif // V8_TURBOFAN_TARGET 511 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698