Unreviewed, rolling out r218512.
https://bugs.webkit.org/show_bug.cgi?id=173981
"It changes the behavior of the JS API's JSEvaluateScript
which breaks TurboTax" (Requested by saamyjoon on #webkit).
Reverted changeset:
"test262: Completion values for control flow do not match the
spec"
https://bugs.webkit.org/show_bug.cgi?id=171265
http://trac.webkit.org/changeset/218512
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@218957 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp b/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
index fa0c5e0..6c1aeb1 100644
--- a/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
+++ b/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
@@ -2461,25 +2461,30 @@
// ------------------------------ SourceElements -------------------------------
+
+inline StatementNode* SourceElements::lastStatement() const
+{
+ return m_tail;
+}
+
inline void SourceElements::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- StatementNode* lastStatementWithCompletionValue = nullptr;
- if (generator.shouldBeConcernedWithCompletionValue()) {
- for (StatementNode* statement = m_head; statement; statement = statement->next()) {
- if (statement->hasCompletionValue())
- lastStatementWithCompletionValue = statement;
- }
- }
-
- for (StatementNode* statement = m_head; statement; statement = statement->next()) {
- if (statement == lastStatementWithCompletionValue)
- generator.emitLoad(dst, jsUndefined());
+ for (StatementNode* statement = m_head; statement; statement = statement->next())
generator.emitNodeInTailPosition(dst, statement);
- }
}
// ------------------------------ BlockNode ------------------------------------
+inline StatementNode* BlockNode::lastStatement() const
+{
+ return m_statements ? m_statements->lastStatement() : 0;
+}
+
+StatementNode* BlockNode::singleStatement() const
+{
+ return m_statements ? m_statements->singleStatement() : 0;
+}
+
void BlockNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
if (!m_statements)
@@ -2603,11 +2608,6 @@
void IfElseNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- if (generator.shouldBeConcernedWithCompletionValue()) {
- if (m_ifBlock->hasEarlyBreakOrContinue() || (m_elseBlock && m_elseBlock->hasEarlyBreakOrContinue()))
- generator.emitLoad(dst, jsUndefined());
- }
-
Ref<Label> beforeThen = generator.newLabel();
Ref<Label> beforeElse = generator.newLabel();
Ref<Label> afterElse = generator.newLabel();
@@ -2643,9 +2643,6 @@
void DoWhileNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- if (generator.shouldBeConcernedWithCompletionValue() && m_statement->hasEarlyBreakOrContinue())
- generator.emitLoad(dst, jsUndefined());
-
Ref<LabelScope> scope = generator.newLabelScope(LabelScope::Loop);
Ref<Label> topOfLoop = generator.newLabel();
@@ -2664,9 +2661,6 @@
void WhileNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- if (generator.shouldBeConcernedWithCompletionValue() && m_statement->hasEarlyBreakOrContinue())
- generator.emitLoad(dst, jsUndefined());
-
Ref<LabelScope> scope = generator.newLabelScope(LabelScope::Loop);
Ref<Label> topOfLoop = generator.newLabel();
@@ -2691,9 +2685,6 @@
void ForNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- if (generator.shouldBeConcernedWithCompletionValue() && m_statement->hasEarlyBreakOrContinue())
- generator.emitLoad(dst, jsUndefined());
-
Ref<LabelScope> scope = generator.newLabelScope(LabelScope::Loop);
RegisterID* forLoopSymbolTable = nullptr;
@@ -2843,9 +2834,6 @@
return;
}
- if (generator.shouldBeConcernedWithCompletionValue() && m_statement->hasEarlyBreakOrContinue())
- generator.emitLoad(dst, jsUndefined());
-
Ref<Label> end = generator.newLabel();
RegisterID* forLoopSymbolTable = nullptr;
@@ -3000,9 +2988,6 @@
return;
}
- if (generator.shouldBeConcernedWithCompletionValue() && m_statement->hasEarlyBreakOrContinue())
- generator.emitLoad(dst, jsUndefined());
-
RegisterID* forLoopSymbolTable = nullptr;
generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested, &forLoopSymbolTable);
auto extractor = [this, dst](BytecodeGenerator& generator, RegisterID* value)
@@ -3156,8 +3141,6 @@
RefPtr<RegisterID> scope = generator.emitNode(m_expr);
generator.emitExpressionInfo(m_divot, m_divot - m_expressionLength, m_divot);
generator.emitPushWithScope(scope.get());
- if (generator.shouldBeConcernedWithCompletionValue() && m_statement->hasEarlyBreakOrContinue())
- generator.emitLoad(dst, jsUndefined());
generator.emitNodeInTailPosition(dst, m_statement);
generator.emitPopWithScope();
}
@@ -3326,9 +3309,6 @@
void SwitchNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- if (generator.shouldBeConcernedWithCompletionValue())
- generator.emitLoad(dst, jsUndefined());
-
Ref<LabelScope> scope = generator.newLabelScope(LabelScope::Switch);
RefPtr<RegisterID> r0 = generator.emitNode(m_expr);
@@ -3373,9 +3353,6 @@
// NOTE: The catch and finally blocks must be labeled explicitly, so the
// optimizer knows they may be jumped to from anywhere.
- if (generator.shouldBeConcernedWithCompletionValue() && m_tryBlock->hasEarlyBreakOrContinue())
- generator.emitLoad(dst, jsUndefined());
-
ASSERT(m_catchBlock || m_finallyBlock);
BytecodeGenerator::CompletionRecordScope completionRecordScope(generator, m_finallyBlock);
@@ -3467,7 +3444,7 @@
int finallyStartOffset = m_catchBlock ? m_catchBlock->endOffset() + 1 : m_tryBlock->endOffset() + 1;
generator.emitProfileControlFlow(finallyStartOffset);
- generator.emitNodeInTailPosition(m_finallyBlock);
+ generator.emitNodeInTailPosition(dst, m_finallyBlock);
generator.emitFinallyCompletion(finallyContext, savedCompletionTypeRegister.get(), *finallyEndLabel);
generator.emitLabel(*finallyEndLabel);
@@ -3742,9 +3719,9 @@
// ------------------------------ ClassDeclNode ---------------------------------
-void ClassDeclNode::emitBytecode(BytecodeGenerator& generator, RegisterID*)
+void ClassDeclNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
- generator.emitNode(m_classDeclaration);
+ generator.emitNode(dst, m_classDeclaration);
}
// ------------------------------ ClassExprNode ---------------------------------