Skip to content

Commit 54b34bd

Browse files
mstarzingerCommit bot
mstarzinger
authored and
Commit bot
committed
[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 Review URL: https://codereview.chromium.org/1155503002 Cr-Commit-Position: refs/heads/master@{#28544}
1 parent c9a49da commit 54b34bd

7 files changed

+25
-5
lines changed

src/ast-numbering.cc

+11-4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ class AstNumberingVisitor final : public AstVisitor {
5252
dont_optimize_reason_ = reason;
5353
DisableSelfOptimization();
5454
}
55+
void DisableCrankshaft(BailoutReason reason) {
56+
if (FLAG_turbo_shipping) {
57+
return properties_.flags()->Add(kDontCrankshaft);
58+
}
59+
dont_optimize_reason_ = reason;
60+
DisableSelfOptimization();
61+
}
5562
void DisableCaching(BailoutReason reason) {
5663
dont_optimize_reason_ = reason;
5764
DisableSelfOptimization();
@@ -148,7 +155,7 @@ void AstNumberingVisitor::VisitRegExpLiteral(RegExpLiteral* node) {
148155
void AstNumberingVisitor::VisitVariableProxy(VariableProxy* node) {
149156
IncrementNodeCount();
150157
if (node->var()->IsLookupSlot()) {
151-
DisableOptimization(kReferenceToAVariableWhichRequiresDynamicLookup);
158+
DisableCrankshaft(kReferenceToAVariableWhichRequiresDynamicLookup);
152159
}
153160
ReserveFeedbackSlots(node);
154161
node->set_base_id(ReserveIdRange(VariableProxy::num_ids()));
@@ -249,7 +256,7 @@ void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) {
249256

250257
void AstNumberingVisitor::VisitWithStatement(WithStatement* node) {
251258
IncrementNodeCount();
252-
DisableOptimization(kWithStatement);
259+
DisableCrankshaft(kWithStatement);
253260
node->set_base_id(ReserveIdRange(WithStatement::num_ids()));
254261
Visit(node->expression());
255262
Visit(node->statement());
@@ -344,7 +351,7 @@ void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) {
344351

345352
void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) {
346353
IncrementNodeCount();
347-
DisableOptimization(kForOfStatement);
354+
DisableCrankshaft(kForOfStatement);
348355
node->set_base_id(ReserveIdRange(ForOfStatement::num_ids()));
349356
Visit(node->assign_iterator());
350357
Visit(node->next_result());
@@ -511,7 +518,7 @@ bool AstNumberingVisitor::Renumber(FunctionLiteral* node) {
511518
}
512519
if (scope->calls_eval()) DisableOptimization(kFunctionCallsEval);
513520
if (scope->arguments() != NULL && !scope->arguments()->IsStackAllocated()) {
514-
DisableOptimization(kContextAllocatedArguments);
521+
DisableCrankshaft(kContextAllocatedArguments);
515522
}
516523

517524
VisitDeclarations(scope->declarations());

src/ast.h

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
140140
enum AstPropertiesFlag {
141141
kDontSelfOptimize,
142142
kDontSoftInline,
143+
kDontCrankshaft,
143144
kDontCache
144145
};
145146

src/compiler.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,9 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
374374
DCHECK(info()->shared_info()->has_deoptimization_support());
375375

376376
// Check the enabling conditions for TurboFan.
377+
bool dont_crankshaft = info()->shared_info()->dont_crankshaft();
377378
if (((FLAG_turbo_asm && info()->shared_info()->asm_function()) ||
379+
(dont_crankshaft && strcmp(FLAG_turbo_filter, "~~") == 0) ||
378380
info()->closure()->PassesFilter(FLAG_turbo_filter)) &&
379381
(FLAG_turbo_osr || !info()->is_osr())) {
380382
// Use TurboFan for the compilation.
@@ -405,7 +407,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
405407
}
406408
}
407409

408-
if (!isolate()->use_crankshaft()) {
410+
if (!isolate()->use_crankshaft() || dont_crankshaft) {
409411
// Crankshaft is entirely disabled.
410412
return SetLastStatus(FAILED);
411413
}
@@ -741,6 +743,7 @@ static bool Renumber(ParseInfo* parse_info) {
741743
FunctionLiteral* lit = parse_info->function();
742744
shared_info->set_ast_node_count(lit->ast_node_count());
743745
MaybeDisableOptimization(shared_info, lit->dont_optimize_reason());
746+
shared_info->set_dont_crankshaft(lit->flags()->Contains(kDontCrankshaft));
744747
shared_info->set_dont_cache(lit->flags()->Contains(kDontCache));
745748
}
746749
return true;

src/flag-definitions.h

+1
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ DEFINE_BOOL(omit_map_checks_for_leaf_maps, true,
383383

384384
// Flags for TurboFan.
385385
DEFINE_BOOL(turbo, false, "enable TurboFan compiler")
386+
DEFINE_BOOL(turbo_shipping, false, "enable TurboFan compiler on subset")
386387
DEFINE_BOOL(turbo_greedy_regalloc, false, "use the greedy register allocator")
387388
DEFINE_IMPLICATION(turbo, turbo_asm_deoptimization)
388389
DEFINE_STRING(turbo_filter, "~~", "optimization filter for TurboFan compiler")

src/objects-inl.h

+2
Original file line numberDiff line numberDiff line change
@@ -5790,6 +5790,8 @@ BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints,
57905790
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, bound, kBoundFunction)
57915791
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_anonymous, kIsAnonymous)
57925792
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_function, kIsFunction)
5793+
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_crankshaft,
5794+
kDontCrankshaft)
57935795
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_cache, kDontCache)
57945796
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_flush, kDontFlush)
57955797
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_arrow, kIsArrow)

src/objects.cc

+2
Original file line numberDiff line numberDiff line change
@@ -10869,6 +10869,8 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
1086910869
if (lit->dont_optimize_reason() != kNoReason) {
1087010870
shared_info->DisableOptimization(lit->dont_optimize_reason());
1087110871
}
10872+
shared_info->set_dont_crankshaft(
10873+
lit->flags()->Contains(AstPropertiesFlag::kDontCrankshaft));
1087210874
shared_info->set_dont_cache(
1087310875
lit->flags()->Contains(AstPropertiesFlag::kDontCache));
1087410876
shared_info->set_kind(lit->kind());

src/objects.h

+4
Original file line numberDiff line numberDiff line change
@@ -7134,6 +7134,9 @@ class SharedFunctionInfo: public HeapObject {
71347134
// Is this a function or top-level/eval code.
71357135
DECL_BOOLEAN_ACCESSORS(is_function)
71367136

7137+
// Indicates that code for this function cannot be compiled with Crankshaft.
7138+
DECL_BOOLEAN_ACCESSORS(dont_crankshaft)
7139+
71377140
// Indicates that code for this function cannot be cached.
71387141
DECL_BOOLEAN_ACCESSORS(dont_cache)
71397142

@@ -7398,6 +7401,7 @@ class SharedFunctionInfo: public HeapObject {
73987401
kIsAnonymous,
73997402
kNameShouldPrintAsAnonymous,
74007403
kIsFunction,
7404+
kDontCrankshaft,
74017405
kDontCache,
74027406
kDontFlush,
74037407
kIsArrow,

0 commit comments

Comments
 (0)