[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. R=bmeurer@chromium.org BUG=v8:4131 LOG=N Review URL: https://codereview.chromium.org/1155503002 Cr-Commit-Position: refs/heads/master@{#28544}
This commit is contained in:
parent
c9a49da0d8
commit
54b34bdd33
@ -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());
|
||||
|
@ -140,6 +140,7 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
|
||||
enum AstPropertiesFlag {
|
||||
kDontSelfOptimize,
|
||||
kDontSoftInline,
|
||||
kDontCrankshaft,
|
||||
kDontCache
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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")
|
||||
|
@ -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)
|
||||
|
@ -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());
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user