@@ -112,11 +112,11 @@ extension Execution {
112
112
@inline ( never)
113
113
private func prepareForIndirectCall(
114
114
sp: Sp , tableIndex: TableIndex , expectedType: InternedFuncType ,
115
- callIndirectOperand : Instruction . CallIndirectOperand
115
+ address : VReg
116
116
) throws -> ( InternalFunction , InternalInstance ) {
117
117
let callerInstance = currentInstance ( sp: sp)
118
118
let table = callerInstance. tables [ Int ( tableIndex) ]
119
- let value = sp [ callIndirectOperand . index ] . asAddressOffset ( table. limits. isMemory64)
119
+ let value = sp [ address ] . asAddressOffset ( table. limits. isMemory64)
120
120
let elementIndex = Int ( value)
121
121
guard elementIndex < table. elements. count else {
122
122
throw Trap ( . tableOutOfBounds( elementIndex) )
@@ -141,7 +141,7 @@ extension Execution {
141
141
var pc = pc
142
142
let ( function, callerInstance) = try prepareForIndirectCall (
143
143
sp: sp, tableIndex: immediate. tableIndex, expectedType: immediate. type,
144
- callIndirectOperand : immediate
144
+ address : immediate. index
145
145
)
146
146
( pc, sp) = try invoke (
147
147
function: function,
@@ -163,6 +163,21 @@ extension Execution {
163
163
return pc. next ( )
164
164
}
165
165
166
+ mutating func returnCallIndirect( sp: inout Sp , pc: Pc , md: inout Md , ms: inout Ms , immediate: Instruction . ReturnCallIndirectOperand ) throws -> ( Pc , CodeSlot ) {
167
+ var pc = pc
168
+ let ( function, callerInstance) = try prepareForIndirectCall (
169
+ sp: sp, tableIndex: immediate. tableIndex, expectedType: immediate. type,
170
+ address: immediate. index
171
+ )
172
+ ( pc, sp) = try tailInvoke (
173
+ function: function,
174
+ callerInstance: callerInstance,
175
+ spAddend: 0 ,
176
+ sp: sp, pc: pc, md: & md, ms: & ms
177
+ )
178
+ return pc. next ( )
179
+ }
180
+
166
181
mutating func resizeFrameHeader( sp: inout Sp , immediate: Instruction . ResizeFrameHeaderOperand ) throws {
167
182
let newSp = sp. advanced ( by: Int ( immediate. delta) )
168
183
try checkStackBoundary ( newSp)
0 commit comments