| 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());
|
| +}
|
|
|