Make byte codes with arithmetic profiles switch to using an index instead of a pointer in metadata
https://bugs.webkit.org/show_bug.cgi?id=230798
Reviewed by Yusuke Suzuki.
This patch makes each bytecode that uses a BinaryArithProfile/UnaryArithProfile
have an index into a table instead of storing a pointer to the profile in its metadata.
Then, we can just load the profile using the index in the bytecode, which saves memory.
* bytecode/BytecodeList.rb:
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::finishCreation):
(JSC::CodeBlock::binaryArithProfileForPC):
(JSC::CodeBlock::unaryArithProfileForPC):
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedCodeBlock::allocateSharedProfiles):
* bytecode/UnlinkedCodeBlock.h:
* bytecode/UnlinkedCodeBlockGenerator.cpp:
(JSC::UnlinkedCodeBlockGenerator::finalize):
* bytecode/UnlinkedCodeBlockGenerator.h:
(JSC::UnlinkedCodeBlockGenerator::addBinaryArithProfile):
(JSC::UnlinkedCodeBlockGenerator::addUnaryArithProfile):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitUnaryOp):
(JSC::BytecodeGenerator::emitInc):
(JSC::BytecodeGenerator::emitDec):
* bytecompiler/BytecodeGenerator.h:
* jit/JITArithmetic.cpp:
(JSC::JIT::emit_op_negate):
(JSC::JIT::emit_op_add):
(JSC::JIT::emit_op_div):
(JSC::JIT::emit_op_mul):
(JSC::JIT::emit_op_sub):
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:
* runtime/CommonSlowPaths.cpp:
(JSC::updateArithProfileForUnaryArithOp):
(JSC::JSC_DEFINE_COMMON_SLOW_PATH):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@283168 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 7bf5ff6..b6fa366 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,45 @@
+2021-09-28 Saam Barati <sbarati@apple.com>
+
+ Make byte codes with arithmetic profiles switch to using an index instead of a pointer in metadata
+ https://bugs.webkit.org/show_bug.cgi?id=230798
+
+ Reviewed by Yusuke Suzuki.
+
+ This patch makes each bytecode that uses a BinaryArithProfile/UnaryArithProfile
+ have an index into a table instead of storing a pointer to the profile in its metadata.
+ Then, we can just load the profile using the index in the bytecode, which saves memory.
+
+ * bytecode/BytecodeList.rb:
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::finishCreation):
+ (JSC::CodeBlock::binaryArithProfileForPC):
+ (JSC::CodeBlock::unaryArithProfileForPC):
+ * bytecode/UnlinkedCodeBlock.cpp:
+ (JSC::UnlinkedCodeBlock::allocateSharedProfiles):
+ * bytecode/UnlinkedCodeBlock.h:
+ * bytecode/UnlinkedCodeBlockGenerator.cpp:
+ (JSC::UnlinkedCodeBlockGenerator::finalize):
+ * bytecode/UnlinkedCodeBlockGenerator.h:
+ (JSC::UnlinkedCodeBlockGenerator::addBinaryArithProfile):
+ (JSC::UnlinkedCodeBlockGenerator::addUnaryArithProfile):
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::emitUnaryOp):
+ (JSC::BytecodeGenerator::emitInc):
+ (JSC::BytecodeGenerator::emitDec):
+ * bytecompiler/BytecodeGenerator.h:
+ * jit/JITArithmetic.cpp:
+ (JSC::JIT::emit_op_negate):
+ (JSC::JIT::emit_op_add):
+ (JSC::JIT::emit_op_div):
+ (JSC::JIT::emit_op_mul):
+ (JSC::JIT::emit_op_sub):
+ * llint/LowLevelInterpreter.asm:
+ * llint/LowLevelInterpreter32_64.asm:
+ * llint/LowLevelInterpreter64.asm:
+ * runtime/CommonSlowPaths.cpp:
+ (JSC::updateArithProfileForUnaryArithOp):
+ (JSC::JSC_DEFINE_COMMON_SLOW_PATH):
+
2021-09-28 Alexey Shvayka <shvaikalesh@gmail.com>
Speed up setting JSFunction's "prototype" property
diff --git a/Source/JavaScriptCore/bytecode/BytecodeList.rb b/Source/JavaScriptCore/bytecode/BytecodeList.rb
index 1b88d0e..8cc5515 100644
--- a/Source/JavaScriptCore/bytecode/BytecodeList.rb
+++ b/Source/JavaScriptCore/bytecode/BytecodeList.rb
@@ -64,8 +64,6 @@
:ValueProfile,
:ValueProfileAndVirtualRegisterBuffer,
- :UnaryArithProfile,
- :BinaryArithProfile,
:ArrayProfile,
:ArrayAllocationProfile,
:ObjectAllocationProfile,
@@ -289,10 +287,8 @@
dst: VirtualRegister,
lhs: VirtualRegister,
rhs: VirtualRegister,
+ profileIndex: unsigned,
operandTypes: OperandTypes,
- },
- metadata: {
- arithProfile: BinaryArithProfile.*
}
op_group :ValueProfiledBinaryOp,
@@ -351,9 +347,7 @@
],
args: {
srcDst: VirtualRegister,
- },
- metadata: {
- arithProfile: UnaryArithProfile.*
+ profileIndex: unsigned,
}
op :to_object,
@@ -383,10 +377,8 @@
args: {
dst: VirtualRegister,
operand: VirtualRegister,
+ profileIndex: unsigned,
resultType: ResultType,
- },
- metadata: {
- arithProfile: UnaryArithProfile.*
}
op :not,
diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp
index 83332e9..027b0aa 100644
--- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp
+++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp
@@ -471,21 +471,6 @@
break; \
}
- unsigned binaryProfileIndex = 0;
- unsigned unaryProfileIndex = 0;
-#define LINK_WITH_BINARY_ARITH_PROFILE(__op) \
- CASE(__op): { \
- INITIALIZE_METADATA(__op) \
- metadata.m_arithProfile = &m_unlinkedCode->binaryArithProfile(binaryProfileIndex++); \
- break; \
- }
-#define LINK_WITH_UNARY_ARITH_PROFILE(__op) \
- CASE(__op): { \
- INITIALIZE_METADATA(__op) \
- metadata.m_arithProfile = &m_unlinkedCode->unaryArithProfile(unaryProfileIndex++); \
- break; \
- }
-
const InstructionStream& instructionStream = instructions();
for (const auto& instruction : instructionStream) {
OpcodeID opcodeID = instruction->opcodeID();
@@ -548,15 +533,6 @@
LINK(OpCreatePromise)
LINK(OpCreateGenerator)
- LINK_WITH_BINARY_ARITH_PROFILE(OpAdd)
- LINK_WITH_BINARY_ARITH_PROFILE(OpMul)
- LINK_WITH_BINARY_ARITH_PROFILE(OpDiv)
- LINK_WITH_BINARY_ARITH_PROFILE(OpSub)
-
- LINK_WITH_UNARY_ARITH_PROFILE(OpNegate)
- LINK_WITH_UNARY_ARITH_PROFILE(OpInc)
- LINK_WITH_UNARY_ARITH_PROFILE(OpDec)
-
LINK(OpJneqPtr)
LINK(OpCatch)
@@ -3413,13 +3389,13 @@
{
switch (pc->opcodeID()) {
case op_add:
- return pc->as<OpAdd>().metadata(this).m_arithProfile;
+ return &unlinkedCodeBlock()->binaryArithProfile(pc->as<OpAdd>().m_profileIndex);
case op_mul:
- return pc->as<OpMul>().metadata(this).m_arithProfile;
+ return &unlinkedCodeBlock()->binaryArithProfile(pc->as<OpMul>().m_profileIndex);
case op_sub:
- return pc->as<OpSub>().metadata(this).m_arithProfile;
+ return &unlinkedCodeBlock()->binaryArithProfile(pc->as<OpSub>().m_profileIndex);
case op_div:
- return pc->as<OpDiv>().metadata(this).m_arithProfile;
+ return &unlinkedCodeBlock()->binaryArithProfile(pc->as<OpDiv>().m_profileIndex);
default:
break;
}
@@ -3431,11 +3407,11 @@
{
switch (pc->opcodeID()) {
case op_negate:
- return pc->as<OpNegate>().metadata(this).m_arithProfile;
+ return &unlinkedCodeBlock()->unaryArithProfile(pc->as<OpNegate>().m_profileIndex);
case op_inc:
- return pc->as<OpInc>().metadata(this).m_arithProfile;
+ return &unlinkedCodeBlock()->unaryArithProfile(pc->as<OpInc>().m_profileIndex);
case op_dec:
- return pc->as<OpDec>().metadata(this).m_arithProfile;
+ return &unlinkedCodeBlock()->unaryArithProfile(pc->as<OpDec>().m_profileIndex);
default:
break;
}
diff --git a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
index 7afdcff..8caa2b1 100644
--- a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
+++ b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
@@ -361,7 +361,7 @@
}
-void UnlinkedCodeBlock::allocateSharedProfiles()
+void UnlinkedCodeBlock::allocateSharedProfiles(unsigned numBinaryArithProfiles, unsigned numUnaryArithProfiles)
{
RELEASE_ASSERT(!m_metadata->isFinalized());
@@ -389,19 +389,10 @@
numberOfArrayProfiles += m_metadata->numEntries<OpIteratorNext>();
numberOfArrayProfiles += m_metadata->numEntries<OpGetById>();
m_arrayProfiles = FixedVector<UnlinkedArrayProfile>(numberOfArrayProfiles);
-
- unsigned numberOfBinaryArithProfiles = 0;
-#define COUNT(__op) numberOfBinaryArithProfiles += m_metadata->numEntries<__op>();
- FOR_EACH_OPCODE_WITH_BINARY_ARITH_PROFILE(COUNT)
-#undef COUNT
- m_binaryArithProfiles = FixedVector<BinaryArithProfile>(numberOfBinaryArithProfiles);
-
- unsigned numberOfUnaryArithProfiles = 0;
-#define COUNT(__op) numberOfUnaryArithProfiles += m_metadata->numEntries<__op>();
- FOR_EACH_OPCODE_WITH_UNARY_ARITH_PROFILE(COUNT)
-#undef COUNT
- m_unaryArithProfiles = FixedVector<UnaryArithProfile>(numberOfUnaryArithProfiles);
}
+
+ m_binaryArithProfiles = FixedVector<BinaryArithProfile>(numBinaryArithProfiles);
+ m_unaryArithProfiles = FixedVector<UnaryArithProfile>(numUnaryArithProfiles);
}
} // namespace JSC
diff --git a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
index da0615f..ca8728b 100644
--- a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
+++ b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
@@ -352,7 +352,7 @@
// Some builtins are required to always complete the loops they run.
return !isBuiltinFunction();
}
- void allocateSharedProfiles();
+ void allocateSharedProfiles(unsigned numBinaryArithProfiles, unsigned numUnaryArithProfiles);
UnlinkedValueProfile& unlinkedValueProfile(unsigned index) { return m_valueProfiles[index]; }
UnlinkedArrayProfile& unlinkedArrayProfile(unsigned index) { return m_arrayProfiles[index]; }
diff --git a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.cpp b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.cpp
index 3b71a80..3c4b3d3 100644
--- a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.cpp
+++ b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.cpp
@@ -119,7 +119,7 @@
{
Locker locker { m_codeBlock->cellLock() };
m_codeBlock->m_instructions = WTFMove(instructions);
- m_codeBlock->allocateSharedProfiles();
+ m_codeBlock->allocateSharedProfiles(m_numBinaryArithProfiles, m_numUnaryArithProfiles);
m_codeBlock->m_metadata->finalize();
m_codeBlock->m_jumpTargets = WTFMove(m_jumpTargets);
diff --git a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.h b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.h
index ce330d6..60a3541 100644
--- a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.h
+++ b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.h
@@ -200,6 +200,9 @@
void dump(PrintStream&) const;
+ unsigned addBinaryArithProfile() { return m_numBinaryArithProfiles++; }
+ unsigned addUnaryArithProfile() { return m_numUnaryArithProfiles++; }
+
private:
VM& m_vm;
Strong<UnlinkedCodeBlock> m_codeBlock;
@@ -221,6 +224,8 @@
Vector<InstructionStream::Offset> m_opProfileControlFlowBytecodeOffsets;
Vector<BitVector> m_bitVectors;
Vector<IdentifierSet> m_constantIdentifierSets;
+ unsigned m_numBinaryArithProfiles { 0 };
+ unsigned m_numUnaryArithProfiles { 0 };
};
} // namespace JSC
diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
index 01f4057..d7258b06 100644
--- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
+++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
@@ -1609,7 +1609,7 @@
emitUnaryOp<OpNot>(dst, src);
break;
case op_negate:
- OpNegate::emit(this, dst, src, type);
+ OpNegate::emit(this, dst, src, m_codeBlock->addUnaryArithProfile(), type);
break;
case op_bitnot:
emitUnaryOp<OpBitnot>(dst, src);
@@ -1707,13 +1707,13 @@
RegisterID* BytecodeGenerator::emitInc(RegisterID* srcDst)
{
- OpInc::emit(this, srcDst);
+ OpInc::emit(this, srcDst, m_codeBlock->addUnaryArithProfile());
return srcDst;
}
RegisterID* BytecodeGenerator::emitDec(RegisterID* srcDst)
{
- OpDec::emit(this, srcDst);
+ OpDec::emit(this, srcDst, m_codeBlock->addUnaryArithProfile());
return srcDst;
}
diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
index 01177af..277b155 100644
--- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
+++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
@@ -682,7 +682,7 @@
RegisterID*>
emitBinaryOp(RegisterID* dst, RegisterID* src1, RegisterID* src2, OperandTypes types)
{
- BinaryOp::emit(this, dst, src1, src2, types);
+ BinaryOp::emit(this, dst, src1, src2, m_codeBlock->addBinaryArithProfile(), types);
return dst;
}
diff --git a/Source/JavaScriptCore/jit/JITArithmetic.cpp b/Source/JavaScriptCore/jit/JITArithmetic.cpp
index b9d0b37..8f1a7c5 100644
--- a/Source/JavaScriptCore/jit/JITArithmetic.cpp
+++ b/Source/JavaScriptCore/jit/JITArithmetic.cpp
@@ -722,7 +722,7 @@
void JIT::emit_op_negate(const Instruction* currentInstruction)
{
- UnaryArithProfile* arithProfile = currentInstruction->as<OpNegate>().metadata(m_profiledCodeBlock).m_arithProfile;
+ UnaryArithProfile* arithProfile = &m_unlinkedCodeBlock->unaryArithProfile(currentInstruction->as<OpNegate>().m_profileIndex);
JITNegIC* negateIC = m_mathICs.addJITNegIC(arithProfile);
m_instructionToMathIC.add(currentInstruction, negateIC);
// FIXME: it would be better to call those operationValueNegate, since the operand can be a BigInt
@@ -904,7 +904,7 @@
void JIT::emit_op_add(const Instruction* currentInstruction)
{
- BinaryArithProfile* arithProfile = currentInstruction->as<OpAdd>().metadata(m_profiledCodeBlock).m_arithProfile;
+ BinaryArithProfile* arithProfile = &m_unlinkedCodeBlock->binaryArithProfile(currentInstruction->as<OpAdd>().m_profileIndex);
JITAddIC* addIC = m_mathICs.addJITAddIC(arithProfile);
m_instructionToMathIC.add(currentInstruction, addIC);
emitMathICFast<OpAdd>(addIC, currentInstruction, operationValueAddProfiled, operationValueAdd);
@@ -1175,7 +1175,7 @@
BinaryArithProfile* arithProfile = nullptr;
if (shouldEmitProfiling())
- arithProfile = currentInstruction->as<OpDiv>().metadata(m_profiledCodeBlock).m_arithProfile;
+ arithProfile = &m_unlinkedCodeBlock->binaryArithProfile(currentInstruction->as<OpDiv>().m_profileIndex);
SnippetOperand leftOperand(bytecode.m_operandTypes.first());
SnippetOperand rightOperand(bytecode.m_operandTypes.second());
@@ -1220,7 +1220,7 @@
void JIT::emit_op_mul(const Instruction* currentInstruction)
{
- BinaryArithProfile* arithProfile = currentInstruction->as<OpMul>().metadata(m_profiledCodeBlock).m_arithProfile;
+ BinaryArithProfile* arithProfile = &m_unlinkedCodeBlock->binaryArithProfile(currentInstruction->as<OpMul>().m_profileIndex);
JITMulIC* mulIC = m_mathICs.addJITMulIC(arithProfile);
m_instructionToMathIC.add(currentInstruction, mulIC);
emitMathICFast<OpMul>(mulIC, currentInstruction, operationValueMulProfiled, operationValueMul);
@@ -1236,7 +1236,7 @@
void JIT::emit_op_sub(const Instruction* currentInstruction)
{
- BinaryArithProfile* arithProfile = currentInstruction->as<OpSub>().metadata(m_profiledCodeBlock).m_arithProfile;
+ BinaryArithProfile* arithProfile = &m_unlinkedCodeBlock->binaryArithProfile(currentInstruction->as<OpSub>().m_profileIndex);
JITSubIC* subIC = m_mathICs.addJITSubIC(arithProfile);
m_instructionToMathIC.add(currentInstruction, subIC);
emitMathICFast<OpSub>(subIC, currentInstruction, operationValueSubProfiled, operationValueSub);
diff --git a/Source/JavaScriptCore/llint/LowLevelInterpreter.asm b/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
index de6a82d..70d52fc 100644
--- a/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
+++ b/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
@@ -2566,14 +2566,20 @@
end
-macro updateUnaryArithProfile(opcodeStruct, type, metadata, temp)
- loadp %opcodeStruct%::Metadata::m_arithProfile[metadata], temp
- orh type, UnaryArithProfile::m_bits[temp]
+macro updateUnaryArithProfile(size, opcodeStruct, type, scratch1, scratch2)
+ getu(size, opcodeStruct, m_profileIndex, scratch1)
+ loadp CodeBlock[cfr], scratch2
+ loadp CodeBlock::m_unlinkedCode[scratch2], scratch2
+ loadp UnlinkedCodeBlock::m_unaryArithProfiles + FixedVector::m_storage + RefCountedArray::m_data[scratch2], scratch2
+ orh type, UnaryArithProfile::m_bits[scratch2, scratch1, 2]
end
-macro updateBinaryArithProfile(opcodeStruct, type, metadata, temp)
- loadp %opcodeStruct%::Metadata::m_arithProfile[metadata], temp
- orh type, BinaryArithProfile::m_bits[temp]
+macro updateBinaryArithProfile(size, opcodeStruct, type, scratch1, scratch2)
+ getu(size, opcodeStruct, m_profileIndex, scratch1)
+ loadp CodeBlock[cfr], scratch2
+ loadp CodeBlock::m_unlinkedCode[scratch2], scratch2
+ loadp UnlinkedCodeBlock::m_binaryArithProfiles + FixedVector::m_storage + RefCountedArray::m_data[scratch2], scratch2
+ orh type, BinaryArithProfile::m_bits[scratch2, scratch1, 2]
end
// FIXME: We should not need the X86_64_WIN condition here, since WEBASSEMBLY should already be false on Windows
diff --git a/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm b/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
index 5806a9e..f3d97ca 100644
--- a/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
+++ b/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
@@ -1012,14 +1012,13 @@
macro preOp(opcodeName, opcodeStruct, integerOperation)
llintOpWithMetadata(op_%opcodeName%, opcodeStruct, macro (size, get, dispatch, metadata, return)
- metadata(t1, t2)
get(m_srcDst, t0)
bineq TagOffset[cfr, t0, 8], Int32Tag, .slow
loadi PayloadOffset[cfr, t0, 8], t2
- # Metadata in t1, srcDst in t2
+ # srcDst in t2
integerOperation(t2, .slow)
storei t2, PayloadOffset[cfr, t0, 8]
- updateUnaryArithProfile(opcodeStruct, ArithProfileInt, t1, t2)
+ updateUnaryArithProfile(size, opcodeStruct, ArithProfileInt, t5, t2)
dispatch()
.slow:
@@ -1084,19 +1083,17 @@
llintOpWithMetadata(op_negate, OpNegate, macro (size, get, dispatch, metadata, return)
-
- metadata(t5, t0)
get(m_operand, t0)
loadConstantOrVariable(size, t0, t1, t2)
bineq t1, Int32Tag, .opNegateSrcNotInt
btiz t2, 0x7fffffff, .opNegateSlow
negi t2
- updateUnaryArithProfile(OpNegate, ArithProfileInt, t5, t3)
+ updateUnaryArithProfile(size, OpNegate, ArithProfileInt, t0, t3)
return (Int32Tag, t2)
.opNegateSrcNotInt:
bia t1, LowestTag, .opNegateSlow
xori 0x80000000, t1
- updateUnaryArithProfile(OpNegate, ArithProfileNumber, t5, t3)
+ updateUnaryArithProfile(size, OpNegate, ArithProfileNumber, t0, t3)
return(t1, t2)
.opNegateSlow:
@@ -1107,14 +1104,13 @@
macro binaryOpCustomStore(opcodeName, opcodeStruct, integerOperationAndStore, doubleOperation)
llintOpWithMetadata(op_%opcodeName%, opcodeStruct, macro (size, get, dispatch, metadata, return)
- metadata(t5, t2)
get(m_rhs, t2)
get(m_lhs, t0)
loadConstantOrVariable(size, t2, t3, t1)
loadConstantOrVariable2Reg(size, t0, t2, t0)
bineq t2, Int32Tag, .op1NotInt
bineq t3, Int32Tag, .op2NotInt
- updateBinaryArithProfile(opcodeStruct, ArithProfileIntInt, t5, t2)
+ updateBinaryArithProfile(size, opcodeStruct, ArithProfileIntInt, t5, t2)
get(m_dst, t2)
integerOperationAndStore(t3, t1, t0, .slow, t2)
dispatch()
@@ -1124,12 +1120,12 @@
bia t2, LowestTag, .slow
bib t3, LowestTag, .op1NotIntOp2Double
bineq t3, Int32Tag, .slow
- updateBinaryArithProfile(opcodeStruct, ArithProfileNumberInt, t5, t4)
+ updateBinaryArithProfile(size, opcodeStruct, ArithProfileNumberInt, t5, t4)
ci2ds t1, ft1
jmp .op1NotIntReady
.op1NotIntOp2Double:
fii2d t1, t3, ft1
- updateBinaryArithProfile(opcodeStruct, ArithProfileNumberNumber, t5, t4)
+ updateBinaryArithProfile(size, opcodeStruct, ArithProfileNumberNumber, t5, t4)
.op1NotIntReady:
get(m_dst, t1)
fii2d t0, t2, ft0
@@ -1141,7 +1137,7 @@
# First operand is definitely an int, the second operand is definitely not.
get(m_dst, t2)
bia t3, LowestTag, .slow
- updateBinaryArithProfile(opcodeStruct, ArithProfileIntNumber, t5, t4)
+ updateBinaryArithProfile(size, opcodeStruct, ArithProfileIntNumber, t5, t4)
ci2ds t0, ft0
fii2d t1, t3, ft1
doubleOperation(ft1, ft0)
diff --git a/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm b/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
index 0f55ca7..4ba0ee2 100644
--- a/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
+++ b/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
@@ -1078,14 +1078,13 @@
llintOpWithMetadata(op_%opcodeName%, opcodeStruct, macro (size, get, dispatch, metadata, return)
get(m_srcDst, t0)
loadq [cfr, t0, 8], t1
- metadata(t2, t3)
- # srcDst in t1, metadata in t2
+ # srcDst in t1
# FIXME: the next line jumps to the slow path for BigInt32. We could instead have a dedicated path in here for them.
bqb t1, numberTag, .slow
integerOperation(t1, .slow)
orq numberTag, t1
storeq t1, [cfr, t0, 8]
- updateUnaryArithProfile(opcodeStruct, ArithProfileInt, t2, t3)
+ updateUnaryArithProfile(size, opcodeStruct, ArithProfileInt, t5, t3)
dispatch()
.slow:
@@ -1152,17 +1151,16 @@
llintOpWithMetadata(op_negate, OpNegate, macro (size, get, dispatch, metadata, return)
get(m_operand, t0)
loadConstantOrVariable(size, t0, t3)
- metadata(t1, t2)
bqb t3, numberTag, .opNegateNotInt
btiz t3, 0x7fffffff, .opNegateSlow
negi t3
orq numberTag, t3
- updateUnaryArithProfile(OpNegate, ArithProfileInt, t1, t2)
+ updateUnaryArithProfile(size, OpNegate, ArithProfileInt, t1, t2)
return(t3)
.opNegateNotInt:
btqz t3, numberTag, .opNegateSlow
xorq 0x8000000000000000, t3
- updateUnaryArithProfile(OpNegate, ArithProfileNumber, t1, t2)
+ updateUnaryArithProfile(size, OpNegate, ArithProfileNumber, t1, t2)
return(t3)
.opNegateSlow:
@@ -1173,8 +1171,6 @@
macro binaryOpCustomStore(opcodeName, opcodeStruct, integerOperationAndStore, doubleOperation)
llintOpWithMetadata(op_%opcodeName%, opcodeStruct, macro (size, get, dispatch, metadata, return)
- metadata(t5, t0)
-
get(m_rhs, t0)
get(m_lhs, t2)
loadConstantOrVariable(size, t0, t1)
@@ -1184,7 +1180,7 @@
get(m_dst, t2)
integerOperationAndStore(t1, t0, .slow, t2)
- updateBinaryArithProfile(opcodeStruct, ArithProfileIntInt, t5, t2)
+ updateBinaryArithProfile(size, opcodeStruct, ArithProfileIntInt, t5, t2)
dispatch()
.op1NotInt:
@@ -1194,10 +1190,10 @@
btqz t1, numberTag, .slow
addq numberTag, t1
fq2d t1, ft1
- updateBinaryArithProfile(opcodeStruct, ArithProfileNumberNumber, t5, t2)
+ updateBinaryArithProfile(size, opcodeStruct, ArithProfileNumberNumber, t5, t2)
jmp .op1NotIntReady
.op1NotIntOp2Int:
- updateBinaryArithProfile(opcodeStruct, ArithProfileNumberInt, t5, t2)
+ updateBinaryArithProfile(size, opcodeStruct, ArithProfileNumberInt, t5, t2)
ci2ds t1, ft1
.op1NotIntReady:
get(m_dst, t2)
@@ -1212,7 +1208,7 @@
.op2NotInt:
# First operand is definitely an int, the second is definitely not.
btqz t1, numberTag, .slow
- updateBinaryArithProfile(opcodeStruct, ArithProfileIntNumber, t5, t2)
+ updateBinaryArithProfile(size, opcodeStruct, ArithProfileIntNumber, t5, t2)
get(m_dst, t2)
ci2ds t0, ft0
addq numberTag, t1
diff --git a/Source/JavaScriptCore/offlineasm/cloop.rb b/Source/JavaScriptCore/offlineasm/cloop.rb
index 641f7d2..b1ce550 100644
--- a/Source/JavaScriptCore/offlineasm/cloop.rb
+++ b/Source/JavaScriptCore/offlineasm/cloop.rb
@@ -259,9 +259,11 @@
case type
when :int8; int8MemRef
when :int32; int32MemRef
+ when :int16; int16MemRef
when :int64; int64MemRef
when :intptr; intptrMemRef
when :uint8; uint8MemRef
+ when :uint16; uint16MemRef
when :uint32; uint32MemRef
when :uint64; uint64MemRef
when :uintptr; uintptrMemRef
diff --git a/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp b/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
index b0a666d..c18cf33 100644
--- a/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
+++ b/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
@@ -478,9 +478,8 @@
}
#if ENABLE(JIT)
-static void updateArithProfileForUnaryArithOp(OpNegate::Metadata& metadata, JSValue result, JSValue operand)
+static void updateArithProfileForUnaryArithOp(UnaryArithProfile& profile, JSValue result, JSValue operand)
{
- UnaryArithProfile& profile = *metadata.m_arithProfile;
profile.observeArg(operand);
ASSERT(result.isNumber() || result.isBigInt());
@@ -514,24 +513,25 @@
}
}
#else
-static void updateArithProfileForUnaryArithOp(OpNegate::Metadata&, JSValue, JSValue) { }
+static void updateArithProfileForUnaryArithOp(UnaryArithProfile&, JSValue, JSValue) { }
#endif
JSC_DEFINE_COMMON_SLOW_PATH(slow_path_negate)
{
BEGIN();
auto bytecode = pc->as<OpNegate>();
- auto& metadata = bytecode.metadata(codeBlock);
JSValue operand = GET_C(bytecode.m_operand).jsValue();
JSValue primValue = operand.toPrimitive(globalObject, PreferNumber);
CHECK_EXCEPTION();
+ auto& profile = codeBlock->unlinkedCodeBlock()->unaryArithProfile(bytecode.m_profileIndex);
+
#if USE(BIGINT32)
if (primValue.isBigInt32()) {
JSValue result = JSBigInt::unaryMinus(globalObject, primValue.bigInt32AsInt32());
CHECK_EXCEPTION();
RETURN_WITH_PROFILING(result, {
- updateArithProfileForUnaryArithOp(metadata, result, operand);
+ updateArithProfileForUnaryArithOp(profile, result, operand);
});
}
#endif
@@ -540,14 +540,14 @@
JSValue result = JSBigInt::unaryMinus(globalObject, primValue.asHeapBigInt());
CHECK_EXCEPTION();
RETURN_WITH_PROFILING(result, {
- updateArithProfileForUnaryArithOp(metadata, result, operand);
+ updateArithProfileForUnaryArithOp(profile, result, operand);
});
}
JSValue result = jsNumber(-primValue.toNumber(globalObject));
CHECK_EXCEPTION();
RETURN_WITH_PROFILING(result, {
- updateArithProfileForUnaryArithOp(metadata, result, operand);
+ updateArithProfileForUnaryArithOp(profile, result, operand);
});
}