Commit 068791e2 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[compiler] Remove is_native and is_eval accessors.

This removes some low-level accessors from the CompilationInfo which
only delegate to the ParseInfo. Instead we add a helper that computes
the flags passed to DeclareGlobals for all backends.

R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/1952623002
Cr-Commit-Position: refs/heads/master@{#36030}
parent ca5aa3c8
...@@ -50,9 +50,6 @@ namespace internal { ...@@ -50,9 +50,6 @@ namespace internal {
PARSE_INFO_GETTER(Handle<Script>, script) PARSE_INFO_GETTER(Handle<Script>, script)
PARSE_INFO_GETTER(bool, is_eval)
PARSE_INFO_GETTER(bool, is_native)
PARSE_INFO_GETTER(bool, is_module)
PARSE_INFO_GETTER(FunctionLiteral*, literal) PARSE_INFO_GETTER(FunctionLiteral*, literal)
PARSE_INFO_GETTER_WITH_DEFAULT(Scope*, scope, nullptr) PARSE_INFO_GETTER_WITH_DEFAULT(Scope*, scope, nullptr)
PARSE_INFO_GETTER_WITH_DEFAULT(Handle<Context>, context, PARSE_INFO_GETTER_WITH_DEFAULT(Handle<Context>, context,
...@@ -268,8 +265,15 @@ StackFrame::Type CompilationInfo::GetOutputStackFrameType() const { ...@@ -268,8 +265,15 @@ StackFrame::Type CompilationInfo::GetOutputStackFrameType() const {
} }
} }
int CompilationInfo::GetDeclareGlobalsFlags() const {
DCHECK(DeclareGlobalsLanguageMode::is_valid(parse_info()->language_mode()));
return DeclareGlobalsEvalFlag::encode(parse_info()->is_eval()) |
DeclareGlobalsNativeFlag::encode(parse_info()->is_native()) |
DeclareGlobalsLanguageMode::encode(parse_info()->language_mode());
}
bool CompilationInfo::ExpectsJSReceiverAsReceiver() { bool CompilationInfo::ExpectsJSReceiverAsReceiver() {
return is_sloppy(parse_info()->language_mode()) && !is_native(); return is_sloppy(parse_info()->language_mode()) && !parse_info()->is_native();
} }
#if DEBUG #if DEBUG
...@@ -1086,17 +1090,17 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { ...@@ -1086,17 +1090,17 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
// Measure how long it takes to do the compilation; only take the // Measure how long it takes to do the compilation; only take the
// rest of the function into account to avoid overlap with the // rest of the function into account to avoid overlap with the
// parsing statistics. // parsing statistics.
HistogramTimer* rate = info->is_eval() HistogramTimer* rate = parse_info->is_eval()
? info->isolate()->counters()->compile_eval() ? info->isolate()->counters()->compile_eval()
: info->isolate()->counters()->compile(); : info->isolate()->counters()->compile();
HistogramTimerScope timer(rate); HistogramTimerScope timer(rate);
TRACE_EVENT0("v8", info->is_eval() ? "V8.CompileEval" : "V8.Compile"); TRACE_EVENT0("v8", parse_info->is_eval() ? "V8.CompileEval" : "V8.Compile");
// Allocate a shared function info object. // Allocate a shared function info object.
DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); DCHECK_EQ(RelocInfo::kNoPosition, 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 (info->is_eval()) { if (parse_info->is_eval()) {
// Eval scripts cannot be (re-)compiled without context. // Eval scripts cannot be (re-)compiled without context.
result->set_allows_lazy_compilation_without_context(false); result->set_allows_lazy_compilation_without_context(false);
} }
...@@ -1117,7 +1121,8 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { ...@@ -1117,7 +1121,8 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
script->name()->IsString() script->name()->IsString()
? Handle<String>(String::cast(script->name())) ? Handle<String>(String::cast(script->name()))
: isolate->factory()->empty_string(); : isolate->factory()->empty_string();
Logger::LogEventsAndTags log_tag = info->is_eval() Logger::LogEventsAndTags log_tag =
parse_info->is_eval()
? Logger::EVAL_TAG ? Logger::EVAL_TAG
: Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script); : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script);
......
...@@ -175,9 +175,6 @@ class CompilationInfo final { ...@@ -175,9 +175,6 @@ class CompilationInfo final {
// TODO(titzer): inline and delete accessors of ParseInfo // TODO(titzer): inline and delete accessors of ParseInfo
// ----------------------------------------------------------- // -----------------------------------------------------------
Handle<Script> script() const; Handle<Script> script() const;
bool is_eval() const;
bool is_native() const;
bool is_module() const;
FunctionLiteral* literal() const; FunctionLiteral* literal() const;
Scope* scope() const; Scope* scope() const;
Handle<Context> context() const; Handle<Context> context() const;
...@@ -460,6 +457,8 @@ class CompilationInfo final { ...@@ -460,6 +457,8 @@ class CompilationInfo final {
StackFrame::Type GetOutputStackFrameType() const; StackFrame::Type GetOutputStackFrameType() const;
int GetDeclareGlobalsFlags() const;
protected: protected:
ParseInfo* parse_info_; ParseInfo* parse_info_;
......
...@@ -2951,9 +2951,7 @@ void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) { ...@@ -2951,9 +2951,7 @@ void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) {
Handle<FixedArray> data = isolate()->factory()->NewFixedArray( Handle<FixedArray> data = isolate()->factory()->NewFixedArray(
static_cast<int>(globals()->size()), TENURED); static_cast<int>(globals()->size()), TENURED);
for (Handle<Object> obj : *globals()) data->set(array_index++, *obj); for (Handle<Object> obj : *globals()) data->set(array_index++, *obj);
int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) | int encoded_flags = info()->GetDeclareGlobalsFlags();
DeclareGlobalsNativeFlag::encode(info()->is_native()) |
DeclareGlobalsLanguageMode::encode(language_mode());
Node* flags = jsgraph()->Constant(encoded_flags); Node* flags = jsgraph()->Constant(encoded_flags);
Node* pairs = jsgraph()->Constant(data); Node* pairs = jsgraph()->Constant(data);
const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals); const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals);
......
...@@ -12266,9 +12266,7 @@ void HOptimizedGraphBuilder::VisitDeclarations( ...@@ -12266,9 +12266,7 @@ void HOptimizedGraphBuilder::VisitDeclarations(
Handle<FixedArray> array = Handle<FixedArray> array =
isolate()->factory()->NewFixedArray(globals_.length(), TENURED); isolate()->factory()->NewFixedArray(globals_.length(), TENURED);
for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i)); for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i));
int flags = DeclareGlobalsEvalFlag::encode(current_info()->is_eval()) | int flags = current_info()->GetDeclareGlobalsFlags();
DeclareGlobalsNativeFlag::encode(current_info()->is_native()) |
DeclareGlobalsLanguageMode::encode(function_language_mode());
Add<HDeclareGlobals>(array, flags); Add<HDeclareGlobals>(array, flags);
globals_.Rewind(0); globals_.Rewind(0);
} }
......
...@@ -442,10 +442,7 @@ void FullCodeGenerator::VisitSloppyBlockFunctionStatement( ...@@ -442,10 +442,7 @@ void FullCodeGenerator::VisitSloppyBlockFunctionStatement(
int FullCodeGenerator::DeclareGlobalsFlags() { int FullCodeGenerator::DeclareGlobalsFlags() {
DCHECK(DeclareGlobalsLanguageMode::is_valid(language_mode())); return info_->GetDeclareGlobalsFlags();
return DeclareGlobalsEvalFlag::encode(is_eval()) |
DeclareGlobalsNativeFlag::encode(is_native()) |
DeclareGlobalsLanguageMode::encode(language_mode());
} }
void FullCodeGenerator::PushOperand(Handle<Object> handle) { void FullCodeGenerator::PushOperand(Handle<Object> handle) {
......
...@@ -726,8 +726,6 @@ class FullCodeGenerator: public AstVisitor { ...@@ -726,8 +726,6 @@ class FullCodeGenerator: public AstVisitor {
Isolate* isolate() const { return isolate_; } Isolate* isolate() const { return isolate_; }
Zone* zone() const { return zone_; } Zone* zone() const { return zone_; }
Handle<Script> script() { return info_->script(); } Handle<Script> script() { return info_->script(); }
bool is_eval() { return info_->is_eval(); }
bool is_native() { return info_->is_native(); }
LanguageMode language_mode() { return scope()->language_mode(); } LanguageMode language_mode() { return scope()->language_mode(); }
bool has_simple_parameters() { return info_->has_simple_parameters(); } bool has_simple_parameters() { return info_->has_simple_parameters(); }
FunctionLiteral* literal() const { return info_->literal(); } FunctionLiteral* literal() const { return info_->literal(); }
......
...@@ -874,9 +874,7 @@ void BytecodeGenerator::VisitDeclarations( ...@@ -874,9 +874,7 @@ void BytecodeGenerator::VisitDeclarations(
Handle<FixedArray> data = isolate()->factory()->NewFixedArray( Handle<FixedArray> data = isolate()->factory()->NewFixedArray(
static_cast<int>(globals()->size()), TENURED); static_cast<int>(globals()->size()), TENURED);
for (Handle<Object> obj : *globals()) data->set(array_index++, *obj); for (Handle<Object> obj : *globals()) data->set(array_index++, *obj);
int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) | int encoded_flags = info()->GetDeclareGlobalsFlags();
DeclareGlobalsNativeFlag::encode(info()->is_native()) |
DeclareGlobalsLanguageMode::encode(language_mode());
Register pairs = register_allocator()->NewRegister(); Register pairs = register_allocator()->NewRegister();
builder()->LoadLiteral(data); builder()->LoadLiteral(data);
......
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