Index: src/ast-numbering.cc |
diff --git a/src/ast-numbering.cc b/src/ast-numbering.cc |
index 8994ac8c78c7ca1a26d1f03fb5fb04114323aaff..3894492a0205f3224246ce90a2458bf0809c4b1d 100644 |
--- a/src/ast-numbering.cc |
+++ b/src/ast-numbering.cc |
@@ -16,7 +16,10 @@ namespace internal { |
class AstNumberingVisitor FINAL : public AstVisitor { |
public: |
explicit AstNumberingVisitor(Zone* zone) |
- : AstVisitor(), next_id_(BailoutId::FirstUsable().ToInt()) { |
+ : AstVisitor(), |
+ next_id_(BailoutId::FirstUsable().ToInt()), |
+ dont_crankshaft_reason_(kNoReason), |
+ dont_turbofan_reason_(kNoReason) { |
InitializeAstVisitor(zone); |
} |
@@ -40,9 +43,36 @@ class AstNumberingVisitor FINAL : public AstVisitor { |
} |
void IncrementNodeCount() { properties_.add_node_count(1); } |
+ void DisableCrankshaft(BailoutReason reason) { |
+ dont_crankshaft_reason_ = reason; |
+ properties_.flags()->Add(kDontSelfOptimize); |
+ } |
+ // TODO(turbofan): Remove the dont_turbofan_reason once no nodes are |
+ // DontTurbofanNode. That set of nodes must be kept in sync with |
+ // Pipeline::GenerateCode. |
+ void DisableTurbofan(BailoutReason reason) { |
+ dont_crankshaft_reason_ = reason; |
+ dont_turbofan_reason_ = reason; |
+ DisableSelfOptimization(); |
+ } |
+ void DisableSelfOptimization() { |
+ properties_.flags()->Add(kDontSelfOptimize); |
+ } |
+ void DisableCaching(BailoutReason reason) { |
+ dont_crankshaft_reason_ = reason; |
+ DisableSelfOptimization(); |
+ properties_.flags()->Add(kDontCache); |
+ } |
+ |
+ BailoutReason dont_optimize_reason() const { |
+ return (dont_turbofan_reason_ != kNoReason) ? dont_turbofan_reason_ |
+ : dont_crankshaft_reason_; |
+ } |
int next_id_; |
AstProperties properties_; |
+ BailoutReason dont_crankshaft_reason_; |
+ BailoutReason dont_turbofan_reason_; |
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor); |
@@ -57,12 +87,14 @@ void AstNumberingVisitor::VisitVariableDeclaration(VariableDeclaration* node) { |
void AstNumberingVisitor::VisitExportDeclaration(ExportDeclaration* node) { |
IncrementNodeCount(); |
+ DisableCrankshaft(kExportDeclaration); |
VisitVariableProxy(node->proxy()); |
} |
void AstNumberingVisitor::VisitModuleUrl(ModuleUrl* node) { |
IncrementNodeCount(); |
+ DisableCrankshaft(kModuleUrl); |
} |
@@ -83,6 +115,7 @@ void AstNumberingVisitor::VisitBreakStatement(BreakStatement* node) { |
void AstNumberingVisitor::VisitDebuggerStatement(DebuggerStatement* node) { |
IncrementNodeCount(); |
+ DisableCrankshaft(kDebuggerStatement); |
node->set_base_id(ReserveIdRange(DebuggerStatement::num_ids())); |
} |
@@ -90,6 +123,7 @@ void AstNumberingVisitor::VisitDebuggerStatement(DebuggerStatement* node) { |
void AstNumberingVisitor::VisitNativeFunctionLiteral( |
NativeFunctionLiteral* node) { |
IncrementNodeCount(); |
+ DisableCrankshaft(kNativeFunctionLiteral); |
node->set_base_id(ReserveIdRange(NativeFunctionLiteral::num_ids())); |
} |
@@ -108,6 +142,9 @@ void AstNumberingVisitor::VisitRegExpLiteral(RegExpLiteral* node) { |
void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) { |
IncrementNodeCount(); |
+ if (node->var()->IsLookupSlot()) { |
+ DisableCrankshaft(kReferenceToAVariableWhichRequiresDynamicLookup); |
+ } |
node->set_base_id(ReserveIdRange(VariableProxy::num_ids())); |
} |
@@ -120,6 +157,7 @@ void AstNumberingVisitor::VisitThisFunction(ThisFunction* node) { |
void AstNumberingVisitor::VisitSuperReference(SuperReference* node) { |
IncrementNodeCount(); |
+ DisableTurbofan(kSuperReference); |
node->set_base_id(ReserveIdRange(SuperReference::num_ids())); |
Visit(node->this_var()); |
} |
@@ -127,6 +165,7 @@ void AstNumberingVisitor::VisitSuperReference(SuperReference* node) { |
void AstNumberingVisitor::VisitModuleDeclaration(ModuleDeclaration* node) { |
IncrementNodeCount(); |
+ DisableCrankshaft(kModuleDeclaration); |
VisitVariableProxy(node->proxy()); |
Visit(node->module()); |
} |
@@ -134,6 +173,7 @@ void AstNumberingVisitor::VisitModuleDeclaration(ModuleDeclaration* node) { |
void AstNumberingVisitor::VisitImportDeclaration(ImportDeclaration* node) { |
IncrementNodeCount(); |
+ DisableCrankshaft(kImportDeclaration); |
VisitVariableProxy(node->proxy()); |
Visit(node->module()); |
} |
@@ -141,18 +181,21 @@ void AstNumberingVisitor::VisitImportDeclaration(ImportDeclaration* node) { |
void AstNumberingVisitor::VisitModuleVariable(ModuleVariable* node) { |
IncrementNodeCount(); |
+ DisableCrankshaft(kModuleVariable); |
Visit(node->proxy()); |
} |
void AstNumberingVisitor::VisitModulePath(ModulePath* node) { |
IncrementNodeCount(); |
+ DisableCrankshaft(kModulePath); |
Visit(node->module()); |
} |
void AstNumberingVisitor::VisitModuleStatement(ModuleStatement* node) { |
IncrementNodeCount(); |
+ DisableCrankshaft(kModuleStatement); |
Visit(node->body()); |
} |
@@ -171,6 +214,7 @@ void AstNumberingVisitor::VisitReturnStatement(ReturnStatement* node) { |
void AstNumberingVisitor::VisitYield(Yield* node) { |
IncrementNodeCount(); |
+ DisableCrankshaft(kYield); |
node->set_base_id(ReserveIdRange(Yield::num_ids())); |
Visit(node->generator_object()); |
Visit(node->expression()); |
@@ -215,12 +259,17 @@ void AstNumberingVisitor::VisitFunctionDeclaration(FunctionDeclaration* node) { |
void AstNumberingVisitor::VisitModuleLiteral(ModuleLiteral* node) { |
IncrementNodeCount(); |
+ DisableCaching(kModuleLiteral); |
VisitBlock(node->body()); |
} |
void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) { |
IncrementNodeCount(); |
+ if (node->is_jsruntime()) { |
+ // Don't try to optimize JS runtime calls because we bailout on them. |
+ DisableCrankshaft(kCallToAJavaScriptRuntimeFunction); |
+ } |
node->set_base_id(ReserveIdRange(CallRuntime::num_ids())); |
VisitArguments(node->arguments()); |
} |
@@ -228,6 +277,7 @@ void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) { |
void AstNumberingVisitor::VisitWithStatement(WithStatement* node) { |
IncrementNodeCount(); |
+ DisableCrankshaft(kWithStatement); |
Visit(node->expression()); |
Visit(node->statement()); |
} |
@@ -235,6 +285,7 @@ void AstNumberingVisitor::VisitWithStatement(WithStatement* node) { |
void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) { |
IncrementNodeCount(); |
+ DisableSelfOptimization(); |
node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids())); |
Visit(node->body()); |
Visit(node->cond()); |
@@ -243,6 +294,7 @@ void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) { |
void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) { |
IncrementNodeCount(); |
+ DisableSelfOptimization(); |
node->set_base_id(ReserveIdRange(WhileStatement::num_ids())); |
Visit(node->cond()); |
Visit(node->body()); |
@@ -251,6 +303,7 @@ void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) { |
void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) { |
IncrementNodeCount(); |
+ DisableTurbofan(kTryCatchStatement); |
Visit(node->try_block()); |
Visit(node->catch_block()); |
} |
@@ -258,6 +311,7 @@ void AstNumberingVisitor::VisitTryCatchStatement(TryCatchStatement* node) { |
void AstNumberingVisitor::VisitTryFinallyStatement(TryFinallyStatement* node) { |
IncrementNodeCount(); |
+ DisableTurbofan(kTryFinallyStatement); |
Visit(node->try_block()); |
Visit(node->finally_block()); |
} |
@@ -298,6 +352,7 @@ void AstNumberingVisitor::VisitCompareOperation(CompareOperation* node) { |
void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) { |
IncrementNodeCount(); |
+ DisableSelfOptimization(); |
node->set_base_id(ReserveIdRange(ForInStatement::num_ids())); |
Visit(node->each()); |
Visit(node->enumerable()); |
@@ -307,6 +362,7 @@ void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) { |
void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) { |
IncrementNodeCount(); |
+ DisableTurbofan(kForOfStatement); |
node->set_base_id(ReserveIdRange(ForOfStatement::num_ids())); |
Visit(node->assign_iterator()); |
Visit(node->next_result()); |
@@ -357,6 +413,7 @@ void AstNumberingVisitor::VisitCaseClause(CaseClause* node) { |
void AstNumberingVisitor::VisitForStatement(ForStatement* node) { |
IncrementNodeCount(); |
+ DisableSelfOptimization(); |
node->set_base_id(ReserveIdRange(ForStatement::num_ids())); |
if (node->init() != NULL) Visit(node->init()); |
if (node->cond() != NULL) Visit(node->cond()); |
@@ -367,6 +424,7 @@ void AstNumberingVisitor::VisitForStatement(ForStatement* node) { |
void AstNumberingVisitor::VisitClassLiteral(ClassLiteral* node) { |
IncrementNodeCount(); |
+ DisableTurbofan(kClassLiteral); |
node->set_base_id(ReserveIdRange(ClassLiteral::num_ids())); |
if (node->extends()) Visit(node->extends()); |
if (node->constructor()) Visit(node->constructor()); |
@@ -467,6 +525,7 @@ void AstNumberingVisitor::Renumber(FunctionLiteral* node) { |
VisitStatements(node->body()); |
node->set_ast_properties(&properties_); |
+ node->set_dont_optimize_reason(dont_optimize_reason()); |
} |