Commit 29d79372 authored by bradnelson's avatar bradnelson Committed by Commit bot

Eliminate use of CompilationInfo in several AstVisitor descendants.

We're moving away from using CompilationInfo as a big bag o' stuff.
Passing in just what we need to several AstVisitors to avoid
increasing the problem.

BUG=None
TEST=trybots
R=titzer@chromium.org
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#30529}
parent 89ff78f3
......@@ -32,15 +32,14 @@ namespace internal {
} while (false)
AstExpressionVisitor::AstExpressionVisitor(CompilationInfo* info)
: compilation_info_(info), depth_(0) {
InitializeAstVisitor(info->isolate(), info->zone());
AstExpressionVisitor::AstExpressionVisitor(Isolate* isolate, Zone* zone,
FunctionLiteral* root)
: root_(root), depth_(0) {
InitializeAstVisitor(isolate, zone);
}
void AstExpressionVisitor::Run() {
RECURSE(VisitFunctionLiteral(compilation_info_->literal()));
}
void AstExpressionVisitor::Run() { RECURSE(VisitFunctionLiteral(root_)); }
void AstExpressionVisitor::VisitVariableDeclaration(VariableDeclaration* decl) {
......
......@@ -21,7 +21,7 @@ namespace internal {
class AstExpressionVisitor : public AstVisitor {
public:
explicit AstExpressionVisitor(CompilationInfo* info);
AstExpressionVisitor(Isolate* isolate, Zone* zone, FunctionLiteral* root);
void Run();
protected:
......@@ -38,7 +38,7 @@ class AstExpressionVisitor : public AstVisitor {
AST_NODE_LIST(DECLARE_VISIT)
#undef DECLARE_VISIT
CompilationInfo* compilation_info_;
FunctionLiteral* root_;
int depth_;
DISALLOW_COPY_AND_ASSIGN(AstExpressionVisitor);
......
......@@ -488,7 +488,9 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
}
// Type-check the function.
AstTyper(info()).Run();
AstTyper(info()->isolate(), info()->zone(), info()->closure(),
info()->scope(), info()->osr_ast_id(), info()->literal())
.Run();
// Optimization could have been disabled by the parser. Note that this check
// is only needed because the Hydrogen graph builder is missing some bailouts.
......
......@@ -8335,7 +8335,9 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
// Type-check the inlined function.
DCHECK(target_shared->has_deoptimization_support());
AstTyper(&target_info).Run();
AstTyper(target_info.isolate(), target_info.zone(), target_info.closure(),
target_info.scope(), target_info.osr_ast_id(), target_info.literal())
.Run();
int inlining_id = 0;
if (top_info()->is_tracking_positions()) {
......
......@@ -14,8 +14,9 @@ namespace v8 {
namespace internal {
TypingReseter::TypingReseter(CompilationInfo* info)
: AstExpressionVisitor(info) {}
TypingReseter::TypingReseter(Isolate* isolate, Zone* zone,
FunctionLiteral* root)
: AstExpressionVisitor(isolate, zone, root) {}
void TypingReseter::VisitExpression(Expression* expression) {
......
......@@ -15,7 +15,7 @@ namespace internal {
class TypingReseter : public AstExpressionVisitor {
public:
explicit TypingReseter(CompilationInfo* info);
TypingReseter(Isolate* isolate, Zone* zone, FunctionLiteral* root);
protected:
void VisitExpression(Expression* expression) override;
......
......@@ -15,14 +15,17 @@ namespace v8 {
namespace internal {
AstTyper::AstTyper(CompilationInfo* info)
: info_(info),
oracle_(info->isolate(), info->zone(),
handle(info->closure()->shared()->code()),
handle(info->closure()->shared()->feedback_vector()),
handle(info->closure()->context()->native_context())),
store_(info->zone()) {
InitializeAstVisitor(info->isolate(), info->zone());
AstTyper::AstTyper(Isolate* isolate, Zone* zone, Handle<JSFunction> closure,
Scope* scope, BailoutId osr_ast_id, FunctionLiteral* root)
: closure_(closure),
scope_(scope),
osr_ast_id_(osr_ast_id),
root_(root),
oracle_(isolate, zone, handle(closure->shared()->code()),
handle(closure->shared()->feedback_vector()),
handle(closure->context()->native_context())),
store_(zone) {
InitializeAstVisitor(isolate, zone);
}
......@@ -45,18 +48,17 @@ Effect AstTyper::ObservedOnStack(Object* value) {
void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) {
if (stmt->OsrEntryId() != info_->osr_ast_id()) return;
if (stmt->OsrEntryId() != osr_ast_id_) return;
DisallowHeapAllocation no_gc;
JavaScriptFrameIterator it(isolate());
JavaScriptFrame* frame = it.frame();
Scope* scope = info_->scope();
// Assert that the frame on the stack belongs to the function we want to OSR.
DCHECK_EQ(*info_->closure(), frame->function());
DCHECK_EQ(*closure_, frame->function());
int params = scope->num_parameters();
int locals = scope->StackLocalCount();
int params = scope_->num_parameters();
int locals = scope_->StackLocalCount();
// Use sequential composition to achieve desired narrowing.
// The receiver is a parameter with index -1.
......@@ -71,20 +73,18 @@ void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) {
#ifdef OBJECT_PRINT
if (FLAG_trace_osr && FLAG_print_scopes) {
PrintObserved(scope->receiver(),
frame->receiver(),
PrintObserved(scope_->receiver(), frame->receiver(),
store_.LookupBounds(parameter_index(-1)).lower);
for (int i = 0; i < params; i++) {
PrintObserved(scope->parameter(i),
frame->GetParameter(i),
PrintObserved(scope_->parameter(i), frame->GetParameter(i),
store_.LookupBounds(parameter_index(i)).lower);
}
ZoneList<Variable*> local_vars(locals, zone());
ZoneList<Variable*> context_vars(scope->ContextLocalCount(), zone());
ZoneList<Variable*> global_vars(scope->ContextGlobalCount(), zone());
scope->CollectStackAndContextLocals(&local_vars, &context_vars,
ZoneList<Variable*> context_vars(scope_->ContextLocalCount(), zone());
ZoneList<Variable*> global_vars(scope_->ContextGlobalCount(), zone());
scope_->CollectStackAndContextLocals(&local_vars, &context_vars,
&global_vars);
for (int i = 0; i < locals; i++) {
PrintObserved(local_vars.at(i),
......@@ -105,9 +105,8 @@ void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) {
void AstTyper::Run() {
Scope* scope = info_->scope();
RECURSE(VisitDeclarations(scope->declarations()));
RECURSE(VisitStatements(info_->literal()->body()));
RECURSE(VisitDeclarations(scope_->declarations()));
RECURSE(VisitStatements(root_->body()));
}
......
......@@ -19,7 +19,8 @@ namespace internal {
class AstTyper: public AstVisitor {
public:
explicit AstTyper(CompilationInfo* info);
AstTyper(Isolate* isolate, Zone* zone, Handle<JSFunction> closure,
Scope* scope, BailoutId osr_ast_id, FunctionLiteral* root);
void Run();
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
......@@ -32,7 +33,10 @@ class AstTyper: public AstVisitor {
typedef v8::internal::Effects<int, kNoVar> Effects;
typedef v8::internal::NestedEffects<int, kNoVar> Store;
CompilationInfo* info_;
Handle<JSFunction> closure_;
Scope* scope_;
BailoutId osr_ast_id_;
FunctionLiteral* root_;
TypeFeedbackOracle oracle_;
Store store_;
......
......@@ -28,8 +28,9 @@ struct {
ExpressionTypeCollector::ExpressionTypeCollector(
CompilationInfo* info, ZoneVector<ExpressionTypeEntry>* dst)
: AstExpressionVisitor(info), result_(dst) {}
Isolate* isolate, Zone* zone, FunctionLiteral* root,
ZoneVector<ExpressionTypeEntry>* dst)
: AstExpressionVisitor(isolate, zone, root), result_(dst) {}
void ExpressionTypeCollector::Run() {
......
......@@ -10,10 +10,9 @@
namespace v8 {
namespace internal {
// A Visitor over a CompilationInfo's AST that collects
// a human readable string summarizing structure and types.
// Used for testing of the typing information attached to the
// expression nodes of an AST.
// A Visitor over an AST that collects a human readable string summarizing
// structure and types. Used for testing of the typing information attached
// to the expression nodes of an AST.
struct ExpressionTypeEntry {
int depth;
......@@ -24,7 +23,7 @@ struct ExpressionTypeEntry {
class ExpressionTypeCollector : public AstExpressionVisitor {
public:
ExpressionTypeCollector(CompilationInfo* info,
ExpressionTypeCollector(Isolate* isolate, Zone* zone, FunctionLiteral* root,
ZoneVector<ExpressionTypeEntry>* dst);
void Run();
......
......@@ -62,16 +62,13 @@ std::string Validate(Zone* zone, const char* source,
info.set_allow_lazy_parsing(false);
info.set_toplevel(true);
i::CompilationInfo compilation_info(&info);
CHECK(i::Compiler::ParseAndAnalyze(&info));
info.set_literal(
info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun());
AsmTyper typer(
isolate, zone, *script,
info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun());
FunctionLiteral* root =
info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun();
AsmTyper typer(isolate, zone, *script, root);
if (typer.Validate()) {
ExpressionTypeCollector(&compilation_info, types).Run();
ExpressionTypeCollector(isolate, zone, root, types).Run();
return "";
} else {
return typer.error_message();
......
......@@ -38,12 +38,12 @@ static void CollectTypes(HandleAndZoneScope* handles, const char* source,
info.set_allow_lazy_parsing(false);
info.set_toplevel(true);
i::CompilationInfo compilation_info(&info);
CHECK(i::Compiler::ParseAndAnalyze(&info));
info.set_literal(
info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun());
ExpressionTypeCollector(&compilation_info, dst).Run();
ExpressionTypeCollector(
isolate, handles->main_zone(),
info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun(), dst)
.Run();
}
}
......
......@@ -25,7 +25,8 @@ namespace {
class TypeSetter : public AstExpressionVisitor {
public:
explicit TypeSetter(CompilationInfo* info) : AstExpressionVisitor(info) {}
TypeSetter(Isolate* isolate, Zone* zone, FunctionLiteral* root)
: AstExpressionVisitor(isolate, zone, root) {}
protected:
void VisitExpression(Expression* expression) {
......@@ -276,23 +277,22 @@ TEST(ResetTypingInfo) {
info.set_allow_lazy_parsing(false);
info.set_toplevel(true);
i::CompilationInfo compilation_info(&info);
CHECK(i::Compiler::ParseAndAnalyze(&info));
info.set_literal(
info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun());
FunctionLiteral* root =
info.scope()->declarations()->at(0)->AsFunctionDeclaration()->fun();
// Core of the test.
ZoneVector<ExpressionTypeEntry> types(handles.main_zone());
ExpressionTypeCollector(&compilation_info, &types).Run();
ExpressionTypeCollector(isolate, handles.main_zone(), root, &types).Run();
CheckAllSame(types, Bounds::Unbounded());
TypeSetter(&compilation_info).Run();
TypeSetter(isolate, handles.main_zone(), root).Run();
ExpressionTypeCollector(&compilation_info, &types).Run();
ExpressionTypeCollector(isolate, handles.main_zone(), root, &types).Run();
CheckAllSame(types, INT32_TYPE);
TypingReseter(&compilation_info).Run();
TypingReseter(isolate, handles.main_zone(), root).Run();
ExpressionTypeCollector(&compilation_info, &types).Run();
ExpressionTypeCollector(isolate, handles.main_zone(), root, &types).Run();
CheckAllSame(types, Bounds::Unbounded());
}
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