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

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

Issue 1965343002: [Interpreter] Support compiling for baseline on return from interpreted function. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test for nosnap build Created 4 years, 7 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 | « src/x64/builtins-x64.cc ('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 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 14 matching lines...) Expand all
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 #include <wchar.h> 29 #include <wchar.h>
30 30
31 #include "src/v8.h" 31 #include "src/v8.h"
32 32
33 #include "src/compiler.h" 33 #include "src/compiler.h"
34 #include "src/disasm.h" 34 #include "src/disasm.h"
35 #include "src/interpreter/interpreter.h"
35 #include "src/parsing/parser.h" 36 #include "src/parsing/parser.h"
36 #include "test/cctest/cctest.h" 37 #include "test/cctest/cctest.h"
37 38
38 using namespace v8::internal; 39 using namespace v8::internal;
39 40
40 static Handle<Object> GetGlobalProperty(const char* name) { 41 static Handle<Object> GetGlobalProperty(const char* name) {
41 Isolate* isolate = CcTest::i_isolate(); 42 Isolate* isolate = CcTest::i_isolate();
42 return JSReceiver::GetProperty(isolate, isolate->global_object(), name) 43 return JSReceiver::GetProperty(isolate, isolate->global_object(), name)
43 .ToHandleChecked(); 44 .ToHandleChecked();
44 } 45 }
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 CompileRun("function f() { a = 12345678 }; f();"); 751 CompileRun("function f() { a = 12345678 }; f();");
751 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 752 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
752 CompileRun("function f(x) { a = 12345678 + x}; f(1);"); 753 CompileRun("function f(x) { a = 12345678 + x}; f(1);");
753 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 754 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
754 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);"); 755 CompileRun("function f(x) { var arguments = 1; x += 12345678}; f(1);");
755 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 756 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
756 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);"); 757 CompileRun("function f(x) { var arguments = 1; x = 12345678}; f(1);");
757 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f")); 758 CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
758 } 759 }
759 #endif 760 #endif
761
762 static void IsBaselineCompiled(
763 const v8::FunctionCallbackInfo<v8::Value>& args) {
764 Handle<Object> object = v8::Utils::OpenHandle(*args[0]);
765 Handle<JSFunction> function = Handle<JSFunction>::cast(object);
766 bool is_baseline = function->shared()->code()->kind() == Code::FUNCTION;
767 return args.GetReturnValue().Set(is_baseline);
768 }
769
770 static void InstallIsBaselineCompiledHelper(v8::Isolate* isolate) {
771 v8::Local<v8::Context> context = isolate->GetCurrentContext();
772 v8::Local<v8::FunctionTemplate> t =
773 v8::FunctionTemplate::New(isolate, IsBaselineCompiled);
774 CHECK(context->Global()
775 ->Set(context, v8_str("IsBaselineCompiled"),
776 t->GetFunction(context).ToLocalChecked())
777 .FromJust());
778 }
779
780 TEST(IgnitionBaselineOnReturn) {
781 FLAG_allow_natives_syntax = true;
782 FLAG_always_opt = false;
783 CcTest::InitializeVM();
784 FLAG_ignition = true;
785 reinterpret_cast<i::Isolate*>(CcTest::isolate())->interpreter()->Initialize();
786 v8::HandleScope scope(CcTest::isolate());
787 InstallIsBaselineCompiledHelper(CcTest::isolate());
788
789 CompileRun(
790 "var is_baseline_in_function, is_baseline_after_return;\n"
791 "var return_val;\n"
792 "function f() {\n"
793 " %CompileBaseline(f);\n"
794 " is_baseline_in_function = IsBaselineCompiled(f);\n"
795 " return 1234;\n"
796 "};\n"
797 "return_val = f();\n"
798 "is_baseline_after_return = IsBaselineCompiled(f);\n");
799 CHECK_EQ(false, GetGlobalProperty("is_baseline_in_function")->BooleanValue());
800 CHECK_EQ(true, GetGlobalProperty("is_baseline_after_return")->BooleanValue());
801 CHECK_EQ(1234.0, GetGlobalProperty("return_val")->Number());
802 }
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698