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

Unified Diff: src/compiler.cc

Issue 1884143003: [compiler] Allow optimization of top-level eval code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-compiler-simplify-13
Patch Set: Fix comment typo. 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 | « no previous file | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698