TaggedTemplateString function calls should emit tail position calls
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Sep 2016 17:48:13 +0000 (17:48 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Sep 2016 17:48:13 +0000 (17:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161948

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-09-14
Reviewed by Yusuke Suzuki.

JSTests:

* stress/tail-call-recognize.js:
(runTests):
Ensure a tagged template string function call is tail call.

* test262.yaml:
These now pass.

Source/JavaScriptCore:

* bytecompiler/NodesCodegen.cpp:
(JSC::TaggedTemplateNode::emitBytecode):
The tagged template string function call can be a tail call:
https://tc39.github.io/ecma262/#sec-tagged-templates-runtime-semantics-evaluation

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205916 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JSTests/ChangeLog
JSTests/stress/tail-call-recognize.js
JSTests/test262.yaml
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

index 496928a..dc32b02 100644 (file)
@@ -1,5 +1,19 @@
 2016-09-14  Joseph Pecoraro  <pecoraro@apple.com>
 
+        TaggedTemplateString function calls should emit tail position calls
+        https://bugs.webkit.org/show_bug.cgi?id=161948
+
+        Reviewed by Yusuke Suzuki.
+
+        * stress/tail-call-recognize.js:
+        (runTests):
+        Ensure a tagged template string function call is tail call.
+
+        * test262.yaml:
+        These now pass.
+
+2016-09-14  Joseph Pecoraro  <pecoraro@apple.com>
+
         test262: Array.prototype.slice should always set length
         https://bugs.webkit.org/show_bug.cgi?id=161953
 
index d4fbe5e..61c2dd3 100644 (file)
@@ -117,6 +117,11 @@ function runTests() {
         dummy: return callerMustBeRun();
     })();
 
+    (function tailCallInTaggedTemplateString() {
+        "use strict";
+        return callerMustBeRun`test`;
+    })();
+
     // Expression tests, we don't enumerate all the cases where there
     // *shouldn't* be a tail call
 
index 01cd1ba..b31172f 100644 (file)
 - path: test262/test/language/expressions/tagged-template/member-expression-context.js
   cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], [:strict]
 - path: test262/test/language/expressions/tagged-template/tco-call.js
-  cmd: runTest262 :fail, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js", "../../../../harness/tco-helper.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js", "../../../../harness/tco-helper.js"], [:strict]
 - path: test262/test/language/expressions/tagged-template/tco-member.js
-  cmd: runTest262 :fail, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js", "../../../../harness/tco-helper.js"], [:strict]
+  cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js", "../../../../harness/tco-helper.js"], [:strict]
 - path: test262/test/language/expressions/tagged-template/template-object-frozen-non-strict.js
   cmd: runTest262 :normal, "NoException", ["../../../../harness/assert.js", "../../../../harness/sta.js"], []
 - path: test262/test/language/expressions/tagged-template/template-object-frozen-strict.js
index 454a6de..f47315b 100644 (file)
@@ -1,5 +1,17 @@
 2016-09-14  Joseph Pecoraro  <pecoraro@apple.com>
 
+        TaggedTemplateString function calls should emit tail position calls
+        https://bugs.webkit.org/show_bug.cgi?id=161948
+
+        Reviewed by Yusuke Suzuki.
+
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::TaggedTemplateNode::emitBytecode):
+        The tagged template string function call can be a tail call:
+        https://tc39.github.io/ecma262/#sec-tagged-templates-runtime-semantics-evaluation
+
+2016-09-14  Joseph Pecoraro  <pecoraro@apple.com>
+
         test262: Array.prototype.slice should always set length
         https://bugs.webkit.org/show_bug.cgi?id=161953
 
index bcdaa27..c80803b 100644 (file)
@@ -343,7 +343,7 @@ RegisterID* TaggedTemplateNode::emitBytecode(BytecodeGenerator& generator, Regis
     for (TemplateExpressionListNode* templateExpression = m_templateLiteral->templateExpressions(); templateExpression; templateExpression = templateExpression->next())
         generator.emitNode(callArguments.argumentRegister(argumentIndex++), templateExpression->value());
 
-    return generator.emitCall(generator.finalDestination(dst, tag.get()), tag.get(), expectedFunction, callArguments, divot(), divotStart(), divotEnd());
+    return generator.emitCallInTailPosition(generator.finalDestination(dst, tag.get()), tag.get(), expectedFunction, callArguments, divot(), divotStart(), divotEnd());
 }
 
 // ------------------------------ ArrayNode ------------------------------------