Title: [186848] branches/jsc-tailcall/Source/_javascript_Core
Revision
186848
Author
[email protected]
Date
2015-07-15 10:42:06 -0700 (Wed, 15 Jul 2015)

Log Message

jsc-tailcall: Only non-constructors functions are candidate for tail calls
https://bugs.webkit.org/show_bug.cgi?id=146967

Reviewed by Saam Barati.

Previously, we were emitting tail calls in any ScopeNode. This is
wrong: we should only be emitting tail calls in FunctionNodes that are
not ES6 constructors.

* bytecompiler/NodesCodegen.cpp:
(JSC::ScopeNode::emitStatementsBytecode):
(JSC::FunctionNode::emitBytecode):
* parser/Nodes.h:

Modified Paths

Diff

Modified: branches/jsc-tailcall/Source/_javascript_Core/ChangeLog (186847 => 186848)


--- branches/jsc-tailcall/Source/_javascript_Core/ChangeLog	2015-07-15 16:04:47 UTC (rev 186847)
+++ branches/jsc-tailcall/Source/_javascript_Core/ChangeLog	2015-07-15 17:42:06 UTC (rev 186848)
@@ -1,3 +1,19 @@
+2015-07-15  Basile Clement  <[email protected]>
+
+        jsc-tailcall: Only non-constructors functions are candidate for tail calls
+        https://bugs.webkit.org/show_bug.cgi?id=146967
+
+        Reviewed by Saam Barati.
+
+        Previously, we were emitting tail calls in any ScopeNode. This is
+        wrong: we should only be emitting tail calls in FunctionNodes that are
+        not ES6 constructors.
+
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::ScopeNode::emitStatementsBytecode):
+        (JSC::FunctionNode::emitBytecode):
+        * parser/Nodes.h:
+
 2015-07-14  Basile Clement  <[email protected]>
 
         [ES6] Recognize calls in tail position

Modified: branches/jsc-tailcall/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (186847 => 186848)


--- branches/jsc-tailcall/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp	2015-07-15 16:04:47 UTC (rev 186847)
+++ branches/jsc-tailcall/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp	2015-07-15 17:42:06 UTC (rev 186848)
@@ -2980,11 +2980,11 @@
 
 // ------------------------------ ScopeNode -----------------------------
 
-inline void ScopeNode::emitStatementsBytecode(BytecodeGenerator& generator, RegisterID* dst)
+inline void ScopeNode::emitStatementsBytecode(BytecodeGenerator& generator, RegisterID* dst, TailCallMode tailCallMode)
 {
     if (!m_statements)
         return;
-    m_statements->emitBytecode(generator, dst, isStrictMode() ? CanHaveTailCalls : NoTailCalls);
+    m_statements->emitBytecode(generator, dst, tailCallMode);
 }
 
 // ------------------------------ ProgramNode -----------------------------
@@ -3038,7 +3038,10 @@
 
     generator.emitProfileControlFlow(startStartOffset());
     generator.emitDebugHook(DidEnterCallFrame, startLine(), startStartOffset(), startLineStartOffset());
-    emitStatementsBytecode(generator, generator.ignoredResult());
+    if (isStrictMode() && generator.constructorKind() == ConstructorKind::None)
+        emitStatementsBytecode(generator, generator.ignoredResult(), CanHaveTailCalls);
+    else
+        emitStatementsBytecode(generator, generator.ignoredResult());
 
     StatementNode* singleStatement = this->singleStatement();
     ReturnNode* returnNode = 0;

Modified: branches/jsc-tailcall/Source/_javascript_Core/parser/Nodes.h (186847 => 186848)


--- branches/jsc-tailcall/Source/_javascript_Core/parser/Nodes.h	2015-07-15 16:04:47 UTC (rev 186847)
+++ branches/jsc-tailcall/Source/_javascript_Core/parser/Nodes.h	2015-07-15 17:42:06 UTC (rev 186848)
@@ -1582,7 +1582,7 @@
 
         StatementNode* singleStatement() const;
 
-        void emitStatementsBytecode(BytecodeGenerator&, RegisterID* destination);
+        void emitStatementsBytecode(BytecodeGenerator&, RegisterID* destination, TailCallMode = NoTailCalls);
         
         void setClosedVariables(Vector<RefPtr<UniquedStringImpl>>&&) { }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to