@@ -112,11 +112,11 @@ extension Execution {
112112 @inline ( never)
113113 private func prepareForIndirectCall(
114114 sp: Sp , tableIndex: TableIndex , expectedType: InternedFuncType ,
115- callIndirectOperand : Instruction . CallIndirectOperand
115+ address : VReg
116116 ) throws -> ( InternalFunction , InternalInstance ) {
117117 let callerInstance = currentInstance ( sp: sp)
118118 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)
120120 let elementIndex = Int ( value)
121121 guard elementIndex < table. elements. count else {
122122 throw Trap ( . tableOutOfBounds( elementIndex) )
@@ -141,7 +141,7 @@ extension Execution {
141141 var pc = pc
142142 let ( function, callerInstance) = try prepareForIndirectCall (
143143 sp: sp, tableIndex: immediate. tableIndex, expectedType: immediate. type,
144- callIndirectOperand : immediate
144+ address : immediate. index
145145 )
146146 ( pc, sp) = try invoke (
147147 function: function,
@@ -163,6 +163,21 @@ extension Execution {
163163 return pc. next ( )
164164 }
165165
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+
166181 mutating func resizeFrameHeader( sp: inout Sp , immediate: Instruction . ResizeFrameHeaderOperand ) throws {
167182 let newSp = sp. advanced ( by: Int ( immediate. delta) )
168183 try checkStackBoundary ( newSp)
0 commit comments