Allow Crankshaft to tolerate certain do-expressions
Crankshaft can't track operand/environment changes between arbitrary statements. We need that to fully support do-expressions. Instead, a subset is supported by bailing out on break statements, continue statements, and if we've made an OSR entry within a do-expression. This partial support is a good idea because do-expressions are a useful tool for desugaring during parsing. BUG= R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/1769463002 Cr-Commit-Position: refs/heads/master@{#34491}
This commit is contained in:
parent
96efefd748
commit
6783854603
@ -138,7 +138,6 @@ void AstNumberingVisitor::VisitNativeFunctionLiteral(
|
||||
|
||||
void AstNumberingVisitor::VisitDoExpression(DoExpression* node) {
|
||||
IncrementNodeCount();
|
||||
DisableCrankshaft(kDoExpression);
|
||||
node->set_base_id(ReserveIdRange(DoExpression::num_ids()));
|
||||
Visit(node->block());
|
||||
Visit(node->result());
|
||||
|
@ -56,7 +56,8 @@ namespace internal {
|
||||
V(kDestinationOfCopyNotAligned, "Destination of copy not aligned") \
|
||||
V(kDontDeleteCellsCannotContainTheHole, \
|
||||
"DontDelete cells can't contain the hole") \
|
||||
V(kDoExpression, "Do expression encountered") \
|
||||
V(kDoExpressionUnmodelable, \
|
||||
"Encountered a do-expression with unmodelable control statements") \
|
||||
V(kDoPushArgumentNotImplementedForDoubleType, \
|
||||
"DoPushArgument not implemented for double type") \
|
||||
V(kEliminatedBoundsCheckFailed, "Eliminated bounds check failed") \
|
||||
|
@ -3569,9 +3569,16 @@ HBasicBlock* HOptimizedGraphBuilder::BuildLoopEntry() {
|
||||
|
||||
HBasicBlock* HOptimizedGraphBuilder::BuildLoopEntry(
|
||||
IterationStatement* statement) {
|
||||
HBasicBlock* loop_entry = osr()->HasOsrEntryAt(statement)
|
||||
? osr()->BuildOsrLoopEntry(statement)
|
||||
: BuildLoopEntry();
|
||||
HBasicBlock* loop_entry;
|
||||
|
||||
if (osr()->HasOsrEntryAt(statement)) {
|
||||
loop_entry = osr()->BuildOsrLoopEntry(statement);
|
||||
if (function_state()->IsInsideDoExpressionScope()) {
|
||||
Bailout(kDoExpressionUnmodelable);
|
||||
}
|
||||
} else {
|
||||
loop_entry = BuildLoopEntry();
|
||||
}
|
||||
return loop_entry;
|
||||
}
|
||||
|
||||
@ -4045,6 +4052,7 @@ FunctionState::FunctionState(HOptimizedGraphBuilder* owner,
|
||||
arguments_elements_(NULL),
|
||||
inlining_id_(inlining_id),
|
||||
outer_source_position_(SourcePosition::Unknown()),
|
||||
do_expression_scope_count_(0),
|
||||
outer_(owner->function_state()) {
|
||||
if (outer_ != NULL) {
|
||||
// State for an inline function.
|
||||
@ -4829,6 +4837,11 @@ void HOptimizedGraphBuilder::VisitContinueStatement(
|
||||
DCHECK(!HasStackOverflow());
|
||||
DCHECK(current_block() != NULL);
|
||||
DCHECK(current_block()->HasPredecessor());
|
||||
|
||||
if (function_state()->IsInsideDoExpressionScope()) {
|
||||
return Bailout(kDoExpressionUnmodelable);
|
||||
}
|
||||
|
||||
Scope* outer_scope = NULL;
|
||||
Scope* inner_scope = scope();
|
||||
int drop_extra = 0;
|
||||
@ -4861,6 +4874,11 @@ void HOptimizedGraphBuilder::VisitBreakStatement(BreakStatement* stmt) {
|
||||
DCHECK(!HasStackOverflow());
|
||||
DCHECK(current_block() != NULL);
|
||||
DCHECK(current_block()->HasPredecessor());
|
||||
|
||||
if (function_state()->IsInsideDoExpressionScope()) {
|
||||
return Bailout(kDoExpressionUnmodelable);
|
||||
}
|
||||
|
||||
Scope* outer_scope = NULL;
|
||||
Scope* inner_scope = scope();
|
||||
int drop_extra = 0;
|
||||
@ -5520,10 +5538,12 @@ void HOptimizedGraphBuilder::VisitNativeFunctionLiteral(
|
||||
|
||||
|
||||
void HOptimizedGraphBuilder::VisitDoExpression(DoExpression* expr) {
|
||||
DoExpressionScope scope(this);
|
||||
DCHECK(!HasStackOverflow());
|
||||
DCHECK(current_block() != NULL);
|
||||
DCHECK(current_block()->HasPredecessor());
|
||||
return Bailout(kDoExpression);
|
||||
CHECK_ALIVE(VisitBlock(expr->block()));
|
||||
Visit(expr->result());
|
||||
}
|
||||
|
||||
|
||||
|
@ -888,6 +888,10 @@ class FunctionState final {
|
||||
|
||||
int inlining_id() const { return inlining_id_; }
|
||||
|
||||
void IncrementInDoExpressionScope() { do_expression_scope_count_++; }
|
||||
void DecrementInDoExpressionScope() { do_expression_scope_count_--; }
|
||||
bool IsInsideDoExpressionScope() { return do_expression_scope_count_ > 0; }
|
||||
|
||||
private:
|
||||
HOptimizedGraphBuilder* owner_;
|
||||
|
||||
@ -924,6 +928,8 @@ class FunctionState final {
|
||||
int inlining_id_;
|
||||
SourcePosition outer_source_position_;
|
||||
|
||||
int do_expression_scope_count_;
|
||||
|
||||
FunctionState* outer_;
|
||||
};
|
||||
|
||||
@ -3038,6 +3044,19 @@ class NoObservableSideEffectsScope final {
|
||||
HGraphBuilder* builder_;
|
||||
};
|
||||
|
||||
class DoExpressionScope final {
|
||||
public:
|
||||
explicit DoExpressionScope(HOptimizedGraphBuilder* builder)
|
||||
: builder_(builder) {
|
||||
builder_->function_state()->IncrementInDoExpressionScope();
|
||||
}
|
||||
~DoExpressionScope() {
|
||||
builder_->function_state()->DecrementInDoExpressionScope();
|
||||
}
|
||||
|
||||
private:
|
||||
HOptimizedGraphBuilder* builder_;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
Loading…
Reference in New Issue
Block a user