| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 612 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
| 613 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); | 613 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); |
| 614 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 614 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
| 615 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); | 615 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); |
| 616 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 616 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
| 617 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); | 617 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); |
| 618 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); | 618 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); |
| 619 } | 619 } |
| 620 #endif | 620 #endif |
| 621 | 621 |
| 622 static void IsBaselineCompiled( | |
| 623 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
| 624 Handle<Object> object = v8::Utils::OpenHandle(*args[0]); | |
| 625 Handle<JSFunction> function = Handle<JSFunction>::cast(object); | |
| 626 bool is_baseline = function->shared()->code()->kind() == Code::FUNCTION; | |
| 627 return args.GetReturnValue().Set(is_baseline); | |
| 628 } | |
| 629 | |
| 630 static void InstallIsBaselineCompiledHelper(v8::Isolate* isolate) { | |
| 631 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | |
| 632 v8::Local<v8::FunctionTemplate> t = | |
| 633 v8::FunctionTemplate::New(isolate, IsBaselineCompiled); | |
| 634 CHECK(context->Global() | |
| 635 ->Set(context, v8_str("IsBaselineCompiled"), | |
| 636 t->GetFunction(context).ToLocalChecked()) | |
| 637 .FromJust()); | |
| 638 } | |
| 639 | |
| 640 TEST(IgnitionBaselineOnReturn) { | |
| 641 // TODO(4280): Remove this entire test once --ignition-preserve-bytecode is | |
| 642 // the default and the flag is removed. This test doesn't provide benefit any | |
| 643 // longer once {InterpreterActivationsFinder} is gone. | |
| 644 if (FLAG_ignition_preserve_bytecode) return; | |
| 645 FLAG_allow_natives_syntax = true; | |
| 646 FLAG_always_opt = false; | |
| 647 CcTest::InitializeVM(); | |
| 648 FLAG_ignition = true; | |
| 649 Isolate* isolate = CcTest::i_isolate(); | |
| 650 isolate->interpreter()->Initialize(); | |
| 651 v8::HandleScope scope(CcTest::isolate()); | |
| 652 InstallIsBaselineCompiledHelper(CcTest::isolate()); | |
| 653 | |
| 654 CompileRun( | |
| 655 "var is_baseline_in_function, is_baseline_after_return;\n" | |
| 656 "var return_val;\n" | |
| 657 "function f() {\n" | |
| 658 " %CompileBaseline(f);\n" | |
| 659 " is_baseline_in_function = IsBaselineCompiled(f);\n" | |
| 660 " return 1234;\n" | |
| 661 "};\n" | |
| 662 "return_val = f();\n" | |
| 663 "is_baseline_after_return = IsBaselineCompiled(f);\n"); | |
| 664 CHECK_EQ(false, GetGlobalProperty("is_baseline_in_function")->BooleanValue()); | |
| 665 CHECK_EQ(true, GetGlobalProperty("is_baseline_after_return")->BooleanValue()); | |
| 666 CHECK_EQ(1234.0, GetGlobalProperty("return_val")->Number()); | |
| 667 } | |
| 668 | |
| 669 TEST(IgnitionEntryTrampolineSelfHealing) { | 622 TEST(IgnitionEntryTrampolineSelfHealing) { |
| 670 FLAG_allow_natives_syntax = true; | 623 FLAG_allow_natives_syntax = true; |
| 671 FLAG_always_opt = false; | 624 FLAG_always_opt = false; |
| 672 CcTest::InitializeVM(); | 625 CcTest::InitializeVM(); |
| 673 FLAG_ignition = true; | 626 FLAG_ignition = true; |
| 674 Isolate* isolate = CcTest::i_isolate(); | 627 Isolate* isolate = CcTest::i_isolate(); |
| 675 isolate->interpreter()->Initialize(); | 628 isolate->interpreter()->Initialize(); |
| 676 v8::HandleScope scope(CcTest::isolate()); | 629 v8::HandleScope scope(CcTest::isolate()); |
| 677 | 630 |
| 678 CompileRun( | 631 CompileRun( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 CompileRun("foo()"); | 667 CompileRun("foo()"); |
| 715 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); | 668 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); |
| 716 CompileRun("bar()"); | 669 CompileRun("bar()"); |
| 717 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); | 670 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); |
| 718 CompileRun("foo(); foo()"); | 671 CompileRun("foo(); foo()"); |
| 719 CHECK_EQ(4, foo->feedback_vector()->invocation_count()); | 672 CHECK_EQ(4, foo->feedback_vector()->invocation_count()); |
| 720 CompileRun("%BaselineFunctionOnNextCall(foo);"); | 673 CompileRun("%BaselineFunctionOnNextCall(foo);"); |
| 721 CompileRun("foo();"); | 674 CompileRun("foo();"); |
| 722 CHECK_EQ(5, foo->feedback_vector()->invocation_count()); | 675 CHECK_EQ(5, foo->feedback_vector()->invocation_count()); |
| 723 } | 676 } |
| OLD | NEW |