<!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>[206289] 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/206289">206289</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-09-22 20:50:22 -0700 (Thu, 22 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[JSC] Use an inline cache to generate op_negate
https://bugs.webkit.org/show_bug.cgi?id=162371
Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-09-22
Reviewed by Saam Barati.
JSTests:
* stress/op-negate-inline-cache.js: Added.
Source/JavaScriptCore:
Use an inline cache to reduce the amount of code
required to implement op_negate.
For pure integer negate, the generated asm shrinks
from 147 bytes to 125 bytes (14%).
For double negate, the generated asm shrinks
to 130 bytes (11%).
The average size on Sunspider is 100bytes, this is due
to the op_negates that are never executed and do not
generate much.
* bytecode/ArithProfile.h:
(JSC::ArithProfile::ArithProfile):
(JSC::ArithProfile::observeLHS):
(JSC::ArithProfile::observeLHSAndRHS):
* bytecode/BytecodeList.json:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::addJITNegIC):
* bytecode/CodeBlock.h:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitUnaryOp):
* bytecompiler/BytecodeGenerator.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::UnaryOpNode::emitBytecode):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileMathIC):
* dfg/DFGSpeculativeJIT.h:
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileMathIC):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupArgumentsWithExecState):
* jit/JIT.h:
* jit/JITArithmetic.cpp:
(JSC::JIT::emit_op_negate):
(JSC::JIT::emitSlow_op_negate):
(JSC::JIT::emitMathICFast):
(JSC::JIT::emitMathICSlow):
* jit/JITInlines.h:
(JSC::JIT::callOperation):
* jit/JITMathIC.h:
(JSC::JITMathIC::generateInline):
(JSC::canGenerateWithBinaryProfile):
(JSC::canGenerateWithUnaryProfile):
* jit/JITMathICForwards.h:
* jit/JITNegGenerator.cpp:
(JSC::JITNegGenerator::generateInline):
(JSC::JITNegGenerator::generateFastPath):
* jit/JITNegGenerator.h:
(JSC::JITNegGenerator::JITNegGenerator):
(JSC::JITNegGenerator::arithProfile):
(JSC::JITNegGenerator::didEmitFastPath): Deleted.
(JSC::JITNegGenerator::endJumpList): Deleted.
(JSC::JITNegGenerator::slowPathJumpList): Deleted.
* jit/JITOperations.cpp:
* jit/JITOperations.h:
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:
* runtime/CommonSlowPaths.cpp:
(JSC::updateArithProfileForUnaryArithOp):
(JSC::SLOW_PATH_DECL):</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="#trunkSourceJavaScriptCorebytecodeArithProfileh">trunk/Source/JavaScriptCore/bytecode/ArithProfile.h</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeBytecodeListjson">trunk/Source/JavaScriptCore/bytecode/BytecodeList.json</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="#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="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITh">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitCCallHelpersh">trunk/Source/JavaScriptCore/jit/CCallHelpers.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITh">trunk/Source/JavaScriptCore/jit/JIT.h</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITArithmeticcpp">trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITInlinesh">trunk/Source/JavaScriptCore/jit/JITInlines.h</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="#trunkSourceJavaScriptCorejitJITNegGeneratorcpp">trunk/Source/JavaScriptCore/jit/JITNegGenerator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITNegGeneratorh">trunk/Source/JavaScriptCore/jit/JITNegGenerator.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="#trunkSourceJavaScriptCorellintLowLevelInterpreterasm">trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm</a></li>
<li><a href="#trunkSourceJavaScriptCorellintLowLevelInterpreter32_64asm">trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm</a></li>
<li><a href="#trunkSourceJavaScriptCorellintLowLevelInterpreter64asm">trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonSlowPathscpp">trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkJSTestsstressopnegateinlinecachejs">trunk/JSTests/stress/op-negate-inline-cache.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/JSTests/ChangeLog        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2016-09-22 Benjamin Poulain <bpoulain@apple.com>
+
+ [JSC] Use an inline cache to generate op_negate
+ https://bugs.webkit.org/show_bug.cgi?id=162371
+
+ Reviewed by Saam Barati.
+
+ * stress/op-negate-inline-cache.js: Added.
+
</ins><span class="cx"> 2016-09-22 Mark Lam <mark.lam@apple.com>
</span><span class="cx">
</span><span class="cx"> Array.prototype.join should do overflow checks on string joins.
</span></span></pre></div>
<a id="trunkJSTestsstressopnegateinlinecachejs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/stress/op-negate-inline-cache.js (0 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/op-negate-inline-cache.js         (rev 0)
+++ trunk/JSTests/stress/op-negate-inline-cache.js        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -0,0 +1,300 @@
</span><ins>+"use strict"
+
+
+function opaqueIdentity(arg) {
+ return arg;
+}
+noInline(opaqueIdentity)
+function negateWithDoubleSub(arg) {
+ // Implement integer negate as a double sub operation.
+ return opaqueIdentity(6.4 - arg) - 6.4;
+}
+noInline(negateWithDoubleSub)
+
+function opaqueNonZeroIntegerNegate(arg)
+{
+ return -arg;
+}
+noInline(opaqueNonZeroIntegerNegate);
+
+function testNonZeroInteger()
+{
+ for (let i = 1; i < 1e4; ++i) {
+ if (opaqueNonZeroIntegerNegate(i) !== negateWithDoubleSub(i)) {
+ throw "Failed testNonZeroInteger() at i = " + i;
+ }
+ }
+}
+testNonZeroInteger();
+
+
+function opaqueDoubleNegate(arg)
+{
+ return -arg;
+}
+noInline(opaqueDoubleNegate);
+
+function testDouble()
+{
+ for (let i = 0; i < 1e4; ++i) {
+ if ((opaqueDoubleNegate(i + 0.5)) + 0.5 + i !== 0) {
+ throw "Failed testDouble() at i = " + i;
+ }
+ }
+}
+testDouble();
+
+
+function opaqueObjectNegate(arg)
+{
+ return -arg;
+}
+noInline(opaqueObjectNegate);
+
+function testObject()
+{
+ for (let i = 0; i < 1e4; ++i) {
+ if ((opaqueObjectNegate({ valueOf: ()=>{ return i + 0.5 }})) + 0.5 + i !== 0) {
+ throw "Failed testObject() at i = " + i;
+ }
+ }
+}
+testObject();
+
+
+function opaqueIntegerAndDoubleNegate(arg)
+{
+ return -arg;
+}
+noInline(opaqueIntegerAndDoubleNegate);
+
+function testIntegerAndDouble()
+{
+ for (let i = 1; i < 1e4; ++i) {
+ if ((opaqueIntegerAndDoubleNegate(i)) + i !== 0) {
+ throw "Failed testIntegerAndDouble() on integers at i = " + i;
+ }
+ if ((opaqueIntegerAndDoubleNegate(i + 0.5)) + 0.5 + i !== 0) {
+ throw "Failed testIntegerAndDouble() on double at i = " + i;
+ }
+ }
+}
+testIntegerAndDouble();
+
+
+function opaqueIntegerThenDoubleNegate(arg)
+{
+ return -arg;
+}
+noInline(opaqueIntegerThenDoubleNegate);
+
+function testIntegerThenDouble()
+{
+ for (let i = 1; i < 1e4; ++i) {
+ if ((opaqueIntegerThenDoubleNegate(i)) + i !== 0) {
+ throw "Failed testIntegerThenDouble() on integers at i = " + i;
+ }
+ }
+ for (let i = 1; i < 1e4; ++i) {
+ if ((opaqueIntegerThenDoubleNegate(i + 0.5)) + 0.5 + i !== 0) {
+ throw "Failed testIntegerThenDouble() on double at i = " + i;
+ }
+ }
+}
+testIntegerThenDouble();
+
+
+function opaqueDoubleThenIntegerNegate(arg)
+{
+ return -arg;
+}
+noInline(opaqueDoubleThenIntegerNegate);
+
+function testDoubleThenInteger()
+{
+ for (let i = 1; i < 1e4; ++i) {
+ if ((opaqueDoubleThenIntegerNegate(i + 0.5)) + 0.5 + i !== 0) {
+ throw "Failed testDoubleThenInteger() on double at i = " + i;
+ }
+ }
+ for (let i = 1; i < 1e4; ++i) {
+ if ((opaqueDoubleThenIntegerNegate(i)) + i !== 0) {
+ throw "Failed testDoubleThenInteger() on integers at i = " + i;
+ }
+ }
+}
+testDoubleThenInteger();
+
+
+function opaqueIntegerAndObjectNegate(arg)
+{
+ return -arg;
+}
+noInline(opaqueIntegerAndObjectNegate);
+
+function testIntegerAndObject()
+{
+ for (let i = 1; i < 1e4; ++i) {
+ if ((opaqueIntegerAndObjectNegate(i)) + i !== 0) {
+ throw "Failed testIntegerAndObject() on integers at i = " + i;
+ }
+ if ((opaqueIntegerAndObjectNegate({ valueOf: ()=>{ return i + 0.5 }})) + 0.5 + i !== 0) {
+ throw "Failed testIntegerAndObject() on double at i = " + i;
+ }
+ }
+}
+testIntegerAndObject();
+
+
+function opaqueDoubleAndObjectNegate(arg)
+{
+ return -arg;
+}
+noInline(opaqueDoubleAndObjectNegate);
+
+function testDoubleAndObject()
+{
+ for (let i = 1; i < 1e4; ++i) {
+ if ((opaqueDoubleAndObjectNegate(i + 0.5)) + i + 0.5 !== 0) {
+ throw "Failed testDoubleAndObject() on integers at i = " + i;
+ }
+ if ((opaqueDoubleAndObjectNegate({ valueOf: ()=>{ return i }})) + i !== 0) {
+ throw "Failed testDoubleAndObject() on double at i = " + i;
+ }
+ }
+}
+testDoubleAndObject();
+
+
+function opaqueIntegerThenObjectNegate(arg)
+{
+ return -arg;
+}
+noInline(opaqueIntegerThenObjectNegate);
+
+function testIntegerThenObject()
+{
+ for (let i = 1; i < 1e4; ++i) {
+ if ((opaqueIntegerThenObjectNegate(i)) + i !== 0) {
+ throw "Failed testIntegerThenObject() on integers at i = " + i;
+ }
+ }
+ for (let i = 1; i < 1e4; ++i) {
+ if ((opaqueIntegerThenObjectNegate({ valueOf: ()=>{ return i + 0.5 }})) + 0.5 + i !== 0) {
+ throw "Failed testIntegerThenObject() on double at i = " + i;
+ }
+ }
+}
+testIntegerThenObject();
+
+
+function opaqueDoubleThenObjectNegate(arg)
+{
+ return -arg;
+}
+noInline(opaqueDoubleThenObjectNegate);
+
+function testDoubleThenObject()
+{
+ for (let i = 1; i < 1e4; ++i) {
+ if ((opaqueDoubleThenObjectNegate(i + 0.5)) + i + 0.5 !== 0) {
+ throw "Failed testDoubleThenObject() on integers at i = " + i;
+ }
+ }
+ for (let i = 1; i < 1e4; ++i) {
+ if ((opaqueDoubleThenObjectNegate(i + 0.5)) + i + 0.5 !== 0) {
+ throw "Failed testDoubleThenObject() on integers at i = " + i;
+ }
+ }
+}
+testDoubleThenObject();
+
+
+function opaqueIntegerAndDoubleAndObjectNegate(arg)
+{
+ return -arg;
+}
+noInline(opaqueIntegerAndDoubleAndObjectNegate);
+
+function testIntegerAndDoubleAndObject()
+{
+ for (let i = 1; i < 1e4; ++i) {
+ if ((opaqueIntegerAndDoubleAndObjectNegate(i)) + i !== 0) {
+ throw "Failed testIntegerAndDoubleAndObject() on integers at i = " + i;
+ }
+ if ((opaqueIntegerAndDoubleAndObjectNegate(i + 0.5)) + i + 0.5 !== 0) {
+ throw "Failed testIntegerAndDoubleAndObject() on integers at i = " + i;
+ }
+ if ((opaqueIntegerAndDoubleAndObjectNegate({ valueOf: ()=>{ return i }})) + i !== 0) {
+ throw "Failed testIntegerAndDoubleAndObject() on double at i = " + i;
+ }
+ }
+}
+testIntegerAndDoubleAndObject();
+
+
+function opaqueIntegerNegateOverflow(arg)
+{
+ return -arg;
+}
+noInline(opaqueIntegerNegateOverflow);
+
+function testIntegerNegateOverflow()
+{
+ for (let i = 1; i < 1e4; ++i) {
+ if (opaqueIntegerNegateOverflow(0x80000000|0) !== 2147483648) {
+ throw "Failed opaqueIntegerNegateOverflow() at i = " + i;
+ }
+ }
+}
+testIntegerNegateOverflow();
+
+
+function opaqueIntegerNegateZero(arg)
+{
+ return -arg;
+}
+noInline(opaqueIntegerNegateZero);
+
+function testIntegerNegateZero()
+{
+ for (let i = 1; i < 1e4; ++i) {
+ if (1 / opaqueIntegerNegateZero(0) !== -Infinity) {
+ throw "Failed testIntegerNegateZero() at i = " + i;
+ }
+ }
+}
+testIntegerNegateZero();
+
+
+function gatedNegate(selector, arg)
+{
+ if (selector === 0) {
+ return -arg;
+ }
+ if (selector == 42) {
+ return -arg;
+ }
+ return arg;
+}
+noInline(gatedNegate);
+
+function testUnusedNegate()
+{
+ for (let i = 1; i < 1e2; ++i) {
+ if (gatedNegate(Math.PI, i) !== i) {
+ throw "Failed first phase of testUnusedNegate";
+ }
+ }
+ for (let i = 1; i < 1e4; ++i) {
+ if (gatedNegate(0, i) + i !== 0) {
+ throw "Failed second phase of testUnusedNegate";
+ }
+ }
+ for (let i = 1; i < 1e4; ++i) {
+ if (gatedNegate(42, i + 0.5) + 0.5 + i !== 0) {
+ throw "Failed third phase of testUnusedNegate";
+ }
+ }
+}
+testUnusedNegate();
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -1,3 +1,72 @@
</span><ins>+2016-09-22 Benjamin Poulain <bpoulain@apple.com>
+
+ [JSC] Use an inline cache to generate op_negate
+ https://bugs.webkit.org/show_bug.cgi?id=162371
+
+ Reviewed by Saam Barati.
+
+ Use an inline cache to reduce the amount of code
+ required to implement op_negate.
+
+ For pure integer negate, the generated asm shrinks
+ from 147 bytes to 125 bytes (14%).
+ For double negate, the generated asm shrinks
+ to 130 bytes (11%).
+ The average size on Sunspider is 100bytes, this is due
+ to the op_negates that are never executed and do not
+ generate much.
+
+ * bytecode/ArithProfile.h:
+ (JSC::ArithProfile::ArithProfile):
+ (JSC::ArithProfile::observeLHS):
+ (JSC::ArithProfile::observeLHSAndRHS):
+ * bytecode/BytecodeList.json:
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::addJITNegIC):
+ * bytecode/CodeBlock.h:
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::emitUnaryOp):
+ * bytecompiler/BytecodeGenerator.h:
+ * bytecompiler/NodesCodegen.cpp:
+ (JSC::UnaryOpNode::emitBytecode):
+ * dfg/DFGSpeculativeJIT.cpp:
+ (JSC::DFG::SpeculativeJIT::compileMathIC):
+ * dfg/DFGSpeculativeJIT.h:
+ * ftl/FTLLowerDFGToB3.cpp:
+ (JSC::FTL::DFG::LowerDFGToB3::compileMathIC):
+ * jit/CCallHelpers.h:
+ (JSC::CCallHelpers::setupArgumentsWithExecState):
+ * jit/JIT.h:
+ * jit/JITArithmetic.cpp:
+ (JSC::JIT::emit_op_negate):
+ (JSC::JIT::emitSlow_op_negate):
+ (JSC::JIT::emitMathICFast):
+ (JSC::JIT::emitMathICSlow):
+ * jit/JITInlines.h:
+ (JSC::JIT::callOperation):
+ * jit/JITMathIC.h:
+ (JSC::JITMathIC::generateInline):
+ (JSC::canGenerateWithBinaryProfile):
+ (JSC::canGenerateWithUnaryProfile):
+ * jit/JITMathICForwards.h:
+ * jit/JITNegGenerator.cpp:
+ (JSC::JITNegGenerator::generateInline):
+ (JSC::JITNegGenerator::generateFastPath):
+ * jit/JITNegGenerator.h:
+ (JSC::JITNegGenerator::JITNegGenerator):
+ (JSC::JITNegGenerator::arithProfile):
+ (JSC::JITNegGenerator::didEmitFastPath): Deleted.
+ (JSC::JITNegGenerator::endJumpList): Deleted.
+ (JSC::JITNegGenerator::slowPathJumpList): Deleted.
+ * jit/JITOperations.cpp:
+ * jit/JITOperations.h:
+ * llint/LowLevelInterpreter.asm:
+ * llint/LowLevelInterpreter32_64.asm:
+ * llint/LowLevelInterpreter64.asm:
+ * runtime/CommonSlowPaths.cpp:
+ (JSC::updateArithProfileForUnaryArithOp):
+ (JSC::SLOW_PATH_DECL):
+
</ins><span class="cx"> 2016-09-22 Mark Lam <mark.lam@apple.com>
</span><span class="cx">
</span><span class="cx"> Removed unused hasErrorInfo().
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeArithProfileh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/ArithProfile.h (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/ArithProfile.h        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/bytecode/ArithProfile.h        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -87,6 +87,14 @@
</span><span class="cx"> static_assert(specialFastPathBit & clearLhsObservedTypeBitMask, "These bits should intersect.");
</span><span class="cx"> static_assert(specialFastPathBit > ~clearLhsObservedTypeBitMask, "These bits should not intersect and specialFastPathBit should be a higher bit.");
</span><span class="cx">
</span><ins>+ ArithProfile(ResultType arg)
+ {
+ m_bits = (arg.bits() << lhsResultTypeShift);
+ ASSERT(lhsResultType().bits() == arg.bits());
+ ASSERT(lhsObservedType().isEmpty());
+ ASSERT(rhsObservedType().isEmpty());
+ }
+
</ins><span class="cx"> ArithProfile(ResultType lhs, ResultType rhs)
</span><span class="cx"> {
</span><span class="cx"> m_bits = (lhs.bits() << lhsResultTypeShift) | (rhs.bits() << rhsResultTypeShift);
</span><span class="lines">@@ -94,7 +102,7 @@
</span><span class="cx"> ASSERT(lhsObservedType().isEmpty());
</span><span class="cx"> ASSERT(rhsObservedType().isEmpty());
</span><span class="cx"> }
</span><del>- ArithProfile() { }
</del><ins>+ ArithProfile() = default;
</ins><span class="cx">
</span><span class="cx"> static ArithProfile fromInt(uint32_t bits)
</span><span class="cx"> {
</span><span class="lines">@@ -170,7 +178,7 @@
</span><span class="cx"> void rhsSawNumber() { setRhsObservedType(rhsObservedType().withNumber()); }
</span><span class="cx"> void rhsSawNonNumber() { setRhsObservedType(rhsObservedType().withNonNumber()); }
</span><span class="cx">
</span><del>- void observeLHSAndRHS(JSValue lhs, JSValue rhs)
</del><ins>+ void observeLHS(JSValue lhs)
</ins><span class="cx"> {
</span><span class="cx"> ArithProfile newProfile = *this;
</span><span class="cx"> if (lhs.isNumber()) {
</span><span class="lines">@@ -181,6 +189,14 @@
</span><span class="cx"> } else
</span><span class="cx"> newProfile.lhsSawNonNumber();
</span><span class="cx">
</span><ins>+ m_bits = newProfile.bits();
+ }
+
+ void observeLHSAndRHS(JSValue lhs, JSValue rhs)
+ {
+ observeLHS(lhs);
+
+ ArithProfile newProfile = *this;
</ins><span class="cx"> if (rhs.isNumber()) {
</span><span class="cx"> if (rhs.isInt32())
</span><span class="cx"> newProfile.rhsSawInt32();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeBytecodeListjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/BytecodeList.json (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/BytecodeList.json        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/bytecode/BytecodeList.json        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx"> { "name" : "op_dec", "length" : 2 },
</span><span class="cx"> { "name" : "op_to_number", "length" : 4 },
</span><span class="cx"> { "name" : "op_to_string", "length" : 3 },
</span><del>- { "name" : "op_negate", "length" : 3 },
</del><ins>+ { "name" : "op_negate", "length" : 4 },
</ins><span class="cx"> { "name" : "op_add", "length" : 5 },
</span><span class="cx"> { "name" : "op_mul", "length" : 5 },
</span><span class="cx"> { "name" : "op_div", "length" : 5 },
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -3015,6 +3015,11 @@
</span><span class="cx"> return m_subICs.add();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+JITNegIC* CodeBlock::addJITNegIC()
+{
+ return m_negICs.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">@@ -4354,8 +4359,15 @@
</span><span class="cx">
</span><span class="cx"> ArithProfile* CodeBlock::arithProfileForBytecodeOffset(int bytecodeOffset)
</span><span class="cx"> {
</span><del>- auto opcodeID = vm()->interpreter->getOpcodeID(instructions()[bytecodeOffset].u.opcode);
</del><ins>+ return arithProfileForPC(instructions().begin() + bytecodeOffset);
+}
+
+ArithProfile* CodeBlock::arithProfileForPC(Instruction* pc)
+{
+ auto opcodeID = vm()->interpreter->getOpcodeID(pc[0].u.opcode);
</ins><span class="cx"> switch (opcodeID) {
</span><ins>+ case op_negate:
+ return bitwise_cast<ArithProfile*>(&pc[3].u.operand);
</ins><span class="cx"> case op_bitor:
</span><span class="cx"> case op_bitand:
</span><span class="cx"> case op_bitxor:
</span><span class="lines">@@ -4363,36 +4375,14 @@
</span><span class="cx"> case op_mul:
</span><span class="cx"> case op_sub:
</span><span class="cx"> case op_div:
</span><ins>+ return bitwise_cast<ArithProfile*>(&pc[4].u.operand);
+ default:
</ins><span class="cx"> break;
</span><del>- default:
- return nullptr;
</del><span class="cx"> }
</span><span class="cx">
</span><del>- return &arithProfileForPC(instructions().begin() + bytecodeOffset);
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-ArithProfile& CodeBlock::arithProfileForPC(Instruction* pc)
-{
- if (!ASSERT_DISABLED) {
- ASSERT(pc >= instructions().begin() && pc < instructions().end());
- auto opcodeID = vm()->interpreter->getOpcodeID(pc[0].u.opcode);
- switch (opcodeID) {
- case op_bitor:
- case op_bitand:
- case op_bitxor:
- case op_add:
- case op_mul:
- case op_sub:
- case op_div:
- break;
- default:
- ASSERT_NOT_REACHED();
- }
- }
-
- return *bitwise_cast<ArithProfile*>(&pc[4].u.operand);
-}
-
</del><span class="cx"> bool CodeBlock::couldTakeSpecialFastCase(int bytecodeOffset)
</span><span class="cx"> {
</span><span class="cx"> if (!hasBaselineJITProfiling())
</span><span class="lines">@@ -4562,6 +4552,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 numNegs = 0.0;
+ double totalNegSize = 0.0;
</ins><span class="cx"> double numSubs = 0.0;
</span><span class="cx"> double totalSubSize = 0.0;
</span><span class="cx">
</span><span class="lines">@@ -4576,6 +4568,11 @@
</span><span class="cx"> totalMulSize += mulIC->codeSize();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ for (JITNegIC* negIC : codeBlock->m_negICs) {
+ numNegs++;
+ totalNegSize += negIC->codeSize();
+ }
+
</ins><span class="cx"> for (JITSubIC* subIC : codeBlock->m_subICs) {
</span><span class="cx"> numSubs++;
</span><span class="cx"> totalSubSize += subIC->codeSize();
</span><span class="lines">@@ -4593,6 +4590,10 @@
</span><span class="cx"> dataLog("Total Mul size in bytes: ", totalMulSize, "\n");
</span><span class="cx"> dataLog("Average Mul size: ", totalMulSize / numMuls, "\n");
</span><span class="cx"> dataLog("\n");
</span><ins>+ dataLog("Num Negs: ", numNegs, "\n");
+ dataLog("Total Neg size in bytes: ", totalNegSize, "\n");
+ dataLog("Average Neg size: ", totalNegSize / numNegs, "\n");
+ dataLog("\n");
</ins><span class="cx"> dataLog("Num Subs: ", numSubs, "\n");
</span><span class="cx"> dataLog("Total Sub size in bytes: ", totalSubSize, "\n");
</span><span class="cx"> dataLog("Average Sub size: ", totalSubSize / numSubs, "\n");
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.h (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.h        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.h        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -245,6 +245,7 @@
</span><span class="cx"> StructureStubInfo* addStubInfo(AccessType);
</span><span class="cx"> JITAddIC* addJITAddIC();
</span><span class="cx"> JITMulIC* addJITMulIC();
</span><ins>+ JITNegIC* addJITNegIC();
</ins><span class="cx"> JITSubIC* addJITSubIC();
</span><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="lines">@@ -447,7 +448,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ArithProfile* arithProfileForBytecodeOffset(int bytecodeOffset);
</span><del>- ArithProfile& arithProfileForPC(Instruction*);
</del><ins>+ ArithProfile* arithProfileForPC(Instruction*);
</ins><span class="cx">
</span><span class="cx"> bool couldTakeSpecialFastCase(int bytecodeOffset);
</span><span class="cx">
</span><span class="lines">@@ -997,6 +998,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<JITNegIC> m_negICs;
</ins><span class="cx"> Bag<JITSubIC> m_subICs;
</span><span class="cx"> Bag<ByValInfo> m_byValInfos;
</span><span class="cx"> Bag<CallLinkInfo> m_callLinkInfos;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -1579,13 +1579,27 @@
</span><span class="cx">
</span><span class="cx"> RegisterID* BytecodeGenerator::emitUnaryOp(OpcodeID opcodeID, RegisterID* dst, RegisterID* src)
</span><span class="cx"> {
</span><del>- ASSERT_WITH_MESSAGE(op_to_number != opcodeID, "op_to_number is profiled.");
</del><ins>+ ASSERT_WITH_MESSAGE(op_to_number != opcodeID, "op_to_number has a Value Profile.");
+ ASSERT_WITH_MESSAGE(op_negate != opcodeID, "op_negate has an Arith Profile.");
</ins><span class="cx"> emitOpcode(opcodeID);
</span><span class="cx"> instructions().append(dst->index());
</span><span class="cx"> instructions().append(src->index());
</span><ins>+
</ins><span class="cx"> return dst;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+RegisterID* BytecodeGenerator::emitUnaryOp(OpcodeID opcodeID, RegisterID* dst, RegisterID* src, OperandTypes types)
+{
+ ASSERT_WITH_MESSAGE(op_to_number != opcodeID, "op_to_number has a Value Profile.");
+ emitOpcode(opcodeID);
+ instructions().append(dst->index());
+ instructions().append(src->index());
+
+ if (opcodeID == op_negate)
+ instructions().append(ArithProfile(types.first()).bits());
+ return dst;
+}
+
</ins><span class="cx"> RegisterID* BytecodeGenerator::emitUnaryOpProfiled(OpcodeID opcodeID, RegisterID* dst, RegisterID* src)
</span><span class="cx"> {
</span><span class="cx"> UnlinkedValueProfile profile = emitProfiledOpcode(opcodeID);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -511,6 +511,7 @@
</span><span class="cx"> RegisterID* emitLoadGlobalObject(RegisterID* dst);
</span><span class="cx">
</span><span class="cx"> RegisterID* emitUnaryOp(OpcodeID, RegisterID* dst, RegisterID* src);
</span><ins>+ RegisterID* emitUnaryOp(OpcodeID, RegisterID* dst, RegisterID* src, OperandTypes);
</ins><span class="cx"> RegisterID* emitUnaryOpProfiled(OpcodeID, RegisterID* dst, RegisterID* src);
</span><span class="cx"> RegisterID* emitBinaryOp(OpcodeID, RegisterID* dst, RegisterID* src1, RegisterID* src2, OperandTypes);
</span><span class="cx"> RegisterID* emitEqualityOp(OpcodeID, RegisterID* dst, RegisterID* src1, RegisterID* src2);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerNodesCodegencpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -1606,7 +1606,7 @@
</span><span class="cx"> {
</span><span class="cx"> RefPtr<RegisterID> src = generator.emitNode(m_expr);
</span><span class="cx"> generator.emitExpressionInfo(position(), position(), position());
</span><del>- return generator.emitUnaryOp(opcodeID(), generator.finalDestination(dst), src.get());
</del><ins>+ return generator.emitUnaryOp(opcodeID(), generator.finalDestination(dst), src.get(), OperandTypes(m_expr->resultDescriptor()));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ------------------------------ UnaryPlusNode -----------------------------------
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -3432,7 +3432,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename Generator, typename RepatchingFunction, typename NonRepatchingFunction>
</span><del>-void SpeculativeJIT::compileMathIC(Node* node, JITMathIC<Generator>* mathIC, bool needsScratchGPRReg, bool needsScratchFPRReg, RepatchingFunction repatchingFunction, NonRepatchingFunction nonRepatchingFunction)
</del><ins>+void SpeculativeJIT::compileMathIC(Node* node, JITBinaryMathIC<Generator>* mathIC, bool needsScratchGPRReg, bool needsScratchFPRReg, RepatchingFunction repatchingFunction, NonRepatchingFunction nonRepatchingFunction)
</ins><span class="cx"> {
</span><span class="cx"> Edge& leftChild = node->child1();
</span><span class="cx"> Edge& rightChild = node->child2();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -2515,7 +2515,7 @@
</span><span class="cx"> void compileShiftOp(Node*);
</span><span class="cx">
</span><span class="cx"> template <typename Generator, typename RepatchingFunction, typename NonRepatchingFunction>
</span><del>- void compileMathIC(Node*, JITMathIC<Generator>*, bool needsScratchGPRReg, bool needsScratchFPRReg, RepatchingFunction, NonRepatchingFunction);
</del><ins>+ void compileMathIC(Node*, JITBinaryMathIC<Generator>*, bool needsScratchGPRReg, bool needsScratchFPRReg, RepatchingFunction, NonRepatchingFunction);
</ins><span class="cx">
</span><span class="cx"> void compileArithDoubleUnaryOp(Node*, double (*doubleFunction)(double), double (*operation)(ExecState*, EncodedJSValue));
</span><span class="cx"> void compileValueAdd(Node*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -1560,7 +1560,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename Generator>
</span><del>- void compileMathIC(JITMathIC<Generator>* mathIC, FunctionPtr repatchingFunction, FunctionPtr nonRepatchingFunction)
</del><ins>+ void compileMathIC(JITBinaryMathIC<Generator>* mathIC, FunctionPtr repatchingFunction, FunctionPtr nonRepatchingFunction)
</ins><span class="cx"> {
</span><span class="cx"> Node* node = m_node;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitCCallHelpersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/CCallHelpers.h (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/CCallHelpers.h        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/jit/CCallHelpers.h        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -361,6 +361,16 @@
</span><span class="cx"> addCallArgument(arg4);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ ALWAYS_INLINE void setupArgumentsWithExecState(GPRReg arg1, GPRReg arg2, TrustedImmPtr arg3, TrustedImmPtr arg4)
+ {
+ resetCallArguments();
+ addCallArgument(GPRInfo::callFrameRegister);
+ addCallArgument(arg1);
+ addCallArgument(arg2);
+ addCallArgument(arg3);
+ addCallArgument(arg4);
+ }
+
</ins><span class="cx"> ALWAYS_INLINE void setupArgumentsWithExecState(GPRReg arg1, TrustedImm32 arg2, TrustedImmPtr arg3)
</span><span class="cx"> {
</span><span class="cx"> resetCallArguments();
</span><span class="lines">@@ -2266,6 +2276,15 @@
</span><span class="cx"> move(arg4, GPRInfo::argumentGPR3);
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><ins>+
+ void setupArgumentsWithExecState(JSValueRegs arg)
+ {
+#if USE(JSVALUE64)
+ setupArgumentsWithExecState(arg.gpr());
+#else
+ setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg.payloadGPR(), arg.tagGPR());
+#endif
+ }
</ins><span class="cx">
</span><span class="cx"> void setupArgumentsWithExecState(JSValueRegs arg1, JSValueRegs arg2)
</span><span class="cx"> {
</span><span class="lines">@@ -2276,6 +2295,15 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ void setupArgumentsWithExecState(JSValueRegs arg1, TrustedImmPtr arg2)
+ {
+#if USE(JSVALUE64)
+ setupArgumentsWithExecState(arg1.gpr(), arg2);
+#else
+ setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1.payloadGPR(), arg1.tagGPR(), arg2);
+#endif
+ }
+
</ins><span class="cx"> void setupArgumentsWithExecState(JSValueRegs arg1, JSValueRegs arg2, TrustedImmPtr arg3)
</span><span class="cx"> {
</span><span class="cx"> #if USE(JSVALUE64)
</span><span class="lines">@@ -2293,6 +2321,15 @@
</span><span class="cx"> setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1.payloadGPR(), arg1.tagGPR(), arg2.payloadGPR(), arg2.tagGPR(), arg3, arg4);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><ins>+
+ void setupArgumentsWithExecState(JSValueRegs arg1, TrustedImmPtr arg2, TrustedImmPtr arg3)
+ {
+#if USE(JSVALUE64)
+ setupArgumentsWithExecState(arg1.gpr(), arg2, arg3);
+#else
+ setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1.payloadGPR(), arg1.tagGPR(), arg2, arg3);
+#endif
+ }
</ins><span class="cx">
</span><span class="cx"> void setupArguments(JSValueRegs arg1)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JIT.h (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JIT.h        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/jit/JIT.h        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -697,10 +697,14 @@
</span><span class="cx"> bool isOperandConstantChar(int src);
</span><span class="cx">
</span><span class="cx"> template <typename Generator, typename ProfiledFunction, typename NonProfiledFunction>
</span><del>- void emitMathICFast(JITMathIC<Generator>*, Instruction*, ProfiledFunction, NonProfiledFunction);
</del><ins>+ void emitMathICFast(JITUnaryMathIC<Generator>*, Instruction*, ProfiledFunction, NonProfiledFunction);
+ template <typename Generator, typename ProfiledFunction, typename NonProfiledFunction>
+ void emitMathICFast(JITBinaryMathIC<Generator>*, Instruction*, ProfiledFunction, NonProfiledFunction);
</ins><span class="cx">
</span><span class="cx"> template <typename Generator, typename ProfiledRepatchFunction, typename ProfiledFunction, typename RepatchFunction>
</span><del>- void emitMathICSlow(JITMathIC<Generator>*, Instruction*, ProfiledRepatchFunction, ProfiledFunction, RepatchFunction);
</del><ins>+ void emitMathICSlow(JITBinaryMathIC<Generator>*, Instruction*, ProfiledRepatchFunction, ProfiledFunction, RepatchFunction);
+ template <typename Generator, typename ProfiledRepatchFunction, typename ProfiledFunction, typename RepatchFunction>
+ void emitMathICSlow(JITUnaryMathIC<Generator>*, Instruction*, ProfiledRepatchFunction, ProfiledFunction, RepatchFunction);
</ins><span class="cx">
</span><span class="cx"> Jump getSlowCase(Vector<SlowCaseEntry>::iterator& iter)
</span><span class="cx"> {
</span><span class="lines">@@ -745,6 +749,7 @@
</span><span class="cx"> MacroAssembler::Call callOperation(J_JITOperation_EC, int, JSCell*);
</span><span class="cx"> MacroAssembler::Call callOperation(V_JITOperation_EC, JSCell*);
</span><span class="cx"> MacroAssembler::Call callOperation(J_JITOperation_EJ, int, GPRReg);
</span><ins>+ MacroAssembler::Call callOperation(J_JITOperation_EJ, JSValueRegs, JSValueRegs);
</ins><span class="cx"> #if USE(JSVALUE64)
</span><span class="cx"> MacroAssembler::Call callOperation(J_JITOperation_ESsiJI, int, StructureStubInfo*, GPRReg, UniquedStringImpl*);
</span><span class="cx"> MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_ESsiJI, int, StructureStubInfo*, GPRReg, UniquedStringImpl*);
</span><span class="lines">@@ -754,9 +759,11 @@
</span><span class="cx"> #endif
</span><span class="cx"> MacroAssembler::Call callOperation(J_JITOperation_EJI, int, GPRReg, UniquedStringImpl*);
</span><span class="cx"> MacroAssembler::Call callOperation(J_JITOperation_EJJ, int, GPRReg, GPRReg);
</span><ins>+ MacroAssembler::Call callOperation(J_JITOperation_EJArp, JSValueRegs, JSValueRegs, ArithProfile*);
</ins><span class="cx"> MacroAssembler::Call callOperation(J_JITOperation_EJJArp, JSValueRegs, JSValueRegs, JSValueRegs, ArithProfile*);
</span><span class="cx"> MacroAssembler::Call callOperation(J_JITOperation_EJJ, JSValueRegs, JSValueRegs, JSValueRegs);
</span><span class="cx"> MacroAssembler::Call callOperation(J_JITOperation_EJJArpMic, JSValueRegs, JSValueRegs, JSValueRegs, ArithProfile*, TrustedImmPtr);
</span><ins>+ MacroAssembler::Call callOperation(J_JITOperation_EJMic, JSValueRegs, JSValueRegs, TrustedImmPtr);
</ins><span class="cx"> MacroAssembler::Call callOperation(J_JITOperation_EJJMic, JSValueRegs, JSValueRegs, JSValueRegs, TrustedImmPtr);
</span><span class="cx"> MacroAssembler::Call callOperation(J_JITOperation_EJJAp, int, GPRReg, GPRReg, ArrayProfile*);
</span><span class="cx"> MacroAssembler::Call callOperation(J_JITOperation_EJJBy, int, GPRReg, GPRReg, ByValInfo*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITArithmeticcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -469,29 +469,9 @@
</span><span class="cx">
</span><span class="cx"> void JIT::emit_op_negate(Instruction* currentInstruction)
</span><span class="cx"> {
</span><del>- int result = currentInstruction[1].u.operand;
- int src = currentInstruction[2].u.operand;
-
-#if USE(JSVALUE64)
- JSValueRegs srcRegs = JSValueRegs(regT0);
- JSValueRegs resultRegs = srcRegs;
- GPRReg scratchGPR = regT2;
-#else
- JSValueRegs srcRegs = JSValueRegs(regT1, regT0);
- JSValueRegs resultRegs = srcRegs;
- GPRReg scratchGPR = regT4;
-#endif
-
- emitGetVirtualRegister(src, srcRegs);
-
- JITNegGenerator gen(resultRegs, srcRegs, scratchGPR);
- gen.generateFastPath(*this);
-
- ASSERT(gen.didEmitFastPath());
- gen.endJumpList().link(this);
- emitPutVirtualRegister(result, resultRegs);
-
- addSlowCase(gen.slowPathJumpList());
</del><ins>+ JITNegIC* negateIC = m_codeBlock->addJITNegIC();
+ m_instructionToMathIC.add(currentInstruction, negateIC);
+ emitMathICFast(negateIC, currentInstruction, operationArithNegateProfiled, operationArithNegate);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void JIT::emitSlow_op_negate(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
</span><span class="lines">@@ -498,8 +478,8 @@
</span><span class="cx"> {
</span><span class="cx"> linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
</span><span class="cx">
</span><del>- JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_negate);
- slowPathCall.call();
</del><ins>+ JITNegIC* negIC = bitwise_cast<JITNegIC*>(m_instructionToMathIC.get(currentInstruction));
+ emitMathICSlow(negIC, currentInstruction, operationArithNegateProfiledOptimize, operationArithNegateProfiled, operationArithNegateOptimize);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template<typename SnippetGenerator>
</span><span class="lines">@@ -698,9 +678,58 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename Generator, typename ProfiledFunction, typename NonProfiledFunction>
</span><del>-void JIT::emitMathICFast(JITMathIC<Generator>* mathIC, Instruction* currentInstruction, ProfiledFunction profiledFunction, NonProfiledFunction nonProfiledFunction)
</del><ins>+void JIT::emitMathICFast(JITUnaryMathIC<Generator>* mathIC, Instruction* currentInstruction, ProfiledFunction profiledFunction, NonProfiledFunction nonProfiledFunction)
</ins><span class="cx"> {
</span><span class="cx"> int result = currentInstruction[1].u.operand;
</span><ins>+ int operand = currentInstruction[2].u.operand;
+
+#if USE(JSVALUE64)
+ // ArithNegate benefits from using the same register as src and dst.
+ // Since regT1==argumentGPR1, using regT1 avoid shuffling register to call the slow path.
+ JSValueRegs srcRegs = JSValueRegs(regT1);
+ JSValueRegs resultRegs = JSValueRegs(regT1);
+ GPRReg scratchGPR = regT2;
+#else
+ JSValueRegs srcRegs = JSValueRegs(regT1, regT0);
+ JSValueRegs resultRegs = JSValueRegs(regT3, regT2);
+ GPRReg scratchGPR = regT4;
+#endif
+
+#if ENABLE(MATH_IC_STATS)
+ auto inlineStart = label();
+#endif
+
+ ArithProfile& arithProfile = *bitwise_cast<ArithProfile*>(&currentInstruction[3].u.operand);
+ mathIC->m_generator = Generator(resultRegs, srcRegs, scratchGPR, arithProfile);
+
+ emitGetVirtualRegister(operand, srcRegs);
+
+ MathICGenerationState& mathICGenerationState = m_instructionToMathICGenerationState.add(currentInstruction, MathICGenerationState()).iterator->value;
+
+ bool generatedInlineCode = mathIC->generateInline(*this, mathICGenerationState);
+ if (!generatedInlineCode) {
+ if (shouldEmitProfiling())
+ callOperation(profiledFunction, resultRegs, srcRegs, &arithProfile);
+ else
+ callOperation(nonProfiledFunction, resultRegs, srcRegs);
+ } else
+ addSlowCase(mathICGenerationState.slowPathJumps);
+
+#if ENABLE(MATH_IC_STATS)
+ auto inlineEnd = label();
+ addLinkTask([=] (LinkBuffer& linkBuffer) {
+ size_t size = static_cast<char*>(linkBuffer.locationOf(inlineEnd).executableAddress()) - static_cast<char*>(linkBuffer.locationOf(inlineStart).executableAddress());
+ mathIC->m_generatedCodeSize += size;
+ });
+#endif
+
+ emitPutVirtualRegister(result, resultRegs);
+}
+
+template <typename Generator, typename ProfiledFunction, typename NonProfiledFunction>
+void JIT::emitMathICFast(JITBinaryMathIC<Generator>* mathIC, Instruction* currentInstruction, ProfiledFunction profiledFunction, NonProfiledFunction nonProfiledFunction)
+{
+ int result = currentInstruction[1].u.operand;
</ins><span class="cx"> int op1 = currentInstruction[2].u.operand;
</span><span class="cx"> int op2 = currentInstruction[3].u.operand;
</span><span class="cx">
</span><span class="lines">@@ -722,7 +751,7 @@
</span><span class="cx">
</span><span class="cx"> ArithProfile* arithProfile = nullptr;
</span><span class="cx"> if (shouldEmitProfiling())
</span><del>- arithProfile = &m_codeBlock->arithProfileForPC(currentInstruction);
</del><ins>+ arithProfile = m_codeBlock->arithProfileForPC(currentInstruction);
</ins><span class="cx">
</span><span class="cx"> SnippetOperand leftOperand(types.first());
</span><span class="cx"> SnippetOperand rightOperand(types.second());
</span><span class="lines">@@ -774,12 +803,57 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename Generator, typename ProfiledRepatchFunction, typename ProfiledFunction, typename RepatchFunction>
</span><del>-void JIT::emitMathICSlow(JITMathIC<Generator>* mathIC, Instruction* currentInstruction, ProfiledRepatchFunction profiledRepatchFunction, ProfiledFunction profiledFunction, RepatchFunction repatchFunction)
</del><ins>+void JIT::emitMathICSlow(JITUnaryMathIC<Generator>* mathIC, Instruction* currentInstruction, ProfiledRepatchFunction profiledRepatchFunction, ProfiledFunction profiledFunction, RepatchFunction repatchFunction)
</ins><span class="cx"> {
</span><span class="cx"> MathICGenerationState& mathICGenerationState = m_instructionToMathICGenerationState.find(currentInstruction)->value;
</span><span class="cx"> mathICGenerationState.slowPathStart = label();
</span><span class="cx">
</span><span class="cx"> int result = currentInstruction[1].u.operand;
</span><ins>+
+#if USE(JSVALUE64)
+ JSValueRegs srcRegs = JSValueRegs(regT1);
+ JSValueRegs resultRegs = JSValueRegs(regT0);
+#else
+ JSValueRegs srcRegs = JSValueRegs(regT1, regT0);
+ JSValueRegs resultRegs = JSValueRegs(regT3, regT2);
+#endif
+
+#if ENABLE(MATH_IC_STATS)
+ auto slowPathStart = label();
+#endif
+
+ if (shouldEmitProfiling()) {
+ ArithProfile* arithProfile = bitwise_cast<ArithProfile*>(&currentInstruction[3].u.operand);
+ if (mathICGenerationState.shouldSlowPathRepatch)
+ mathICGenerationState.slowPathCall = callOperation(reinterpret_cast<J_JITOperation_EJMic>(profiledRepatchFunction), resultRegs, srcRegs, TrustedImmPtr(mathIC));
+ else
+ mathICGenerationState.slowPathCall = callOperation(profiledFunction, resultRegs, srcRegs, arithProfile);
+ } else
+ mathICGenerationState.slowPathCall = callOperation(reinterpret_cast<J_JITOperation_EJMic>(repatchFunction), resultRegs, srcRegs, TrustedImmPtr(mathIC));
+
+#if ENABLE(MATH_IC_STATS)
+ auto slowPathEnd = label();
+ addLinkTask([=] (LinkBuffer& linkBuffer) {
+ size_t size = static_cast<char*>(linkBuffer.locationOf(slowPathEnd).executableAddress()) - static_cast<char*>(linkBuffer.locationOf(slowPathStart).executableAddress());
+ mathIC->m_generatedCodeSize += size;
+ });
+#endif
+
+ emitPutVirtualRegister(result, resultRegs);
+
+ addLinkTask([=] (LinkBuffer& linkBuffer) {
+ MathICGenerationState& mathICGenerationState = m_instructionToMathICGenerationState.find(currentInstruction)->value;
+ mathIC->finalizeInlineCode(mathICGenerationState, linkBuffer);
+ });
+}
+
+template <typename Generator, typename ProfiledRepatchFunction, typename ProfiledFunction, typename RepatchFunction>
+void JIT::emitMathICSlow(JITBinaryMathIC<Generator>* mathIC, Instruction* currentInstruction, ProfiledRepatchFunction profiledRepatchFunction, ProfiledFunction profiledFunction, RepatchFunction repatchFunction)
+{
+ MathICGenerationState& mathICGenerationState = m_instructionToMathICGenerationState.find(currentInstruction)->value;
+ mathICGenerationState.slowPathStart = label();
+
+ int result = currentInstruction[1].u.operand;
</ins><span class="cx"> int op1 = currentInstruction[2].u.operand;
</span><span class="cx"> int op2 = currentInstruction[3].u.operand;
</span><span class="cx">
</span><span class="lines">@@ -815,7 +889,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> if (shouldEmitProfiling()) {
</span><del>- ArithProfile& arithProfile = m_codeBlock->arithProfileForPC(currentInstruction);
</del><ins>+ ArithProfile& arithProfile = *m_codeBlock->arithProfileForPC(currentInstruction);
</ins><span class="cx"> if (mathICGenerationState.shouldSlowPathRepatch)
</span><span class="cx"> mathICGenerationState.slowPathCall = callOperation(bitwise_cast<J_JITOperation_EJJArpMic>(profiledRepatchFunction), resultRegs, leftRegs, rightRegs, &arithProfile, TrustedImmPtr(mathIC));
</span><span class="cx"> else
</span><span class="lines">@@ -862,7 +936,7 @@
</span><span class="cx">
</span><span class="cx"> ArithProfile* arithProfile = nullptr;
</span><span class="cx"> if (shouldEmitProfiling())
</span><del>- arithProfile = &m_codeBlock->arithProfileForPC(currentInstruction);
</del><ins>+ arithProfile = m_codeBlock->arithProfileForPC(currentInstruction);
</ins><span class="cx">
</span><span class="cx"> SnippetOperand leftOperand(types.first());
</span><span class="cx"> SnippetOperand rightOperand(types.second());
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITInlines.h (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITInlines.h        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/jit/JITInlines.h        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -416,6 +416,14 @@
</span><span class="cx"> return appendCallWithExceptionCheck(operation);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJ operation, JSValueRegs result, JSValueRegs arg)
+{
+ setupArgumentsWithExecState(arg);
+ Call call = appendCallWithExceptionCheck(operation);
+ setupResults(result);
+ return call;
+}
+
</ins><span class="cx"> ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJJ operation, JSValueRegs result, JSValueRegs arg1, JSValueRegs arg2)
</span><span class="cx"> {
</span><span class="cx"> setupArgumentsWithExecState(arg1, arg2);
</span><span class="lines">@@ -424,6 +432,14 @@
</span><span class="cx"> return call;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJArp operation, JSValueRegs result, JSValueRegs operand, ArithProfile* arithProfile)
+{
+ setupArgumentsWithExecState(operand, TrustedImmPtr(arithProfile));
+ Call call = appendCallWithExceptionCheck(operation);
+ setupResults(result);
+ return call;
+}
+
</ins><span class="cx"> ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJJArp operation, JSValueRegs result, JSValueRegs arg1, JSValueRegs arg2, ArithProfile* arithProfile)
</span><span class="cx"> {
</span><span class="cx"> setupArgumentsWithExecState(arg1, arg2, TrustedImmPtr(arithProfile));
</span><span class="lines">@@ -440,6 +456,14 @@
</span><span class="cx"> return call;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJMic operation, JSValueRegs result, JSValueRegs arg, TrustedImmPtr mathIC)
+{
+ setupArgumentsWithExecState(arg, mathIC);
+ Call call = appendCallWithExceptionCheck(operation);
+ setupResults(result);
+ return call;
+}
+
</ins><span class="cx"> ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJJMic operation, JSValueRegs result, JSValueRegs arg1, JSValueRegs arg2, TrustedImmPtr mathIC)
</span><span class="cx"> {
</span><span class="cx"> setupArgumentsWithExecState(arg1, arg2, mathIC);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITMathICh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITMathIC.h (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITMathIC.h        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/jit/JITMathIC.h        2016-09-23 03:50:22 UTC (rev 206289)
</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 "JITNegGenerator.h"
</ins><span class="cx"> #include "JITSubGenerator.h"
</span><span class="cx"> #include "LinkBuffer.h"
</span><span class="cx"> #include "Repatch.h"
</span><span class="lines">@@ -52,7 +53,7 @@
</span><span class="cx">
</span><span class="cx"> #define ENABLE_MATH_IC_STATS 0
</span><span class="cx">
</span><del>-template <typename GeneratorType>
</del><ins>+template <typename GeneratorType, bool(*isProfileEmpty)(ArithProfile*)>
</ins><span class="cx"> class JITMathIC {
</span><span class="cx"> public:
</span><span class="cx"> CodeLocationLabel doneLocation() { return m_inlineStart.labelAtOffset(m_inlineSize); }
</span><span class="lines">@@ -72,17 +73,17 @@
</span><span class="cx"> size_t startSize = jit.m_assembler.buffer().codeSize();
</span><span class="cx">
</span><span class="cx"> if (ArithProfile* arithProfile = m_generator.arithProfile()) {
</span><del>- if (arithProfile->lhsObservedType().isEmpty() || arithProfile->rhsObservedType().isEmpty()) {
</del><ins>+ if (!isProfileEmpty(arithProfile)) {
</ins><span class="cx"> // It looks like the MathIC has yet to execute. We don't want to emit code in this
</span><span class="cx"> // case for a couple reasons. First, the operation may never execute, so if we don't emit
</span><span class="cx"> // code, it's a win. Second, if the operation does execute, we can emit better code
</span><del>- // once we have an idea about the types of lhs and rhs.
</del><ins>+ // once we have an idea about the types.
</ins><span class="cx"> state.slowPathJumps.append(jit.patchableJump());
</span><span class="cx"> size_t inlineSize = jit.m_assembler.buffer().codeSize() - startSize;
</span><span class="cx"> ASSERT_UNUSED(inlineSize, static_cast<ptrdiff_t>(inlineSize) <= MacroAssembler::patchableJumpSize());
</span><span class="cx"> state.shouldSlowPathRepatch = true;
</span><span class="cx"> state.fastPathEnd = jit.label();
</span><del>- ASSERT(!m_generateFastPathOnRepatch); // We should have gathered some observed type info for lhs and rhs before trying to regenerate again.
</del><ins>+ ASSERT(!m_generateFastPathOnRepatch); // We should have gathered some observed type info about the types before trying to regenerate again.
</ins><span class="cx"> m_generateFastPathOnRepatch = true;
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -243,10 +244,27 @@
</span><span class="cx"> GeneratorType m_generator;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-typedef JITMathIC<JITAddGenerator> JITAddIC;
-typedef JITMathIC<JITMulGenerator> JITMulIC;
-typedef JITMathIC<JITSubGenerator> JITSubIC;
</del><ins>+inline bool canGenerateWithBinaryProfile(ArithProfile* arithProfile)
+{
+ return !arithProfile->lhsObservedType().isEmpty() && !arithProfile->rhsObservedType().isEmpty();
+}
+template <typename GeneratorType>
+class JITBinaryMathIC : public JITMathIC<GeneratorType, canGenerateWithBinaryProfile> { };
</ins><span class="cx">
</span><ins>+typedef JITBinaryMathIC<JITAddGenerator> JITAddIC;
+typedef JITBinaryMathIC<JITMulGenerator> JITMulIC;
+typedef JITBinaryMathIC<JITSubGenerator> JITSubIC;
+
+
+inline bool canGenerateWithUnaryProfile(ArithProfile* arithProfile)
+{
+ return !arithProfile->lhsObservedType().isEmpty();
+}
+template <typename GeneratorType>
+class JITUnaryMathIC : public JITMathIC<GeneratorType, canGenerateWithUnaryProfile> { };
+
+typedef JITUnaryMathIC<JITNegGenerator> JITNegIC;
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(JIT)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITMathICForwardsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITMathICForwards.h (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITMathICForwards.h        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/jit/JITMathICForwards.h        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -29,14 +29,17 @@
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><del>-template <typename Generator> class JITMathIC;
</del><ins>+template <typename Generator> class JITBinaryMathIC;
+template <typename Generator> class JITUnaryMathIC;
</ins><span class="cx"> class JITAddGenerator;
</span><span class="cx"> class JITMulGenerator;
</span><ins>+class JITNegGenerator;
</ins><span class="cx"> class JITSubGenerator;
</span><span class="cx">
</span><del>-typedef JITMathIC<JITAddGenerator> JITAddIC;
-typedef JITMathIC<JITMulGenerator> JITMulIC;
-typedef JITMathIC<JITSubGenerator> JITSubIC;
</del><ins>+typedef JITBinaryMathIC<JITAddGenerator> JITAddIC;
+typedef JITBinaryMathIC<JITMulGenerator> JITMulIC;
+typedef JITUnaryMathIC<JITNegGenerator> JITNegIC;
+typedef JITBinaryMathIC<JITSubGenerator> JITSubIC;
</ins><span class="cx">
</span><span class="cx"> } // namespace JSC
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITNegGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITNegGenerator.cpp (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITNegGenerator.cpp        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/jit/JITNegGenerator.cpp        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -26,14 +26,63 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "JITNegGenerator.h"
</span><span class="cx">
</span><ins>+#include "ArithProfile.h"
+
</ins><span class="cx"> #if ENABLE(JIT)
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><del>-void JITNegGenerator::generateFastPath(CCallHelpers& jit)
</del><ins>+JITMathICInlineResult JITNegGenerator::generateInline(CCallHelpers& jit, MathICGenerationState& state)
</ins><span class="cx"> {
</span><ins>+ ASSERT(m_scratchGPR != InvalidGPRReg);
</ins><span class="cx"> ASSERT(m_scratchGPR != m_src.payloadGPR());
</span><span class="cx"> ASSERT(m_scratchGPR != m_result.payloadGPR());
</span><ins>+#if USE(JSVALUE32_64)
+ ASSERT(m_scratchGPR != m_src.tagGPR());
+ ASSERT(m_scratchGPR != m_result.tagGPR());
+#endif
+
+ ObservedType observedTypes = m_arithProfile->lhsObservedType();
+ ASSERT_WITH_MESSAGE(!observedTypes.isEmpty(), "We should not attempt to generate anything if we do not have a profile.");
+
+ if (observedTypes.isOnlyNonNumber())
+ return JITMathICInlineResult::DontGenerate;
+
+ if (observedTypes.isOnlyInt32()) {
+ jit.moveValueRegs(m_src, m_result);
+ state.slowPathJumps.append(jit.branchIfNotInt32(m_src));
+ state.slowPathJumps.append(jit.branchTest32(CCallHelpers::Zero, m_src.payloadGPR(), CCallHelpers::TrustedImm32(0x7fffffff)));
+ jit.neg32(m_result.payloadGPR());
+#if USE(JSVALUE64)
+ jit.boxInt32(m_result.payloadGPR(), m_result);
+#endif
+
+ return JITMathICInlineResult::GeneratedFastPath;
+ }
+ if (observedTypes.isOnlyNumber()) {
+ state.slowPathJumps.append(jit.branchIfInt32(m_src));
+ state.slowPathJumps.append(jit.branchIfNotNumber(m_src, m_scratchGPR));
+#if USE(JSVALUE64)
+ if (m_src.payloadGPR() != m_result.payloadGPR()) {
+ jit.move(CCallHelpers::TrustedImm64(static_cast<int64_t>(1ull << 63)), m_result.payloadGPR());
+ jit.xor64(m_src.payloadGPR(), m_result.payloadGPR());
+ } else {
+ jit.move(CCallHelpers::TrustedImm64(static_cast<int64_t>(1ull << 63)), m_scratchGPR);
+ jit.xor64(m_scratchGPR, m_result.payloadGPR());
+ }
+#else
+ jit.moveValueRegs(m_src, m_result);
+ jit.xor32(CCallHelpers::TrustedImm32(1 << 31), m_result.tagGPR());
+#endif
+ return JITMathICInlineResult::GeneratedFastPath;
+ }
+ return JITMathICInlineResult::GenerateFullSnippet;
+}
+
+bool JITNegGenerator::generateFastPath(CCallHelpers& jit, CCallHelpers::JumpList& endJumpList, CCallHelpers::JumpList& slowPathJumpList, bool)
+{
+ ASSERT(m_scratchGPR != m_src.payloadGPR());
+ ASSERT(m_scratchGPR != m_result.payloadGPR());
</ins><span class="cx"> ASSERT(m_scratchGPR != InvalidGPRReg);
</span><span class="cx"> #if USE(JSVALUE32_64)
</span><span class="cx"> ASSERT(m_scratchGPR != m_src.tagGPR());
</span><span class="lines">@@ -40,23 +89,21 @@
</span><span class="cx"> ASSERT(m_scratchGPR != m_result.tagGPR());
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- m_didEmitFastPath = true;
-
</del><span class="cx"> jit.moveValueRegs(m_src, m_result);
</span><span class="cx"> CCallHelpers::Jump srcNotInt = jit.branchIfNotInt32(m_src);
</span><span class="cx">
</span><span class="cx"> // -0 should produce a double, and hence cannot be negated as an int.
</span><span class="cx"> // The negative int32 0x80000000 doesn't have a positive int32 representation, and hence cannot be negated as an int.
</span><del>- m_slowPathJumpList.append(jit.branchTest32(CCallHelpers::Zero, m_src.payloadGPR(), CCallHelpers::TrustedImm32(0x7fffffff)));
</del><ins>+ slowPathJumpList.append(jit.branchTest32(CCallHelpers::Zero, m_src.payloadGPR(), CCallHelpers::TrustedImm32(0x7fffffff)));
</ins><span class="cx">
</span><span class="cx"> jit.neg32(m_result.payloadGPR());
</span><span class="cx"> #if USE(JSVALUE64)
</span><span class="cx"> jit.boxInt32(m_result.payloadGPR(), m_result);
</span><span class="cx"> #endif
</span><del>- m_endJumpList.append(jit.jump());
</del><ins>+ endJumpList.append(jit.jump());
</ins><span class="cx">
</span><span class="cx"> srcNotInt.link(&jit);
</span><del>- m_slowPathJumpList.append(jit.branchIfNotNumber(m_src, m_scratchGPR));
</del><ins>+ slowPathJumpList.append(jit.branchIfNotNumber(m_src, m_scratchGPR));
</ins><span class="cx">
</span><span class="cx"> // For a double, all we need to do is to invert the sign bit.
</span><span class="cx"> #if USE(JSVALUE64)
</span><span class="lines">@@ -65,6 +112,7 @@
</span><span class="cx"> #else
</span><span class="cx"> jit.xor32(CCallHelpers::TrustedImm32(1 << 31), m_result.tagGPR());
</span><span class="cx"> #endif
</span><ins>+ return true;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITNegGeneratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITNegGenerator.h (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITNegGenerator.h        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/jit/JITNegGenerator.h        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -29,32 +29,32 @@
</span><span class="cx"> #if ENABLE(JIT)
</span><span class="cx">
</span><span class="cx"> #include "CCallHelpers.h"
</span><del>-#include "SnippetOperand.h"
</del><ins>+#include "JITMathIC.h"
+#include "JITMathICInlineResult.h"
</ins><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><span class="cx"> class JITNegGenerator {
</span><span class="cx"> public:
</span><del>- JITNegGenerator(JSValueRegs result, JSValueRegs src, GPRReg scratchGPR)
- : m_result(result)
</del><ins>+ JITNegGenerator() = default;
+
+ JITNegGenerator(JSValueRegs result, JSValueRegs src, GPRReg scratchGPR, ArithProfile& arithProfile)
+ : m_arithProfile(&arithProfile)
+ , m_result(result)
</ins><span class="cx"> , m_src(src)
</span><span class="cx"> , m_scratchGPR(scratchGPR)
</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>+ ArithProfile* arithProfile() const { return m_arithProfile; }
</ins><span class="cx">
</span><span class="cx"> private:
</span><ins>+ ArithProfile* m_arithProfile { nullptr };
</ins><span class="cx"> JSValueRegs m_result;
</span><span class="cx"> JSValueRegs m_src;
</span><span class="cx"> GPRReg m_scratchGPR;
</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>
<a id="trunkSourceJavaScriptCorejitJITOperationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITOperations.cpp (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITOperations.cpp        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/jit/JITOperations.cpp        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -2469,6 +2469,90 @@
</span><span class="cx"> return profiledMul(*vm, exec, encodedOp1, encodedOp2, arithProfile);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ALWAYS_INLINE static EncodedJSValue unprofiledNegate(ExecState* exec, EncodedJSValue encodedOperand)
+{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ NativeCallFrameTracer tracer(&vm, exec);
+
+ JSValue operand = JSValue::decode(encodedOperand);
+ double number = operand.toNumber(exec);
+ if (UNLIKELY(scope.exception()))
+ return JSValue::encode(JSValue());
+ return JSValue::encode(jsNumber(-number));
+}
+
+ALWAYS_INLINE static EncodedJSValue profiledNegate(ExecState* exec, EncodedJSValue encodedOperand, ArithProfile* arithProfile)
+{
+ ASSERT(arithProfile);
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ NativeCallFrameTracer tracer(&vm, exec);
+
+ JSValue operand = JSValue::decode(encodedOperand);
+ arithProfile->observeLHS(operand);
+ double number = operand.toNumber(exec);
+ if (UNLIKELY(scope.exception()))
+ return JSValue::encode(JSValue());
+ return JSValue::encode(jsNumber(-number));
+}
+
+EncodedJSValue JIT_OPERATION operationArithNegate(ExecState* exec, EncodedJSValue operand)
+{
+ return unprofiledNegate(exec, operand);
+}
+
+EncodedJSValue JIT_OPERATION operationArithNegateProfiled(ExecState* exec, EncodedJSValue operand, ArithProfile* arithProfile)
+{
+ return profiledNegate(exec, operand, arithProfile);
+}
+
+EncodedJSValue JIT_OPERATION operationArithNegateProfiledOptimize(ExecState* exec, EncodedJSValue encodedOperand, JITNegIC* negIC)
+{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ NativeCallFrameTracer tracer(&vm, exec);
+
+ JSValue operand = JSValue::decode(encodedOperand);
+
+ ArithProfile* arithProfile = negIC->m_generator.arithProfile();
+ ASSERT(arithProfile);
+ arithProfile->observeLHS(operand);
+ negIC->generateOutOfLine(vm, exec->codeBlock(), operationArithNegateProfiled);
+
+#if ENABLE(MATH_IC_STATS)
+ exec->codeBlock()->dumpMathICStats();
+#endif
+
+ double number = operand.toNumber(exec);
+ if (UNLIKELY(scope.exception()))
+ return JSValue::encode(JSValue());
+ return JSValue::encode(jsNumber(-number));
+}
+
+EncodedJSValue JIT_OPERATION operationArithNegateOptimize(ExecState* exec, EncodedJSValue encodedOperand, JITNegIC* negIC)
+{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ NativeCallFrameTracer tracer(&vm, exec);
+
+ JSValue operand = JSValue::decode(encodedOperand);
+
+ ArithProfile* arithProfile = negIC->m_generator.arithProfile();
+ ASSERT(arithProfile);
+ arithProfile->observeLHS(operand);
+ negIC->generateOutOfLine(vm, exec->codeBlock(), operationArithNegate);
+
+#if ENABLE(MATH_IC_STATS)
+ exec->codeBlock()->dumpMathICStats();
+#endif
+
+ double number = operand.toNumber(exec);
+ if (UNLIKELY(scope.exception()))
+ return JSValue::encode(JSValue());
+ return JSValue::encode(jsNumber(-number));
+}
+
</ins><span class="cx"> ALWAYS_INLINE static EncodedJSValue unprofiledSub(VM& vm, ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2)
</span><span class="cx"> {
</span><span class="cx"> auto scope = DECLARE_THROW_SCOPE(vm);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITOperationsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITOperations.h (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITOperations.h        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/jit/JITOperations.h        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -140,6 +140,7 @@
</span><span class="cx"> typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJZ)(ExecState*, EncodedJSValue, int32_t);
</span><span class="cx"> typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJC)(ExecState*, EncodedJSValue, JSCell*);
</span><span class="cx"> typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJA)(ExecState*, EncodedJSValue, JSArray*);
</span><ins>+typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJArp)(ExecState*, EncodedJSValue, ArithProfile*);
</ins><span class="cx"> typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJI)(ExecState*, EncodedJSValue, UniquedStringImpl*);
</span><span class="cx"> typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJJ)(ExecState*, EncodedJSValue, EncodedJSValue);
</span><span class="cx"> typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJJJ)(ExecState*, EncodedJSValue, EncodedJSValue, EncodedJSValue);
</span><span class="lines">@@ -149,6 +150,7 @@
</span><span class="cx"> typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJJArp)(ExecState*, EncodedJSValue, EncodedJSValue, ArithProfile*);
</span><span class="cx"> typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJJArpMic)(ExecState*, EncodedJSValue, EncodedJSValue, ArithProfile*, void*);
</span><span class="cx"> typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJJMic)(ExecState*, EncodedJSValue, EncodedJSValue, void*);
</span><ins>+typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJMic)(ExecState*, EncodedJSValue, void*);
</ins><span class="cx"> typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJssZ)(ExecState*, JSString*, int32_t);
</span><span class="cx"> typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJssReo)(ExecState*, JSString*, RegExpObject*);
</span><span class="cx"> typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJssReoJss)(ExecState*, JSString*, RegExpObject*, JSString*);
</span><span class="lines">@@ -437,6 +439,10 @@
</span><span class="cx"> EncodedJSValue JIT_OPERATION operationValueMulProfiledOptimize(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile*, JITMulIC*) WTF_INTERNAL;
</span><span class="cx"> EncodedJSValue JIT_OPERATION operationValueMulProfiledNoOptimize(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile*, JITMulIC*) WTF_INTERNAL;
</span><span class="cx"> EncodedJSValue JIT_OPERATION operationValueMulProfiled(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile*) WTF_INTERNAL;
</span><ins>+EncodedJSValue JIT_OPERATION operationArithNegate(ExecState*, EncodedJSValue operand);
+EncodedJSValue JIT_OPERATION operationArithNegateProfiled(ExecState*, EncodedJSValue operand, ArithProfile*);
+EncodedJSValue JIT_OPERATION operationArithNegateProfiledOptimize(ExecState*, EncodedJSValue encodedOperand, JITNegIC*);
+EncodedJSValue JIT_OPERATION operationArithNegateOptimize(ExecState*, EncodedJSValue encodedOperand, JITNegIC*);
</ins><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><span class="cx"> EncodedJSValue JIT_OPERATION operationValueSubOptimize(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, JITSubIC*) WTF_INTERNAL;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLowLevelInterpreterasm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -253,7 +253,9 @@
</span><span class="cx"> const ShadowChickenTailMarker = 0x7a11
</span><span class="cx">
</span><span class="cx"> # ArithProfile data
</span><ins>+const ArithProfileInt = 0x100000
</ins><span class="cx"> const ArithProfileIntInt = 0x120000
</span><ins>+const ArithProfileNumber = 0x200000
</ins><span class="cx"> const ArithProfileNumberInt = 0x220000
</span><span class="cx"> const ArithProfileNumberNumber = 0x240000
</span><span class="cx"> const ArithProfileIntNumber = 0x140000
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLowLevelInterpreter32_64asm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -948,22 +948,27 @@
</span><span class="cx"> loadi 8[PC], t0
</span><span class="cx"> loadi 4[PC], t3
</span><span class="cx"> loadConstantOrVariable(t0, t1, t2)
</span><ins>+ loadisFromInstruction(3, t0)
</ins><span class="cx"> bineq t1, Int32Tag, .opNegateSrcNotInt
</span><span class="cx"> btiz t2, 0x7fffffff, .opNegateSlow
</span><span class="cx"> negi t2
</span><ins>+ ori ArithProfileInt, t0
</ins><span class="cx"> storei Int32Tag, TagOffset[cfr, t3, 8]
</span><ins>+ storeisToInstruction(t0, 3)
</ins><span class="cx"> storei t2, PayloadOffset[cfr, t3, 8]
</span><del>- dispatch(3)
</del><ins>+ dispatch(4)
</ins><span class="cx"> .opNegateSrcNotInt:
</span><span class="cx"> bia t1, LowestTag, .opNegateSlow
</span><span class="cx"> xori 0x80000000, t1
</span><ins>+ ori ArithProfileNumber, t0
+ storei t2, PayloadOffset[cfr, t3, 8]
+ storeisToInstruction(t0, 3)
</ins><span class="cx"> storei t1, TagOffset[cfr, t3, 8]
</span><del>- storei t2, PayloadOffset[cfr, t3, 8]
- dispatch(3)
</del><ins>+ dispatch(4)
</ins><span class="cx">
</span><span class="cx"> .opNegateSlow:
</span><span class="cx"> callOpcodeSlowPath(_slow_path_negate)
</span><del>- dispatch(3)
</del><ins>+ dispatch(4)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> macro binaryOpCustomStore(integerOperationAndStore, doubleOperation, slowPath)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLowLevelInterpreter64asm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -827,22 +827,27 @@
</span><span class="cx"> traceExecution()
</span><span class="cx"> loadisFromInstruction(2, t0)
</span><span class="cx"> loadisFromInstruction(1, t1)
</span><del>- loadConstantOrVariable(t0, t2)
- bqb t2, tagTypeNumber, .opNegateNotInt
- btiz t2, 0x7fffffff, .opNegateSlow
- negi t2
- orq tagTypeNumber, t2
- storeq t2, [cfr, t1, 8]
- dispatch(3)
</del><ins>+ loadConstantOrVariable(t0, t3)
+ loadisFromInstruction(3, t2)
+ bqb t3, tagTypeNumber, .opNegateNotInt
+ btiz t3, 0x7fffffff, .opNegateSlow
+ negi t3
+ ori ArithProfileInt, t2
+ orq tagTypeNumber, t3
+ storeisToInstruction(t2, 3)
+ storeq t3, [cfr, t1, 8]
+ dispatch(4)
</ins><span class="cx"> .opNegateNotInt:
</span><del>- btqz t2, tagTypeNumber, .opNegateSlow
- xorq 0x8000000000000000, t2
- storeq t2, [cfr, t1, 8]
- dispatch(3)
</del><ins>+ btqz t3, tagTypeNumber, .opNegateSlow
+ xorq 0x8000000000000000, t3
+ ori ArithProfileNumber, t2
+ storeq t3, [cfr, t1, 8]
+ storeisToInstruction(t2, 3)
+ dispatch(4)
</ins><span class="cx">
</span><span class="cx"> .opNegateSlow:
</span><span class="cx"> callOpcodeSlowPath(_slow_path_negate)
</span><del>- dispatch(3)
</del><ins>+ dispatch(4)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> macro binaryOpCustomStore(integerOperationAndStore, doubleOperation, slowPath)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonSlowPathscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp (206288 => 206289)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp        2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp        2016-09-23 03:50:22 UTC (rev 206289)
</span><span class="lines">@@ -350,10 +350,44 @@
</span><span class="cx"> RETURN(OP_C(2).jsValue().toString(exec));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(JIT)
+static void updateArithProfileForUnaryArithOp(Instruction* pc, JSValue result, JSValue operand)
+{
+ ArithProfile& profile = *bitwise_cast<ArithProfile*>(&pc[3].u.operand);
+ profile.observeLHS(operand);
+ ASSERT(result.isNumber());
+ if (!result.isInt32()) {
+ if (operand.isInt32())
+ profile.setObservedInt32Overflow();
+
+ double doubleVal = result.asNumber();
+ if (!doubleVal && std::signbit(doubleVal))
+ profile.setObservedNegZeroDouble();
+ else {
+ profile.setObservedNonNegZeroDouble();
+
+ // The Int52 overflow check here intentionally omits 1ll << 51 as a valid negative Int52 value.
+ // Therefore, we will get a false positive if the result is that value. This is intentionally
+ // done to simplify the checking algorithm.
+ static const int64_t int52OverflowPoint = (1ll << 51);
+ int64_t int64Val = static_cast<int64_t>(std::abs(doubleVal));
+ if (int64Val >= int52OverflowPoint)
+ profile.setObservedInt52Overflow();
+ }
+ }
+}
+#else
+static void updateArithProfileForUnaryArithOp(Instruction*, JSValue, JSValue) { }
+#endif
+
</ins><span class="cx"> SLOW_PATH_DECL(slow_path_negate)
</span><span class="cx"> {
</span><span class="cx"> BEGIN();
</span><del>- RETURN(jsNumber(-OP_C(2).jsValue().toNumber(exec)));
</del><ins>+ JSValue operand = OP_C(2).jsValue();
+ JSValue result = jsNumber(-operand.toNumber(exec));
+ RETURN_WITH_PROFILING(result, {
+ updateArithProfileForUnaryArithOp(pc, result, operand);
+ });
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(DFG_JIT)
</span><span class="lines">@@ -360,7 +394,7 @@
</span><span class="cx"> static void updateArithProfileForBinaryArithOp(ExecState* exec, Instruction* pc, JSValue result, JSValue left, JSValue right)
</span><span class="cx"> {
</span><span class="cx"> CodeBlock* codeBlock = exec->codeBlock();
</span><del>- ArithProfile& profile = codeBlock->arithProfileForPC(pc);
</del><ins>+ ArithProfile& profile = *codeBlock->arithProfileForPC(pc);
</ins><span class="cx">
</span><span class="cx"> if (result.isNumber()) {
</span><span class="cx"> if (!result.isInt32()) {
</span><span class="lines">@@ -404,7 +438,7 @@
</span><span class="cx"> JSValue v2 = OP_C(3).jsValue();
</span><span class="cx"> JSValue result;
</span><span class="cx">
</span><del>- ArithProfile& arithProfile = exec->codeBlock()->arithProfileForPC(pc);
</del><ins>+ ArithProfile& arithProfile = *exec->codeBlock()->arithProfileForPC(pc);
</ins><span class="cx"> arithProfile.observeLHSAndRHS(v1, v2);
</span><span class="cx">
</span><span class="cx"> if (v1.isString() && !v2.isObject())
</span></span></pre>
</div>
</div>
</body>
</html>