Modified: trunk/Source/_javascript_Core/jit/JITCall32_64.cpp (265035 => 265036)
--- trunk/Source/_javascript_Core/jit/JITCall32_64.cpp 2020-07-29 08:45:12 UTC (rev 265035)
+++ trunk/Source/_javascript_Core/jit/JITCall32_64.cpp 2020-07-29 10:32:27 UTC (rev 265036)
@@ -1,4 +1,6 @@
/*
+ * Copyright (C) 2020 Igalia, S.L. All rights reserved.
+ * Copyright (C) 2020 Metrological Group B.V.
* Copyright (C) 2008-2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,6 +31,7 @@
#if USE(JSVALUE32_64)
#include "JIT.h"
+#include "CacheableIdentifierInlines.h"
#include "CodeBlock.h"
#include "Interpreter.h"
#include "JITInlines.h"
@@ -39,6 +42,7 @@
#include "OpcodeInlines.h"
#include "ResultType.h"
#include "SetupVarargsFrame.h"
+#include "SlowPathCall.h"
#include "StackAlignment.h"
#include "ThunkGenerators.h"
#include <wtf/StringPrintStream.h>
@@ -49,7 +53,7 @@
void JIT::emitPutCallResult(const Op& bytecode)
{
emitValueProfilingSite(bytecode.metadata(m_codeBlock));
- emitStore(bytecode.m_dst, regT1, regT0);
+ emitStore(destinationFor(bytecode, m_bytecodeIndex.checkpoint()).virtualRegister(), regT1, regT0);
}
void JIT::emit_op_ret(const Instruction* currentInstruction)
@@ -152,9 +156,10 @@
, void>
JIT::compileSetupFrame(const Op& bytecode, CallLinkInfo*)
{
+ unsigned checkpoint = m_bytecodeIndex.checkpoint();
auto& metadata = bytecode.metadata(m_codeBlock);
- int argCount = bytecode.m_argc;
- int registerOffset = -static_cast<int>(bytecode.m_argv);
+ int argCount = argumentCountIncludingThisFor(bytecode, checkpoint);
+ int registerOffset = -static_cast<int>(stackOffsetInRegistersForCall(bytecode, checkpoint));
if (Op::opcodeID == op_call && shouldEmitProfiling()) {
emitLoad(VirtualRegister(registerOffset + CallFrame::argumentOffsetIncludingThis(0)), regT0, regT1);
@@ -269,7 +274,7 @@
{
OpcodeID opcodeID = Op::opcodeID;
auto bytecode = instruction->as<Op>();
- VirtualRegister callee = bytecode.m_callee;
+ VirtualRegister callee = calleeFor(bytecode, m_bytecodeIndex.checkpoint());
/* Caller always:
- Updates callFrameRegister to callee callFrame.
@@ -366,24 +371,263 @@
emitPutCallResult(bytecode);
}
-void JIT::emit_op_iterator_open(const Instruction*)
+void JIT::emit_op_iterator_open(const Instruction* instruction)
{
- UNREACHABLE_FOR_PLATFORM();
+ auto bytecode = instruction->as<OpIteratorOpen>();
+ auto* tryFastFunction = ([&] () {
+ switch (instruction->width()) {
+ case Narrow: return iterator_open_try_fast_narrow;
+ case Wide16: return iterator_open_try_fast_wide16;
+ case Wide32: return iterator_open_try_fast_wide32;
+ default: RELEASE_ASSERT_NOT_REACHED();
+ }
+ })();
+
+ JITSlowPathCall slowPathCall(this, instruction, tryFastFunction);
+ slowPathCall.call();
+ Jump fastCase = branch32(NotEqual, GPRInfo::returnValueGPR2, TrustedImm32(static_cast<uint32_t>(IterationMode::Generic)));
+
+ compileOpCall<OpIteratorOpen>(instruction, m_callLinkInfoIndex++);
+
+ VirtualRegister vr = destinationFor(bytecode, m_bytecodeIndex.checkpoint()).virtualRegister();
+ advanceToNextCheckpoint();
+
+ // call result (iterator) is in regT1 (tag)/regT0 (payload)
+ const Identifier* ident = &vm().propertyNames->next;
+
+ emitJumpSlowCaseIfNotJSCell(vr, regT1);
+
+ GPRReg tagIteratorGPR = regT1;
+ GPRReg payloadIteratorGPR = regT0;
+
+ GPRReg tagNextGPR = tagIteratorGPR;
+ GPRReg payloadNextGPR = payloadIteratorGPR;
+
+ JITGetByIdGenerator gen(
+ m_codeBlock,
+ CodeOrigin(m_bytecodeIndex),
+ CallSiteIndex(BytecodeIndex(m_bytecodeIndex.offset())),
+ RegisterSet::stubUnavailableRegisters(),
+ CacheableIdentifier::createFromImmortalIdentifier(ident->impl()),
+ JSValueRegs(tagIteratorGPR, payloadIteratorGPR),
+ JSValueRegs(tagNextGPR, payloadNextGPR),
+ AccessType::GetById);
+
+ gen.generateFastPath(*this);
+ addSlowCase(gen.slowPathJump());
+ m_getByIds.append(gen);
+
+ emitValueProfilingSite(bytecode.metadata(m_codeBlock));
+ emitPutVirtualRegister(bytecode.m_next, JSValueRegs(tagNextGPR, payloadNextGPR));
+
+ fastCase.link(this);
}
-void JIT::emitSlow_op_iterator_open(const Instruction*, Vector<SlowCaseEntry>::iterator&)
+void JIT::emitSlow_op_iterator_open(const Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter)
{
- UNREACHABLE_FOR_PLATFORM();
+ linkAllSlowCases(iter);
+ compileOpCallSlowCase<OpIteratorOpen>(instruction, iter, m_callLinkInfoIndex++);
+ emitJumpSlowToHotForCheckpoint(jump());
+
+ linkAllSlowCases(iter);
+
+ GPRReg tagIteratorGPR = regT1;
+ GPRReg payloadIteratorGPR = regT0;
+
+ JumpList notObject;
+ notObject.append(branchIfNotCell(tagIteratorGPR));
+ notObject.append(branchIfNotObject(payloadIteratorGPR));
+
+ auto bytecode = instruction->as<OpIteratorOpen>();
+ VirtualRegister nextVReg = bytecode.m_next;
+ UniquedStringImpl* ident = vm().propertyNames->next.impl();
+
+ JITGetByIdGenerator& gen = m_getByIds[m_getByIdIndex++];
+
+ Label coldPathBegin = label();
+
+ Call call = callOperationWithProfile(
+ bytecode.metadata(m_codeBlock), // metadata
+ operationGetByIdOptimize, // operation
+ nextVReg, // result
+ TrustedImmPtr(m_codeBlock->globalObject()), // arg1
+ gen.stubInfo(), // arg2
+ JSValueRegs(tagIteratorGPR, payloadIteratorGPR), // arg3
+ CacheableIdentifier::createFromImmortalIdentifier(ident).rawBits()); // arg4
+
+ gen.reportSlowPathCall(coldPathBegin, call);
+ auto done = jump();
+
+ notObject.link(this);
+ callOperation(operationThrowIteratorResultIsNotObject, TrustedImmPtr(m_codeBlock->globalObject()));
+
+ done.link(this);
}
-void JIT::emit_op_iterator_next(const Instruction*)
+void JIT::emit_op_iterator_next(const Instruction* instruction)
{
- UNREACHABLE_FOR_PLATFORM();
+ auto bytecode = instruction->as<OpIteratorNext>();
+ auto& metadata = bytecode.metadata(m_codeBlock);
+ auto* tryFastFunction = ([&] () {
+ switch (instruction->width()) {
+ case Narrow: return iterator_next_try_fast_narrow;
+ case Wide16: return iterator_next_try_fast_wide16;
+ case Wide32: return iterator_next_try_fast_wide32;
+ default: RELEASE_ASSERT_NOT_REACHED();
+ }
+ })();
+
+ JSValueRegs nextRegs(regT1, regT0);
+ emitGetVirtualRegister(bytecode.m_next, nextRegs);
+ Jump genericCase = branchIfNotEmpty(nextRegs);
+
+ JITSlowPathCall slowPathCall(this, instruction, tryFastFunction);
+ slowPathCall.call();
+ Jump fastCase = branch32(NotEqual, GPRInfo::returnValueGPR2, TrustedImm32(static_cast<uint32_t>(IterationMode::Generic)));
+
+ genericCase.link(this);
+ or8(TrustedImm32(static_cast<uint8_t>(IterationMode::Generic)), AbsoluteAddress(&metadata.m_iterationMetadata.seenModes));
+ compileOpCall<OpIteratorNext>(instruction, m_callLinkInfoIndex++);
+ advanceToNextCheckpoint();
+ // call result ({ done, value } JSObject) in regT1, regT0
+
+ GPRReg tagValueGPR = regT1;
+ GPRReg payloadValueGPR = regT0;
+
+ GPRReg tagDoneGPR = regT5;
+ GPRReg payloadDoneGPR = regT4;
+
+ {
+ GPRReg tagIterResultGPR = regT3;
+ GPRReg payloadIterResultGPR = regT2;
+
+ // iterResultGPR will get trashed by the first get by id below.
+ move(regT1, tagIterResultGPR);
+ move(regT0, payloadIterResultGPR);
+
+ emitJumpSlowCaseIfNotJSCell(tagIterResultGPR);
+
+ RegisterSet preservedRegs = RegisterSet::stubUnavailableRegisters();
+ preservedRegs.add(tagValueGPR);
+ preservedRegs.add(payloadValueGPR);
+ JITGetByIdGenerator gen(
+ m_codeBlock,
+ CodeOrigin(m_bytecodeIndex),
+ CallSiteIndex(BytecodeIndex(m_bytecodeIndex.offset())),
+ preservedRegs,
+ CacheableIdentifier::createFromImmortalIdentifier(vm().propertyNames->done.impl()),
+ JSValueRegs(tagIterResultGPR, payloadIterResultGPR),
+ JSValueRegs(tagDoneGPR, payloadDoneGPR),
+ AccessType::GetById);
+ gen.generateFastPath(*this);
+ addSlowCase(gen.slowPathJump());
+ m_getByIds.append(gen);
+
+ emitValueProfilingSite(metadata);
+ emitPutVirtualRegister(bytecode.m_done, JSValueRegs(tagDoneGPR, payloadDoneGPR));
+ advanceToNextCheckpoint();
+ }
+
+ {
+ GPRReg tagIterResultGPR = regT1;
+ GPRReg payloadIterResultGPR = regT0;
+
+ GPRReg scratch1 = regT6;
+ GPRReg scratch2 = regT7;
+ const bool shouldCheckMasqueradesAsUndefined = false;
+ JumpList iterationDone = branchIfTruthy(vm(), JSValueRegs(tagDoneGPR, payloadDoneGPR), scratch1, scratch2, fpRegT0, fpRegT1, shouldCheckMasqueradesAsUndefined, m_codeBlock->globalObject());
+
+ JITGetByIdGenerator gen(
+ m_codeBlock,
+ CodeOrigin(m_bytecodeIndex),
+ CallSiteIndex(BytecodeIndex(m_bytecodeIndex.offset())),
+ RegisterSet::stubUnavailableRegisters(),
+ CacheableIdentifier::createFromImmortalIdentifier(vm().propertyNames->value.impl()),
+ JSValueRegs(tagIterResultGPR, payloadIterResultGPR),
+ JSValueRegs(tagValueGPR, payloadValueGPR),
+ AccessType::GetById);
+ gen.generateFastPath(*this);
+ addSlowCase(gen.slowPathJump());
+ m_getByIds.append(gen);
+
+ emitValueProfilingSite(metadata);
+ emitPutVirtualRegister(bytecode.m_value, JSValueRegs(tagValueGPR, payloadValueGPR));
+
+ iterationDone.link(this);
+ }
+
+ fastCase.link(this);
}
-void JIT::emitSlow_op_iterator_next(const Instruction*, Vector<SlowCaseEntry>::iterator&)
+void JIT::emitSlow_op_iterator_next(const Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter)
{
- UNREACHABLE_FOR_PLATFORM();
+ linkAllSlowCases(iter);
+ compileOpCallSlowCase<OpIteratorNext>(instruction, iter, m_callLinkInfoIndex++);
+ emitJumpSlowToHotForCheckpoint(jump());
+
+ auto bytecode = instruction->as<OpIteratorNext>();
+ {
+ VirtualRegister doneVReg = bytecode.m_done;
+ GPRReg tagValueGPR = regT1;
+ GPRReg payloadValueGPR = regT0;
+
+ GPRReg tagIterResultGPR = regT3;
+ GPRReg payloadIterResultGPR = regT2;
+
+ GPRReg tagDoneGPR = regT5;
+ GPRReg payloadDoneGPR = regT4;
+
+ linkAllSlowCases(iter);
+ JumpList notObject;
+ notObject.append(branchIfNotCell(tagIterResultGPR));
+ notObject.append(branchIfNotObject(payloadIterResultGPR));
+
+ UniquedStringImpl* ident = vm().propertyNames->done.impl();
+ JITGetByIdGenerator& gen = m_getByIds[m_getByIdIndex++];
+
+ Label coldPathBegin = label();
+
+ Call call = callOperationWithProfile(
+ bytecode.metadata(m_codeBlock), // metadata
+ operationGetByIdOptimize, // operation
+ doneVReg, // result
+ TrustedImmPtr(m_codeBlock->globalObject()), // arg1
+ gen.stubInfo(), // arg2
+ JSValueRegs(tagIterResultGPR, payloadIterResultGPR), // arg3
+ CacheableIdentifier::createFromImmortalIdentifier(ident).rawBits()); // arg4
+
+ gen.reportSlowPathCall(coldPathBegin, call);
+ emitGetVirtualRegister(doneVReg, JSValueRegs(tagDoneGPR, payloadDoneGPR));
+ emitGetVirtualRegister(bytecode.m_value, JSValueRegs(tagValueGPR, payloadValueGPR));
+ emitJumpSlowToHotForCheckpoint(jump());
+
+ notObject.link(this);
+ callOperation(operationThrowIteratorResultIsNotObject, TrustedImmPtr(m_codeBlock->globalObject()));
+ }
+
+ {
+ GPRReg tagIterResultGPR = regT1;
+ GPRReg payloadIterResultGPR = regT0;
+
+ linkAllSlowCases(iter);
+ VirtualRegister valueVReg = bytecode.m_value;
+
+ UniquedStringImpl* ident = vm().propertyNames->value.impl();
+ JITGetByIdGenerator& gen = m_getByIds[m_getByIdIndex++];
+
+ Label coldPathBegin = label();
+
+ Call call = callOperationWithProfile(
+ bytecode.metadata(m_codeBlock), // metadata
+ operationGetByIdOptimize, // operation
+ valueVReg, // result
+ TrustedImmPtr(m_codeBlock->globalObject()), // arg1
+ gen.stubInfo(), // arg2
+ JSValueRegs(tagIterResultGPR, payloadIterResultGPR), // arg3
+ CacheableIdentifier::createFromImmortalIdentifier(ident).rawBits()); // arg4
+
+ gen.reportSlowPathCall(coldPathBegin, call);
+ }
}
} // namespace JSC
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm (265035 => 265036)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm 2020-07-29 08:45:12 UTC (rev 265035)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm 2020-07-29 10:32:27 UTC (rev 265036)
@@ -488,6 +488,9 @@
end)
end
+# loadVariable loads the value of field fieldName using macro get
+# into register tagReg and payloadReg
+# Clobbers: indexReg
macro loadVariable(get, fieldName, indexReg, tagReg, payloadReg)
get(fieldName, indexReg)
loadi TagOffset[cfr, indexReg, 8], tagReg
@@ -651,7 +654,7 @@
end
macro valueProfile(opcodeStruct, profileName, metadata, tag, payload)
- storei tag, %opcodeStruct%::Metadata::m_profile.m_buckets + TagOffset[metadata]
+ storei tag, %opcodeStruct%::Metadata::%profileName%.m_buckets + TagOffset[metadata]
storei payload, %opcodeStruct%::Metadata::%profileName%.m_buckets + PayloadOffset[metadata]
end
@@ -1410,7 +1413,54 @@
dispatch()
end)
+# Assumption: The base object is in t3
+# FIXME: this is very close to the 64bit version. Consider refactoring.
+macro performGetByIDHelper(opcodeStruct, modeMetadataName, valueProfileName, slowLabel, size, metadata, return)
+ metadata(t2, t1)
+ loadb %opcodeStruct%::Metadata::%modeMetadataName%.mode[t2], t1
+
+.opGetByIdDefault:
+ bbneq t1, constexpr GetByIdMode::Default, .opGetByIdProtoLoad
+ loadi JSCell::m_structureID[t3], t1 # assumes base object in t3
+ loadi %opcodeStruct%::Metadata::%modeMetadataName%.defaultMode.structureID[t2], t0
+ bineq t0, t1, slowLabel
+ loadis %opcodeStruct%::Metadata::%modeMetadataName%.defaultMode.cachedOffset[t2], t1
+ loadPropertyAtVariableOffset(t1, t3, t0, t1)
+ valueProfile(opcodeStruct, valueProfileName, t2, t0, t1)
+ return(t0, t1)
+.opGetByIdProtoLoad:
+ bbneq t1, constexpr GetByIdMode::ProtoLoad, .opGetByIdArrayLength
+ loadi JSCell::m_structureID[t3], t1
+ loadi %opcodeStruct%::Metadata::%modeMetadataName%.protoLoadMode.structureID[t2], t3
+ bineq t3, t1, slowLabel
+ loadis %opcodeStruct%::Metadata::%modeMetadataName%.protoLoadMode.cachedOffset[t2], t1
+ loadp %opcodeStruct%::Metadata::%modeMetadataName%.protoLoadMode.cachedSlot[t2], t3
+ loadPropertyAtVariableOffset(t1, t3, t0, t1)
+ valueProfile(opcodeStruct, valueProfileName, t2, t0, t1)
+ return(t0, t1)
+
+.opGetByIdArrayLength:
+ bbneq t1, constexpr GetByIdMode::ArrayLength, .opGetByIdUnset
+ move t3, t0
+ arrayProfile(%opcodeStruct%::Metadata::%modeMetadataName%.arrayLengthMode.arrayProfile, t0, t2, t5)
+ btiz t0, IsArray, slowLabel
+ btiz t0, IndexingShapeMask, slowLabel
+ loadp JSObject::m_butterfly[t3], t0
+ loadi -sizeof IndexingHeader + IndexingHeader::u.lengths.publicLength[t0], t0
+ bilt t0, 0, slowLabel
+ valueProfile(opcodeStruct, valueProfileName, t2, Int32Tag, t0)
+ return(Int32Tag, t0)
+
+.opGetByIdUnset:
+ loadi JSCell::m_structureID[t3], t1
+ loadi %opcodeStruct%::Metadata::%modeMetadataName%.unsetMode.structureID[t2], t0
+ bineq t0, t1, slowLabel
+ valueProfile(opcodeStruct, valueProfileName, t2, UndefinedTag, 0)
+ return(UndefinedTag, 0)
+
+end
+
llintOpWithMetadata(op_get_by_id, OpGetById, macro (size, get, dispatch, metadata, return)
metadata(t5, t0)
loadb OpGetById::Metadata::m_modeMetadata.mode[t5], t1
@@ -1982,6 +2032,30 @@
.done:
end
+macro callHelper(opcodeName, slowPath, opcodeStruct, valueProfileName, dstVirtualRegister, prepareCall, size, dispatch, metadata, getCallee, getArgumentStart, getArgumentCountIncludingThis)
+ metadata(t5, t0)
+ getCallee(t0)
+
+ loadp %opcodeStruct%::Metadata::m_callLinkInfo.m_calleeOrLastSeenCalleeWithLinkBit[t5], t2
+ loadConstantOrVariablePayload(size, t0, CellTag, t3, .opCallSlow)
+ bineq t3, t2, .opCallSlow
+ getArgumentStart(t3)
+ lshifti 3, t3
+ negi t3
+ addp cfr, t3 # t3 contains the new value of cfr
+ storei t2, Callee + PayloadOffset[t3]
+ getArgumentCountIncludingThis(t2)
+ storei PC, ArgumentCountIncludingThis + TagOffset[cfr]
+ storei t2, ArgumentCountIncludingThis + PayloadOffset[t3]
+ storei CellTag, Callee + TagOffset[t3]
+ move t3, sp
+ prepareCall(%opcodeStruct%::Metadata::m_callLinkInfo.m_machineCodeTarget[t5], t2, t3, t4, JSEntryPtrTag)
+ callTargetFunction(opcodeName, size, opcodeStruct, valueProfileName, dstVirtualRegister, dispatch, %opcodeStruct%::Metadata::m_callLinkInfo.m_machineCodeTarget[t5], JSEntryPtrTag)
+
+.opCallSlow:
+ slowPathForCall(opcodeName, size, opcodeStruct, valueProfileName, dstVirtualRegister, dispatch, slowPath, prepareCall)
+end
+
macro commonCallOp(opcodeName, slowPath, opcodeStruct, prepareCall, prologue)
llintOpWithMetadata(opcodeName, opcodeStruct, macro (size, get, dispatch, metadata, return)
metadata(t5, t0)
@@ -1990,25 +2064,19 @@
getu(size, opcodeStruct, fieldName, dst)
end, metadata)
- get(m_callee, t0)
- loadp %opcodeStruct%::Metadata::m_callLinkInfo.m_calleeOrLastSeenCalleeWithLinkBit[t5], t2
- loadConstantOrVariablePayload(size, t0, CellTag, t3, .opCallSlow)
- bineq t3, t2, .opCallSlow
- getu(size, opcodeStruct, m_argv, t3)
- lshifti 3, t3
- negi t3
- addp cfr, t3 # t3 contains the new value of cfr
- storei t2, Callee + PayloadOffset[t3]
- getu(size, opcodeStruct, m_argc, t2)
- storei PC, ArgumentCountIncludingThis + TagOffset[cfr]
- storei t2, ArgumentCountIncludingThis + PayloadOffset[t3]
- storei CellTag, Callee + TagOffset[t3]
- move t3, sp
- prepareCall(%opcodeStruct%::Metadata::m_callLinkInfo.m_machineCodeTarget[t5], t2, t3, t4, JSEntryPtrTag)
- callTargetFunction(opcodeName, size, opcodeStruct, m_profile, m_dst, dispatch, %opcodeStruct%::Metadata::m_callLinkInfo.m_machineCodeTarget[t5], JSEntryPtrTag)
+ macro getCallee(dst)
+ get(m_callee, t0)
+ end
- .opCallSlow:
- slowPathForCall(opcodeName, size, opcodeStruct, m_profile, m_dst, dispatch, slowPath, prepareCall)
+ macro getArgumentStart(dst)
+ getu(size, opcodeStruct, m_argv, dst)
+ end
+
+ macro getArgumentCount(dst)
+ getu(size, opcodeStruct, m_argc, dst)
+ end
+
+ callHelper(opcodeName, slowPath, opcodeStruct, m_profile, m_dst, prepareCall, size, dispatch, metadata, getCallee, getArgumentStart, getArgumentCount)
end)
end
@@ -2642,25 +2710,150 @@
return(Int32Tag, t0)
end)
-llintOp(op_iterator_open, OpIteratorOpen, macro (size, get, dispatch)
- defineOSRExitReturnLabel(op_iterator_open, size)
- break
- if C_LOOP or C_LOOP_WIN
- # Insert superflous call return labels for Cloop.
- cloopCallJSFunction a0 # symbolIterator
- cloopCallJSFunction a0 # get next
+llintOpWithMetadata(op_iterator_open, OpIteratorOpen, macro (size, get, dispatch, metadata, return)
+ macro fastNarrow()
+ callSlowPath(_iterator_open_try_fast_narrow)
end
+ macro fastWide16()
+ callSlowPath(_iterator_open_try_fast_wide16)
+ end
+ macro fastWide32()
+ callSlowPath(_iterator_open_try_fast_wide32)
+ end
+ size(fastNarrow, fastWide16, fastWide32, macro (callOp) callOp() end)
+
+ # FIXME: We should do this with inline assembly since it's the "fast" case.
+ bbeq r1, constexpr IterationMode::Generic, .iteratorOpenGeneric
+ dispatch()
+
+.iteratorOpenGeneric:
+ macro gotoGetByIdCheckpoint()
+ jmp .getByIdStart
+ end
+
+ macro getCallee(dst)
+ get(m_symbolIterator, dst)
+ end
+
+ macro getArgumentIncludingThisStart(dst)
+ getu(size, OpIteratorOpen, m_stackOffset, dst)
+ end
+
+ macro getArgumentIncludingThisCount(dst)
+ move 1, dst
+ end
+
+ callHelper(op_iterator_open, _llint_slow_path_iterator_open_call, OpIteratorOpen, m_iteratorProfile, m_iterator, prepareForRegularCall, size, gotoGetByIdCheckpoint, metadata, getCallee, getArgumentIncludingThisStart, getArgumentIncludingThisCount)
+
+.getByIdStart:
+ macro storeNextAndDispatch(valueTag, valuePayload)
+ move valueTag, t2
+ move valuePayload, t3
+ get(m_next, t1)
+ storei t2, TagOffset[cfr, t1, 8]
+ storei t3, PayloadOffset[cfr, t1, 8]
+ dispatch()
+ end
+
+ # We need to load m_iterator into t3 because that's where
+ # performGetByIDHelper expects the base object
+ loadVariable(get, m_iterator, t3, t0, t3)
+ bineq t0, CellTag, .iteratorOpenGenericGetNextSlow
+ performGetByIDHelper(OpIteratorOpen, m_modeMetadata, m_nextProfile, .iteratorOpenGenericGetNextSlow, size, metadata, storeNextAndDispatch)
+
+.iteratorOpenGenericGetNextSlow:
+ callSlowPath(_llint_slow_path_iterator_open_get_next)
+ dispatch()
end)
-llintOp(op_iterator_next, OpIteratorNext, macro (size, get, dispatch)
- defineOSRExitReturnLabel(op_iterator_next, size)
- break
- if C_LOOP or C_LOOP_WIN
- # Insert superflous call return labels for Cloop.
- # FIXME: Not sure why two are only needed...
- cloopCallJSFunction a0 # next
- cloopCallJSFunction a0 # get done
+llintOpWithMetadata(op_iterator_next, OpIteratorNext, macro (size, get, dispatch, metadata, return)
+
+ loadVariable(get, m_next, t0, t1, t0)
+ bieq t1, UndefinedTag, .iteratorNextGeneric
+ btinz t0, .iteratorNextGeneric
+
+ macro fastNarrow()
+ callSlowPath(_iterator_next_try_fast_narrow)
end
+ macro fastWide16()
+ callSlowPath(_iterator_next_try_fast_wide16)
+ end
+ macro fastWide32()
+ callSlowPath(_iterator_next_try_fast_wide32)
+ end
+ size(fastNarrow, fastWide16, fastWide32, macro (callOp) callOp() end)
+
+ # FIXME: We should do this with inline assembly since it's the "fast" case.
+ bbeq r1, constexpr IterationMode::Generic, .iteratorNextGeneric
+ dispatch()
+
+.iteratorNextGeneric:
+ macro gotoGetDoneCheckpoint()
+ jmp .getDoneStart
+ end
+
+ macro getCallee(dst)
+ get(m_next, dst)
+ end
+
+ macro getArgumentIncludingThisStart(dst)
+ getu(size, OpIteratorNext, m_stackOffset, dst)
+ end
+
+ macro getArgumentIncludingThisCount(dst)
+ move 1, dst
+ end
+
+ # Use m_value slot as a tmp since we are going to write to it later.
+ callHelper(op_iterator_next, _llint_slow_path_iterator_next_call, OpIteratorNext, m_nextResultProfile, m_value, prepareForRegularCall, size, gotoGetDoneCheckpoint, metadata, getCallee, getArgumentIncludingThisStart, getArgumentIncludingThisCount)
+
+.getDoneStart:
+ macro storeDoneAndJmpToGetValue(doneValueTag, doneValuePayload)
+ move doneValueTag, t0
+ move doneValuePayload, t1
+ get(m_done, t2)
+ storei t0, TagOffset[cfr, t2, 8]
+ storei t1, PayloadOffset[cfr, t2, 8]
+ jmp .getValueStart
+ end
+
+ loadVariable(get, m_value, t3, t0, t3)
+ bineq t0, CellTag, .getDoneSlow
+ performGetByIDHelper(OpIteratorNext, m_doneModeMetadata, m_doneProfile, .getDoneSlow, size, metadata, storeDoneAndJmpToGetValue)
+
+.getDoneSlow:
+ callSlowPath(_llint_slow_path_iterator_next_get_done)
+ branchIfException(_llint_throw_from_slow_path_trampoline)
+ loadVariable(get, m_done, t1, t0, t1)
+
+ # storeDoneAndJmpToGetValue puts the doneValue into t0
+.getValueStart:
+ # In 32 bits, following slow path if tags is not null, undefined, int32, boolean.
+ # These satisfy the mask ~0x3.
+ # Therefore if the mask is _not_ satisfied, we branch to the slow case.
+ btinz t0, ~0x3, .getValueSlow
+ btiz t1, 0x1, .notDone
+ dispatch()
+
+.notDone:
+ macro storeValueAndDispatch(vTag, vPayload)
+ move vTag, t2
+ move vPayload, t3
+ get(m_value, t1)
+ storei t2, TagOffset[cfr, t1, 8]
+ storei t3, PayloadOffset[cfr, t1, 8]
+ checkStackPointerAlignment(t0, 0xbaddb01e)
+ dispatch()
+ end
+
+ # Reload the next result tmp since the get_by_id above may have clobbered t3.
+ loadVariable(get, m_value, t3, t0, t3)
+ # We don't need to check if the iterator result is a cell here since we will have thrown an error before.
+ performGetByIDHelper(OpIteratorNext, m_valueModeMetadata, m_valueProfile, .getValueSlow, size, metadata, storeValueAndDispatch)
+
+.getValueSlow:
+ callSlowPath(_llint_slow_path_iterator_next_get_value)
+ dispatch()
end)
llintOpWithProfile(op_get_internal_field, OpGetInternalField, macro (size, get, dispatch, return)