<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[214931] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/214931">214931</a></dd>
<dt>Author</dt> <dd>utatane.tea@gmail.com</dd>
<dt>Date</dt> <dd>2017-04-05 00:09:41 -0700 (Wed, 05 Apr 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[JSC] Generate TemplateObjects at linking time
https://bugs.webkit.org/show_bug.cgi?id=169743

Reviewed by Keith Miller.

JSTests:

* stress/template-string-tags-eval.js: Added.
(shouldBe):
(tag):

Source/JavaScriptCore:

Currently, the code calls getTemplateObject to get appropriate template objects at runtime.
But this template object is constant value and never changed. So instead of creating it
at runtime, we should create it at linking time and store it in the constant registers.

* builtins/BuiltinNames.h:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::finishCreation):
(JSC::CodeBlock::setConstantRegisters):
* bytecode/CodeBlock.h:
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedCodeBlock::shrinkToFit):
* bytecode/UnlinkedCodeBlock.h:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::addTemplateRegistryKeyConstant):
(JSC::BytecodeGenerator::emitGetTemplateObject):
* bytecompiler/BytecodeGenerator.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::TaggedTemplateNode::emitBytecode):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::getTemplateObject): Deleted.
* runtime/JSTemplateRegistryKey.cpp:
* runtime/JSTemplateRegistryKey.h:
(JSC::isTemplateRegistryKey):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebuiltinsBuiltinNamesh">trunk/Source/JavaScriptCore/builtins/BuiltinNames.h</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeCodeBlockcpp">trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeCodeBlockh">trunk/Source/JavaScriptCore/bytecode/CodeBlock.h</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeUnlinkedCodeBlockcpp">trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeUnlinkedCodeBlockh">trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp">trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorh">trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecompilerNodesCodegencpp">trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSTemplateRegistryKeycpp">trunk/Source/JavaScriptCore/runtime/JSTemplateRegistryKey.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSTemplateRegistryKeyh">trunk/Source/JavaScriptCore/runtime/JSTemplateRegistryKey.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkJSTestsstresstemplatestringtagsevaljs">trunk/JSTests/stress/template-string-tags-eval.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/JSTests/ChangeLog        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-03-16  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        [JSC] Generate TemplateObjects at linking time
+        https://bugs.webkit.org/show_bug.cgi?id=169743
+
+        Reviewed by Keith Miller.
+
+        * stress/template-string-tags-eval.js: Added.
+        (shouldBe):
+        (tag):
+
</ins><span class="cx"> 2017-04-04  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         On ARM64, DFG::SpeculativeJIT::compileArithMod() failed to ensure result is of DataFormatInt32.
</span></span></pre></div>
<a id="trunkJSTestsstresstemplatestringtagsevaljs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/stress/template-string-tags-eval.js (0 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/template-string-tags-eval.js                                (rev 0)
+++ trunk/JSTests/stress/template-string-tags-eval.js        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+function shouldBe(actual, expected)
+{
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+function tag(site)
+{
+    return site;
+}
+
+var site1 = eval(&quot;0, tag`Cocoa`&quot;);
+var site2 = eval(&quot;1, tag`Cappuccino`&quot;);
+var site3 = eval(&quot;2, tag`Cocoa`&quot;);
+
+shouldBe(site1 === site3, true);
+shouldBe(site1 !== site2, true);
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2017-03-16  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
+
+        [JSC] Generate TemplateObjects at linking time
+        https://bugs.webkit.org/show_bug.cgi?id=169743
+
+        Reviewed by Keith Miller.
+
+        Currently, the code calls getTemplateObject to get appropriate template objects at runtime.
+        But this template object is constant value and never changed. So instead of creating it
+        at runtime, we should create it at linking time and store it in the constant registers.
+
+        * builtins/BuiltinNames.h:
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::finishCreation):
+        (JSC::CodeBlock::setConstantRegisters):
+        * bytecode/CodeBlock.h:
+        * bytecode/UnlinkedCodeBlock.cpp:
+        (JSC::UnlinkedCodeBlock::shrinkToFit):
+        * bytecode/UnlinkedCodeBlock.h:
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::addTemplateRegistryKeyConstant):
+        (JSC::BytecodeGenerator::emitGetTemplateObject):
+        * bytecompiler/BytecodeGenerator.h:
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::TaggedTemplateNode::emitBytecode):
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init):
+        (JSC::getTemplateObject): Deleted.
+        * runtime/JSTemplateRegistryKey.cpp:
+        * runtime/JSTemplateRegistryKey.h:
+        (JSC::isTemplateRegistryKey):
+
</ins><span class="cx"> 2017-04-04  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         On ARM64, DFG::SpeculativeJIT::compileArithMod() failed to ensure result is of DataFormatInt32.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsBuiltinNamesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/builtins/BuiltinNames.h (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/BuiltinNames.h        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/Source/JavaScriptCore/builtins/BuiltinNames.h        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -80,7 +80,6 @@
</span><span class="cx">     macro(typedArraySubarrayCreate) \
</span><span class="cx">     macro(BuiltinLog) \
</span><span class="cx">     macro(homeObject) \
</span><del>-    macro(getTemplateObject) \
</del><span class="cx">     macro(templateRegistryKey) \
</span><span class="cx">     macro(enqueueJob) \
</span><span class="cx">     macro(promiseState) \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -60,6 +60,7 @@
</span><span class="cx"> #include &quot;JSModuleEnvironment.h&quot;
</span><span class="cx"> #include &quot;JSSet.h&quot;
</span><span class="cx"> #include &quot;JSString.h&quot;
</span><ins>+#include &quot;JSTemplateRegistryKey.h&quot;
</ins><span class="cx"> #include &quot;LLIntData.h&quot;
</span><span class="cx"> #include &quot;LLIntEntrypoint.h&quot;
</span><span class="cx"> #include &quot;LLIntPrototypeLoadAdaptiveStructureWatchpoint.h&quot;
</span><span class="lines">@@ -404,7 +405,8 @@
</span><span class="cx">     if (vm.typeProfiler() || vm.controlFlowProfiler())
</span><span class="cx">         vm.functionHasExecutedCache()-&gt;removeUnexecutedRange(ownerExecutable-&gt;sourceID(), ownerExecutable-&gt;typeProfilingStartOffset(), ownerExecutable-&gt;typeProfilingEndOffset());
</span><span class="cx"> 
</span><del>-    setConstantRegisters(unlinkedCodeBlock-&gt;constantRegisters(), unlinkedCodeBlock-&gt;constantsSourceCodeRepresentation());
</del><ins>+    if (!setConstantRegisters(unlinkedCodeBlock-&gt;constantRegisters(), unlinkedCodeBlock-&gt;constantsSourceCodeRepresentation()))
+        return false;
</ins><span class="cx">     if (!setConstantIdentifierSetRegisters(vm, unlinkedCodeBlock-&gt;constantIdentifierSets()))
</span><span class="cx">         return false;
</span><span class="cx">     if (unlinkedCodeBlock-&gt;usesGlobalObject())
</span><span class="lines">@@ -885,13 +887,15 @@
</span><span class="cx">         }
</span><span class="cx">         m_constantRegisters[entry.second].set(vm, this, JSValue(jsSet));
</span><span class="cx">     }
</span><del>-    
-    scope.release();
</del><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CodeBlock::setConstantRegisters(const Vector&lt;WriteBarrier&lt;Unknown&gt;&gt;&amp; constants, const Vector&lt;SourceCodeRepresentation&gt;&amp; constantsSourceCodeRepresentation)
</del><ins>+bool CodeBlock::setConstantRegisters(const Vector&lt;WriteBarrier&lt;Unknown&gt;&gt;&amp; constants, const Vector&lt;SourceCodeRepresentation&gt;&amp; constantsSourceCodeRepresentation)
</ins><span class="cx"> {
</span><ins>+    auto scope = DECLARE_THROW_SCOPE(*m_vm);
+    JSGlobalObject* globalObject = m_globalObject.get();
+    ExecState* exec = globalObject-&gt;globalExec();
+
</ins><span class="cx">     ASSERT(constants.size() == constantsSourceCodeRepresentation.size());
</span><span class="cx">     size_t count = constants.size();
</span><span class="cx">     m_constantRegisters.resizeToFit(count);
</span><span class="lines">@@ -900,7 +904,7 @@
</span><span class="cx">         JSValue constant = constants[i].get();
</span><span class="cx"> 
</span><span class="cx">         if (!constant.isEmpty()) {
</span><del>-            if (SymbolTable* symbolTable = jsDynamicCast&lt;SymbolTable*&gt;(*vm(), constant)) {
</del><ins>+            if (SymbolTable* symbolTable = jsDynamicCast&lt;SymbolTable*&gt;(*m_vm, constant)) {
</ins><span class="cx">                 if (hasTypeProfiler) {
</span><span class="cx">                     ConcurrentJSLocker locker(symbolTable-&gt;m_lock);
</span><span class="cx">                     symbolTable-&gt;prepareForTypeProfiling(locker);
</span><span class="lines">@@ -911,6 +915,10 @@
</span><span class="cx">                     clone-&gt;setRareDataCodeBlock(this);
</span><span class="cx"> 
</span><span class="cx">                 constant = clone;
</span><ins>+            } else if (isTemplateRegistryKey(*m_vm, constant)) {
+                auto* templateObject = globalObject-&gt;templateRegistry().getTemplateObject(exec, jsCast&lt;JSTemplateRegistryKey*&gt;(constant));
+                RETURN_IF_EXCEPTION(scope, false);
+                constant = templateObject;
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -918,6 +926,8 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_constantsSourceCodeRepresentation = constantsSourceCodeRepresentation;
</span><ins>+
+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CodeBlock::setAlternative(VM&amp; vm, CodeBlock* alternative)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.h (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.h        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.h        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -921,7 +921,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool setConstantIdentifierSetRegisters(VM&amp;, const Vector&lt;ConstantIndentifierSetEntry&gt;&amp; constants);
</span><span class="cx"> 
</span><del>-    void setConstantRegisters(const Vector&lt;WriteBarrier&lt;Unknown&gt;&gt;&amp; constants, const Vector&lt;SourceCodeRepresentation&gt;&amp; constantsSourceCodeRepresentation);
</del><ins>+    bool setConstantRegisters(const Vector&lt;WriteBarrier&lt;Unknown&gt;&gt;&amp; constants, const Vector&lt;SourceCodeRepresentation&gt;&amp; constantsSourceCodeRepresentation);
</ins><span class="cx"> 
</span><span class="cx">     void replaceConstant(int index, JSValue value)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeUnlinkedCodeBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -410,6 +410,7 @@
</span><span class="cx">         m_rareData-&gt;m_switchJumpTables.shrinkToFit();
</span><span class="cx">         m_rareData-&gt;m_stringSwitchJumpTables.shrinkToFit();
</span><span class="cx">         m_rareData-&gt;m_expressionInfoFatPositions.shrinkToFit();
</span><ins>+        m_rareData-&gt;m_opProfileControlFlowBytecodeOffsets.shrinkToFit();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeUnlinkedCodeBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -220,6 +220,7 @@
</span><span class="cx">         m_constantsSourceCodeRepresentation.append(SourceCodeRepresentation::Other);
</span><span class="cx">         return result;
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     unsigned registerIndexForLinkTimeConstant(LinkTimeConstant type)
</span><span class="cx">     {
</span><span class="cx">         unsigned index = static_cast&lt;unsigned&gt;(type);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -3057,12 +3057,15 @@
</span><span class="cx">     return stringInMap;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSTemplateRegistryKey* BytecodeGenerator::addTemplateRegistryKeyConstant(Ref&lt;TemplateRegistryKey&gt;&amp;&amp; templateRegistryKey)
</del><ins>+RegisterID* BytecodeGenerator::addTemplateRegistryKeyConstant(Ref&lt;TemplateRegistryKey&gt;&amp;&amp; templateRegistryKey)
</ins><span class="cx"> {
</span><span class="cx">     return m_templateRegistryKeyMap.ensure(templateRegistryKey.copyRef(), [&amp;] {
</span><span class="cx">         auto* result = JSTemplateRegistryKey::create(*vm(), WTFMove(templateRegistryKey));
</span><del>-        addConstantValue(result);
-        return result;
</del><ins>+        unsigned index = m_nextConstantOffset;
+        m_constantPoolRegisters.append(FirstConstantRegisterIndex + m_nextConstantOffset);
+        ++m_nextConstantOffset;
+        m_codeBlock-&gt;addConstant(result);
+        return &amp;m_constantPoolRegisters[index];
</ins><span class="cx">     }).iterator-&gt;value;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -4311,11 +4314,10 @@
</span><span class="cx">         else
</span><span class="cx">             cookedStrings.append(string-&gt;cooked()-&gt;impl());
</span><span class="cx">     }
</span><del>-
-    RefPtr&lt;RegisterID&gt; getTemplateObject = emitGetGlobalPrivate(newTemporary(), propertyNames().builtinNames().getTemplateObjectPrivateName());
-    CallArguments arguments(*this, nullptr);
-    emitLoad(arguments.thisRegister(), JSValue(addTemplateRegistryKeyConstant(m_vm-&gt;templateRegistryKeyTable().createKey(WTFMove(rawStrings), WTFMove(cookedStrings)))));
-    return emitCall(dst, getTemplateObject.get(), NoExpectedFunction, arguments, taggedTemplate-&gt;divot(), taggedTemplate-&gt;divotStart(), taggedTemplate-&gt;divotEnd(), DebuggableCall::No);
</del><ins>+    RefPtr&lt;RegisterID&gt; constant = addTemplateRegistryKeyConstant(m_vm-&gt;templateRegistryKeyTable().createKey(WTFMove(rawStrings), WTFMove(cookedStrings)));
+    if (!dst)
+        return constant.get();
+    return emitMove(dst, constant.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RegisterID* BytecodeGenerator::emitGetGlobalPrivate(RegisterID* dst, const Identifier&amp; property)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -943,7 +943,7 @@
</span><span class="cx"> 
</span><span class="cx">         typedef HashMap&lt;double, JSValue&gt; NumberMap;
</span><span class="cx">         typedef HashMap&lt;UniquedStringImpl*, JSString*, IdentifierRepHash&gt; IdentifierStringMap;
</span><del>-        typedef HashMap&lt;Ref&lt;TemplateRegistryKey&gt;, JSTemplateRegistryKey*&gt; TemplateRegistryKeyMap;
</del><ins>+        typedef HashMap&lt;Ref&lt;TemplateRegistryKey&gt;, RegisterID*&gt; TemplateRegistryKeyMap;
</ins><span class="cx">         
</span><span class="cx">         // Helper for emitCall() and emitConstruct(). This works because the set of
</span><span class="cx">         // expected functions have identical behavior for both call and construct
</span><span class="lines">@@ -1028,7 +1028,7 @@
</span><span class="cx"> 
</span><span class="cx">     public:
</span><span class="cx">         JSString* addStringConstant(const Identifier&amp;);
</span><del>-        JSTemplateRegistryKey* addTemplateRegistryKeyConstant(Ref&lt;TemplateRegistryKey&gt;&amp;&amp;);
</del><ins>+        RegisterID* addTemplateRegistryKeyConstant(Ref&lt;TemplateRegistryKey&gt;&amp;&amp;);
</ins><span class="cx"> 
</span><span class="cx">         Vector&lt;UnlinkedInstruction, 0, UnsafeVectorOverflow&gt;&amp; instructions() { return m_instructions; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerNodesCodegencpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -344,7 +344,7 @@
</span><span class="cx">             tag = generator.emitGetById(generator.newTemporary(), base.get(), dot-&gt;identifier());
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    RefPtr&lt;RegisterID&gt; templateObject = generator.emitGetTemplateObject(generator.newTemporary(), this);
</del><ins>+    RefPtr&lt;RegisterID&gt; templateObject = generator.emitGetTemplateObject(nullptr, this);
</ins><span class="cx"> 
</span><span class="cx">     unsigned expressionsCount = 0;
</span><span class="cx">     for (TemplateExpressionListNode* templateExpression = m_templateLiteral-&gt;templateExpressions(); templateExpression; templateExpression = templateExpression-&gt;next())
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -297,14 +297,6 @@
</span><span class="cx"> @end
</span><span class="cx"> */
</span><span class="cx"> 
</span><del>-static EncodedJSValue JSC_HOST_CALL getTemplateObject(ExecState* exec)
-{
-    JSValue thisValue = exec-&gt;thisValue();
-    ASSERT(thisValue.inherits(exec-&gt;vm(), JSTemplateRegistryKey::info()));
-    return JSValue::encode(exec-&gt;lexicalGlobalObject()-&gt;templateRegistry().getTemplateObject(exec, jsCast&lt;JSTemplateRegistryKey*&gt;(thisValue)));
-}
-
-
</del><span class="cx"> static EncodedJSValue JSC_HOST_CALL enqueueJob(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     VM&amp; vm = exec-&gt;vm();
</span><span class="lines">@@ -731,7 +723,6 @@
</span><span class="cx">     JSFunction* privateFuncFloor = JSFunction::create(vm, this, 0, String(), mathProtoFuncFloor, FloorIntrinsic);
</span><span class="cx">     JSFunction* privateFuncTrunc = JSFunction::create(vm, this, 0, String(), mathProtoFuncTrunc, TruncIntrinsic);
</span><span class="cx"> 
</span><del>-    JSFunction* privateFuncGetTemplateObject = JSFunction::create(vm, this, 0, String(), getTemplateObject);
</del><span class="cx">     JSFunction* privateFuncImportModule = JSFunction::create(vm, this, 0, String(), globalFuncImportModule);
</span><span class="cx">     JSFunction* privateFuncTypedArrayLength = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncLength);
</span><span class="cx">     JSFunction* privateFuncTypedArrayGetOriginalConstructor = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncGetOriginalConstructor);
</span><span class="lines">@@ -785,7 +776,6 @@
</span><span class="cx">         GlobalPropertyInfo(vm.propertyNames-&gt;Infinity, jsNumber(std::numeric_limits&lt;double&gt;::infinity()), DontEnum | DontDelete | ReadOnly),
</span><span class="cx">         GlobalPropertyInfo(vm.propertyNames-&gt;undefinedKeyword, jsUndefined(), DontEnum | DontDelete | ReadOnly),
</span><span class="cx">         GlobalPropertyInfo(vm.propertyNames-&gt;builtinNames().ownEnumerablePropertyKeysPrivateName(), JSFunction::create(vm, this, 0, String(), ownEnumerablePropertyKeys), DontEnum | DontDelete | ReadOnly),
</span><del>-        GlobalPropertyInfo(vm.propertyNames-&gt;builtinNames().getTemplateObjectPrivateName(), privateFuncGetTemplateObject, DontEnum | DontDelete | ReadOnly),
</del><span class="cx">         GlobalPropertyInfo(vm.propertyNames-&gt;builtinNames().importModulePrivateName(), privateFuncImportModule, DontEnum | DontDelete | ReadOnly),
</span><span class="cx">         GlobalPropertyInfo(vm.propertyNames-&gt;builtinNames().enqueueJobPrivateName(), JSFunction::create(vm, this, 0, String(), enqueueJob), DontEnum | DontDelete | ReadOnly),
</span><span class="cx">         GlobalPropertyInfo(vm.propertyNames-&gt;builtinNames().ErrorPrivateName(), m_errorConstructor.get(), DontEnum | DontDelete | ReadOnly),
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSTemplateRegistryKeycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSTemplateRegistryKey.cpp (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSTemplateRegistryKey.cpp        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/Source/JavaScriptCore/runtime/JSTemplateRegistryKey.cpp        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-const ClassInfo JSTemplateRegistryKey::s_info = { &quot;TemplateRegistryKey&quot;, &amp;Base::s_info, nullptr, CREATE_METHOD_TABLE(JSTemplateRegistryKey) };
</del><ins>+const ClassInfo JSTemplateRegistryKey::s_info = { &quot;TemplateRegistryKey&quot;, nullptr, nullptr, CREATE_METHOD_TABLE(JSTemplateRegistryKey) };
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> JSTemplateRegistryKey::JSTemplateRegistryKey(VM&amp; vm, Ref&lt;TemplateRegistryKey&gt;&amp;&amp; templateRegistryKey)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSTemplateRegistryKeyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSTemplateRegistryKey.h (214930 => 214931)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSTemplateRegistryKey.h        2017-04-05 05:38:25 UTC (rev 214930)
+++ trunk/Source/JavaScriptCore/runtime/JSTemplateRegistryKey.h        2017-04-05 07:09:41 UTC (rev 214931)
</span><span class="lines">@@ -31,19 +31,21 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><del>-class JSTemplateRegistryKey final : public JSDestructibleObject {
</del><ins>+class JSTemplateRegistryKey final : public JSCell {
</ins><span class="cx"> public:
</span><del>-    typedef JSDestructibleObject Base;
</del><ins>+    using Base = JSCell;
</ins><span class="cx"> 
</span><ins>+    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
+    static const bool needsDestruction = true;
+    DECLARE_INFO;
+
</ins><span class="cx">     static JSTemplateRegistryKey* create(VM&amp;, Ref&lt;TemplateRegistryKey&gt;&amp;&amp;);
</span><span class="cx"> 
</span><span class="cx">     static Structure* createStructure(VM&amp; vm, JSGlobalObject* globalObject, JSValue prototype)
</span><span class="cx">     {
</span><del>-        return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
</del><ins>+        return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    DECLARE_INFO;
-
</del><span class="cx">     const TemplateRegistryKey&amp; templateRegistryKey() const { return m_templateRegistryKey.get(); }
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="lines">@@ -55,4 +57,14 @@
</span><span class="cx">     Ref&lt;TemplateRegistryKey&gt; m_templateRegistryKey;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+inline bool isTemplateRegistryKey(VM&amp; vm, JSCell* cell)
+{
+    return cell-&gt;classInfo(vm) == JSTemplateRegistryKey::info();
+}
+
+inline bool isTemplateRegistryKey(VM&amp; vm, JSValue v)
+{
+    return v.isCell() &amp;&amp; isTemplateRegistryKey(vm, v.asCell());
+}
+
</ins><span class="cx"> } // namespace JSC
</span></span></pre>
</div>
</div>

</body>
</html>