[turbofan] Prepare mechanism to enable TF on language subset.
authormstarzinger <mstarzinger@chromium.org>
Thu, 21 May 2015 11:41:14 +0000 (04:41 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 21 May 2015 11:40:54 +0000 (11:40 +0000)
This allows enabling TurboFan on a certain subset of language features
in the AstNumberingVisitor. The heuristics of when to optimize remain
unchanged, only the choice of which optimizing compiler to use changes.

R=bmeurer@chromium.org
BUG=v8:4131
LOG=N

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

Cr-Commit-Position: refs/heads/master@{#28544}

src/ast-numbering.cc
src/ast.h
src/compiler.cc
src/flag-definitions.h
src/objects-inl.h
src/objects.cc
src/objects.h

index 13d8bf8a34f9f450a90a6a7ed02ea2c5aab7ef44..68dc65a79d35a4516796029d6293fc21d8f2fc87 100644 (file)
@@ -52,6 +52,13 @@ class AstNumberingVisitor final : public AstVisitor {
     dont_optimize_reason_ = reason;
     DisableSelfOptimization();
   }
+  void DisableCrankshaft(BailoutReason reason) {
+    if (FLAG_turbo_shipping) {
+      return properties_.flags()->Add(kDontCrankshaft);
+    }
+    dont_optimize_reason_ = reason;
+    DisableSelfOptimization();
+  }
   void DisableCaching(BailoutReason reason) {
     dont_optimize_reason_ = reason;
     DisableSelfOptimization();
@@ -148,7 +155,7 @@ void AstNumberingVisitor::VisitRegExpLiteral(RegExpLiteral* node) {
 void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) {
   IncrementNodeCount();
   if (node->var()->IsLookupSlot()) {
-    DisableOptimization(kReferenceToAVariableWhichRequiresDynamicLookup);
+    DisableCrankshaft(kReferenceToAVariableWhichRequiresDynamicLookup);
   }
   ReserveFeedbackSlots(node);
   node->set_base_id(ReserveIdRange(VariableProxy::num_ids()));
@@ -249,7 +256,7 @@ void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) {
 
 void AstNumberingVisitor::VisitWithStatement(WithStatement* node) {
   IncrementNodeCount();
-  DisableOptimization(kWithStatement);
+  DisableCrankshaft(kWithStatement);
   node->set_base_id(ReserveIdRange(WithStatement::num_ids()));
   Visit(node->expression());
   Visit(node->statement());
@@ -344,7 +351,7 @@ void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) {
 
 void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) {
   IncrementNodeCount();
-  DisableOptimization(kForOfStatement);
+  DisableCrankshaft(kForOfStatement);
   node->set_base_id(ReserveIdRange(ForOfStatement::num_ids()));
   Visit(node->assign_iterator());
   Visit(node->next_result());
@@ -511,7 +518,7 @@ bool AstNumberingVisitor::Renumber(FunctionLiteral* node) {
   }
   if (scope->calls_eval()) DisableOptimization(kFunctionCallsEval);
   if (scope->arguments() != NULL && !scope->arguments()->IsStackAllocated()) {
-    DisableOptimization(kContextAllocatedArguments);
+    DisableCrankshaft(kContextAllocatedArguments);
   }
 
   VisitDeclarations(scope->declarations());
index 60f0068d37aebe855c31c352469af4d9ca058bf5..93003303706d4387634b7cbf373f7c00b7c75cc6 100644 (file)
--- a/src/ast.h
+++ b/src/ast.h
@@ -140,6 +140,7 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
 enum AstPropertiesFlag {
   kDontSelfOptimize,
   kDontSoftInline,
+  kDontCrankshaft,
   kDontCache
 };
 
index 717913613e52dbfbf1b8f5ec0eb636422e4ee486..0268bbd94d4a0c119a601c51bab1c8463c916755 100644 (file)
@@ -374,7 +374,9 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
   DCHECK(info()->shared_info()->has_deoptimization_support());
 
   // Check the enabling conditions for TurboFan.
+  bool dont_crankshaft = info()->shared_info()->dont_crankshaft();
   if (((FLAG_turbo_asm && info()->shared_info()->asm_function()) ||
+       (dont_crankshaft && strcmp(FLAG_turbo_filter, "~~") == 0) ||
        info()->closure()->PassesFilter(FLAG_turbo_filter)) &&
       (FLAG_turbo_osr || !info()->is_osr())) {
     // Use TurboFan for the compilation.
@@ -405,7 +407,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
     }
   }
 
-  if (!isolate()->use_crankshaft()) {
+  if (!isolate()->use_crankshaft() || dont_crankshaft) {
     // Crankshaft is entirely disabled.
     return SetLastStatus(FAILED);
   }
@@ -741,6 +743,7 @@ static bool Renumber(ParseInfo* parse_info) {
     FunctionLiteral* lit = parse_info->function();
     shared_info->set_ast_node_count(lit->ast_node_count());
     MaybeDisableOptimization(shared_info, lit->dont_optimize_reason());
+    shared_info->set_dont_crankshaft(lit->flags()->Contains(kDontCrankshaft));
     shared_info->set_dont_cache(lit->flags()->Contains(kDontCache));
   }
   return true;
index 9c2ab3d15fbc4b35c68b4b57ce6ad9cf024b7694..9937daf2280278360c0ade0205b0b1b45c702d04 100644 (file)
@@ -383,6 +383,7 @@ DEFINE_BOOL(omit_map_checks_for_leaf_maps, true,
 
 // Flags for TurboFan.
 DEFINE_BOOL(turbo, false, "enable TurboFan compiler")
+DEFINE_BOOL(turbo_shipping, false, "enable TurboFan compiler on subset")
 DEFINE_BOOL(turbo_greedy_regalloc, false, "use the greedy register allocator")
 DEFINE_IMPLICATION(turbo, turbo_asm_deoptimization)
 DEFINE_STRING(turbo_filter, "~~", "optimization filter for TurboFan compiler")
index 33e147fade85627bd4742910d66ad79ca512281e..fea849afaa242b3a4f25c3ca68fe8fac720f2b79 100644 (file)
@@ -5790,6 +5790,8 @@ BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints,
 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, bound, kBoundFunction)
 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_anonymous, kIsAnonymous)
 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_function, kIsFunction)
+BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_crankshaft,
+               kDontCrankshaft)
 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_cache, kDontCache)
 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_flush, kDontFlush)
 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_arrow, kIsArrow)
