<!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>[277902] trunk/Source/JavaScriptCore</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/277902">277902</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2021-05-21 17:46:03 -0700 (Fri, 21 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove the unnecessary use of CompileOpStrictEqType.
https://bugs.webkit.org/show_bug.cgi?id=226121

Reviewed by Saam Barati and Robin Morisset.

We're already emitting template code.  Might as well make the relevant condition
checks a build time check on the opcode type the template is specializing on
instead of a runtime check on a passed in CompileOpStrictEqType.

* jit/JIT.h:
* jit/JITOpcodes.cpp:
(JSC::JIT::compileOpStrictEq):
(JSC::JIT::emit_op_stricteq):
(JSC::JIT::emit_op_nstricteq):
(JSC::JIT::compileOpStrictEqJump):
(JSC::JIT::emit_op_jstricteq):
(JSC::JIT::emit_op_jnstricteq):
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::compileOpStrictEq):
(JSC::JIT::emit_op_stricteq):
(JSC::JIT::emit_op_nstricteq):
(JSC::JIT::compileOpStrictEqJump):
(JSC::JIT::emit_op_jstricteq):
(JSC::JIT::emit_op_jnstricteq):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITh">trunk/Source/JavaScriptCore/jit/JIT.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITOpcodescpp">trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITOpcodes32_64cpp">trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (277901 => 277902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog    2021-05-22 00:13:39 UTC (rev 277901)
+++ trunk/Source/JavaScriptCore/ChangeLog       2021-05-22 00:46:03 UTC (rev 277902)
</span><span class="lines">@@ -1,5 +1,32 @@
</span><span class="cx"> 2021-05-21  Mark Lam  <mark.lam@apple.com>
</span><span class="cx"> 
</span><ins>+        Remove the unnecessary use of CompileOpStrictEqType.
+        https://bugs.webkit.org/show_bug.cgi?id=226121
+
+        Reviewed by Saam Barati and Robin Morisset.
+
+        We're already emitting template code.  Might as well make the relevant condition
+        checks a build time check on the opcode type the template is specializing on
+        instead of a runtime check on a passed in CompileOpStrictEqType.
+
+        * jit/JIT.h:
+        * jit/JITOpcodes.cpp:
+        (JSC::JIT::compileOpStrictEq):
+        (JSC::JIT::emit_op_stricteq):
+        (JSC::JIT::emit_op_nstricteq):
+        (JSC::JIT::compileOpStrictEqJump):
+        (JSC::JIT::emit_op_jstricteq):
+        (JSC::JIT::emit_op_jnstricteq):
+        * jit/JITOpcodes32_64.cpp:
+        (JSC::JIT::compileOpStrictEq):
+        (JSC::JIT::emit_op_stricteq):
+        (JSC::JIT::emit_op_nstricteq):
+        (JSC::JIT::compileOpStrictEqJump):
+        (JSC::JIT::emit_op_jstricteq):
+        (JSC::JIT::emit_op_jnstricteq):
+
+2021-05-21  Mark Lam  <mark.lam@apple.com>
+
</ins><span class="cx">         Introducing JITThunks::preinitializeCTIThunks().
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=226105
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JIT.h (277901 => 277902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JIT.h    2021-05-22 00:13:39 UTC (rev 277901)
+++ trunk/Source/JavaScriptCore/jit/JIT.h       2021-05-22 00:46:03 UTC (rev 277902)
</span><span class="lines">@@ -353,11 +353,8 @@
</span><span class="cx">         template<typename Op>
</span><span class="cx">         void emitPutCallResult(const Op&);
</span><span class="cx"> 
</span><del>-        enum class CompileOpStrictEqType { StrictEq, NStrictEq };
-        template<typename Op>
-        void compileOpStrictEq(const Instruction*, CompileOpStrictEqType);
-        template<typename Op>
-        void compileOpStrictEqJump(const Instruction*, CompileOpStrictEqType);
</del><ins>+        template<typename Op> void compileOpStrictEq(const Instruction*);
+        template<typename Op> void compileOpStrictEqJump(const Instruction*);
</ins><span class="cx">         enum class CompileOpEqType { Eq, NEq };
</span><span class="cx">         void compileOpEqJumpSlow(Vector<SlowCaseEntry>::iterator&, CompileOpEqType, int jumpTarget);
</span><span class="cx">         bool isOperandConstantDouble(VirtualRegister);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITOpcodescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp (277901 => 277902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp   2021-05-22 00:13:39 UTC (rev 277901)
+++ trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp      2021-05-22 00:46:03 UTC (rev 277902)
</span><span class="lines">@@ -648,7 +648,7 @@
</span><span class="cx"> #endif // ENABLE(EXTRA_CTI_THUNKS)
</span><span class="cx"> 
</span><span class="cx"> template<typename Op>
</span><del>-void JIT::compileOpStrictEq(const Instruction* currentInstruction, CompileOpStrictEqType type)
</del><ins>+void JIT::compileOpStrictEq(const Instruction* currentInstruction)
</ins><span class="cx"> {
</span><span class="cx">     auto bytecode = currentInstruction->as<Op>();
</span><span class="cx">     VirtualRegister dst = bytecode.m_dst;
</span><span class="lines">@@ -693,7 +693,7 @@
</span><span class="cx">     addSlowCase(branchIfCell(regT2));
</span><span class="cx"> 
</span><span class="cx">     done.link(this);
</span><del>-    if (type == CompileOpStrictEqType::NStrictEq)
</del><ins>+    if constexpr (std::is_same<Op, OpNstricteq>::value)
</ins><span class="cx">         xor64(TrustedImm64(1), regT5);
</span><span class="cx">     boxBoolean(regT5, JSValueRegs { regT5 });
</span><span class="cx">     emitPutVirtualRegister(dst, regT5);
</span><span class="lines">@@ -712,7 +712,7 @@
</span><span class="cx">     addSlowCase(branchIfNumber(regT1));
</span><span class="cx">     rightOK.link(this);
</span><span class="cx"> 
</span><del>-    if (type == CompileOpStrictEqType::StrictEq)
</del><ins>+    if constexpr (std::is_same<Op, OpStricteq>::value)
</ins><span class="cx">         compare64(Equal, regT1, regT0, regT0);
</span><span class="cx">     else
</span><span class="cx">         compare64(NotEqual, regT1, regT0, regT0);
</span><span class="lines">@@ -724,16 +724,16 @@
</span><span class="cx"> 
</span><span class="cx"> void JIT::emit_op_stricteq(const Instruction* currentInstruction)
</span><span class="cx"> {
</span><del>-    compileOpStrictEq<OpStricteq>(currentInstruction, CompileOpStrictEqType::StrictEq);
</del><ins>+    compileOpStrictEq<OpStricteq>(currentInstruction);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void JIT::emit_op_nstricteq(const Instruction* currentInstruction)
</span><span class="cx"> {
</span><del>-    compileOpStrictEq<OpNstricteq>(currentInstruction, CompileOpStrictEqType::NStrictEq);
</del><ins>+    compileOpStrictEq<OpNstricteq>(currentInstruction);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template<typename Op>
</span><del>-void JIT::compileOpStrictEqJump(const Instruction* currentInstruction, CompileOpStrictEqType type)
</del><ins>+void JIT::compileOpStrictEqJump(const Instruction* currentInstruction)
</ins><span class="cx"> {
</span><span class="cx">     auto bytecode = currentInstruction->as<Op>();
</span><span class="cx">     int target = jumpTarget(currentInstruction, bytecode.m_targetLabel);
</span><span class="lines">@@ -767,7 +767,7 @@
</span><span class="cx">     addSlowCase(branch64(AboveOrEqual, regT3, regT5));
</span><span class="cx"> 
</span><span class="cx">     Jump areEqual = branch64(Equal, regT0, regT1);
</span><del>-    if (type == CompileOpStrictEqType::StrictEq)
</del><ins>+    if constexpr (std::is_same<Op, OpJstricteq>::value)
</ins><span class="cx">         addJump(areEqual, target);
</span><span class="cx"> 
</span><span class="cx">     move(regT0, regT2);
</span><span class="lines">@@ -776,7 +776,7 @@
</span><span class="cx">     // FIXME: we could do something more precise: unless there is a BigInt32, we only need to do the slow path if both are strings
</span><span class="cx">     addSlowCase(branchIfCell(regT2));
</span><span class="cx"> 
</span><del>-    if (type == CompileOpStrictEqType::NStrictEq) {
</del><ins>+    if constexpr (std::is_same<Op, OpJnstricteq>::value) {
</ins><span class="cx">         addJump(jump(), target);
</span><span class="cx">         areEqual.link(this);
</span><span class="cx">     }
</span><span class="lines">@@ -794,7 +794,7 @@
</span><span class="cx">     Jump rightOK = branchIfInt32(regT1);
</span><span class="cx">     addSlowCase(branchIfNumber(regT1));
</span><span class="cx">     rightOK.link(this);
</span><del>-    if (type == CompileOpStrictEqType::StrictEq)
</del><ins>+    if constexpr (std::is_same<Op, OpJstricteq>::value)
</ins><span class="cx">         addJump(branch64(Equal, regT1, regT0), target);
</span><span class="cx">     else
</span><span class="cx">         addJump(branch64(NotEqual, regT1, regT0), target);
</span><span class="lines">@@ -803,12 +803,12 @@
</span><span class="cx"> 
</span><span class="cx"> void JIT::emit_op_jstricteq(const Instruction* currentInstruction)
</span><span class="cx"> {
</span><del>-    compileOpStrictEqJump<OpJstricteq>(currentInstruction, CompileOpStrictEqType::StrictEq);
</del><ins>+    compileOpStrictEqJump<OpJstricteq>(currentInstruction);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void JIT::emit_op_jnstricteq(const Instruction* currentInstruction)
</span><span class="cx"> {
</span><del>-    compileOpStrictEqJump<OpJnstricteq>(currentInstruction, CompileOpStrictEqType::NStrictEq);
</del><ins>+    compileOpStrictEqJump<OpJnstricteq>(currentInstruction);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void JIT::emitSlow_op_jstricteq(const Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITOpcodes32_64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp (277901 => 277902)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp      2021-05-22 00:13:39 UTC (rev 277901)
+++ trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp 2021-05-22 00:46:03 UTC (rev 277902)
</span><span class="lines">@@ -677,7 +677,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template <typename Op>
</span><del>-void JIT::compileOpStrictEq(const Instruction* currentInstruction, CompileOpStrictEqType type)
</del><ins>+void JIT::compileOpStrictEq(const Instruction* currentInstruction)
</ins><span class="cx"> {
</span><span class="cx">     auto bytecode = currentInstruction->as<Op>();
</span><span class="cx">     VirtualRegister dst = bytecode.m_dst;
</span><span class="lines">@@ -698,7 +698,7 @@
</span><span class="cx">     firstIsObject.link(this);
</span><span class="cx"> 
</span><span class="cx">     // Simply compare the payloads.
</span><del>-    if (type == CompileOpStrictEqType::StrictEq)
</del><ins>+    if constexpr (std::is_same<Op, OpStricteq>::value)
</ins><span class="cx">         compare32(Equal, regT0, regT2, regT0);
</span><span class="cx">     else
</span><span class="cx">         compare32(NotEqual, regT0, regT2, regT0);
</span><span class="lines">@@ -708,16 +708,16 @@
</span><span class="cx"> 
</span><span class="cx"> void JIT::emit_op_stricteq(const Instruction* currentInstruction)
</span><span class="cx"> {
</span><del>-    compileOpStrictEq<OpStricteq>(currentInstruction, CompileOpStrictEqType::StrictEq);
</del><ins>+    compileOpStrictEq<OpStricteq>(currentInstruction);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void JIT::emit_op_nstricteq(const Instruction* currentInstruction)
</span><span class="cx"> {
</span><del>-    compileOpStrictEq<OpNstricteq>(currentInstruction, CompileOpStrictEqType::NStrictEq);
</del><ins>+    compileOpStrictEq<OpNstricteq>(currentInstruction);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template<typename Op>
</span><del>-void JIT::compileOpStrictEqJump(const Instruction* currentInstruction, CompileOpStrictEqType type)
</del><ins>+void JIT::compileOpStrictEqJump(const Instruction* currentInstruction)
</ins><span class="cx"> {
</span><span class="cx">     auto bytecode = currentInstruction->as<Op>();
</span><span class="cx">     int target = jumpTarget(currentInstruction, bytecode.m_targetLabel);
</span><span class="lines">@@ -738,7 +738,7 @@
</span><span class="cx">     firstIsObject.link(this);
</span><span class="cx"> 
</span><span class="cx">     // Simply compare the payloads.
</span><del>-    if (type == CompileOpStrictEqType::StrictEq)
</del><ins>+    if constexpr (std::is_same<Op, OpJstricteq>::value)
</ins><span class="cx">         addJump(branch32(Equal, regT0, regT2), target);
</span><span class="cx">     else
</span><span class="cx">         addJump(branch32(NotEqual, regT0, regT2), target);
</span><span class="lines">@@ -746,12 +746,12 @@
</span><span class="cx"> 
</span><span class="cx"> void JIT::emit_op_jstricteq(const Instruction* currentInstruction)
</span><span class="cx"> {
</span><del>-    compileOpStrictEqJump<OpJstricteq>(currentInstruction, CompileOpStrictEqType::StrictEq);
</del><ins>+    compileOpStrictEqJump<OpJstricteq>(currentInstruction);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void JIT::emit_op_jnstricteq(const Instruction* currentInstruction)
</span><span class="cx"> {
</span><del>-    compileOpStrictEqJump<OpJnstricteq>(currentInstruction, CompileOpStrictEqType::NStrictEq);
</del><ins>+    compileOpStrictEqJump<OpJnstricteq>(currentInstruction);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void JIT::emitSlow_op_jstricteq(const Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
</span></span></pre>
</div>
</div>

</body>
</html>