blob: db81907f9b0440f67bfcd862dc8a4e28cf9b854a [file] [log] [blame]
/*
* Copyright (C) 2008-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#if ENABLE(JIT)
#include "BytecodeOperandsForCheckpoint.h"
#include "CommonSlowPathsInlines.h"
#include "JIT.h"
#include "JSCInlines.h"
namespace JSC {
ALWAYS_INLINE bool JIT::isOperandConstantDouble(VirtualRegister src)
{
if (!src.isConstant())
return false;
if (m_unlinkedCodeBlock->constantSourceCodeRepresentation(src) == SourceCodeRepresentation::LinkTimeConstant)
return false;
return getConstantOperand(src).isDouble();
}
ALWAYS_INLINE bool JIT::isOperandConstantInt(VirtualRegister src)
{
if (!src.isConstant())
return false;
if (m_unlinkedCodeBlock->constantSourceCodeRepresentation(src) == SourceCodeRepresentation::LinkTimeConstant)
return false;
return getConstantOperand(src).isInt32();
}
ALWAYS_INLINE bool JIT::isKnownCell(VirtualRegister src)
{
if (!src.isConstant())
return false;
if (m_unlinkedCodeBlock->constantSourceCodeRepresentation(src) == SourceCodeRepresentation::LinkTimeConstant) {
// All link time constants are cells.
return true;
}
return getConstantOperand(src).isCell();
}
ALWAYS_INLINE JSValue JIT::getConstantOperand(VirtualRegister src)
{
ASSERT(src.isConstant());
RELEASE_ASSERT(m_unlinkedCodeBlock->constantSourceCodeRepresentation(src) != SourceCodeRepresentation::LinkTimeConstant);
return m_unlinkedCodeBlock->getConstant(src);
}
ALWAYS_INLINE void JIT::emitPutIntToCallFrameHeader(RegisterID from, VirtualRegister entry)
{
ASSERT(entry.isHeader());
#if USE(JSVALUE32_64)
store32(TrustedImm32(JSValue::Int32Tag), tagFor(entry));
store32(from, payloadFor(entry));
#else
store64(from, addressFor(entry));
#endif
}
ALWAYS_INLINE void JIT::emitLoadCharacterString(RegisterID src, RegisterID dst, JumpList& failures)
{
failures.append(branchIfNotString(src));
loadPtr(MacroAssembler::Address(src, JSString::offsetOfValue()), dst);
failures.append(branchIfRopeStringImpl(dst));
failures.append(branch32(NotEqual, MacroAssembler::Address(dst, StringImpl::lengthMemoryOffset()), TrustedImm32(1)));
loadPtr(MacroAssembler::Address(dst, StringImpl::dataOffset()), regT1);
auto is16Bit = branchTest32(Zero, Address(dst, StringImpl::flagsOffset()), TrustedImm32(StringImpl::flagIs8Bit()));
load8(MacroAssembler::Address(regT1, 0), dst);
auto done = jump();
is16Bit.link(this);
load16(MacroAssembler::Address(regT1, 0), dst);
done.link(this);
}
ALWAYS_INLINE JIT::Call JIT::emitNakedNearCall(CodePtr<NoPtrTag> target)
{
ASSERT(m_bytecodeIndex); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
Call nakedCall = nearCall();
m_nearCalls.append(NearCallRecord(nakedCall, FunctionPtr<JSInternalPtrTag>(target.retagged<JSInternalPtrTag>())));
return nakedCall;
}
ALWAYS_INLINE JIT::Call JIT::emitNakedNearTailCall(CodePtr<NoPtrTag> target)
{
ASSERT(m_bytecodeIndex); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
Call nakedCall = nearTailCall();
m_nearCalls.append(NearCallRecord(nakedCall, FunctionPtr<JSInternalPtrTag>(target.retagged<JSInternalPtrTag>())));
return nakedCall;
}
ALWAYS_INLINE JIT::Jump JIT::emitNakedNearJump(CodePtr<JITThunkPtrTag> target)
{
ASSERT(m_bytecodeIndex); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
Jump nakedJump = jump();
m_nearJumps.append(NearJumpRecord(nakedJump, CodeLocationLabel(target)));
return nakedJump;
}
ALWAYS_INLINE void JIT::updateTopCallFrame()
{
uint32_t locationBits = CallSiteIndex(m_bytecodeIndex.offset()).bits();
store32(TrustedImm32(locationBits), tagFor(CallFrameSlot::argumentCountIncludingThis));
prepareCallOperation(*m_vm);
}
ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheck(const FunctionPtr<CFunctionPtrTag> function)
{
updateTopCallFrame();
MacroAssembler::Call call = appendCall(function);
exceptionCheck();
return call;
}
ALWAYS_INLINE void JIT::appendCallWithExceptionCheck(Address function)
{
updateTopCallFrame();
appendCall(function);
exceptionCheck();
}
#if OS(WINDOWS) && CPU(X86_64)
ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr<CFunctionPtrTag> function)
{
updateTopCallFrame();
MacroAssembler::Call call = appendCallWithSlowPathReturnType(function);
exceptionCheck();
return call;
}
#endif
ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithCallFrameRollbackOnException(const FunctionPtr<CFunctionPtrTag> function)
{
updateTopCallFrame(); // The callee is responsible for setting topCallFrame to their caller
MacroAssembler::Call call = appendCall(function);
exceptionCheckWithCallFrameRollback();
return call;
}
ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr<CFunctionPtrTag> function, VirtualRegister dst)
{
MacroAssembler::Call call = appendCallWithExceptionCheck(function);
emitPutVirtualRegister(dst, returnValueJSR);
return call;
}
ALWAYS_INLINE void JIT::appendCallWithExceptionCheckSetJSValueResult(Address function, VirtualRegister dst)
{
appendCallWithExceptionCheck(function);
emitPutVirtualRegister(dst, returnValueJSR);
}
template<typename Bytecode>
ALWAYS_INLINE MacroAssembler::Call JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile(const Bytecode& bytecode, const FunctionPtr<CFunctionPtrTag> function, VirtualRegister dst)
{
MacroAssembler::Call call = appendCallWithExceptionCheck(function);
emitValueProfilingSite(bytecode, returnValueJSR);
emitPutVirtualRegister(dst, returnValueJSR);
return call;
}
template<typename Bytecode>
ALWAYS_INLINE void JIT::appendCallWithExceptionCheckSetJSValueResultWithProfile(const Bytecode& bytecode, Address function, VirtualRegister dst)
{
appendCallWithExceptionCheck(function);
emitValueProfilingSite(bytecode, returnValueJSR);
emitPutVirtualRegister(dst, returnValueJSR);
}
ALWAYS_INLINE void JIT::linkSlowCaseIfNotJSCell(Vector<SlowCaseEntry>::iterator& iter, VirtualRegister reg)
{
if (!isKnownCell(reg))
linkSlowCase(iter);
}
ALWAYS_INLINE void JIT::linkAllSlowCasesForBytecodeIndex(Vector<SlowCaseEntry>& slowCases, Vector<SlowCaseEntry>::iterator& iter, BytecodeIndex bytecodeIndex)
{
while (iter != slowCases.end() && iter->to == bytecodeIndex)
linkSlowCase(iter);
}
ALWAYS_INLINE bool JIT::hasAnySlowCases(Vector<SlowCaseEntry>& slowCases, Vector<SlowCaseEntry>::iterator& iter, BytecodeIndex bytecodeIndex)
{
if (iter != slowCases.end() && iter->to == bytecodeIndex)
return true;
return false;
}
inline void JIT::advanceToNextCheckpoint()
{
ASSERT_WITH_MESSAGE(m_bytecodeIndex, "This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set");
ASSERT(m_unlinkedCodeBlock->instructionAt(m_bytecodeIndex)->hasCheckpoints());
m_bytecodeIndex = BytecodeIndex(m_bytecodeIndex.offset(), m_bytecodeIndex.checkpoint() + 1);
auto result = m_checkpointLabels.add(m_bytecodeIndex, label());
ASSERT_UNUSED(result, result.isNewEntry);
}
inline void JIT::emitJumpSlowToHotForCheckpoint(Jump jump)
{
ASSERT_WITH_MESSAGE(m_bytecodeIndex, "This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set");
ASSERT(m_unlinkedCodeBlock->instructionAt(m_bytecodeIndex)->hasCheckpoints());
m_bytecodeIndex = BytecodeIndex(m_bytecodeIndex.offset(), m_bytecodeIndex.checkpoint() + 1);
auto iter = m_checkpointLabels.find(m_bytecodeIndex);
ASSERT(iter != m_checkpointLabels.end());
jump.linkTo(iter->value, this);
}
ALWAYS_INLINE void JIT::addSlowCase(Jump jump)
{
ASSERT(m_bytecodeIndex); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
m_slowCases.append(SlowCaseEntry(jump, m_bytecodeIndex));
}
ALWAYS_INLINE void JIT::addSlowCase(const JumpList& jumpList)
{
ASSERT(m_bytecodeIndex); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
for (const Jump& jump : jumpList.jumps())
m_slowCases.append(SlowCaseEntry(jump, m_bytecodeIndex));
}
ALWAYS_INLINE void JIT::addSlowCase()
{
ASSERT(m_bytecodeIndex); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
Jump emptyJump; // Doing it this way to make Windows happy.
m_slowCases.append(SlowCaseEntry(emptyJump, m_bytecodeIndex));
}
ALWAYS_INLINE void JIT::addJump(Jump jump, int relativeOffset)
{
ASSERT(m_bytecodeIndex); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
m_jmpTable.append(JumpTable(jump, m_bytecodeIndex.offset() + relativeOffset));
}
ALWAYS_INLINE void JIT::addJump(const JumpList& jumpList, int relativeOffset)
{
ASSERT(m_bytecodeIndex); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
for (auto& jump : jumpList.jumps())
addJump(jump, relativeOffset);
}
ALWAYS_INLINE void JIT::emitJumpSlowToHot(Jump jump, int relativeOffset)
{
ASSERT(m_bytecodeIndex); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
jump.linkTo(m_labels[m_bytecodeIndex.offset() + relativeOffset], this);
}
#if ENABLE(SAMPLING_FLAGS)
ALWAYS_INLINE void JIT::setSamplingFlag(int32_t flag)
{
ASSERT(flag >= 1);
ASSERT(flag <= 32);
or32(TrustedImm32(1u << (flag - 1)), AbsoluteAddress(SamplingFlags::addressOfFlags()));
}
ALWAYS_INLINE void JIT::clearSamplingFlag(int32_t flag)
{
ASSERT(flag >= 1);
ASSERT(flag <= 32);
and32(TrustedImm32(~(1u << (flag - 1))), AbsoluteAddress(SamplingFlags::addressOfFlags()));
}
#endif
#if ENABLE(SAMPLING_COUNTERS)
ALWAYS_INLINE void JIT::emitCount(AbstractSamplingCounter& counter, int32_t count)
{
add64(TrustedImm32(count), AbsoluteAddress(counter.addressOfCounter()));
}
#endif
ALWAYS_INLINE bool JIT::isOperandConstantChar(VirtualRegister src)
{
if (!src.isConstant())
return false;
if (m_unlinkedCodeBlock->constantSourceCodeRepresentation(src) == SourceCodeRepresentation::LinkTimeConstant)
return false;
return getConstantOperand(src).isString() && asString(getConstantOperand(src).asCell())->length() == 1;
}
template<typename Op>
inline std::enable_if_t<std::is_same<decltype(Op::Metadata::m_profile), ValueProfile>::value, void> JIT::emitValueProfilingSiteIfProfiledOpcode(Op bytecode)
{
emitValueProfilingSite(bytecode, jsRegT10);
}
inline void JIT::emitValueProfilingSiteIfProfiledOpcode(...) { }
template<typename Bytecode>
inline void JIT::emitValueProfilingSite(const Bytecode& bytecode, JSValueRegs value)
{
if (!shouldEmitProfiling())
return;
ptrdiff_t offset = m_unlinkedCodeBlock->metadata().offsetInMetadataTable(bytecode) + valueProfileOffsetFor<Bytecode>(m_bytecodeIndex.checkpoint()) + ValueProfile::offsetOfFirstBucket();
storeValue(value, Address(s_metadataGPR, offset));
}
#if USE(JSVALUE64)
template<typename Bytecode>
inline void JIT::emitValueProfilingSite(const Bytecode& bytecode, GPRReg resultReg)
{
emitValueProfilingSite(bytecode, JSValueRegs(resultReg));
}
#endif
template <typename Bytecode>
inline void JIT::emitArrayProfilingSiteWithCell(const Bytecode& bytecode, ptrdiff_t offsetOfArrayProfile, RegisterID cellGPR, RegisterID scratchGPR)
{
if (shouldEmitProfiling()) {
load32(Address(cellGPR, JSCell::structureIDOffset()), scratchGPR);
store32ToMetadata(scratchGPR, bytecode, offsetOfArrayProfile);
}
}
template <typename Bytecode>
inline void JIT::emitArrayProfilingSiteWithCell(const Bytecode& bytecode, RegisterID cellGPR, RegisterID scratchGPR)
{
emitArrayProfilingSiteWithCell(bytecode, Bytecode::Metadata::offsetOfArrayProfile() + ArrayProfile::offsetOfLastSeenStructureID(), cellGPR, scratchGPR);
}
ALWAYS_INLINE int32_t JIT::getOperandConstantInt(VirtualRegister src)
{
return getConstantOperand(src).asInt32();
}
ALWAYS_INLINE double JIT::getOperandConstantDouble(VirtualRegister src)
{
return getConstantOperand(src).asDouble();
}
ALWAYS_INLINE void JIT::emitInitRegister(VirtualRegister dst)
{
storeTrustedValue(jsUndefined(), addressFor(dst));
}
ALWAYS_INLINE void JIT::emitGetVirtualRegister(VirtualRegister src, JSValueRegs dst)
{
ASSERT(m_bytecodeIndex); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
if (src.isConstant()) {
if (m_profiledCodeBlock->isConstantOwnedByUnlinkedCodeBlock(src))
moveValue(m_unlinkedCodeBlock->getConstant(src), dst);
else
loadCodeBlockConstant(src, dst);
return;
}
loadValue(addressFor(src), dst);
}
ALWAYS_INLINE void JIT::emitPutVirtualRegister(VirtualRegister dst, JSValueRegs from)
{
storeValue(from, addressFor(dst));
}
#if USE(JSVALUE32_64)
ALWAYS_INLINE void JIT::emitGetVirtualRegister(VirtualRegister src, RegisterID tag, RegisterID payload)
{
emitGetVirtualRegister(src, JSValueRegs { tag, payload });
}
ALWAYS_INLINE void JIT::emitGetVirtualRegisterPayload(VirtualRegister src, RegisterID dst)
{
ASSERT(m_bytecodeIndex); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
if (src.isConstant()) {
if (m_profiledCodeBlock->isConstantOwnedByUnlinkedCodeBlock(src))
move(Imm32(m_unlinkedCodeBlock->getConstant(src).payload()), dst);
else
loadCodeBlockConstantPayload(src, dst);
return;
}
load32(payloadFor(src), dst);
}
ALWAYS_INLINE void JIT::emitGetVirtualRegisterTag(VirtualRegister src, RegisterID dst)
{
ASSERT(m_bytecodeIndex); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
if (src.isConstant()) {
if (m_profiledCodeBlock->isConstantOwnedByUnlinkedCodeBlock(src))
move(Imm32(m_unlinkedCodeBlock->getConstant(src).tag()), dst);
else
loadCodeBlockConstantTag(src, dst);
return;
}
load32(tagFor(src), dst);
}
#elif USE(JSVALUE64)
ALWAYS_INLINE void JIT::emitGetVirtualRegister(VirtualRegister src, RegisterID dst)
{
emitGetVirtualRegister(src, JSValueRegs { dst });
}
ALWAYS_INLINE void JIT::emitGetVirtualRegisterPayload(VirtualRegister src, RegisterID dst)
{
emitGetVirtualRegister(src, JSValueRegs { dst });
}
ALWAYS_INLINE void JIT::emitPutVirtualRegister(VirtualRegister dst, RegisterID from)
{
emitPutVirtualRegister(dst, JSValueRegs { from });
}
#endif
#if USE(JSVALUE32_64)
inline void JIT::emitLoadDouble(VirtualRegister reg, FPRegisterID value)
{
if (reg.isConstant()) {
ASSERT(m_profiledCodeBlock->isConstantOwnedByUnlinkedCodeBlock(reg));
WriteBarrier<Unknown>& inConstantPool = m_unlinkedCodeBlock->constantRegister(reg);
loadDouble(TrustedImmPtr(&inConstantPool), value);
} else
loadDouble(addressFor(reg), value);
}
inline void JIT::emitStore(VirtualRegister reg, RegisterID tag, RegisterID payload, RegisterID base)
{
store32(payload, payloadFor(reg, base));
store32(tag, tagFor(reg, base));
}
inline void JIT::emitStoreInt32(VirtualRegister reg, RegisterID payload, bool indexIsInt32)
{
store32(payload, payloadFor(reg));
if (!indexIsInt32)
store32(TrustedImm32(JSValue::Int32Tag), tagFor(reg));
}
inline void JIT::emitStoreCell(VirtualRegister reg, RegisterID payload, bool indexIsCell)
{
store32(payload, payloadFor(reg));
if (!indexIsCell)
store32(TrustedImm32(JSValue::CellTag), tagFor(reg));
}
inline void JIT::emitStoreBool(VirtualRegister reg, RegisterID payload, bool indexIsBool)
{
store32(payload, payloadFor(reg));
if (!indexIsBool)
store32(TrustedImm32(JSValue::BooleanTag), tagFor(reg));
}
inline void JIT::emitStore(VirtualRegister reg, const JSValue constant, RegisterID base)
{
store32(Imm32(constant.payload()), payloadFor(reg, base));
store32(Imm32(constant.tag()), tagFor(reg, base));
}
inline void JIT::emitJumpSlowCaseIfNotJSCell(VirtualRegister reg)
{
if (!isKnownCell(reg)) {
if (reg.isConstant())
addSlowCase(jump());
else
addSlowCase(emitJumpIfNotJSCell(reg));
}
}
inline void JIT::emitJumpSlowCaseIfNotJSCell(VirtualRegister reg, RegisterID tag)
{
if (!isKnownCell(reg)) {
if (reg.isConstant())
addSlowCase(jump());
else
addSlowCase(branchIfNotCell(tag));
}
}
ALWAYS_INLINE bool JIT::getOperandConstantInt(VirtualRegister op1, VirtualRegister op2, VirtualRegister& op, int32_t& constant)
{
if (isOperandConstantInt(op1)) {
constant = getConstantOperand(op1).asInt32();
op = op2;
return true;
}
if (isOperandConstantInt(op2)) {
constant = getConstantOperand(op2).asInt32();
op = op1;
return true;
}
return false;
}
#else // USE(JSVALUE32_64)
ALWAYS_INLINE JIT::Jump JIT::emitJumpIfBothJSCells(RegisterID reg1, RegisterID reg2, RegisterID scratch)
{
move(reg1, scratch);
or64(reg2, scratch);
return branchIfCell(scratch);
}
ALWAYS_INLINE void JIT::emitJumpSlowCaseIfJSCell(RegisterID reg)
{
addSlowCase(branchIfCell(reg));
}
ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotJSCell(RegisterID reg, VirtualRegister vReg)
{
if (!isKnownCell(vReg))
emitJumpSlowCaseIfNotJSCell(reg);
}
ALWAYS_INLINE JIT::PatchableJump JIT::emitPatchableJumpIfNotInt(RegisterID reg)
{
return patchableBranch64(Below, reg, numberTagRegister);
}
ALWAYS_INLINE JIT::Jump JIT::emitJumpIfNotInt(RegisterID reg1, RegisterID reg2, RegisterID scratch)
{
move(reg1, scratch);
and64(reg2, scratch);
return branchIfNotInt32(scratch);
}
ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotInt(RegisterID reg)
{
addSlowCase(branchIfNotInt32(reg));
}
ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotInt(RegisterID reg1, RegisterID reg2, RegisterID scratch)
{
addSlowCase(emitJumpIfNotInt(reg1, reg2, scratch));
}
ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotNumber(RegisterID reg)
{
addSlowCase(branchIfNotNumber(reg));
}
#endif // USE(JSVALUE32_64)
ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotJSCell(RegisterID reg)
{
addSlowCase(branchIfNotCell(reg));
}
ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotJSCell(JSValueRegs reg)
{
addSlowCase(branchIfNotCell(reg));
}
ALWAYS_INLINE void JIT::emitJumpSlowCaseIfNotJSCell(JSValueRegs jsReg, VirtualRegister vReg)
{
if (!isKnownCell(vReg))
emitJumpSlowCaseIfNotJSCell(jsReg);
}
ALWAYS_INLINE int JIT::jumpTarget(const Instruction* instruction, int target)
{
if (target)
return target;
return m_unlinkedCodeBlock->outOfLineJumpOffset(instruction);
}
template<typename Op>
ALWAYS_INLINE ECMAMode JIT::ecmaMode(Op op)
{
return op.m_ecmaMode;
}
template<>
ALWAYS_INLINE ECMAMode JIT::ecmaMode<OpPutById>(OpPutById op)
{
return op.m_flags.ecmaMode();
}
template<>
ALWAYS_INLINE ECMAMode JIT::ecmaMode<OpPutPrivateName>(OpPutPrivateName)
{
return ECMAMode::strict();
}
template <typename Bytecode>
ALWAYS_INLINE void JIT::loadPtrFromMetadata(const Bytecode& bytecode, size_t offset, GPRReg result)
{
loadPtr(Address(s_metadataGPR, m_unlinkedCodeBlock->metadata().offsetInMetadataTable(bytecode) + offset), result);
}
template <typename Bytecode>
ALWAYS_INLINE void JIT::load32FromMetadata(const Bytecode& bytecode, size_t offset, GPRReg result)
{
load32(Address(s_metadataGPR, m_unlinkedCodeBlock->metadata().offsetInMetadataTable(bytecode) + offset), result);
}
template <typename Bytecode>
ALWAYS_INLINE void JIT::load8FromMetadata(const Bytecode& bytecode, size_t offset, GPRReg result)
{
load8(Address(s_metadataGPR, m_unlinkedCodeBlock->metadata().offsetInMetadataTable(bytecode) + offset), result);
}
template <typename ValueType, typename Bytecode>
ALWAYS_INLINE void JIT::store8ToMetadata(ValueType value, const Bytecode& bytecode, size_t offset)
{
store8(value, Address(s_metadataGPR, m_unlinkedCodeBlock->metadata().offsetInMetadataTable(bytecode) + offset));
}
template <typename Bytecode>
ALWAYS_INLINE void JIT::store32ToMetadata(GPRReg value, const Bytecode& bytecode, size_t offset)
{
store32(value, Address(s_metadataGPR, m_unlinkedCodeBlock->metadata().offsetInMetadataTable(bytecode) + offset));
}
template <typename Bytecode>
ALWAYS_INLINE void JIT::materializePointerIntoMetadata(const Bytecode& bytecode, size_t offset, GPRReg result)
{
addPtr(TrustedImm32(m_unlinkedCodeBlock->metadata().offsetInMetadataTable(bytecode) + offset), s_metadataGPR, result);
}
ALWAYS_INLINE void JIT::loadConstant(JITConstantPool::Constant constantIndex, GPRReg result)
{
loadPtr(Address(s_constantsGPR, static_cast<uintptr_t>(constantIndex) * sizeof(void*)), result);
}
ALWAYS_INLINE void JIT::loadGlobalObject(GPRReg result)
{
loadConstant(m_globalObjectConstant, result);
}
ALWAYS_INLINE static void loadAddrOfCodeBlockConstantBuffer(JIT &jit, GPRReg dst)
{
jit.loadPtr(jit.addressFor(CallFrameSlot::codeBlock), dst);
jit.loadPtr(JIT::Address(dst, CodeBlock::offsetOfConstantsVectorBuffer()), dst);
}
ALWAYS_INLINE void JIT::loadCodeBlockConstant(VirtualRegister constant, JSValueRegs dst)
{
RELEASE_ASSERT(constant.isConstant());
loadAddrOfCodeBlockConstantBuffer(*this, dst.payloadGPR());
loadValue(Address(dst.payloadGPR(), constant.toConstantIndex() * sizeof(Register)), dst);
}
#if USE(JSVALUE32_64)
ALWAYS_INLINE void JIT::loadCodeBlockConstantPayload(VirtualRegister constant, RegisterID dst)
{
RELEASE_ASSERT(constant.isConstant());
loadAddrOfCodeBlockConstantBuffer(*this, dst);
load32(Address(dst, constant.toConstantIndex() * sizeof(Register) + PayloadOffset), dst);
}
ALWAYS_INLINE void JIT::loadCodeBlockConstantTag(VirtualRegister constant, RegisterID dst)
{
RELEASE_ASSERT(constant.isConstant());
loadAddrOfCodeBlockConstantBuffer(*this, dst);
load32(Address(dst, constant.toConstantIndex() * sizeof(Register) + TagOffset), dst);
}
#endif
} // namespace JSC
#endif // ENABLE(JIT)