<!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>[203979] 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/203979">203979</a></dd>
<dt>Author</dt> <dd>sbarati@apple.com</dd>
<dt>Date</dt> <dd>2016-08-01 11:48:14 -0700 (Mon, 01 Aug 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Sub should be a Math IC
https://bugs.webkit.org/show_bug.cgi?id=160270
Reviewed by Mark Lam.
This makes Sub an IC like Mul and Add. I'm seeing the following
improvements of average Sub size on Unity and JetStream:
| JetStream | Unity 3D |
------| -------------|--------------
Old | 202 bytes | 205 bytes |
------| -------------|--------------
New | 134 bytes | 134 bytes |
------------------------------------
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::addJITMulIC):
(JSC::CodeBlock::addJITSubIC):
(JSC::CodeBlock::findStubInfo):
(JSC::CodeBlock::dumpMathICStats):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::stubInfoBegin):
(JSC::CodeBlock::stubInfoEnd):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileArithSub):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileArithAddOrSub):
* jit/JITArithmetic.cpp:
(JSC::JIT::emit_op_sub):
(JSC::JIT::emitSlow_op_sub):
(JSC::JIT::emit_op_pow):
* jit/JITMathIC.h:
* jit/JITMathICForwards.h:
* jit/JITOperations.cpp:
* jit/JITOperations.h:
* jit/JITSubGenerator.cpp:
(JSC::JITSubGenerator::generateInline):
(JSC::JITSubGenerator::generateFastPath):
* jit/JITSubGenerator.h:
(JSC::JITSubGenerator::JITSubGenerator):
(JSC::JITSubGenerator::isLeftOperandValidConstant):
(JSC::JITSubGenerator::isRightOperandValidConstant):
(JSC::JITSubGenerator::arithProfile):
(JSC::JITSubGenerator::didEmitFastPath): Deleted.
(JSC::JITSubGenerator::endJumpList): Deleted.
(JSC::JITSubGenerator::slowPathJumpList): Deleted.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</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="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITArithmeticcpp">trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITMathICh">trunk/Source/JavaScriptCore/jit/JITMathIC.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITMathICForwardsh">trunk/Source/JavaScriptCore/jit/JITMathICForwards.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITOperationscpp">trunk/Source/JavaScriptCore/jit/JITOperations.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITOperationsh">trunk/Source/JavaScriptCore/jit/JITOperations.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITSubGeneratorcpp">trunk/Source/JavaScriptCore/jit/JITSubGenerator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITSubGeneratorh">trunk/Source/JavaScriptCore/jit/JITSubGenerator.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (203978 => 203979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-08-01 18:45:17 UTC (rev 203978)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-08-01 18:48:14 UTC (rev 203979)
</span><span class="lines">@@ -1,3 +1,52 @@
</span><ins>+2016-08-01 Saam Barati <sbarati@apple.com>
+
+ Sub should be a Math IC
+ https://bugs.webkit.org/show_bug.cgi?id=160270
+
+ Reviewed by Mark Lam.
+
+ This makes Sub an IC like Mul and Add. I'm seeing the following
+ improvements of average Sub size on Unity and JetStream:
+
+ | JetStream | Unity 3D |
+ ------| -------------|--------------
+ Old | 202 bytes | 205 bytes |
+ ------| -------------|--------------
+ New | 134 bytes | 134 bytes |
+ ------------------------------------
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::addJITMulIC):
+ (JSC::CodeBlock::addJITSubIC):
+ (JSC::CodeBlock::findStubInfo):
+ (JSC::CodeBlock::dumpMathICStats):
+ * bytecode/CodeBlock.h:
+ (JSC::CodeBlock::stubInfoBegin):
+ (JSC::CodeBlock::stubInfoEnd):
+ * dfg/DFGSpeculativeJIT.cpp:
+ (JSC::DFG::SpeculativeJIT::compileArithSub):
+ * ftl/FTLLowerDFGToB3.cpp:
+ (JSC::FTL::DFG::LowerDFGToB3::compileArithAddOrSub):
+ * jit/JITArithmetic.cpp:
+ (JSC::JIT::emit_op_sub):
+ (JSC::JIT::emitSlow_op_sub):
+ (JSC::JIT::emit_op_pow):
+ * jit/JITMathIC.h:
+ * jit/JITMathICForwards.h:
+ * jit/JITOperations.cpp:
+ * jit/JITOperations.h:
+ * jit/JITSubGenerator.cpp:
+ (JSC::JITSubGenerator::generateInline):
+ (JSC::JITSubGenerator::generateFastPath):
+ * jit/JITSubGenerator.h:
+ (JSC::JITSubGenerator::JITSubGenerator):
+ (JSC::JITSubGenerator::isLeftOperandValidConstant):
+ (JSC::JITSubGenerator::isRightOperandValidConstant):
+ (JSC::JITSubGenerator::arithProfile):
+ (JSC::JITSubGenerator::didEmitFastPath): Deleted.
+ (JSC::JITSubGenerator::endJumpList): Deleted.
+ (JSC::JITSubGenerator::slowPathJumpList): Deleted.
+
</ins><span class="cx"> 2016-08-01 Keith Miller <keith_miller@apple.com>
</span><span class="cx">
</span><span class="cx"> We should not keep the JavaScript tests inside the Source/JavaScriptCore/ directory.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp (203978 => 203979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2016-08-01 18:45:17 UTC (rev 203978)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2016-08-01 18:48:14 UTC (rev 203979)
</span><span class="lines">@@ -3018,6 +3018,11 @@
</span><span class="cx"> return m_mulICs.add();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+JITSubIC* CodeBlock::addJITSubIC()
+{
+ return m_subICs.add();
+}
+
</ins><span class="cx"> StructureStubInfo* CodeBlock::findStubInfo(CodeOrigin codeOrigin)
</span><span class="cx"> {
</span><span class="cx"> for (StructureStubInfo* stubInfo : m_stubInfos) {
</span><span class="lines">@@ -4585,6 +4590,8 @@
</span><span class="cx"> double totalAddSize = 0.0;
</span><span class="cx"> double numMuls = 0.0;
</span><span class="cx"> double totalMulSize = 0.0;
</span><ins>+ double numSubs = 0.0;
+ double totalSubSize = 0.0;
</ins><span class="cx">
</span><span class="cx"> auto countICs = [&] (CodeBlock* codeBlock) {
</span><span class="cx"> for (JITAddIC* addIC : codeBlock->m_addICs) {
</span><span class="lines">@@ -4597,6 +4604,11 @@
</span><span class="cx"> totalMulSize += mulIC->codeSize();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ for (JITSubIC* subIC : codeBlock->m_subICs) {
+ numSubs++;
+ totalSubSize += subIC->codeSize();
+ }
+
</ins><span class="cx"> return false;
</span><span class="cx"> };
</span><span class="cx"> heap()->forEachCodeBlock(countICs);
</span><span class="lines">@@ -4608,6 +4620,10 @@
</span><span class="cx"> dataLog("Num Muls: ", numMuls, "\n");
</span><span class="cx"> dataLog("Total Mul size in bytes: ", totalMulSize, "\n");
</span><span class="cx"> dataLog("Average Mul size: ", totalMulSize / numMuls, "\n");
</span><ins>+ dataLog("\n");
+ dataLog("Num Subs: ", numSubs, "\n");
+ dataLog("Total Sub size in bytes: ", totalSubSize, "\n");
+ dataLog("Average Sub size: ", totalSubSize / numSubs, "\n");
</ins><span class="cx">
</span><span class="cx"> dataLog("-----------------------\n");
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.h (203978 => 203979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.h        2016-08-01 18:45:17 UTC (rev 203978)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.h        2016-08-01 18:48:14 UTC (rev 203979)
</span><span class="lines">@@ -253,6 +253,7 @@
</span><span class="cx"> StructureStubInfo* addStubInfo(AccessType);
</span><span class="cx"> JITAddIC* addJITAddIC();
</span><span class="cx"> JITMulIC* addJITMulIC();
</span><ins>+ JITSubIC* addJITSubIC();
</ins><span class="cx"> Bag<StructureStubInfo>::iterator stubInfoBegin() { return m_stubInfos.begin(); }
</span><span class="cx"> Bag<StructureStubInfo>::iterator stubInfoEnd() { return m_stubInfos.end(); }
</span><span class="cx">
</span><span class="lines">@@ -1018,6 +1019,7 @@
</span><span class="cx"> Bag<StructureStubInfo> m_stubInfos;
</span><span class="cx"> Bag<JITAddIC> m_addICs;
</span><span class="cx"> Bag<JITMulIC> m_mulICs;
</span><ins>+ Bag<JITSubIC> m_subICs;
</ins><span class="cx"> Bag<ByValInfo> m_byValInfos;
</span><span class="cx"> Bag<CallLinkInfo> m_callLinkInfos;
</span><span class="cx"> SentinelLinkedList<CallLinkInfo, BasicRawSentinelNode<CallLinkInfo>> m_incomingCalls;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (203978 => 203979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-08-01 18:45:17 UTC (rev 203978)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-08-01 18:48:14 UTC (rev 203979)
</span><span class="lines">@@ -3923,53 +3923,19 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> case UntypedUse: {
</span><del>- Edge& leftChild = node->child1();
- Edge& rightChild = node->child2();
-
- JSValueOperand left(this, leftChild);
- JSValueOperand right(this, rightChild);
-
- JSValueRegs leftRegs = left.jsValueRegs();
- JSValueRegs rightRegs = right.jsValueRegs();
-
- FPRTemporary leftNumber(this);
- FPRTemporary rightNumber(this);
- FPRReg leftFPR = leftNumber.fpr();
- FPRReg rightFPR = rightNumber.fpr();
-
</del><span class="cx"> #if USE(JSVALUE64)
</span><del>- GPRTemporary result(this);
- JSValueRegs resultRegs = JSValueRegs(result.gpr());
- GPRTemporary scratch(this);
- GPRReg scratchGPR = scratch.gpr();
- FPRReg scratchFPR = InvalidFPRReg;
</del><ins>+ bool needsScratchGPRReg = true;
+ bool needsScratchFPRReg = false;
</ins><span class="cx"> #else
</span><del>- GPRTemporary resultTag(this);
- GPRTemporary resultPayload(this);
- JSValueRegs resultRegs = JSValueRegs(resultPayload.gpr(), resultTag.gpr());
- GPRReg scratchGPR = resultTag.gpr();
- FPRTemporary fprScratch(this);
- FPRReg scratchFPR = fprScratch.fpr();
</del><ins>+ bool needsScratchGPRReg = true;
+ bool needsScratchFPRReg = true;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- SnippetOperand leftOperand(m_state.forNode(leftChild).resultType());
- SnippetOperand rightOperand(m_state.forNode(rightChild).resultType());
-
- JITSubGenerator gen(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs,
- leftFPR, rightFPR, scratchGPR, scratchFPR);
- gen.generateFastPath(m_jit);
-
- ASSERT(gen.didEmitFastPath());
- gen.endJumpList().append(m_jit.jump());
-
- gen.slowPathJumpList().link(&m_jit);
- silentSpillAllRegisters(resultRegs);
- callOperation(operationValueSub, resultRegs, leftRegs, rightRegs);
- silentFillAllRegisters(resultRegs);
- m_jit.exceptionCheck();
-
- gen.endJumpList().link(&m_jit);
- jsValueResult(resultRegs, node);
</del><ins>+ JITSubIC* subIC = m_jit.codeBlock()->addJITSubIC();
+ auto repatchingFunction = operationValueSubOptimize;
+ auto nonRepatchingFunction = operationValueSub;
+
+ compileMathIC(node, subIC, needsScratchGPRReg, needsScratchFPRReg, repatchingFunction, nonRepatchingFunction);
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (203978 => 203979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-08-01 18:45:17 UTC (rev 203978)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-08-01 18:48:14 UTC (rev 203979)
</span><span class="lines">@@ -1710,7 +1710,10 @@
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- emitBinarySnippet<JITSubGenerator>(operationValueSub);
</del><ins>+ JITSubIC* subIC = codeBlock()->addJITSubIC();
+ auto repatchingFunction = operationValueSubOptimize;
+ auto nonRepatchingFunction = operationValueSub;
+ compileMathIC(subIC, repatchingFunction, nonRepatchingFunction);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITArithmeticcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp (203978 => 203979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp        2016-08-01 18:45:17 UTC (rev 203978)
+++ trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp        2016-08-01 18:48:14 UTC (rev 203979)
</span><span class="lines">@@ -926,71 +926,16 @@
</span><span class="cx">
</span><span class="cx"> void JIT::emit_op_sub(Instruction* currentInstruction)
</span><span class="cx"> {
</span><del>- int result = currentInstruction[1].u.operand;
- int op1 = currentInstruction[2].u.operand;
- int op2 = currentInstruction[3].u.operand;
-
-#if USE(JSVALUE64)
- OperandTypes types = getOperandTypes(copiedInstruction(currentInstruction));
- JSValueRegs leftRegs = JSValueRegs(regT0);
- JSValueRegs rightRegs = JSValueRegs(regT1);
- JSValueRegs resultRegs = leftRegs;
- GPRReg scratchGPR = regT2;
- FPRReg scratchFPR = InvalidFPRReg;
-#else
- OperandTypes types = getOperandTypes(currentInstruction);
- JSValueRegs leftRegs = JSValueRegs(regT1, regT0);
- JSValueRegs rightRegs = JSValueRegs(regT3, regT2);
- JSValueRegs resultRegs = leftRegs;
- GPRReg scratchGPR = regT4;
- FPRReg scratchFPR = fpRegT2;
-#endif
-
- ArithProfile* arithProfile = nullptr;
- if (shouldEmitProfiling())
- arithProfile = &m_codeBlock->arithProfileForPC(currentInstruction);
-
- SnippetOperand leftOperand(types.first());
- SnippetOperand rightOperand(types.second());
-
- emitGetVirtualRegister(op1, leftRegs);
- emitGetVirtualRegister(op2, rightRegs);
-
- JITSubGenerator gen(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs,
- fpRegT0, fpRegT1, scratchGPR, scratchFPR, arithProfile);
-
- gen.generateFastPath(*this);
-
- ASSERT(gen.didEmitFastPath());
- gen.endJumpList().link(this);
- emitPutVirtualRegister(result, resultRegs);
-
- addSlowCase(gen.slowPathJumpList());
</del><ins>+ JITSubIC* subIC = m_codeBlock->addJITSubIC();
+ m_instructionToMathIC.add(currentInstruction, subIC);
+ emitMathICFast(subIC, currentInstruction, operationValueSubProfiled, operationValueSub);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void JIT::emitSlow_op_sub(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
</span><span class="cx"> {
</span><span class="cx"> linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
</span><del>-
- int result = currentInstruction[1].u.operand;
-#if USE(JSVALUE64)
- JSValueRegs leftRegs = JSValueRegs(regT0);
- JSValueRegs rightRegs = JSValueRegs(regT1);
- JSValueRegs resultRegs = leftRegs;
-#else
- JSValueRegs leftRegs = JSValueRegs(regT1, regT0);
- JSValueRegs rightRegs = JSValueRegs(regT3, regT2);
- JSValueRegs resultRegs = leftRegs;
-#endif
-
- if (shouldEmitProfiling()) {
- ArithProfile& arithProfile = m_codeBlock->arithProfileForPC(currentInstruction);
- callOperation(operationValueSubProfiled, resultRegs, leftRegs, rightRegs, &arithProfile);
- emitPutVirtualRegister(result, resultRegs);
- } else {
- JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_sub);
- slowPathCall.call();
- }
</del><ins>+ JITSubIC* subIC = bitwise_cast<JITSubIC*>(m_instructionToMathIC.get(currentInstruction));
+ emitMathICSlow(subIC, currentInstruction, operationValueSubProfiledOptimize, operationValueSubProfiled, operationValueSubOptimize);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void JIT::emit_op_pow(Instruction* currentInstruction)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITMathICh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITMathIC.h (203978 => 203979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITMathIC.h        2016-08-01 18:45:17 UTC (rev 203978)
+++ trunk/Source/JavaScriptCore/jit/JITMathIC.h        2016-08-01 18:48:14 UTC (rev 203979)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include "JITAddGenerator.h"
</span><span class="cx"> #include "JITMathICInlineResult.h"
</span><span class="cx"> #include "JITMulGenerator.h"
</span><ins>+#include "JITSubGenerator.h"
</ins><span class="cx"> #include "LinkBuffer.h"
</span><span class="cx"> #include "Repatch.h"
</span><span class="cx"> #include "SnippetOperand.h"
</span><span class="lines">@@ -240,6 +241,7 @@
</span><span class="cx">
</span><span class="cx"> typedef JITMathIC<JITAddGenerator> JITAddIC;
</span><span class="cx"> typedef JITMathIC<JITMulGenerator> JITMulIC;
</span><ins>+typedef JITMathIC<JITSubGenerator> JITSubIC;
</ins><span class="cx">
</span><span class="cx"> } // namespace JSC
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITMathICForwardsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITMathICForwards.h (203978 => 203979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITMathICForwards.h        2016-08-01 18:45:17 UTC (rev 203978)
+++ trunk/Source/JavaScriptCore/jit/JITMathICForwards.h        2016-08-01 18:48:14 UTC (rev 203979)
</span><span class="lines">@@ -32,9 +32,11 @@
</span><span class="cx"> template <typename Generator> class JITMathIC;
</span><span class="cx"> class JITAddGenerator;
</span><span class="cx"> class JITMulGenerator;
</span><ins>+class JITSubGenerator;
</ins><span class="cx">
</span><span class="cx"> typedef JITMathIC<JITAddGenerator> JITAddIC;
</span><span class="cx"> typedef JITMathIC<JITMulGenerator> JITMulIC;
</span><ins>+typedef JITMathIC<JITSubGenerator> JITSubIC;
</ins><span class="cx">
</span><span class="cx"> } // namespace JSC
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITOperationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITOperations.cpp (203978 => 203979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITOperations.cpp        2016-08-01 18:45:17 UTC (rev 203978)
+++ trunk/Source/JavaScriptCore/jit/JITOperations.cpp        2016-08-01 18:48:14 UTC (rev 203979)
</span><span class="lines">@@ -2447,11 +2447,8 @@
</span><span class="cx"> return profiledMul(exec, encodedOp1, encodedOp2, arithProfile);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-EncodedJSValue JIT_OPERATION operationValueSub(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2)
</del><ins>+ALWAYS_INLINE static EncodedJSValue unprofiledSub(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2)
</ins><span class="cx"> {
</span><del>- VM* vm = &exec->vm();
- NativeCallFrameTracer tracer(vm, exec);
-
</del><span class="cx"> JSValue op1 = JSValue::decode(encodedOp1);
</span><span class="cx"> JSValue op2 = JSValue::decode(encodedOp2);
</span><span class="cx">
</span><span class="lines">@@ -2460,14 +2457,14 @@
</span><span class="cx"> return JSValue::encode(jsNumber(a - b));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-EncodedJSValue JIT_OPERATION operationValueSubProfiled(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile* arithProfile)
</del><ins>+ALWAYS_INLINE static EncodedJSValue profiledSub(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile* arithProfile, bool shouldObserveLHSAndRHSTypes = true)
</ins><span class="cx"> {
</span><del>- VM* vm = &exec->vm();
- NativeCallFrameTracer tracer(vm, exec);
-
</del><span class="cx"> JSValue op1 = JSValue::decode(encodedOp1);
</span><span class="cx"> JSValue op2 = JSValue::decode(encodedOp2);
</span><span class="cx">
</span><ins>+ if (shouldObserveLHSAndRHSTypes)
+ arithProfile->observeLHSAndRHS(op1, op2);
+
</ins><span class="cx"> double a = op1.toNumber(exec);
</span><span class="cx"> double b = op2.toNumber(exec);
</span><span class="cx">
</span><span class="lines">@@ -2476,6 +2473,70 @@
</span><span class="cx"> return JSValue::encode(result);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+EncodedJSValue JIT_OPERATION operationValueSub(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2)
+{
+ VM* vm = &exec->vm();
+ NativeCallFrameTracer tracer(vm, exec);
+ return unprofiledSub(exec, encodedOp1, encodedOp2);
+}
+
+EncodedJSValue JIT_OPERATION operationValueSubProfiled(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile* arithProfile)
+{
+ VM* vm = &exec->vm();
+ NativeCallFrameTracer tracer(vm, exec);
+
+ return profiledSub(exec, encodedOp1, encodedOp2, arithProfile);
+}
+
+EncodedJSValue JIT_OPERATION operationValueSubOptimize(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, JITSubIC* subIC)
+{
+ VM* vm = &exec->vm();
+ NativeCallFrameTracer tracer(vm, exec);
+
+ auto nonOptimizeVariant = operationValueSubNoOptimize;
+ if (ArithProfile* arithProfile = subIC->m_generator.arithProfile())
+ arithProfile->observeLHSAndRHS(JSValue::decode(encodedOp1), JSValue::decode(encodedOp2));
+ subIC->generateOutOfLine(*vm, exec->codeBlock(), nonOptimizeVariant);
+
+#if ENABLE(MATH_IC_STATS)
+ exec->codeBlock()->dumpMathICStats();
+#endif
+
+ return unprofiledSub(exec, encodedOp1, encodedOp2);
+}
+
+EncodedJSValue JIT_OPERATION operationValueSubNoOptimize(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, JITSubIC*)
+{
+ VM* vm = &exec->vm();
+ NativeCallFrameTracer tracer(vm, exec);
+
+ return unprofiledSub(exec, encodedOp1, encodedOp2);
+}
+
+EncodedJSValue JIT_OPERATION operationValueSubProfiledOptimize(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile* arithProfile, JITSubIC* subIC)
+{
+ VM* vm = &exec->vm();
+ NativeCallFrameTracer tracer(vm, exec);
+
+ arithProfile->observeLHSAndRHS(JSValue::decode(encodedOp1), JSValue::decode(encodedOp2));
+ auto nonOptimizeVariant = operationValueSubProfiledNoOptimize;
+ subIC->generateOutOfLine(*vm, exec->codeBlock(), nonOptimizeVariant);
+
+#if ENABLE(MATH_IC_STATS)
+ exec->codeBlock()->dumpMathICStats();
+#endif
+
+ return profiledSub(exec, encodedOp1, encodedOp2, arithProfile, false);
+}
+
+EncodedJSValue JIT_OPERATION operationValueSubProfiledNoOptimize(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile* arithProfile, JITSubIC*)
+{
+ VM* vm = &exec->vm();
+ NativeCallFrameTracer tracer(vm, exec);
+
+ return profiledSub(exec, encodedOp1, encodedOp2, arithProfile);
+}
+
</ins><span class="cx"> void JIT_OPERATION operationProcessTypeProfilerLog(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx"> VM& vm = exec->vm();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITOperationsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITOperations.h (203978 => 203979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITOperations.h        2016-08-01 18:45:17 UTC (rev 203978)
+++ trunk/Source/JavaScriptCore/jit/JITOperations.h        2016-08-01 18:48:14 UTC (rev 203979)
</span><span class="lines">@@ -426,6 +426,10 @@
</span><span class="cx"> EncodedJSValue JIT_OPERATION operationValueMulProfiled(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile*) WTF_INTERNAL;
</span><span class="cx"> EncodedJSValue JIT_OPERATION operationValueSub(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) WTF_INTERNAL;
</span><span class="cx"> EncodedJSValue JIT_OPERATION operationValueSubProfiled(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile*) WTF_INTERNAL;
</span><ins>+EncodedJSValue JIT_OPERATION operationValueSubOptimize(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, JITSubIC*) WTF_INTERNAL;
+EncodedJSValue JIT_OPERATION operationValueSubNoOptimize(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, JITSubIC*) WTF_INTERNAL;
+EncodedJSValue JIT_OPERATION operationValueSubProfiledOptimize(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile*, JITSubIC*) WTF_INTERNAL;
+EncodedJSValue JIT_OPERATION operationValueSubProfiledNoOptimize(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile*, JITSubIC*) WTF_INTERNAL;
</ins><span class="cx">
</span><span class="cx"> void JIT_OPERATION operationProcessTypeProfilerLog(ExecState*) WTF_INTERNAL;
</span><span class="cx"> void JIT_OPERATION operationProcessShadowChickenLog(ExecState*) WTF_INTERNAL;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITSubGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITSubGenerator.cpp (203978 => 203979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITSubGenerator.cpp        2016-08-01 18:45:17 UTC (rev 203978)
+++ trunk/Source/JavaScriptCore/jit/JITSubGenerator.cpp        2016-08-01 18:48:14 UTC (rev 203979)
</span><span class="lines">@@ -27,13 +27,59 @@
</span><span class="cx"> #include "JITSubGenerator.h"
</span><span class="cx">
</span><span class="cx"> #include "ArithProfile.h"
</span><ins>+#include "JITMathIC.h"
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(JIT)
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><del>-void JITSubGenerator::generateFastPath(CCallHelpers& jit)
</del><ins>+JITMathICInlineResult JITSubGenerator::generateInline(CCallHelpers& jit, MathICGenerationState& state)
</ins><span class="cx"> {
</span><ins>+ // We default to speculating int32.
+ ObservedType lhs = ObservedType().withInt32();
+ ObservedType rhs = ObservedType().withInt32();
+ if (m_arithProfile) {
+ lhs = m_arithProfile->lhsObservedType();
+ rhs = m_arithProfile->rhsObservedType();
+ }
+
+ if (lhs.isOnlyNonNumber() && rhs.isOnlyNonNumber())
+ return JITMathICInlineResult::DontGenerate;
+
+ if (lhs.isOnlyNumber() && rhs.isOnlyNumber()) {
+ if (!jit.supportsFloatingPoint())
+ return JITMathICInlineResult::DontGenerate;
+
+ if (!m_leftOperand.definitelyIsNumber())
+ state.slowPathJumps.append(jit.branchIfNotNumber(m_left, m_scratchGPR));
+ if (!m_rightOperand.definitelyIsNumber())
+ state.slowPathJumps.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
+ state.slowPathJumps.append(jit.branchIfInt32(m_left));
+ state.slowPathJumps.append(jit.branchIfInt32(m_right));
+ jit.unboxDoubleNonDestructive(m_left, m_leftFPR, m_scratchGPR, m_scratchFPR);
+ jit.unboxDoubleNonDestructive(m_right, m_rightFPR, m_scratchGPR, m_scratchFPR);
+ jit.subDouble(m_rightFPR, m_leftFPR);
+ jit.boxDouble(m_leftFPR, m_result);
+
+ return JITMathICInlineResult::GeneratedFastPath;
+ }
+ if (lhs.isOnlyInt32() && rhs.isOnlyInt32()) {
+ ASSERT(!m_leftOperand.isConstInt32() || !m_rightOperand.isConstInt32());
+ state.slowPathJumps.append(jit.branchIfNotInt32(m_left));
+ state.slowPathJumps.append(jit.branchIfNotInt32(m_right));
+
+ jit.move(m_left.payloadGPR(), m_scratchGPR);
+ state.slowPathJumps.append(jit.branchSub32(CCallHelpers::Overflow, m_right.payloadGPR(), m_scratchGPR));
+
+ jit.boxInt32(m_scratchGPR, m_result);
+ return JITMathICInlineResult::GeneratedFastPath;
+ }
+
+ return JITMathICInlineResult::GenerateFullSnippet;
+}
+
+bool JITSubGenerator::generateFastPath(CCallHelpers& jit, CCallHelpers::JumpList& endJumpList, CCallHelpers::JumpList& slowPathJumpList, bool shouldEmitProfiling)
+{
</ins><span class="cx"> ASSERT(m_scratchGPR != InvalidGPRReg);
</span><span class="cx"> ASSERT(m_scratchGPR != m_left.payloadGPR());
</span><span class="cx"> ASSERT(m_scratchGPR != m_right.payloadGPR());
</span><span class="lines">@@ -43,29 +89,27 @@
</span><span class="cx"> ASSERT(m_scratchFPR != InvalidFPRReg);
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- m_didEmitFastPath = true;
-
</del><span class="cx"> CCallHelpers::Jump leftNotInt = jit.branchIfNotInt32(m_left);
</span><span class="cx"> CCallHelpers::Jump rightNotInt = jit.branchIfNotInt32(m_right);
</span><span class="cx">
</span><span class="cx"> jit.move(m_left.payloadGPR(), m_scratchGPR);
</span><del>- m_slowPathJumpList.append(jit.branchSub32(CCallHelpers::Overflow, m_right.payloadGPR(), m_scratchGPR));
</del><ins>+ slowPathJumpList.append(jit.branchSub32(CCallHelpers::Overflow, m_right.payloadGPR(), m_scratchGPR));
</ins><span class="cx">
</span><span class="cx"> jit.boxInt32(m_scratchGPR, m_result);
</span><span class="cx">
</span><del>- m_endJumpList.append(jit.jump());
</del><ins>+ endJumpList.append(jit.jump());
</ins><span class="cx">
</span><span class="cx"> if (!jit.supportsFloatingPoint()) {
</span><del>- m_slowPathJumpList.append(leftNotInt);
- m_slowPathJumpList.append(rightNotInt);
- return;
</del><ins>+ slowPathJumpList.append(leftNotInt);
+ slowPathJumpList.append(rightNotInt);
+ return true;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> leftNotInt.link(&jit);
</span><span class="cx"> if (!m_leftOperand.definitelyIsNumber())
</span><del>- m_slowPathJumpList.append(jit.branchIfNotNumber(m_left, m_scratchGPR));
</del><ins>+ slowPathJumpList.append(jit.branchIfNotNumber(m_left, m_scratchGPR));
</ins><span class="cx"> if (!m_rightOperand.definitelyIsNumber())
</span><del>- m_slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
</del><ins>+ slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
</ins><span class="cx">
</span><span class="cx"> jit.unboxDoubleNonDestructive(m_left, m_leftFPR, m_scratchGPR, m_scratchFPR);
</span><span class="cx"> CCallHelpers::Jump rightIsDouble = jit.branchIfNotInt32(m_right);
</span><span class="lines">@@ -75,7 +119,7 @@
</span><span class="cx">
</span><span class="cx"> rightNotInt.link(&jit);
</span><span class="cx"> if (!m_rightOperand.definitelyIsNumber())
</span><del>- m_slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
</del><ins>+ slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
</ins><span class="cx">
</span><span class="cx"> jit.convertInt32ToDouble(m_left.payloadGPR(), m_leftFPR);
</span><span class="cx">
</span><span class="lines">@@ -85,10 +129,12 @@
</span><span class="cx"> rightWasInteger.link(&jit);
</span><span class="cx">
</span><span class="cx"> jit.subDouble(m_rightFPR, m_leftFPR);
</span><del>- if (m_arithProfile)
</del><ins>+ if (m_arithProfile && shouldEmitProfiling)
</ins><span class="cx"> m_arithProfile->emitSetDouble(jit);
</span><span class="cx">
</span><span class="cx"> jit.boxDouble(m_leftFPR, m_result);
</span><ins>+
+ return true;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITSubGeneratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITSubGenerator.h (203978 => 203979)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITSubGenerator.h        2016-08-01 18:45:17 UTC (rev 203978)
+++ trunk/Source/JavaScriptCore/jit/JITSubGenerator.h        2016-08-01 18:48:14 UTC (rev 203979)
</span><span class="lines">@@ -29,12 +29,17 @@
</span><span class="cx"> #if ENABLE(JIT)
</span><span class="cx">
</span><span class="cx"> #include "CCallHelpers.h"
</span><ins>+#include "JITMathICInlineResult.h"
</ins><span class="cx"> #include "SnippetOperand.h"
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><ins>+struct MathICGenerationState;
+
</ins><span class="cx"> class JITSubGenerator {
</span><span class="cx"> public:
</span><ins>+ JITSubGenerator() { }
+
</ins><span class="cx"> JITSubGenerator(SnippetOperand leftOperand, SnippetOperand rightOperand,
</span><span class="cx"> JSValueRegs result, JSValueRegs left, JSValueRegs right,
</span><span class="cx"> FPRReg leftFPR, FPRReg rightFPR, GPRReg scratchGPR, FPRReg scratchFPR,
</span><span class="lines">@@ -51,11 +56,12 @@
</span><span class="cx"> , m_arithProfile(arithProfile)
</span><span class="cx"> { }
</span><span class="cx">
</span><del>- void generateFastPath(CCallHelpers&);
</del><ins>+ JITMathICInlineResult generateInline(CCallHelpers&, MathICGenerationState&);
+ bool generateFastPath(CCallHelpers&, CCallHelpers::JumpList& endJumpList, CCallHelpers::JumpList& slowPathJumpList, bool shouldEmitProfiling);
</ins><span class="cx">
</span><del>- bool didEmitFastPath() const { return m_didEmitFastPath; }
- CCallHelpers::JumpList& endJumpList() { return m_endJumpList; }
- CCallHelpers::JumpList& slowPathJumpList() { return m_slowPathJumpList; }
</del><ins>+ bool isLeftOperandValidConstant() const { return false; }
+ bool isRightOperandValidConstant() const { return false; }
+ ArithProfile* arithProfile() const { return m_arithProfile; }
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> SnippetOperand m_leftOperand;
</span><span class="lines">@@ -68,10 +74,6 @@
</span><span class="cx"> GPRReg m_scratchGPR;
</span><span class="cx"> FPRReg m_scratchFPR;
</span><span class="cx"> ArithProfile* m_arithProfile;
</span><del>- bool m_didEmitFastPath { false };
-
- CCallHelpers::JumpList m_endJumpList;
- CCallHelpers::JumpList m_slowPathJumpList;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre>
</div>
</div>
</body>
</html>