Commit 89160006 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[compiler] Allow debug compilation for top-level eval.

This removes the restriction of only allowing lazy compilation for
top-level eval code with a context. We can by now compile such code
without a concrete closure.

R=yangguo@chromium.org

Review-Url: https://codereview.chromium.org/2400973002
Cr-Commit-Position: refs/heads/master@{#40089}
parent e4cc9557
...@@ -1106,10 +1106,6 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { ...@@ -1106,10 +1106,6 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
DCHECK_EQ(kNoSourcePosition, lit->function_token_position()); DCHECK_EQ(kNoSourcePosition, lit->function_token_position());
result = NewSharedFunctionInfoForLiteral(isolate, lit, script); result = NewSharedFunctionInfoForLiteral(isolate, lit, script);
result->set_is_toplevel(true); result->set_is_toplevel(true);
if (parse_info->is_eval()) {
// Eval scripts cannot be (re-)compiled without context.
result->set_allows_lazy_compilation_without_context(false);
}
parse_info->set_shared_info(result); parse_info->set_shared_info(result);
// Compile the code. // Compile the code.
...@@ -1285,8 +1281,12 @@ bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) { ...@@ -1285,8 +1281,12 @@ bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) {
Zone zone(isolate->allocator()); Zone zone(isolate->allocator());
ParseInfo parse_info(&zone, shared); ParseInfo parse_info(&zone, shared);
CompilationInfo info(&parse_info, Handle<JSFunction>::null()); CompilationInfo info(&parse_info, Handle<JSFunction>::null());
DCHECK(shared->allows_lazy_compilation_without_context()); if (IsEvalToplevel(shared)) {
DCHECK(!IsEvalToplevel(shared)); parse_info.set_eval();
parse_info.set_toplevel();
parse_info.set_allow_lazy_parsing(false);
parse_info.set_lazy(false);
}
info.MarkAsDebug(); info.MarkAsDebug();
if (GetUnoptimizedCode(&info).is_null()) { if (GetUnoptimizedCode(&info).is_null()) {
isolate->clear_pending_exception(); isolate->clear_pending_exception();
......
...@@ -1451,7 +1451,7 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script, ...@@ -1451,7 +1451,7 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
} }
} }
// If not, compile to reveal inner functions, if possible. // If not, compile to reveal inner functions, if possible.
if (shared->allows_lazy_compilation_without_context()) { if (shared->allows_lazy_compilation()) {
HandleScope scope(isolate_); HandleScope scope(isolate_);
if (!Compiler::CompileDebugCode(handle(shared))) break; if (!Compiler::CompileDebugCode(handle(shared))) break;
continue; continue;
...@@ -1470,7 +1470,7 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script, ...@@ -1470,7 +1470,7 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
candidate = candidate_closure->shared(); candidate = candidate_closure->shared();
} else if (object->IsSharedFunctionInfo()) { } else if (object->IsSharedFunctionInfo()) {
candidate = SharedFunctionInfo::cast(object); candidate = SharedFunctionInfo::cast(object);
if (!candidate->allows_lazy_compilation_without_context()) continue; if (!candidate->allows_lazy_compilation()) continue;
} else { } else {
continue; continue;
} }
......
...@@ -5949,10 +5949,6 @@ BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel, ...@@ -5949,10 +5949,6 @@ BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel,
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, allows_lazy_compilation, BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, allows_lazy_compilation,
kAllowLazyCompilation) kAllowLazyCompilation)
BOOL_ACCESSORS(SharedFunctionInfo,
compiler_hints,
allows_lazy_compilation_without_context,
kAllowLazyCompilationWithoutContext)
BOOL_ACCESSORS(SharedFunctionInfo, BOOL_ACCESSORS(SharedFunctionInfo,
compiler_hints, compiler_hints,
uses_arguments, uses_arguments,
......
...@@ -13718,8 +13718,6 @@ void SharedFunctionInfo::InitFromFunctionLiteral( ...@@ -13718,8 +13718,6 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
shared_info->set_is_anonymous_expression(lit->is_anonymous_expression()); shared_info->set_is_anonymous_expression(lit->is_anonymous_expression());
shared_info->set_inferred_name(*lit->inferred_name()); shared_info->set_inferred_name(*lit->inferred_name());
shared_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); shared_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation());
shared_info->set_allows_lazy_compilation_without_context(
lit->AllowsLazyCompilation());
shared_info->set_language_mode(lit->language_mode()); shared_info->set_language_mode(lit->language_mode());
shared_info->set_uses_arguments(lit->scope()->arguments() != NULL); shared_info->set_uses_arguments(lit->scope()->arguments() != NULL);
shared_info->set_has_duplicate_parameters(lit->has_duplicate_parameters()); shared_info->set_has_duplicate_parameters(lit->has_duplicate_parameters());
......
...@@ -7363,12 +7363,6 @@ class SharedFunctionInfo: public HeapObject { ...@@ -7363,12 +7363,6 @@ class SharedFunctionInfo: public HeapObject {
// when doing GC if we expect that the function will no longer be used. // when doing GC if we expect that the function will no longer be used.
DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation) DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation)
// Indicates if this function can be lazy compiled without a context.
// This is used to determine if we can force compilation without reaching
// the function through program execution but through other means (e.g. heap
// iteration by the debugger).
DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation_without_context)
// Indicates whether optimizations have been disabled for this // Indicates whether optimizations have been disabled for this
// shared function info. If a function is repeatedly optimized or if // shared function info. If a function is repeatedly optimized or if
// we cannot optimize the function we disable optimization to avoid // we cannot optimize the function we disable optimization to avoid
...@@ -7686,7 +7680,7 @@ class SharedFunctionInfo: public HeapObject { ...@@ -7686,7 +7680,7 @@ class SharedFunctionInfo: public HeapObject {
enum CompilerHints { enum CompilerHints {
// byte 0 // byte 0
kAllowLazyCompilation, kAllowLazyCompilation,
kAllowLazyCompilationWithoutContext, kIsDeclaration,
kOptimizationDisabled, kOptimizationDisabled,
kNeverCompiled, kNeverCompiled,
kNative, kNative,
...@@ -7707,7 +7701,6 @@ class SharedFunctionInfo: public HeapObject { ...@@ -7707,7 +7701,6 @@ class SharedFunctionInfo: public HeapObject {
// rest of byte 2 and first two bits of byte 3 are used by FunctionKind // rest of byte 2 and first two bits of byte 3 are used by FunctionKind
// byte 3 // byte 3
kDeserialized = kFunctionKind + 10, kDeserialized = kFunctionKind + 10,
kIsDeclaration,
kIsAsmWasmBroken, kIsAsmWasmBroken,
kRequiresClassFieldInit, kRequiresClassFieldInit,
kIsClassFieldInitializer, kIsClassFieldInitializer,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment