Commit 1407c894 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[parser] Remove ParseInfo::closure field.

The parser should never need to look at the underlying closure object,
hence the field can be moved from ParseInfo into CompilationInfo.

R=rossberg@chromium.org

Review URL: https://codereview.chromium.org/1863083002

Cr-Commit-Position: refs/heads/master@{#35358}
parent 68317868
......@@ -57,8 +57,6 @@ PARSE_INFO_GETTER(bool, is_native)
PARSE_INFO_GETTER(bool, is_module)
PARSE_INFO_GETTER(FunctionLiteral*, literal)
PARSE_INFO_GETTER_WITH_DEFAULT(LanguageMode, language_mode, STRICT)
PARSE_INFO_GETTER_WITH_DEFAULT(Handle<JSFunction>, closure,
Handle<JSFunction>::null())
PARSE_INFO_GETTER_WITH_DEFAULT(Scope*, scope, nullptr)
PARSE_INFO_GETTER_WITH_DEFAULT(Handle<Context>, context,
Handle<Context>::null())
......@@ -86,7 +84,7 @@ class CompilationHandleScope BASE_EMBEDDED {
class CompilationInfoWithZone : public CompilationInfo {
public:
explicit CompilationInfoWithZone(Handle<JSFunction> function)
: CompilationInfo(new ParseInfo(&zone_, function)),
: CompilationInfo(new ParseInfo(&zone_, function), function),
zone_(function->GetIsolate()->allocator()) {}
// Virtual destructor because a CompilationInfoWithZone has to exit the
......@@ -110,10 +108,12 @@ bool CompilationInfo::has_shared_info() const {
return parse_info_ && !parse_info_->shared_info().is_null();
}
CompilationInfo::CompilationInfo(ParseInfo* parse_info)
CompilationInfo::CompilationInfo(ParseInfo* parse_info,
Handle<JSFunction> closure)
: CompilationInfo(parse_info, nullptr, Code::ComputeFlags(Code::FUNCTION),
BASE, parse_info->isolate(), parse_info->zone()) {
closure_ = closure;
// Compiling for the snapshot typically results in different code than
// compiling later on. This means that code recompiled with deoptimization
// support won't be "equivalent" (as defined by SharedFunctionInfo::
......@@ -1116,7 +1116,7 @@ bool CompileEvalForDebugging(Handle<JSFunction> function,
Zone zone(function->GetIsolate()->allocator());
ParseInfo parse_info(&zone, script);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, Handle<JSFunction>::null());
Isolate* isolate = info.isolate();
parse_info.set_eval();
......@@ -1377,7 +1377,7 @@ bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) {
DCHECK(!IsEvalToplevel(shared));
Zone zone(shared->GetIsolate()->allocator());
ParseInfo parse_info(&zone, shared);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, Handle<JSFunction>::null());
return CompileForDebugging(&info);
}
......@@ -1429,7 +1429,7 @@ void Compiler::CompileForLiveEdit(Handle<Script> script) {
// TODO(635): support extensions.
Zone zone(script->GetIsolate()->allocator());
ParseInfo parse_info(&zone, script);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, Handle<JSFunction>::null());
PostponeInterruptsScope postpone(info.isolate());
VMState<COMPILER> state(info.isolate());
......@@ -1471,7 +1471,7 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
script->set_origin_options(options);
Zone zone(isolate->allocator());
ParseInfo parse_info(&zone, script);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, Handle<JSFunction>::null());
parse_info.set_eval();
if (context->IsNativeContext()) parse_info.set_global();
parse_info.set_language_mode(language_mode);
......@@ -1595,7 +1595,7 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
// Compile the function and add it to the cache.
Zone zone(isolate->allocator());
ParseInfo parse_info(&zone, script);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, Handle<JSFunction>::null());
if (is_module) {
parse_info.set_module();
} else {
......@@ -1652,7 +1652,7 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForStreamedScript(
parse_info->set_language_mode(
static_cast<LanguageMode>(parse_info->language_mode() | language_mode));
CompilationInfo compile_info(parse_info);
CompilationInfo compile_info(parse_info, Handle<JSFunction>::null());
// The source was parsed lazily, so compiling for debugging is not possible.
DCHECK(!compile_info.is_debug());
......@@ -1699,7 +1699,7 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
Zone zone(isolate->allocator());
ParseInfo parse_info(&zone, script);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, Handle<JSFunction>::null());
parse_info.set_literal(literal);
parse_info.set_shared_info(result);
parse_info.set_scope(literal->scope());
......
......@@ -163,7 +163,7 @@ class CompilationInfo {
kBailoutOnUninitialized = 1 << 19,
};
explicit CompilationInfo(ParseInfo* parse_info);
CompilationInfo(ParseInfo* parse_info, Handle<JSFunction> closure);
CompilationInfo(const char* debug_name, Isolate* isolate, Zone* zone,
Code::Flags code_flags = Code::ComputeFlags(Code::STUB));
virtual ~CompilationInfo();
......@@ -178,7 +178,6 @@ class CompilationInfo {
bool is_native() const;
bool is_module() const;
LanguageMode language_mode() const;
Handle<JSFunction> closure() const;
FunctionLiteral* literal() const;
Scope* scope() const;
Handle<Context> context() const;
......@@ -191,6 +190,7 @@ class CompilationInfo {
}
Zone* zone() { return zone_; }
bool is_osr() const { return !osr_ast_id_.IsNone(); }
Handle<JSFunction> closure() const { return closure_; }
Handle<Code> code() const { return code_; }
Code::Flags code_flags() const { return code_flags_; }
BailoutId osr_ast_id() const { return osr_ast_id_; }
......@@ -378,7 +378,7 @@ class CompilationInfo {
}
void ReopenHandlesInNewHandleScope() {
// Empty for now but will be needed once fields move from ParseInfo.
closure_ = Handle<JSFunction>(*closure_);
}
void AbortOptimization(BailoutReason reason) {
......@@ -522,6 +522,8 @@ class CompilationInfo {
Code::Flags code_flags_;
Handle<JSFunction> closure_;
// The compiled code.
Handle<Code> code_;
......
......@@ -414,7 +414,7 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) {
Zone zone(info_->isolate()->allocator());
ParseInfo parse_info(&zone, function);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, function);
if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled();
if (!Compiler::ParseAndAnalyze(info.parse_info())) {
......
......@@ -8383,7 +8383,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
top_info()->parse_info()->ast_value_factory());
parse_info.set_ast_value_factory_owned(false);
CompilationInfo target_info(&parse_info);
CompilationInfo target_info(&parse_info, target);
Handle<SharedFunctionInfo> target_shared(target->shared());
if (inlining_kind != CONSTRUCT_CALL_RETURN &&
......
......@@ -39,7 +39,6 @@ ScriptData::ScriptData(const byte* data, int length)
}
}
ParseInfo::ParseInfo(Zone* zone)
: zone_(zone),
flags_(0),
......@@ -51,15 +50,14 @@ ParseInfo::ParseInfo(Zone* zone)
unicode_cache_(nullptr),
stack_limit_(0),
hash_seed_(0),
isolate_(nullptr),
cached_data_(nullptr),
ast_value_factory_(nullptr),
literal_(nullptr),
scope_(nullptr) {}
ParseInfo::ParseInfo(Zone* zone, Handle<JSFunction> function)
: ParseInfo(zone, Handle<SharedFunctionInfo>(function->shared())) {
set_closure(function);
set_context(Handle<Context>(function->context()));
}
......@@ -1048,12 +1046,12 @@ FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info,
// Parse the function literal.
Scope* scope = NewScope(scope_, SCRIPT_SCOPE);
info->set_script_scope(scope);
if (!info->closure().is_null()) {
if (!info->context().is_null()) {
// Ok to use Isolate here, since lazy function parsing is only done in the
// main thread.
DCHECK(parsing_on_main_thread_);
scope = Scope::DeserializeScopeChain(isolate, zone(),
info->closure()->context(), scope);
scope = Scope::DeserializeScopeChain(isolate, zone(), *info->context(),
scope);
}
original_scope_ = scope;
AstNodeFactory function_factory(ast_value_factory());
......
......@@ -125,7 +125,6 @@ class ParseInfo {
// TODO(titzer): these should not be part of ParseInfo.
//--------------------------------------------------------------------------
Isolate* isolate() { return isolate_; }
Handle<JSFunction> closure() { return closure_; }
Handle<SharedFunctionInfo> shared_info() { return shared_; }
Handle<Script> script() { return script_; }
Handle<Context> context() { return context_; }
......@@ -145,7 +144,6 @@ class ParseInfo {
}
void ReopenHandlesInNewHandleScope() {
closure_ = Handle<JSFunction>(*closure_);
shared_ = Handle<SharedFunctionInfo>(*shared_);
script_ = Handle<Script>(*script_);
context_ = Handle<Context>(*context_);
......@@ -186,7 +184,6 @@ class ParseInfo {
// TODO(titzer): Move handles and isolate out of ParseInfo.
Isolate* isolate_;
Handle<JSFunction> closure_;
Handle<SharedFunctionInfo> shared_;
Handle<Script> script_;
Handle<Context> context_;
......@@ -202,8 +199,6 @@ class ParseInfo {
void SetFlag(Flag f) { flags_ |= f; }
void SetFlag(Flag f, bool v) { flags_ = v ? flags_ | f : flags_ & ~f; }
bool GetFlag(Flag f) const { return (flags_ & f) != 0; }
void set_closure(Handle<JSFunction> closure) { closure_ = closure; }
};
class FunctionEntry BASE_EMBEDDED {
......
......@@ -177,7 +177,7 @@ class FunctionTester : public InitializedHandleScope {
Handle<JSFunction> Compile(Handle<JSFunction> function) {
Zone zone(function->GetIsolate()->allocator());
ParseInfo parse_info(&zone, function);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, function);
info.MarkAsDeoptimizationEnabled();
CHECK(Parser::ParseStatic(info.parse_info()));
......@@ -226,7 +226,7 @@ class FunctionTester : public InitializedHandleScope {
Handle<JSFunction> CompileGraph(Graph* graph) {
Zone zone(function->GetIsolate()->allocator());
ParseInfo parse_info(&zone, function);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, function);
CHECK(Parser::ParseStatic(info.parse_info()));
info.SetOptimizing();
......
......@@ -43,7 +43,7 @@ TEST(TestLinkageCreate) {
HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + b");
ParseInfo parse_info(handles.main_zone(), function);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, function);
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
CHECK(descriptor);
}
......@@ -59,7 +59,7 @@ TEST(TestLinkageJSFunctionIncoming) {
Handle<JSFunction>::cast(v8::Utils::OpenHandle(
*v8::Local<v8::Function>::Cast(CompileRun(sources[i]))));
ParseInfo parse_info(handles.main_zone(), function);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, function);
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
CHECK(descriptor);
......@@ -75,7 +75,7 @@ TEST(TestLinkageJSCall) {
HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + c");
ParseInfo parse_info(handles.main_zone(), function);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, function);
for (int i = 0; i < 32; i++) {
CallDescriptor* descriptor = Linkage::GetJSCallDescriptor(
......
......@@ -31,7 +31,7 @@ struct TestHelper : public HandleAndZoneScope {
void CheckLoopAssignedCount(int expected, const char* var_name) {
// TODO(titzer): don't scope analyze every single time.
ParseInfo parse_info(main_zone(), function);
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, function);
CHECK(Parser::ParseStatic(&parse_info));
CHECK(Rewriter::Rewrite(&parse_info));
......
......@@ -17,7 +17,7 @@ static void RunPipeline(Zone* zone, const char* source) {
*v8::Local<v8::Function>::Cast(CompileRun(source))));
ParseInfo parse_info(zone, function);
CHECK(Compiler::ParseAndAnalyze(&parse_info));
CompilationInfo info(&parse_info);
CompilationInfo info(&parse_info, function);
info.SetOptimizing();
Pipeline pipeline(&info);
......
......@@ -125,7 +125,7 @@ class BytecodeGraphTester {
// having to instantiate a ParseInfo first. Fix this!
ParseInfo parse_info(zone_, function);
CompilationInfo compilation_info(&parse_info);
CompilationInfo compilation_info(&parse_info, function);
compilation_info.SetOptimizing();
compilation_info.MarkAsDeoptimizationEnabled();
compiler::Pipeline pipeline(&compilation_info);
......
......@@ -1126,7 +1126,6 @@ static void CheckParsesToNumber(const char* source, bool with_dot) {
info.set_allow_lazy_parsing(false);
info.set_toplevel(true);
i::CompilationInfo compilation_info(&info);
CHECK(i::Compiler::ParseAndAnalyze(&info));
CHECK(info.scope()->declarations()->length() == 1);
......
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