| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3f65598 commit bcb255d
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3199,7 +3199,7 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction( | |||
| 3199 | 3199 | // functions fully non-lazy instead thus preventing source positions from | |
| 3200 | 3200 | // being omitted. | |
| 3201 | 3201 | flags.set_collect_source_positions(true); | |
| 3202 | - // flags.set_eager(compile_options == ScriptCompiler::kEagerCompile); | ||
| 3202 | + flags.set_is_eager(compile_options == ScriptCompiler::kEagerCompile); | ||
| 3203 | 3203 | ||
| 3204 | 3204 | UnoptimizedCompileState compile_state; | |
| 3205 | 3205 | ReusableUnoptimizedCompileState reusable_state(isolate); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4937,6 +4937,37 @@ TEST(CachedCompileFunction) { | |||
| 4937 | 4937 | } | |
| 4938 | 4938 | } | |
| 4939 | 4939 | ||
| 4940 | + TEST(CachedCompileFunctionRespectsEager) { | ||
| 4941 | + DisableAlwaysOpt(); | ||
| 4942 | + LocalContext env; | ||
| 4943 | + Isolate* isolate = CcTest::i_isolate(); | ||
| 4944 | + isolate->compilation_cache() | ||
| 4945 | + ->DisableScriptAndEval(); // Disable same-isolate code cache. | ||
| 4946 | + | ||
| 4947 | + v8::HandleScope scope(CcTest::isolate()); | ||
| 4948 | + | ||
| 4949 | + v8::Local<v8::String> source = v8_str("return function() { return 42; }"); | ||
| 4950 | + v8::ScriptCompiler::Source script_source(source); | ||
| 4951 | + | ||
| 4952 | + for (bool eager_compile : {false, true}) { | ||
| 4953 | + v8::ScriptCompiler::CompileOptions options = | ||
| 4954 | + eager_compile ? v8::ScriptCompiler::kEagerCompile | ||
| 4955 | + : v8::ScriptCompiler::kNoCompileOptions; | ||
| 4956 | + v8::Local<v8::Value> fun = | ||
| 4957 | + v8::ScriptCompiler::CompileFunction(env.local(), &script_source, 0, | ||
| 4958 | + nullptr, 0, nullptr, options) | ||
| 4959 | + .ToLocalChecked() | ||
| 4960 | + .As<v8::Function>() | ||
| 4961 | + ->Call(env.local(), v8::Undefined(CcTest::isolate()), 0, nullptr) | ||
| 4962 | + .ToLocalChecked(); | ||
| 4963 | + | ||
| 4964 | + auto i_fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(*fun)); | ||
| 4965 | + | ||
| 4966 | + // Function should be compiled iff kEagerCompile was used. | ||
| 4967 | + CHECK_EQ(i_fun->shared().is_compiled(), eager_compile); | ||
| 4968 | + } | ||
| 4969 | + } | ||
| 4970 | + | ||
| 4940 | 4971 | UNINITIALIZED_TEST(SnapshotCreatorAnonClassWithKeep) { | |
| 4941 | 4972 | DisableAlwaysOpt(); | |
| 4942 | 4973 | v8::SnapshotCreator creator; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments