Reviewers: Benedikt Meurer,
Description:
[turbofan] Prepare mechanism to enable TF on language subset.
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.
[email protected]
BUG=v8:4131
LOG=N
Please review this at https://codereview.chromium.org/1155503002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+24, -5 lines):
M src/ast.h
M src/ast-numbering.cc
M src/compiler.cc
M src/flag-definitions.h
M src/objects.h
M src/objects.cc
M src/objects-inl.h
Index: src/ast-numbering.cc
diff --git a/src/ast-numbering.cc b/src/ast-numbering.cc
index
13d8bf8a34f9f450a90a6a7ed02ea2c5aab7ef44..87b96346cbcf74bea1ae87fcb889e98a71cc44bc
100644
--- a/src/ast-numbering.cc
+++ b/src/ast-numbering.cc
@@ -52,6 +52,12 @@ class AstNumberingVisitor final : public AstVisitor {
dont_optimize_reason_ = reason;
DisableSelfOptimization();
}
+ void DisableCrankshaft(BailoutReason reason) {
+ properties_.flags()->Add(kDontCrankshaft);
+ if (FLAG_turbo_shipping) return;
+ dont_optimize_reason_ = reason;
+ DisableSelfOptimization();
+ }
void DisableCaching(BailoutReason reason) {
dont_optimize_reason_ = reason;
DisableSelfOptimization();
@@ -148,7 +154,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 +255,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 +350,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 +517,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: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index
60f0068d37aebe855c31c352469af4d9ca058bf5..93003303706d4387634b7cbf373f7c00b7c75cc6
100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -140,6 +140,7 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
enum AstPropertiesFlag {
kDontSelfOptimize,
kDontSoftInline,
+ kDontCrankshaft,
kDontCache
};
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
c3c14a5704d7ceef78c0c6ad5ab33bbe4af32357..8460881272523230e26057d49daecbc9625d7e11
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -375,7 +375,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.
@@ -402,7 +404,7 @@ OptimizedCompileJob::Status
OptimizedCompileJob::CreateGraph() {
}
}
- if (!isolate()->use_crankshaft()) {
+ if (!isolate()->use_crankshaft() || dont_crankshaft) {
// Crankshaft is entirely disabled.
return SetLastStatus(FAILED);
}
@@ -738,6 +740,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: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
f7cfffd026da6242e5825490b5807fbe0e0c8e38..0d2ad7da40b707e1e39d34ac7f06d76c4443526f
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -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_deoptimization)
DEFINE_STRING(turbo_filter, "~~", "optimization filter for TurboFan
compiler")
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
c086fa3d5f16f3fb825c7b2d3a63bcf39548d5e4..1ed40e22a70e62f13e1a19c6c63d1d59e69e545e
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -5797,6 +5797,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: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
f919c9da78d7c7539fbf04b35c30b19e3182872a..d6c4cd4e7b40e7fcd6cdd8356a67e69318ee0d66
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -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: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
94c04c68eae9e739067e7c684a7ddd7b555c6a05..ac88ec8ee13d4f8b51b9557da6804803a555a5ad
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -7135,6 +7135,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)
@@ -7399,6 +7402,7 @@ class SharedFunctionInfo: public HeapObject {
kIsAnonymous,
kNameShouldPrintAsAnonymous,
kIsFunction,
+ kDontCrankshaft,
kDontCache,
kDontFlush,
kIsArrow,
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.