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