Diff
Modified: trunk/JSTests/ChangeLog (206288 => 206289)
--- trunk/JSTests/ChangeLog 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/JSTests/ChangeLog 2016-09-23 03:50:22 UTC (rev 206289)
@@ -1,3 +1,12 @@
+2016-09-22 Benjamin Poulain <bpoul...@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.
+
2016-09-22 Mark Lam <mark....@apple.com>
Array.prototype.join should do overflow checks on string joins.
Added: trunk/JSTests/stress/op-negate-inline-cache.js (0 => 206289)
--- 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)
@@ -0,0 +1,300 @@
+"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();
Modified: trunk/Source/_javascript_Core/ChangeLog (206288 => 206289)
--- trunk/Source/_javascript_Core/ChangeLog 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-09-23 03:50:22 UTC (rev 206289)
@@ -1,3 +1,72 @@
+2016-09-22 Benjamin Poulain <bpoul...@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):
+
2016-09-22 Mark Lam <mark....@apple.com>
Removed unused hasErrorInfo().
Modified: trunk/Source/_javascript_Core/bytecode/ArithProfile.h (206288 => 206289)
--- trunk/Source/_javascript_Core/bytecode/ArithProfile.h 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/bytecode/ArithProfile.h 2016-09-23 03:50:22 UTC (rev 206289)
@@ -87,6 +87,14 @@
static_assert(specialFastPathBit & clearLhsObservedTypeBitMask, "These bits should intersect.");
static_assert(specialFastPathBit > ~clearLhsObservedTypeBitMask, "These bits should not intersect and specialFastPathBit should be a higher bit.");
+ ArithProfile(ResultType arg)
+ {
+ m_bits = (arg.bits() << lhsResultTypeShift);
+ ASSERT(lhsResultType().bits() == arg.bits());
+ ASSERT(lhsObservedType().isEmpty());
+ ASSERT(rhsObservedType().isEmpty());
+ }
+
ArithProfile(ResultType lhs, ResultType rhs)
{
m_bits = (lhs.bits() << lhsResultTypeShift) | (rhs.bits() << rhsResultTypeShift);
@@ -94,7 +102,7 @@
ASSERT(lhsObservedType().isEmpty());
ASSERT(rhsObservedType().isEmpty());
}
- ArithProfile() { }
+ ArithProfile() = default;
static ArithProfile fromInt(uint32_t bits)
{
@@ -170,7 +178,7 @@
void rhsSawNumber() { setRhsObservedType(rhsObservedType().withNumber()); }
void rhsSawNonNumber() { setRhsObservedType(rhsObservedType().withNonNumber()); }
- void observeLHSAndRHS(JSValue lhs, JSValue rhs)
+ void observeLHS(JSValue lhs)
{
ArithProfile newProfile = *this;
if (lhs.isNumber()) {
@@ -181,6 +189,14 @@
} else
newProfile.lhsSawNonNumber();
+ m_bits = newProfile.bits();
+ }
+
+ void observeLHSAndRHS(JSValue lhs, JSValue rhs)
+ {
+ observeLHS(lhs);
+
+ ArithProfile newProfile = *this;
if (rhs.isNumber()) {
if (rhs.isInt32())
newProfile.rhsSawInt32();
Modified: trunk/Source/_javascript_Core/bytecode/BytecodeList.json (206288 => 206289)
--- trunk/Source/_javascript_Core/bytecode/BytecodeList.json 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeList.json 2016-09-23 03:50:22 UTC (rev 206289)
@@ -33,7 +33,7 @@
{ "name" : "op_dec", "length" : 2 },
{ "name" : "op_to_number", "length" : 4 },
{ "name" : "op_to_string", "length" : 3 },
- { "name" : "op_negate", "length" : 3 },
+ { "name" : "op_negate", "length" : 4 },
{ "name" : "op_add", "length" : 5 },
{ "name" : "op_mul", "length" : 5 },
{ "name" : "op_div", "length" : 5 },
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (206288 => 206289)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2016-09-23 03:50:22 UTC (rev 206289)
@@ -3015,6 +3015,11 @@
return m_subICs.add();
}
+JITNegIC* CodeBlock::addJITNegIC()
+{
+ return m_negICs.add();
+}
+
StructureStubInfo* CodeBlock::findStubInfo(CodeOrigin codeOrigin)
{
for (StructureStubInfo* stubInfo : m_stubInfos) {
@@ -4354,8 +4359,15 @@
ArithProfile* CodeBlock::arithProfileForBytecodeOffset(int bytecodeOffset)
{
- auto opcodeID = vm()->interpreter->getOpcodeID(instructions()[bytecodeOffset].u.opcode);
+ return arithProfileForPC(instructions().begin() + bytecodeOffset);
+}
+
+ArithProfile* CodeBlock::arithProfileForPC(Instruction* pc)
+{
+ auto opcodeID = vm()->interpreter->getOpcodeID(pc[0].u.opcode);
switch (opcodeID) {
+ case op_negate:
+ return bitwise_cast<ArithProfile*>(&pc[3].u.operand);
case op_bitor:
case op_bitand:
case op_bitxor:
@@ -4363,36 +4375,14 @@
case op_mul:
case op_sub:
case op_div:
+ return bitwise_cast<ArithProfile*>(&pc[4].u.operand);
+ default:
break;
- default:
- return nullptr;
}
- return &arithProfileForPC(instructions().begin() + bytecodeOffset);
+ return nullptr;
}
-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);
-}
-
bool CodeBlock::couldTakeSpecialFastCase(int bytecodeOffset)
{
if (!hasBaselineJITProfiling())
@@ -4562,6 +4552,8 @@
double totalAddSize = 0.0;
double numMuls = 0.0;
double totalMulSize = 0.0;
+ double numNegs = 0.0;
+ double totalNegSize = 0.0;
double numSubs = 0.0;
double totalSubSize = 0.0;
@@ -4576,6 +4568,11 @@
totalMulSize += mulIC->codeSize();
}
+ for (JITNegIC* negIC : codeBlock->m_negICs) {
+ numNegs++;
+ totalNegSize += negIC->codeSize();
+ }
+
for (JITSubIC* subIC : codeBlock->m_subICs) {
numSubs++;
totalSubSize += subIC->codeSize();
@@ -4593,6 +4590,10 @@
dataLog("Total Mul size in bytes: ", totalMulSize, "\n");
dataLog("Average Mul size: ", totalMulSize / numMuls, "\n");
dataLog("\n");
+ dataLog("Num Negs: ", numNegs, "\n");
+ dataLog("Total Neg size in bytes: ", totalNegSize, "\n");
+ dataLog("Average Neg size: ", totalNegSize / numNegs, "\n");
+ dataLog("\n");
dataLog("Num Subs: ", numSubs, "\n");
dataLog("Total Sub size in bytes: ", totalSubSize, "\n");
dataLog("Average Sub size: ", totalSubSize / numSubs, "\n");
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.h (206288 => 206289)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2016-09-23 03:50:22 UTC (rev 206289)
@@ -245,6 +245,7 @@
StructureStubInfo* addStubInfo(AccessType);
JITAddIC* addJITAddIC();
JITMulIC* addJITMulIC();
+ JITNegIC* addJITNegIC();
JITSubIC* addJITSubIC();
Bag<StructureStubInfo>::iterator stubInfoBegin() { return m_stubInfos.begin(); }
Bag<StructureStubInfo>::iterator stubInfoEnd() { return m_stubInfos.end(); }
@@ -447,7 +448,7 @@
}
ArithProfile* arithProfileForBytecodeOffset(int bytecodeOffset);
- ArithProfile& arithProfileForPC(Instruction*);
+ ArithProfile* arithProfileForPC(Instruction*);
bool couldTakeSpecialFastCase(int bytecodeOffset);
@@ -997,6 +998,7 @@
Bag<StructureStubInfo> m_stubInfos;
Bag<JITAddIC> m_addICs;
Bag<JITMulIC> m_mulICs;
+ Bag<JITNegIC> m_negICs;
Bag<JITSubIC> m_subICs;
Bag<ByValInfo> m_byValInfos;
Bag<CallLinkInfo> m_callLinkInfos;
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (206288 => 206289)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2016-09-23 03:50:22 UTC (rev 206289)
@@ -1579,13 +1579,27 @@
RegisterID* BytecodeGenerator::emitUnaryOp(OpcodeID opcodeID, RegisterID* dst, RegisterID* src)
{
- ASSERT_WITH_MESSAGE(op_to_number != opcodeID, "op_to_number is profiled.");
+ 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.");
emitOpcode(opcodeID);
instructions().append(dst->index());
instructions().append(src->index());
+
return dst;
}
+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;
+}
+
RegisterID* BytecodeGenerator::emitUnaryOpProfiled(OpcodeID opcodeID, RegisterID* dst, RegisterID* src)
{
UnlinkedValueProfile profile = ""
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h (206288 => 206289)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h 2016-09-23 03:50:22 UTC (rev 206289)
@@ -511,6 +511,7 @@
RegisterID* emitLoadGlobalObject(RegisterID* dst);
RegisterID* emitUnaryOp(OpcodeID, RegisterID* dst, RegisterID* src);
+ RegisterID* emitUnaryOp(OpcodeID, RegisterID* dst, RegisterID* src, OperandTypes);
RegisterID* emitUnaryOpProfiled(OpcodeID, RegisterID* dst, RegisterID* src);
RegisterID* emitBinaryOp(OpcodeID, RegisterID* dst, RegisterID* src1, RegisterID* src2, OperandTypes);
RegisterID* emitEqualityOp(OpcodeID, RegisterID* dst, RegisterID* src1, RegisterID* src2);
Modified: trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (206288 => 206289)
--- trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2016-09-23 03:50:22 UTC (rev 206289)
@@ -1606,7 +1606,7 @@
{
RefPtr<RegisterID> src = ""
generator.emitExpressionInfo(position(), position(), position());
- return generator.emitUnaryOp(opcodeID(), generator.finalDestination(dst), src.get());
+ return generator.emitUnaryOp(opcodeID(), generator.finalDestination(dst), src.get(), OperandTypes(m_expr->resultDescriptor()));
}
// ------------------------------ UnaryPlusNode -----------------------------------
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (206288 => 206289)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2016-09-23 03:50:22 UTC (rev 206289)
@@ -3432,7 +3432,7 @@
}
template <typename Generator, typename RepatchingFunction, typename NonRepatchingFunction>
-void SpeculativeJIT::compileMathIC(Node* node, JITMathIC<Generator>* mathIC, bool needsScratchGPRReg, bool needsScratchFPRReg, RepatchingFunction repatchingFunction, NonRepatchingFunction nonRepatchingFunction)
+void SpeculativeJIT::compileMathIC(Node* node, JITBinaryMathIC<Generator>* mathIC, bool needsScratchGPRReg, bool needsScratchFPRReg, RepatchingFunction repatchingFunction, NonRepatchingFunction nonRepatchingFunction)
{
Edge& leftChild = node->child1();
Edge& rightChild = node->child2();
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h (206288 => 206289)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h 2016-09-23 03:50:22 UTC (rev 206289)
@@ -2515,7 +2515,7 @@
void compileShiftOp(Node*);
template <typename Generator, typename RepatchingFunction, typename NonRepatchingFunction>
- void compileMathIC(Node*, JITMathIC<Generator>*, bool needsScratchGPRReg, bool needsScratchFPRReg, RepatchingFunction, NonRepatchingFunction);
+ void compileMathIC(Node*, JITBinaryMathIC<Generator>*, bool needsScratchGPRReg, bool needsScratchFPRReg, RepatchingFunction, NonRepatchingFunction);
void compileArithDoubleUnaryOp(Node*, double (*doubleFunction)(double), double (*operation)(ExecState*, EncodedJSValue));
void compileValueAdd(Node*);
Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp (206288 => 206289)
--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp 2016-09-23 03:50:22 UTC (rev 206289)
@@ -1560,7 +1560,7 @@
}
template <typename Generator>
- void compileMathIC(JITMathIC<Generator>* mathIC, FunctionPtr repatchingFunction, FunctionPtr nonRepatchingFunction)
+ void compileMathIC(JITBinaryMathIC<Generator>* mathIC, FunctionPtr repatchingFunction, FunctionPtr nonRepatchingFunction)
{
Node* node = m_node;
Modified: trunk/Source/_javascript_Core/jit/CCallHelpers.h (206288 => 206289)
--- trunk/Source/_javascript_Core/jit/CCallHelpers.h 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/jit/CCallHelpers.h 2016-09-23 03:50:22 UTC (rev 206289)
@@ -361,6 +361,16 @@
addCallArgument(arg4);
}
+ ALWAYS_INLINE void setupArgumentsWithExecState(GPRReg arg1, GPRReg arg2, TrustedImmPtr arg3, TrustedImmPtr arg4)
+ {
+ resetCallArguments();
+ addCallArgument(GPRInfo::callFrameRegister);
+ addCallArgument(arg1);
+ addCallArgument(arg2);
+ addCallArgument(arg3);
+ addCallArgument(arg4);
+ }
+
ALWAYS_INLINE void setupArgumentsWithExecState(GPRReg arg1, TrustedImm32 arg2, TrustedImmPtr arg3)
{
resetCallArguments();
@@ -2266,6 +2276,15 @@
move(arg4, GPRInfo::argumentGPR3);
}
#endif
+
+ void setupArgumentsWithExecState(JSValueRegs arg)
+ {
+#if USE(JSVALUE64)
+ setupArgumentsWithExecState(arg.gpr());
+#else
+ setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg.payloadGPR(), arg.tagGPR());
+#endif
+ }
void setupArgumentsWithExecState(JSValueRegs arg1, JSValueRegs arg2)
{
@@ -2276,6 +2295,15 @@
#endif
}
+ 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
+ }
+
void setupArgumentsWithExecState(JSValueRegs arg1, JSValueRegs arg2, TrustedImmPtr arg3)
{
#if USE(JSVALUE64)
@@ -2293,6 +2321,15 @@
setupArgumentsWithExecState(EABI_32BIT_DUMMY_ARG arg1.payloadGPR(), arg1.tagGPR(), arg2.payloadGPR(), arg2.tagGPR(), arg3, arg4);
#endif
}
+
+ 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
+ }
void setupArguments(JSValueRegs arg1)
{
Modified: trunk/Source/_javascript_Core/jit/JIT.h (206288 => 206289)
--- trunk/Source/_javascript_Core/jit/JIT.h 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/jit/JIT.h 2016-09-23 03:50:22 UTC (rev 206289)
@@ -697,10 +697,14 @@
bool isOperandConstantChar(int src);
template <typename Generator, typename ProfiledFunction, typename NonProfiledFunction>
- void emitMathICFast(JITMathIC<Generator>*, Instruction*, ProfiledFunction, NonProfiledFunction);
+ void emitMathICFast(JITUnaryMathIC<Generator>*, Instruction*, ProfiledFunction, NonProfiledFunction);
+ template <typename Generator, typename ProfiledFunction, typename NonProfiledFunction>
+ void emitMathICFast(JITBinaryMathIC<Generator>*, Instruction*, ProfiledFunction, NonProfiledFunction);
template <typename Generator, typename ProfiledRepatchFunction, typename ProfiledFunction, typename RepatchFunction>
- void emitMathICSlow(JITMathIC<Generator>*, Instruction*, ProfiledRepatchFunction, ProfiledFunction, RepatchFunction);
+ 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);
Jump getSlowCase(Vector<SlowCaseEntry>::iterator& iter)
{
@@ -745,6 +749,7 @@
MacroAssembler::Call callOperation(J_JITOperation_EC, int, JSCell*);
MacroAssembler::Call callOperation(V_JITOperation_EC, JSCell*);
MacroAssembler::Call callOperation(J_JITOperation_EJ, int, GPRReg);
+ MacroAssembler::Call callOperation(J_JITOperation_EJ, JSValueRegs, JSValueRegs);
#if USE(JSVALUE64)
MacroAssembler::Call callOperation(J_JITOperation_ESsiJI, int, StructureStubInfo*, GPRReg, UniquedStringImpl*);
MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_ESsiJI, int, StructureStubInfo*, GPRReg, UniquedStringImpl*);
@@ -754,9 +759,11 @@
#endif
MacroAssembler::Call callOperation(J_JITOperation_EJI, int, GPRReg, UniquedStringImpl*);
MacroAssembler::Call callOperation(J_JITOperation_EJJ, int, GPRReg, GPRReg);
+ MacroAssembler::Call callOperation(J_JITOperation_EJArp, JSValueRegs, JSValueRegs, ArithProfile*);
MacroAssembler::Call callOperation(J_JITOperation_EJJArp, JSValueRegs, JSValueRegs, JSValueRegs, ArithProfile*);
MacroAssembler::Call callOperation(J_JITOperation_EJJ, JSValueRegs, JSValueRegs, JSValueRegs);
MacroAssembler::Call callOperation(J_JITOperation_EJJArpMic, JSValueRegs, JSValueRegs, JSValueRegs, ArithProfile*, TrustedImmPtr);
+ MacroAssembler::Call callOperation(J_JITOperation_EJMic, JSValueRegs, JSValueRegs, TrustedImmPtr);
MacroAssembler::Call callOperation(J_JITOperation_EJJMic, JSValueRegs, JSValueRegs, JSValueRegs, TrustedImmPtr);
MacroAssembler::Call callOperation(J_JITOperation_EJJAp, int, GPRReg, GPRReg, ArrayProfile*);
MacroAssembler::Call callOperation(J_JITOperation_EJJBy, int, GPRReg, GPRReg, ByValInfo*);
Modified: trunk/Source/_javascript_Core/jit/JITArithmetic.cpp (206288 => 206289)
--- trunk/Source/_javascript_Core/jit/JITArithmetic.cpp 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/jit/JITArithmetic.cpp 2016-09-23 03:50:22 UTC (rev 206289)
@@ -469,29 +469,9 @@
void JIT::emit_op_negate(Instruction* currentInstruction)
{
- int result = currentInstruction[1].u.operand;
- int src = ""
-
-#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());
+ JITNegIC* negateIC = m_codeBlock->addJITNegIC();
+ m_instructionToMathIC.add(currentInstruction, negateIC);
+ emitMathICFast(negateIC, currentInstruction, operationArithNegateProfiled, operationArithNegate);
}
void JIT::emitSlow_op_negate(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
@@ -498,8 +478,8 @@
{
linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
- JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_negate);
- slowPathCall.call();
+ JITNegIC* negIC = bitwise_cast<JITNegIC*>(m_instructionToMathIC.get(currentInstruction));
+ emitMathICSlow(negIC, currentInstruction, operationArithNegateProfiledOptimize, operationArithNegateProfiled, operationArithNegateOptimize);
}
template<typename SnippetGenerator>
@@ -698,9 +678,58 @@
}
template <typename Generator, typename ProfiledFunction, typename NonProfiledFunction>
-void JIT::emitMathICFast(JITMathIC<Generator>* mathIC, Instruction* currentInstruction, ProfiledFunction profiledFunction, NonProfiledFunction nonProfiledFunction)
+void JIT::emitMathICFast(JITUnaryMathIC<Generator>* mathIC, Instruction* currentInstruction, ProfiledFunction profiledFunction, NonProfiledFunction nonProfiledFunction)
{
int result = currentInstruction[1].u.operand;
+ 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*>(¤tInstruction[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;
int op1 = currentInstruction[2].u.operand;
int op2 = currentInstruction[3].u.operand;
@@ -722,7 +751,7 @@
ArithProfile* arithProfile = nullptr;
if (shouldEmitProfiling())
- arithProfile = &m_codeBlock->arithProfileForPC(currentInstruction);
+ arithProfile = m_codeBlock->arithProfileForPC(currentInstruction);
SnippetOperand leftOperand(types.first());
SnippetOperand rightOperand(types.second());
@@ -774,12 +803,57 @@
}
template <typename Generator, typename ProfiledRepatchFunction, typename ProfiledFunction, typename RepatchFunction>
-void JIT::emitMathICSlow(JITMathIC<Generator>* mathIC, Instruction* currentInstruction, ProfiledRepatchFunction profiledRepatchFunction, ProfiledFunction profiledFunction, RepatchFunction repatchFunction)
+void JIT::emitMathICSlow(JITUnaryMathIC<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;
+
+#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*>(¤tInstruction[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;
int op1 = currentInstruction[2].u.operand;
int op2 = currentInstruction[3].u.operand;
@@ -815,7 +889,7 @@
#endif
if (shouldEmitProfiling()) {
- ArithProfile& arithProfile = m_codeBlock->arithProfileForPC(currentInstruction);
+ ArithProfile& arithProfile = *m_codeBlock->arithProfileForPC(currentInstruction);
if (mathICGenerationState.shouldSlowPathRepatch)
mathICGenerationState.slowPathCall = callOperation(bitwise_cast<J_JITOperation_EJJArpMic>(profiledRepatchFunction), resultRegs, leftRegs, rightRegs, &arithProfile, TrustedImmPtr(mathIC));
else
@@ -862,7 +936,7 @@
ArithProfile* arithProfile = nullptr;
if (shouldEmitProfiling())
- arithProfile = &m_codeBlock->arithProfileForPC(currentInstruction);
+ arithProfile = m_codeBlock->arithProfileForPC(currentInstruction);
SnippetOperand leftOperand(types.first());
SnippetOperand rightOperand(types.second());
Modified: trunk/Source/_javascript_Core/jit/JITInlines.h (206288 => 206289)
--- trunk/Source/_javascript_Core/jit/JITInlines.h 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/jit/JITInlines.h 2016-09-23 03:50:22 UTC (rev 206289)
@@ -416,6 +416,14 @@
return appendCallWithExceptionCheck(operation);
}
+ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJ operation, JSValueRegs result, JSValueRegs arg)
+{
+ setupArgumentsWithExecState(arg);
+ Call call = appendCallWithExceptionCheck(operation);
+ setupResults(result);
+ return call;
+}
+
ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJJ operation, JSValueRegs result, JSValueRegs arg1, JSValueRegs arg2)
{
setupArgumentsWithExecState(arg1, arg2);
@@ -424,6 +432,14 @@
return call;
}
+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;
+}
+
ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJJArp operation, JSValueRegs result, JSValueRegs arg1, JSValueRegs arg2, ArithProfile* arithProfile)
{
setupArgumentsWithExecState(arg1, arg2, TrustedImmPtr(arithProfile));
@@ -440,6 +456,14 @@
return call;
}
+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;
+}
+
ALWAYS_INLINE MacroAssembler::Call JIT::callOperation(J_JITOperation_EJJMic operation, JSValueRegs result, JSValueRegs arg1, JSValueRegs arg2, TrustedImmPtr mathIC)
{
setupArgumentsWithExecState(arg1, arg2, mathIC);
Modified: trunk/Source/_javascript_Core/jit/JITMathIC.h (206288 => 206289)
--- trunk/Source/_javascript_Core/jit/JITMathIC.h 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/jit/JITMathIC.h 2016-09-23 03:50:22 UTC (rev 206289)
@@ -32,6 +32,7 @@
#include "JITAddGenerator.h"
#include "JITMathICInlineResult.h"
#include "JITMulGenerator.h"
+#include "JITNegGenerator.h"
#include "JITSubGenerator.h"
#include "LinkBuffer.h"
#include "Repatch.h"
@@ -52,7 +53,7 @@
#define ENABLE_MATH_IC_STATS 0
-template <typename GeneratorType>
+template <typename GeneratorType, bool(*isProfileEmpty)(ArithProfile*)>
class JITMathIC {
public:
CodeLocationLabel doneLocation() { return m_inlineStart.labelAtOffset(m_inlineSize); }
@@ -72,17 +73,17 @@
size_t startSize = jit.m_assembler.buffer().codeSize();
if (ArithProfile* arithProfile = m_generator.arithProfile()) {
- if (arithProfile->lhsObservedType().isEmpty() || arithProfile->rhsObservedType().isEmpty()) {
+ if (!isProfileEmpty(arithProfile)) {
// It looks like the MathIC has yet to execute. We don't want to emit code in this
// case for a couple reasons. First, the operation may never execute, so if we don't emit
// code, it's a win. Second, if the operation does execute, we can emit better code
- // once we have an idea about the types of lhs and rhs.
+ // once we have an idea about the types.
state.slowPathJumps.append(jit.patchableJump());
size_t inlineSize = jit.m_assembler.buffer().codeSize() - startSize;
ASSERT_UNUSED(inlineSize, static_cast<ptrdiff_t>(inlineSize) <= MacroAssembler::patchableJumpSize());
state.shouldSlowPathRepatch = true;
state.fastPathEnd = jit.label();
- ASSERT(!m_generateFastPathOnRepatch); // We should have gathered some observed type info for lhs and rhs before trying to regenerate again.
+ ASSERT(!m_generateFastPathOnRepatch); // We should have gathered some observed type info about the types before trying to regenerate again.
m_generateFastPathOnRepatch = true;
return true;
}
@@ -243,10 +244,27 @@
GeneratorType m_generator;
};
-typedef JITMathIC<JITAddGenerator> JITAddIC;
-typedef JITMathIC<JITMulGenerator> JITMulIC;
-typedef JITMathIC<JITSubGenerator> JITSubIC;
+inline bool canGenerateWithBinaryProfile(ArithProfile* arithProfile)
+{
+ return !arithProfile->lhsObservedType().isEmpty() && !arithProfile->rhsObservedType().isEmpty();
+}
+template <typename GeneratorType>
+class JITBinaryMathIC : public JITMathIC<GeneratorType, canGenerateWithBinaryProfile> { };
+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;
+
} // namespace JSC
#endif // ENABLE(JIT)
Modified: trunk/Source/_javascript_Core/jit/JITMathICForwards.h (206288 => 206289)
--- trunk/Source/_javascript_Core/jit/JITMathICForwards.h 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/jit/JITMathICForwards.h 2016-09-23 03:50:22 UTC (rev 206289)
@@ -29,14 +29,17 @@
namespace JSC {
-template <typename Generator> class JITMathIC;
+template <typename Generator> class JITBinaryMathIC;
+template <typename Generator> class JITUnaryMathIC;
class JITAddGenerator;
class JITMulGenerator;
+class JITNegGenerator;
class JITSubGenerator;
-typedef JITMathIC<JITAddGenerator> JITAddIC;
-typedef JITMathIC<JITMulGenerator> JITMulIC;
-typedef JITMathIC<JITSubGenerator> JITSubIC;
+typedef JITBinaryMathIC<JITAddGenerator> JITAddIC;
+typedef JITBinaryMathIC<JITMulGenerator> JITMulIC;
+typedef JITUnaryMathIC<JITNegGenerator> JITNegIC;
+typedef JITBinaryMathIC<JITSubGenerator> JITSubIC;
} // namespace JSC
Modified: trunk/Source/_javascript_Core/jit/JITNegGenerator.cpp (206288 => 206289)
--- trunk/Source/_javascript_Core/jit/JITNegGenerator.cpp 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/jit/JITNegGenerator.cpp 2016-09-23 03:50:22 UTC (rev 206289)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,14 +26,63 @@
#include "config.h"
#include "JITNegGenerator.h"
+#include "ArithProfile.h"
+
#if ENABLE(JIT)
namespace JSC {
-void JITNegGenerator::generateFastPath(CCallHelpers& jit)
+JITMathICInlineResult JITNegGenerator::generateInline(CCallHelpers& jit, MathICGenerationState& state)
{
+ ASSERT(m_scratchGPR != InvalidGPRReg);
ASSERT(m_scratchGPR != m_src.payloadGPR());
ASSERT(m_scratchGPR != m_result.payloadGPR());
+#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());
ASSERT(m_scratchGPR != InvalidGPRReg);
#if USE(JSVALUE32_64)
ASSERT(m_scratchGPR != m_src.tagGPR());
@@ -40,23 +89,21 @@
ASSERT(m_scratchGPR != m_result.tagGPR());
#endif
- m_didEmitFastPath = true;
-
jit.moveValueRegs(m_src, m_result);
CCallHelpers::Jump srcNotInt = jit.branchIfNotInt32(m_src);
// -0 should produce a double, and hence cannot be negated as an int.
// The negative int32 0x80000000 doesn't have a positive int32 representation, and hence cannot be negated as an int.
- m_slowPathJumpList.append(jit.branchTest32(CCallHelpers::Zero, m_src.payloadGPR(), CCallHelpers::TrustedImm32(0x7fffffff)));
+ slowPathJumpList.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
- m_endJumpList.append(jit.jump());
+ endJumpList.append(jit.jump());
srcNotInt.link(&jit);
- m_slowPathJumpList.append(jit.branchIfNotNumber(m_src, m_scratchGPR));
+ slowPathJumpList.append(jit.branchIfNotNumber(m_src, m_scratchGPR));
// For a double, all we need to do is to invert the sign bit.
#if USE(JSVALUE64)
@@ -65,6 +112,7 @@
#else
jit.xor32(CCallHelpers::TrustedImm32(1 << 31), m_result.tagGPR());
#endif
+ return true;
}
} // namespace JSC
Modified: trunk/Source/_javascript_Core/jit/JITNegGenerator.h (206288 => 206289)
--- trunk/Source/_javascript_Core/jit/JITNegGenerator.h 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/jit/JITNegGenerator.h 2016-09-23 03:50:22 UTC (rev 206289)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,32 +29,32 @@
#if ENABLE(JIT)
#include "CCallHelpers.h"
-#include "SnippetOperand.h"
+#include "JITMathIC.h"
+#include "JITMathICInlineResult.h"
namespace JSC {
class JITNegGenerator {
public:
- JITNegGenerator(JSValueRegs result, JSValueRegs src, GPRReg scratchGPR)
- : m_result(result)
+ JITNegGenerator() = default;
+
+ JITNegGenerator(JSValueRegs result, JSValueRegs src, GPRReg scratchGPR, ArithProfile& arithProfile)
+ : m_arithProfile(&arithProfile)
+ , m_result(result)
, m_src(src)
, m_scratchGPR(scratchGPR)
{ }
- void generateFastPath(CCallHelpers&);
+ JITMathICInlineResult generateInline(CCallHelpers&, MathICGenerationState&);
+ bool generateFastPath(CCallHelpers&, CCallHelpers::JumpList& endJumpList, CCallHelpers::JumpList& slowPathJumpList, bool shouldEmitProfiling);
- bool didEmitFastPath() const { return m_didEmitFastPath; }
- CCallHelpers::JumpList& endJumpList() { return m_endJumpList; }
- CCallHelpers::JumpList& slowPathJumpList() { return m_slowPathJumpList; }
+ ArithProfile* arithProfile() const { return m_arithProfile; }
private:
+ ArithProfile* m_arithProfile { nullptr };
JSValueRegs m_result;
JSValueRegs m_src;
GPRReg m_scratchGPR;
- bool m_didEmitFastPath { false };
-
- CCallHelpers::JumpList m_endJumpList;
- CCallHelpers::JumpList m_slowPathJumpList;
};
} // namespace JSC
Modified: trunk/Source/_javascript_Core/jit/JITOperations.cpp (206288 => 206289)
--- trunk/Source/_javascript_Core/jit/JITOperations.cpp 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/jit/JITOperations.cpp 2016-09-23 03:50:22 UTC (rev 206289)
@@ -2469,6 +2469,90 @@
return profiledMul(*vm, exec, encodedOp1, encodedOp2, arithProfile);
}
+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));
+}
+
ALWAYS_INLINE static EncodedJSValue unprofiledSub(VM& vm, ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2)
{
auto scope = DECLARE_THROW_SCOPE(vm);
Modified: trunk/Source/_javascript_Core/jit/JITOperations.h (206288 => 206289)
--- trunk/Source/_javascript_Core/jit/JITOperations.h 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/jit/JITOperations.h 2016-09-23 03:50:22 UTC (rev 206289)
@@ -140,6 +140,7 @@
typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJZ)(ExecState*, EncodedJSValue, int32_t);
typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJC)(ExecState*, EncodedJSValue, JSCell*);
typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJA)(ExecState*, EncodedJSValue, JSArray*);
+typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJArp)(ExecState*, EncodedJSValue, ArithProfile*);
typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJI)(ExecState*, EncodedJSValue, UniquedStringImpl*);
typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJJ)(ExecState*, EncodedJSValue, EncodedJSValue);
typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJJJ)(ExecState*, EncodedJSValue, EncodedJSValue, EncodedJSValue);
@@ -149,6 +150,7 @@
typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJJArp)(ExecState*, EncodedJSValue, EncodedJSValue, ArithProfile*);
typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJJArpMic)(ExecState*, EncodedJSValue, EncodedJSValue, ArithProfile*, void*);
typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJJMic)(ExecState*, EncodedJSValue, EncodedJSValue, void*);
+typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJMic)(ExecState*, EncodedJSValue, void*);
typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJssZ)(ExecState*, JSString*, int32_t);
typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJssReo)(ExecState*, JSString*, RegExpObject*);
typedef EncodedJSValue (JIT_OPERATION *J_JITOperation_EJssReoJss)(ExecState*, JSString*, RegExpObject*, JSString*);
@@ -437,6 +439,10 @@
EncodedJSValue JIT_OPERATION operationValueMulProfiledOptimize(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile*, JITMulIC*) WTF_INTERNAL;
EncodedJSValue JIT_OPERATION operationValueMulProfiledNoOptimize(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile*, JITMulIC*) WTF_INTERNAL;
EncodedJSValue JIT_OPERATION operationValueMulProfiled(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile*) WTF_INTERNAL;
+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*);
EncodedJSValue JIT_OPERATION operationValueSub(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) WTF_INTERNAL;
EncodedJSValue JIT_OPERATION operationValueSubProfiled(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, ArithProfile*) WTF_INTERNAL;
EncodedJSValue JIT_OPERATION operationValueSubOptimize(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2, JITSubIC*) WTF_INTERNAL;
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm (206288 => 206289)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2016-09-23 03:50:22 UTC (rev 206289)
@@ -253,7 +253,9 @@
const ShadowChickenTailMarker = 0x7a11
# ArithProfile data
+const ArithProfileInt = 0x100000
const ArithProfileIntInt = 0x120000
+const ArithProfileNumber = 0x200000
const ArithProfileNumberInt = 0x220000
const ArithProfileNumberNumber = 0x240000
const ArithProfileIntNumber = 0x140000
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm (206288 => 206289)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm 2016-09-23 03:50:22 UTC (rev 206289)
@@ -948,22 +948,27 @@
loadi 8[PC], t0
loadi 4[PC], t3
loadConstantOrVariable(t0, t1, t2)
+ loadisFromInstruction(3, t0)
bineq t1, Int32Tag, .opNegateSrcNotInt
btiz t2, 0x7fffffff, .opNegateSlow
negi t2
+ ori ArithProfileInt, t0
storei Int32Tag, TagOffset[cfr, t3, 8]
+ storeisToInstruction(t0, 3)
storei t2, PayloadOffset[cfr, t3, 8]
- dispatch(3)
+ dispatch(4)
.opNegateSrcNotInt:
bia t1, LowestTag, .opNegateSlow
xori 0x80000000, t1
+ ori ArithProfileNumber, t0
+ storei t2, PayloadOffset[cfr, t3, 8]
+ storeisToInstruction(t0, 3)
storei t1, TagOffset[cfr, t3, 8]
- storei t2, PayloadOffset[cfr, t3, 8]
- dispatch(3)
+ dispatch(4)
.opNegateSlow:
callOpcodeSlowPath(_slow_path_negate)
- dispatch(3)
+ dispatch(4)
macro binaryOpCustomStore(integerOperationAndStore, doubleOperation, slowPath)
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm (206288 => 206289)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm 2016-09-23 03:50:22 UTC (rev 206289)
@@ -827,22 +827,27 @@
traceExecution()
loadisFromInstruction(2, t0)
loadisFromInstruction(1, t1)
- loadConstantOrVariable(t0, t2)
- bqb t2, tagTypeNumber, .opNegateNotInt
- btiz t2, 0x7fffffff, .opNegateSlow
- negi t2
- orq tagTypeNumber, t2
- storeq t2, [cfr, t1, 8]
- dispatch(3)
+ 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)
.opNegateNotInt:
- btqz t2, tagTypeNumber, .opNegateSlow
- xorq 0x8000000000000000, t2
- storeq t2, [cfr, t1, 8]
- dispatch(3)
+ btqz t3, tagTypeNumber, .opNegateSlow
+ xorq 0x8000000000000000, t3
+ ori ArithProfileNumber, t2
+ storeq t3, [cfr, t1, 8]
+ storeisToInstruction(t2, 3)
+ dispatch(4)
.opNegateSlow:
callOpcodeSlowPath(_slow_path_negate)
- dispatch(3)
+ dispatch(4)
macro binaryOpCustomStore(integerOperationAndStore, doubleOperation, slowPath)
Modified: trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp (206288 => 206289)
--- trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp 2016-09-23 02:10:59 UTC (rev 206288)
+++ trunk/Source/_javascript_Core/runtime/CommonSlowPaths.cpp 2016-09-23 03:50:22 UTC (rev 206289)
@@ -350,10 +350,44 @@
RETURN(OP_C(2).jsValue().toString(exec));
}
+#if ENABLE(JIT)
+static void updateArithProfileForUnaryArithOp(Instruction* pc, JSValue result, JSValue operand)
+{
+ ArithProfile& profile = ""
+ 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
+
SLOW_PATH_DECL(slow_path_negate)
{
BEGIN();
- RETURN(jsNumber(-OP_C(2).jsValue().toNumber(exec)));
+ JSValue operand = OP_C(2).jsValue();
+ JSValue result = jsNumber(-operand.toNumber(exec));
+ RETURN_WITH_PROFILING(result, {
+ updateArithProfileForUnaryArithOp(pc, result, operand);
+ });
}
#if ENABLE(DFG_JIT)
@@ -360,7 +394,7 @@
static void updateArithProfileForBinaryArithOp(ExecState* exec, Instruction* pc, JSValue result, JSValue left, JSValue right)
{
CodeBlock* codeBlock = exec->codeBlock();
- ArithProfile& profile = ""
+ ArithProfile& profile = ""
if (result.isNumber()) {
if (!result.isInt32()) {
@@ -404,7 +438,7 @@
JSValue v2 = OP_C(3).jsValue();
JSValue result;
- ArithProfile& arithProfile = exec->codeBlock()->arithProfileForPC(pc);
+ ArithProfile& arithProfile = *exec->codeBlock()->arithProfileForPC(pc);
arithProfile.observeLHSAndRHS(v1, v2);
if (v1.isString() && !v2.isObject())