index b8fc57ab76d194958b7e6959f1a820a4b429c0c7..24ecc6b50e99272e7d10110f2e286369aca12bbc 100644 (file)
@@ -10869,6 +10869,8 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
   if (lit->dont_optimize_reason() != kNoReason) {
     shared_info->DisableOptimization(lit->dont_optimize_reason());
   }
+  shared_info->set_dont_crankshaft(
+      lit->flags()->Contains(AstPropertiesFlag::kDontCrankshaft));
   shared_info->set_dont_cache(
       lit->flags()->Contains(AstPropertiesFlag::kDontCache));
   shared_info->set_kind(lit->kind());
index f5dcd8442d409d5006d5026750ea54f47a9f6434..665da0384ce861d661fed39ac2101fd03a31bc2a 100644 (file)
@@ -7134,6 +7134,9 @@ class SharedFunctionInfo: public HeapObject {
   // Is this a function or top-level/eval code.
   DECL_BOOLEAN_ACCESSORS(is_function)
 
+  // Indicates that code for this function cannot be compiled with Crankshaft.
+  DECL_BOOLEAN_ACCESSORS(dont_crankshaft)
+
   // Indicates that code for this function cannot be cached.
   DECL_BOOLEAN_ACCESSORS(dont_cache)
 
@@ -7398,6 +7401,7 @@ class SharedFunctionInfo: public HeapObject {
     kIsAnonymous,
     kNameShouldPrintAsAnonymous,
     kIsFunction,
+    kDontCrankshaft,
     kDontCache,
     kDontFlush,
     kIsArrow,