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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-compiler.cc
diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc
index 18f00097cdedd10fc3835d2f063bb3b4c7114fb3..38c02a0f461c394f7042e0e1b69a0579b98cd43a 100644
--- a/test/cctest/test-compiler.cc
+++ b/test/cctest/test-compiler.cc
@@ -32,6 +32,7 @@
#include "src/compiler.h"
#include "src/disasm.h"
+#include "src/interpreter/interpreter.h"
#include "src/parsing/parser.h"
#include "test/cctest/cctest.h"
@@ -757,3 +758,45 @@ TEST(SplitConstantsInFullCompiler) {
CheckCodeForUnsafeLiteral(GetJSFunction(context->Global(), "f"));
}
#endif
+
+static void IsBaselineCompiled(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ Handle<Object> object = v8::Utils::OpenHandle(*args[0]);
+ Handle<JSFunction> function = Handle<JSFunction>::cast(object);
+ bool is_baseline = function->shared()->code()->kind() == Code::FUNCTION;
+ return args.GetReturnValue().Set(is_baseline);
+}
+
+static void InstallIsBaselineCompiledHelper(v8::Isolate* isolate) {
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::FunctionTemplate> t =
+ v8::FunctionTemplate::New(isolate, IsBaselineCompiled);
+ CHECK(context->Global()
+ ->Set(context, v8_str("IsBaselineCompiled"),
+ t->GetFunction(context).ToLocalChecked())
+ .FromJust());
+}
+
+TEST(IgnitionBaselineOnReturn) {
+ FLAG_allow_natives_syntax = true;
+ FLAG_always_opt = false;
+ CcTest::InitializeVM();
+ FLAG_ignition = true;
+ reinterpret_cast<i::Isolate*>(CcTest::isolate())->interpreter()->Initialize();
+ v8::HandleScope scope(CcTest::isolate());
+ InstallIsBaselineCompiledHelper(CcTest::isolate());
+
+ CompileRun(
+ "var is_baseline_in_function, is_baseline_after_return;\n"
+ "var return_val;\n"
+ "function f() {\n"
+ " %CompileBaseline(f);\n"
+ " is_baseline_in_function = IsBaselineCompiled(f);\n"
+ " return 1234;\n"
+ "};\n"
+ "return_val = f();\n"
+ "is_baseline_after_return = IsBaselineCompiled(f);\n");
+ CHECK_EQ(false, GetGlobalProperty("is_baseline_in_function")->BooleanValue());
+ CHECK_EQ(true, GetGlobalProperty("is_baseline_after_return")->BooleanValue());
+ CHECK_EQ(1234.0, GetGlobalProperty("return_val")->Number());
+}
« 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