} 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) {
class AstExpressionVisitor : public AstVisitor {
public:
- explicit AstExpressionVisitor(CompilationInfo* info);
+ AstExpressionVisitor(Isolate* isolate, Zone* zone, FunctionLiteral* root);
void Run();
protected:
AST_NODE_LIST(DECLARE_VISIT)
#undef DECLARE_VISIT
- CompilationInfo* compilation_info_;
+ FunctionLiteral* root_;
int depth_;
DISALLOW_COPY_AND_ASSIGN(AstExpressionVisitor);
}
// 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.
// 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()) {
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) {
class TypingReseter : public AstExpressionVisitor {
public:
- explicit TypingReseter(CompilationInfo* info);
+ TypingReseter(Isolate* isolate, Zone* zone, FunctionLiteral* root);
protected:
void VisitExpression(Expression* expression) override;
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);
}
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.
#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,
- &global_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),
frame->GetExpression(i),
void AstTyper::Run() {
- Scope* scope = info_->scope();
- RECURSE(VisitDeclarations(scope->declarations()));
- RECURSE(VisitStatements(info_->literal()->body()));
+ RECURSE(VisitDeclarations(scope_->declarations()));
+ RECURSE(VisitStatements(root_->body()));
}
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();
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_;
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() {
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;
class ExpressionTypeCollector : public AstExpressionVisitor {
public:
- ExpressionTypeCollector(CompilationInfo* info,
+ ExpressionTypeCollector(Isolate* isolate, Zone* zone, FunctionLiteral* root,
ZoneVector<ExpressionTypeEntry>* dst);
void Run();
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();
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();
}
}
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) {
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());
}