Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (229814 => 229815)
--- trunk/Source/_javascript_Core/ChangeLog 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-03-21 18:23:30 UTC (rev 229815)
@@ -1,3 +1,74 @@
+2018-03-21 Mark Lam <[email protected]>
+
+ Use CodeBlock::instructions()[] and CodeBlock::bytecodeOffset() instead of doing own pointer math.
+ https://bugs.webkit.org/show_bug.cgi?id=183857
+ <rdar://problem/38712184>
+
+ Reviewed by JF Bastien.
+
+ We should avoid doing pointer math with CodeBlock::instructions().begin().
+ Instead, we should use the operator[] that comes with CodeBlock::instructions()
+ for computing an Instruction*, and use CodeBlock::bytecodeOffset() for computing
+ the bytecode offset of a given Instruction*. These methods will do assertions
+ which helps catch bugs sooner, plus they are more descriptive of the operation
+ we're trying to do.
+
+ * bytecode/BytecodeKills.h:
+ (JSC::BytecodeKills::operandIsKilled const):
+ (JSC::BytecodeKills::forEachOperandKilledAt const):
+ * bytecode/CallLinkStatus.cpp:
+ (JSC::CallLinkStatus::computeFromLLInt):
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::dumpBytecode):
+ (JSC::CodeBlock::arithProfileForBytecodeOffset):
+ (JSC::CodeBlock::bytecodeOffsetFromCallSiteIndex):
+ * bytecode/GetByIdStatus.cpp:
+ (JSC::GetByIdStatus::computeFromLLInt):
+ * bytecode/PutByIdStatus.cpp:
+ (JSC::PutByIdStatus::computeFromLLInt):
+ * dfg/DFGByteCodeParser.cpp:
+ (JSC::DFG::ByteCodeParser::getPredictionWithoutOSRExit):
+ * dfg/DFGOSRExit.cpp:
+ (JSC::DFG::reifyInlinedCallFrames):
+ * dfg/DFGOSRExitCompilerCommon.cpp:
+ (JSC::DFG::reifyInlinedCallFrames):
+ * interpreter/CallFrame.cpp:
+ (JSC::CallFrame::callSiteBitsAsBytecodeOffset const):
+ (JSC::CallFrame::currentVPC const):
+ (JSC::CallFrame::setCurrentVPC):
+ * jit/JITCall.cpp:
+ (JSC::JIT::compileOpCall):
+ * jit/JITInlines.h:
+ (JSC::JIT::updateTopCallFrame):
+ (JSC::JIT::copiedInstruction):
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::privateCompileHasIndexedProperty):
+ * jit/JITOpcodes32_64.cpp:
+ (JSC::JIT::privateCompileHasIndexedProperty):
+ * jit/JITPropertyAccess.cpp:
+ (JSC::JIT::privateCompileGetByVal):
+ (JSC::JIT::privateCompileGetByValWithCachedId):
+ (JSC::JIT::privateCompilePutByVal):
+ (JSC::JIT::privateCompilePutByValWithCachedId):
+ * jit/SlowPathCall.h:
+ (JSC::JITSlowPathCall::call):
+ * llint/LLIntSlowPaths.cpp:
+ (JSC::LLInt::llint_trace_operand):
+ (JSC::LLInt::llint_trace_value):
+ (JSC::LLInt::LLINT_SLOW_PATH_DECL):
+ (JSC::LLInt::setupGetByIdPrototypeCache): Deleted.
+ (JSC::LLInt::getByVal): Deleted.
+ (JSC::LLInt::handleHostCall): Deleted.
+ (JSC::LLInt::setUpCall): Deleted.
+ (JSC::LLInt::genericCall): Deleted.
+ (JSC::LLInt::varargsSetup): Deleted.
+ (JSC::LLInt::llint_throw_stack_overflow_error): Deleted.
+ (JSC::LLInt::llint_stack_check_at_vm_entry): Deleted.
+ (JSC::LLInt::llint_write_barrier_slow): Deleted.
+ (JSC::LLInt::llint_crash): Deleted.
+ * runtime/SamplingProfiler.cpp:
+ (JSC::tryGetBytecodeIndex):
+
2018-03-21 Keith Miller <[email protected]>
btjs should print the bytecode offset in the stack trace for JS frames
Modified: trunk/Source/_javascript_Core/bytecode/BytecodeKills.h (229814 => 229815)
--- trunk/Source/_javascript_Core/bytecode/BytecodeKills.h 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeKills.h 2018-03-21 18:23:30 UTC (rev 229815)
@@ -52,7 +52,7 @@
bool operandIsKilled(Instruction* instruction, int operand) const
{
- return operandIsKilled(instruction - m_codeBlock->instructions().begin(), operand);
+ return operandIsKilled(m_codeBlock->bytecodeOffset(instruction), operand);
}
template<typename Functor>
@@ -68,7 +68,7 @@
template<typename Functor>
void forEachOperandKilledAt(Instruction* pc, const Functor& functor) const
{
- forEachOperandKilledAt(pc - m_codeBlock->instructions().begin(), functor);
+ forEachOperandKilledAt(m_codeBlock->bytecodeOffset(pc), functor);
}
private:
Modified: trunk/Source/_javascript_Core/bytecode/CallLinkStatus.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/bytecode/CallLinkStatus.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/bytecode/CallLinkStatus.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -66,7 +66,7 @@
}
#endif
- Instruction* instruction = profiledBlock->instructions().begin() + bytecodeIndex;
+ Instruction* instruction = &profiledBlock->instructions()[bytecodeIndex];
OpcodeID op = Interpreter::getOpcodeID(instruction[0].u.opcode);
if (op != op_call && op != op_construct && op != op_tail_call)
return CallLinkStatus();
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -253,7 +253,7 @@
PrintStream& out, unsigned bytecodeOffset,
const StubInfoMap& stubInfos, const CallLinkInfoMap& callLinkInfos)
{
- const Instruction* it = instructions().begin() + bytecodeOffset;
+ const Instruction* it = &instructions()[bytecodeOffset];
dumpBytecode(out, instructions().begin(), it, stubInfos, callLinkInfos);
}
@@ -2874,7 +2874,7 @@
ArithProfile* CodeBlock::arithProfileForBytecodeOffset(int bytecodeOffset)
{
- return arithProfileForPC(instructions().begin() + bytecodeOffset);
+ return arithProfileForPC(&instructions()[bytecodeOffset]);
}
ArithProfile* CodeBlock::arithProfileForPC(Instruction* pc)
@@ -3021,7 +3021,7 @@
bytecodeOffset = callSiteIndex.bits();
#else
Instruction* instruction = bitwise_cast<Instruction*>(callSiteIndex.bits());
- bytecodeOffset = instruction - instructions().begin();
+ bytecodeOffset = this->bytecodeOffset(instruction);
#endif
} else if (jitType == JITCode::DFGJIT || jitType == JITCode::FTLJIT) {
#if ENABLE(DFG_JIT)
Modified: trunk/Source/_javascript_Core/bytecode/GetByIdStatus.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/bytecode/GetByIdStatus.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/bytecode/GetByIdStatus.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -82,7 +82,7 @@
VM& vm = *profiledBlock->vm();
- Instruction* instruction = profiledBlock->instructions().begin() + bytecodeIndex;
+ Instruction* instruction = &profiledBlock->instructions()[bytecodeIndex];
Opcode opcode = instruction[0].u.opcode;
Modified: trunk/Source/_javascript_Core/bytecode/PutByIdStatus.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/bytecode/PutByIdStatus.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/bytecode/PutByIdStatus.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -72,7 +72,7 @@
VM& vm = *profiledBlock->vm();
- Instruction* instruction = profiledBlock->instructions().begin() + bytecodeIndex;
+ Instruction* instruction = &profiledBlock->instructions()[bytecodeIndex];
StructureID structureID = instruction[4].u.structureID;
if (!structureID)
Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -829,7 +829,7 @@
// chain and use its prediction. If we only have
// inlined tail call frames, we use SpecFullTop
// to avoid a spurious OSR exit.
- Instruction* instruction = m_inlineStackTop->m_profiledBlock->instructions().begin() + bytecodeIndex;
+ Instruction* instruction = &m_inlineStackTop->m_profiledBlock->instructions()[bytecodeIndex];
OpcodeID opcodeID = Interpreter::getOpcodeID(instruction->u.opcode);
switch (opcodeID) {
Modified: trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/dfg/DFGOSRExit.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -807,7 +807,7 @@
if (!inlineCallFrame->isClosureCall)
frame.setOperand(inlineCallFrame->stackOffset + CallFrameSlot::callee, JSValue(inlineCallFrame->calleeConstant()));
#else // USE(JSVALUE64) // so this is the 32-bit part
- Instruction* instruction = baselineCodeBlock->instructions().begin() + codeOrigin->bytecodeIndex;
+ Instruction* instruction = &baselineCodeBlock->instructions()[codeOrigin->bytecodeIndex];
uint32_t locationBits = CallSiteIndex(instruction).bits();
frame.setOperand<uint32_t>(inlineCallFrame->stackOffset + CallFrameSlot::argumentCount, TagOffset, locationBits);
frame.setOperand<uint32_t>(inlineCallFrame->stackOffset + CallFrameSlot::callee, TagOffset, static_cast<uint32_t>(JSValue::CellTag));
@@ -821,7 +821,7 @@
#if USE(JSVALUE64)
uint32_t locationBits = CallSiteIndex(codeOrigin->bytecodeIndex).bits();
#else
- Instruction* instruction = outermostBaselineCodeBlock->instructions().begin() + codeOrigin->bytecodeIndex;
+ Instruction* instruction = &outermostBaselineCodeBlock->instructions()[codeOrigin->bytecodeIndex];
uint32_t locationBits = CallSiteIndex(instruction).bits();
#endif
frame.setOperand<uint32_t>(CallFrameSlot::argumentCount, TagOffset, locationBits);
Modified: trunk/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -231,7 +231,7 @@
jit.store64(AssemblyHelpers::TrustedImm64(JSValue::encode(JSValue(inlineCallFrame->calleeConstant()))), AssemblyHelpers::addressFor((VirtualRegister)(inlineCallFrame->stackOffset + CallFrameSlot::callee)));
#else // USE(JSVALUE64) // so this is the 32-bit part
jit.storePtr(callerFrameGPR, AssemblyHelpers::addressForByteOffset(inlineCallFrame->callerFrameOffset()));
- Instruction* instruction = baselineCodeBlock->instructions().begin() + codeOrigin->bytecodeIndex;
+ Instruction* instruction = &baselineCodeBlock->instructions()[codeOrigin->bytecodeIndex];
uint32_t locationBits = CallSiteIndex(instruction).bits();
jit.store32(AssemblyHelpers::TrustedImm32(locationBits), AssemblyHelpers::tagFor((VirtualRegister)(inlineCallFrame->stackOffset + CallFrameSlot::argumentCount)));
jit.store32(AssemblyHelpers::TrustedImm32(JSValue::CellTag), AssemblyHelpers::tagFor((VirtualRegister)(inlineCallFrame->stackOffset + CallFrameSlot::callee)));
@@ -245,7 +245,7 @@
#if USE(JSVALUE64)
uint32_t locationBits = CallSiteIndex(codeOrigin->bytecodeIndex).bits();
#else
- Instruction* instruction = jit.baselineCodeBlock()->instructions().begin() + codeOrigin->bytecodeIndex;
+ Instruction* instruction = &jit.baselineCodeBlock()->instructions()[codeOrigin->bytecodeIndex];
uint32_t locationBits = CallSiteIndex(instruction).bits();
#endif
jit.store32(AssemblyHelpers::TrustedImm32(locationBits), AssemblyHelpers::tagFor((VirtualRegister)(CallFrameSlot::argumentCount)));
Modified: trunk/Source/_javascript_Core/interpreter/CallFrame.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/interpreter/CallFrame.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/interpreter/CallFrame.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -121,7 +121,7 @@
{
ASSERT(codeBlock());
ASSERT(callSiteBitsAreBytecodeOffset());
- return currentVPC() - codeBlock()->instructions().begin();
+ return codeBlock()->bytecodeOffset(currentVPC());
}
#else // USE(JSVALUE32_64)
@@ -128,12 +128,12 @@
Instruction* CallFrame::currentVPC() const
{
ASSERT(callSiteBitsAreBytecodeOffset());
- return codeBlock()->instructions().begin() + callSiteBitsAsBytecodeOffset();
+ return &codeBlock()->instructions()[callSiteBitsAsBytecodeOffset()];
}
void CallFrame::setCurrentVPC(Instruction* vpc)
{
- CallSiteIndex callSite(vpc - codeBlock()->instructions().begin());
+ CallSiteIndex callSite(codeBlock()->bytecodeOffset(vpc));
this[CallFrameSlot::argumentCount].tag() = static_cast<int32_t>(callSite.bits());
}
Modified: trunk/Source/_javascript_Core/jit/JITCall.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/jit/JITCall.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/jit/JITCall.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -175,7 +175,7 @@
store32(TrustedImm32(argCount), Address(stackPointerRegister, CallFrameSlot::argumentCount * static_cast<int>(sizeof(Register)) + PayloadOffset - sizeof(CallerFrameAndPC)));
} // SP holds newCallFrame + sizeof(CallerFrameAndPC), with ArgumentCount initialized.
- uint32_t bytecodeOffset = instruction - m_codeBlock->instructions().begin();
+ uint32_t bytecodeOffset = m_codeBlock->bytecodeOffset(instruction);
uint32_t locationBits = CallSiteIndex(bytecodeOffset).bits();
store32(TrustedImm32(locationBits), Address(callFrameRegister, CallFrameSlot::argumentCount * static_cast<int>(sizeof(Register)) + TagOffset));
Modified: trunk/Source/_javascript_Core/jit/JITInlines.h (229814 => 229815)
--- trunk/Source/_javascript_Core/jit/JITInlines.h 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/jit/JITInlines.h 2018-03-21 18:23:30 UTC (rev 229815)
@@ -138,7 +138,7 @@
{
ASSERT(static_cast<int>(m_bytecodeOffset) >= 0);
#if USE(JSVALUE32_64)
- Instruction* instruction = m_codeBlock->instructions().begin() + m_bytecodeOffset;
+ Instruction* instruction = &m_codeBlock->instructions()[m_bytecodeOffset];
uint32_t locationBits = CallSiteIndex(instruction).bits();
#else
uint32_t locationBits = CallSiteIndex(m_bytecodeOffset).bits();
@@ -740,8 +740,7 @@
inline Instruction* JIT::copiedInstruction(Instruction* inst)
{
- ASSERT(inst >= m_codeBlock->instructions().begin() && inst < m_codeBlock->instructions().end());
- return m_instructions.begin() + (inst - m_codeBlock->instructions().begin());
+ return &m_instructions[m_codeBlock->bytecodeOffset(inst)];
}
#endif // USE(JSVALUE32_64)
Modified: trunk/Source/_javascript_Core/jit/JITOpcodes.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/jit/JITOpcodes.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/jit/JITOpcodes.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -1063,7 +1063,7 @@
void JIT::privateCompileHasIndexedProperty(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
{
- Instruction* currentInstruction = m_codeBlock->instructions().begin() + byValInfo->bytecodeIndex;
+ Instruction* currentInstruction = &m_codeBlock->instructions()[byValInfo->bytecodeIndex];
PatchableJump badType;
Modified: trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/jit/JITOpcodes32_64.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -914,7 +914,7 @@
void JIT::privateCompileHasIndexedProperty(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
{
- Instruction* currentInstruction = m_codeBlock->instructions().begin() + byValInfo->bytecodeIndex;
+ Instruction* currentInstruction = &m_codeBlock->instructions()[byValInfo->bytecodeIndex];
PatchableJump badType;
Modified: trunk/Source/_javascript_Core/jit/JITPropertyAccess.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/jit/JITPropertyAccess.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/jit/JITPropertyAccess.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -1222,7 +1222,7 @@
void JIT::privateCompileGetByVal(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
{
- Instruction* currentInstruction = m_codeBlock->instructions().begin() + byValInfo->bytecodeIndex;
+ Instruction* currentInstruction = &m_codeBlock->instructions()[byValInfo->bytecodeIndex];
PatchableJump badType;
JumpList slowCases;
@@ -1274,7 +1274,7 @@
void JIT::privateCompileGetByValWithCachedId(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, const Identifier& propertyName)
{
- Instruction* currentInstruction = m_codeBlock->instructions().begin() + byValInfo->bytecodeIndex;
+ Instruction* currentInstruction = &m_codeBlock->instructions()[byValInfo->bytecodeIndex];
Jump fastDoneCase;
Jump slowDoneCase;
@@ -1307,7 +1307,7 @@
void JIT::privateCompilePutByVal(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
{
- Instruction* currentInstruction = m_codeBlock->instructions().begin() + byValInfo->bytecodeIndex;
+ Instruction* currentInstruction = &m_codeBlock->instructions()[byValInfo->bytecodeIndex];
PatchableJump badType;
JumpList slowCases;
@@ -1366,7 +1366,7 @@
void JIT::privateCompilePutByValWithCachedId(ByValInfo* byValInfo, ReturnAddressPtr returnAddress, PutKind putKind, const Identifier& propertyName)
{
- Instruction* currentInstruction = m_codeBlock->instructions().begin() + byValInfo->bytecodeIndex;
+ Instruction* currentInstruction = &m_codeBlock->instructions()[byValInfo->bytecodeIndex];
JumpList doneCases;
JumpList slowCases;
Modified: trunk/Source/_javascript_Core/jit/SlowPathCall.h (229814 => 229815)
--- trunk/Source/_javascript_Core/jit/SlowPathCall.h 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/jit/SlowPathCall.h 2018-03-21 18:23:30 UTC (rev 229815)
@@ -46,7 +46,7 @@
{
#if ENABLE(OPCODE_SAMPLING)
if (m_jit->m_bytecodeOffset != std::numeric_limits<unsigned>::max())
- m_jit->sampleInstruction(m_jit->m_codeBlock->instructions().begin() + m_jit->m_bytecodeOffset, true);
+ m_jit->sampleInstruction(&m_jit->m_codeBlock->instructions()[m_jit->m_bytecodeOffset], true);
#endif
m_jit->updateTopCallFrame();
#if CPU(X86) && USE(JSVALUE32_64)
@@ -75,7 +75,7 @@
#if ENABLE(OPCODE_SAMPLING)
if (m_jit->m_bytecodeOffset != std::numeric_limits<unsigned>::max())
- m_jit->sampleInstruction(m_jit->m_codeBlock->instructions().begin() + m_jit->m_bytecodeOffset, false);
+ m_jit->sampleInstruction(&m_jit->m_codeBlock->instructions()[m_jit->m_bytecodeOffset], false);
#endif
m_jit->exceptionCheck();
Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -196,7 +196,7 @@
&Thread::current(),
exec->codeBlock(),
exec,
- static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
+ static_cast<intptr_t>(exec->codeBlock()->bytecodeOffset(pc)),
Interpreter::getOpcodeID(pc[0].u.opcode),
fromWhere,
operand,
@@ -220,7 +220,7 @@
&Thread::current(),
exec->codeBlock(),
exec,
- static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
+ static_cast<intptr_t>(exec->codeBlock()->bytecodeOffset(pc)),
Interpreter::getOpcodeID(pc[0].u.opcode),
fromWhere,
operand,
@@ -280,7 +280,7 @@
&Thread::current(),
exec->codeBlock(),
exec,
- static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
+ static_cast<intptr_t>(exec->codeBlock()->bytecodeOffset(pc)),
opcodeNames[opcodeID], pc);
if (opcodeID == op_enter) {
dataLogF("Frame will eventually return to %p\n", exec->returnPC().value());
@@ -299,7 +299,7 @@
&Thread::current(),
exec->codeBlock(),
exec,
- static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
+ static_cast<intptr_t>(exec->codeBlock()->bytecodeOffset(pc)),
Interpreter::getOpcodeID(pc[0].u.opcode),
exec->returnPC().value());
LLINT_END_IMPL();
@@ -429,7 +429,7 @@
codeBlock->llintExecuteCounter(), "\n");
}
- unsigned loopOSREntryBytecodeOffset = pc - codeBlock->instructions().begin();
+ unsigned loopOSREntryBytecodeOffset = codeBlock->bytecodeOffset(pc);
if (!shouldJIT(codeBlock)) {
codeBlock->dontJITAnytimeSoon();
@@ -439,15 +439,15 @@
if (!jitCompileAndSetHeuristics(codeBlock, exec, loopOSREntryBytecodeOffset))
LLINT_RETURN_TWO(0, 0);
- CODEBLOCK_LOG_EVENT(codeBlock, "osrEntry", ("at bc#", pc - codeBlock->instructions().begin()));
+ CODEBLOCK_LOG_EVENT(codeBlock, "osrEntry", ("at bc#", loopOSREntryBytecodeOffset));
ASSERT(codeBlock->jitType() == JITCode::BaselineJIT);
Vector<BytecodeAndMachineOffset> map;
codeBlock->jitCodeMap()->decode(map);
- BytecodeAndMachineOffset* mapping = binarySearch<BytecodeAndMachineOffset, unsigned>(map, map.size(), pc - codeBlock->instructions().begin(), BytecodeAndMachineOffset::getBytecodeIndex);
+ BytecodeAndMachineOffset* mapping = binarySearch<BytecodeAndMachineOffset, unsigned>(map, map.size(), loopOSREntryBytecodeOffset, BytecodeAndMachineOffset::getBytecodeIndex);
ASSERT(mapping);
- ASSERT(mapping->m_bytecodeIndex == static_cast<unsigned>(pc - codeBlock->instructions().begin()));
+ ASSERT(mapping->m_bytecodeIndex == loopOSREntryBytecodeOffset);
void* jumpTarget = codeBlock->jitCode()->executableAddressAtOffset(mapping->m_machineCodeOffset);
ASSERT(jumpTarget);
@@ -714,7 +714,7 @@
&& isJSArray(baseValue)
&& ident == vm.propertyNames->length) {
pc[0].u.opcode = LLInt::getOpcode(op_get_array_length);
- ArrayProfile* arrayProfile = codeBlock->getOrAddArrayProfile(pc - codeBlock->instructions().begin());
+ ArrayProfile* arrayProfile = codeBlock->getOrAddArrayProfile(codeBlock->bytecodeOffset(pc));
arrayProfile->observeStructure(baseValue.asCell()->structure());
pc[4].u.arrayProfile = arrayProfile;
Modified: trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp (229814 => 229815)
--- trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp 2018-03-21 18:10:38 UTC (rev 229814)
+++ trunk/Source/_javascript_Core/runtime/SamplingProfiler.cpp 2018-03-21 18:23:30 UTC (rev 229815)
@@ -435,10 +435,9 @@
return 0;
#else
Instruction* instruction = bitwise_cast<Instruction*>(llintPC);
- if (instruction >= codeBlock->instructions().begin() && instruction < codeBlock->instructions().begin() + codeBlock->instructionCount()) {
+ if (instruction >= codeBlock->instructions().begin() && instruction < codeBlock->instructions().end()) {
isValid = true;
- unsigned bytecodeIndex = instruction - codeBlock->instructions().begin();
- return bytecodeIndex;
+ return codeBlock->bytecodeOffset(instruction);
}
isValid = false;
return 0;