| Index: src/compiler.cc
|
| diff --git a/src/compiler.cc b/src/compiler.cc
|
| index 73eeba09cf96e96cc417aaccf1cdb87e46a6f62d..be5f9a1583a15100fefb8d7f1ce6d095566c47e3 100644
|
| --- a/src/compiler.cc
|
| +++ b/src/compiler.cc
|
| @@ -419,6 +419,12 @@ void CompilationJob::RecordOptimizationStats() {
|
|
|
| namespace {
|
|
|
| +bool IsEvalToplevel(Handle<SharedFunctionInfo> shared) {
|
| + return shared->is_toplevel() && shared->script()->IsScript() &&
|
| + Script::cast(shared->script())->compilation_type() ==
|
| + Script::COMPILATION_TYPE_EVAL;
|
| +}
|
| +
|
| void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
|
| CompilationInfo* info) {
|
| // Log the code generation. If source information is available include
|
| @@ -766,12 +772,6 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
|
| shared->code()->set_profiler_ticks(0);
|
| }
|
|
|
| - // TODO(mstarzinger): We cannot properly deserialize a scope chain containing
|
| - // an eval scope and hence would fail at parsing the eval source again.
|
| - if (shared->disable_optimization_reason() == kEval) {
|
| - return MaybeHandle<Code>();
|
| - }
|
| -
|
| VMState<COMPILER> state(isolate);
|
| DCHECK(!isolate->has_pending_exception());
|
| PostponeInterruptsScope postpone(isolate);
|
| @@ -780,6 +780,7 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
|
| use_turbofan ? compiler::Pipeline::NewCompilationJob(function)
|
| : new HCompilationJob(function));
|
| CompilationInfo* info = job->info();
|
| + ParseInfo* parse_info = info->parse_info();
|
|
|
| info->SetOptimizingForOsr(osr_ast_id);
|
|
|
| @@ -814,6 +815,14 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
|
| info->MarkAsOptimizeFromBytecode();
|
| }
|
|
|
| + if (IsEvalToplevel(shared)) {
|
| + parse_info->set_eval();
|
| + if (function->context()->IsNativeContext()) parse_info->set_global();
|
| + parse_info->set_toplevel();
|
| + parse_info->set_allow_lazy_parsing(false);
|
| + parse_info->set_lazy(false);
|
| + }
|
| +
|
| if (mode == Compiler::CONCURRENT) {
|
| if (GetOptimizedCodeLater(job.get())) {
|
| job.Detach(); // The background recompile job owns this now.
|
| @@ -1002,12 +1011,6 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) {
|
| }
|
|
|
|
|
| -inline bool IsEvalToplevel(Handle<SharedFunctionInfo> shared) {
|
| - return shared->is_toplevel() && shared->script()->IsScript() &&
|
| - Script::cast(shared->script())->compilation_type() ==
|
| - Script::COMPILATION_TYPE_EVAL;
|
| -}
|
| -
|
| Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral(
|
| Isolate* isolate, FunctionLiteral* literal, Handle<Script> script) {
|
| Handle<Code> code = isolate->builtins()->CompileLazy();
|
|
|