Commit c13acc81 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[TurboFan] Ensure value is pushed for StackOverflow in AstVisitor::Visit.

AstGraphBuilder overrides Visit(Expression*) to ensure that even if there is a
stack overflow, a value still gets produced. However, if there was no stack
overflow in the overriden function, but calling
AstVisitor<AstGraphBuilder>::Visit(expr) pushes us over the stack limit, then
the stack overflow check in that function will return without visiting the
expression, and the result will never get pushed.

To fix this, we add a new VisitNoStackOverflowCheck function which avoids the
inner stack check, and call that instead.

Since this depends on the size of C++ stack frames, there is no reliable test
I can add, however regress-635429.js exibits this behavior after
https://codereview.chromium.org/2240463002/ lands.

Review-Url: https://codereview.chromium.org/2262703002
Cr-Commit-Position: refs/heads/master@{#38774}
parent 3db269f9
......@@ -2867,9 +2867,13 @@ class AstVisitor BASE_EMBEDDED {
#define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \
public: \
void VisitNoStackOverflowCheck(AstNode* node) { \
GENERATE_AST_VISITOR_SWITCH() \
} \
\
void Visit(AstNode* node) { \
if (CheckStackOverflow()) return; \
GENERATE_AST_VISITOR_SWITCH() \
VisitNoStackOverflowCheck(node); \
} \
\
void SetStackOverflow() { stack_overflow_ = true; } \
......
......@@ -1045,7 +1045,7 @@ void AstGraphBuilder::VisitForValues(ZoneList<Expression*>* exprs) {
void AstGraphBuilder::VisitForValue(Expression* expr) {
AstValueContext for_value(this);
if (!CheckStackOverflow()) {
AstVisitor<AstGraphBuilder>::Visit(expr);
VisitNoStackOverflowCheck(expr);
} else {
ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant());
}
......@@ -1055,7 +1055,7 @@ void AstGraphBuilder::VisitForValue(Expression* expr) {
void AstGraphBuilder::VisitForEffect(Expression* expr) {
AstEffectContext for_effect(this);
if (!CheckStackOverflow()) {
AstVisitor<AstGraphBuilder>::Visit(expr);
VisitNoStackOverflowCheck(expr);
} else {
ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant());
}
......@@ -1065,7 +1065,7 @@ void AstGraphBuilder::VisitForEffect(Expression* expr) {
void AstGraphBuilder::VisitForTest(Expression* expr) {
AstTestContext for_condition(this, expr->test_id());
if (!CheckStackOverflow()) {
AstVisitor<AstGraphBuilder>::Visit(expr);
VisitNoStackOverflowCheck(expr);
} else {
ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant());
}
......@@ -1075,7 +1075,7 @@ void AstGraphBuilder::VisitForTest(Expression* expr) {
void AstGraphBuilder::Visit(Expression* expr) {
// Reuses enclosing AstContext.
if (!CheckStackOverflow()) {
AstVisitor<AstGraphBuilder>::Visit(expr);
VisitNoStackOverflowCheck(expr);
} else {
ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment