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 |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 | 34 |
35 void InstallAssertInlineCountHelper(v8::Isolate* isolate) { | 35 void InstallAssertInlineCountHelper(v8::Isolate* isolate) { |
36 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 36 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
37 v8::Local<v8::FunctionTemplate> t = | 37 v8::Local<v8::FunctionTemplate> t = |
38 v8::FunctionTemplate::New(isolate, AssertInlineCount); | 38 v8::FunctionTemplate::New(isolate, AssertInlineCount); |
39 context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction()); | 39 context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction()); |
40 } | 40 } |
41 | 41 |
42 | 42 |
43 const uint32_t kBuiltinInlineFlags = CompilationInfo::kBuiltinInliningEnabled | | 43 const uint32_t kRestrictedInliningFlags = |
44 CompilationInfo::kContextSpecializing | | 44 CompilationInfo::kContextSpecializing | CompilationInfo::kTypingEnabled; |
45 CompilationInfo::kTypingEnabled; | |
46 | 45 |
47 const uint32_t kInlineFlags = CompilationInfo::kInliningEnabled | | 46 const uint32_t kInlineFlags = CompilationInfo::kInliningEnabled | |
48 CompilationInfo::kContextSpecializing | | 47 CompilationInfo::kContextSpecializing | |
49 CompilationInfo::kTypingEnabled; | 48 CompilationInfo::kTypingEnabled; |
50 | 49 |
51 } // namespace | 50 } // namespace |
52 | 51 |
53 | 52 |
54 TEST(SimpleInlining) { | 53 TEST(SimpleInlining) { |
55 FLAG_turbo_deoptimization = true; | 54 FLAG_turbo_deoptimization = true; |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); | 491 T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); |
493 } | 492 } |
494 | 493 |
495 | 494 |
496 TEST(InlineBuiltin) { | 495 TEST(InlineBuiltin) { |
497 FLAG_turbo_deoptimization = true; | 496 FLAG_turbo_deoptimization = true; |
498 FunctionTester T( | 497 FunctionTester T( |
499 "(function () {" | 498 "(function () {" |
500 " function foo(s,t,u) { AssertInlineCount(2); return true; }" | 499 " function foo(s,t,u) { AssertInlineCount(2); return true; }" |
501 " function bar() { return foo(); };" | 500 " function bar() { return foo(); };" |
502 " %SetInlineBuiltinFlag(foo);" | 501 " %SetForceInlineFlag(foo);" |
503 " return bar;" | 502 " return bar;" |
504 "})();", | 503 "})();", |
505 kBuiltinInlineFlags); | 504 kRestrictedInliningFlags); |
506 | 505 |
507 InstallAssertInlineCountHelper(CcTest::isolate()); | 506 InstallAssertInlineCountHelper(CcTest::isolate()); |
508 T.CheckCall(T.true_value()); | 507 T.CheckCall(T.true_value()); |
509 } | 508 } |
510 | 509 |
511 | 510 |
512 TEST(InlineNestedBuiltin) { | 511 TEST(InlineNestedBuiltin) { |
513 FLAG_turbo_deoptimization = true; | 512 FLAG_turbo_deoptimization = true; |
514 FunctionTester T( | 513 FunctionTester T( |
515 "(function () {" | 514 "(function () {" |
516 " function foo(s,t,u) { AssertInlineCount(3); return true; }" | 515 " function foo(s,t,u) { AssertInlineCount(3); return true; }" |
517 " function baz(s,t,u) { return foo(s,t,u); }" | 516 " function baz(s,t,u) { return foo(s,t,u); }" |
518 " function bar() { return baz(); };" | 517 " function bar() { return baz(); };" |
519 " %SetInlineBuiltinFlag(foo);" | 518 " %SetForceInlineFlag(foo);" |
520 " %SetInlineBuiltinFlag(baz);" | 519 " %SetForceInlineFlag(baz);" |
521 " return bar;" | 520 " return bar;" |
522 "})();", | 521 "})();", |
523 kBuiltinInlineFlags); | 522 kRestrictedInliningFlags); |
524 | 523 |
525 InstallAssertInlineCountHelper(CcTest::isolate()); | 524 InstallAssertInlineCountHelper(CcTest::isolate()); |
526 T.CheckCall(T.true_value()); | 525 T.CheckCall(T.true_value()); |
527 } | 526 } |
528 | 527 |
529 | 528 |
530 TEST(StrongModeArity) { | 529 TEST(StrongModeArity) { |
531 FLAG_turbo_deoptimization = true; | 530 FLAG_turbo_deoptimization = true; |
532 FLAG_strong_mode = true; | 531 FLAG_strong_mode = true; |
533 FunctionTester T( | 532 FunctionTester T( |
(...skipping 14 matching lines...) Expand all Loading... |
548 "(function () {" | 547 "(function () {" |
549 " 'use strong';" | 548 " 'use strong';" |
550 " function foo(x, y) { return x; }" | 549 " function foo(x, y) { return x; }" |
551 " function bar(x, y) { return foo(x); }" | 550 " function bar(x, y) { return foo(x); }" |
552 " return bar;" | 551 " return bar;" |
553 "})();", | 552 "})();", |
554 kInlineFlags); | 553 kInlineFlags); |
555 T.CheckThrows(T.undefined(), T.undefined()); | 554 T.CheckThrows(T.undefined(), T.undefined()); |
556 } | 555 } |
557 #endif // V8_TURBOFAN_TARGET | 556 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |