@@ -43,6 +43,7 @@ enum TargetArch {
4343 Target_Arm64 ,
4444 Target_LoongArch64 ,
4545 Target_RiscV64 ,
46+ Target_Wasm32 ,
4647};
4748
4849struct CorDisasm ;
@@ -191,6 +192,44 @@ typedef void __cdecl DumpDiffBlocks_t(const CorAsmDiff *AsmDiff,
191192 const uint8_t * Bytes2 , size_t Size2 );
192193DllIface DumpDiffBlocks_t DumpDiffBlocks ;
193194
195+ // "Framed" variants -- intended for Target_Wasm32 today, where the JIT writes
196+ // the code buffer as a sequence of length-prefixed Wasm function/funclet
197+ // bodies rather than a flat instruction stream.
198+ //
199+ // Layout of each record:
200+ // [ULEB128 body_size_in_bytes][body bytes]
201+ //
202+ // Each body begins with the standard Wasm locals declaration
203+ // [ULEB128 num_local_decls][(ULEB128 count, u8 valtype)*]
204+ // followed by the opcode stream (which is expected to end with the outer
205+ // function's `end` opcode 0x0B).
206+ //
207+ // The OffsetComparator callback is invoked with BlockOffset set to the byte
208+ // offset of the current instruction's *opcode byte*, measured from the start
209+ // of the whole framed buffer (Bytes). This matches the offsets used by the
210+ // JIT-recorded relocation tables, so callers can look up reloc kind / target
211+ // directly without further bookkeeping.
212+ //
213+ // The non-framed entry points (NearDiffCodeBlocks, DumpCodeBlock,
214+ // DumpDiffBlocks) automatically delegate to these framed implementations
215+ // when the configured target architecture is Target_Wasm32.
216+ typedef bool __cdecl NearDiffCodeBlocksFramed_t (const CorAsmDiff * AsmDiff ,
217+ const void * UserData ,
218+ const uint8_t * Address1 ,
219+ const uint8_t * Bytes1 , size_t Size1 ,
220+ const uint8_t * Address2 ,
221+ const uint8_t * Bytes2 , size_t Size2 );
222+ DllIface NearDiffCodeBlocksFramed_t NearDiffCodeBlocksFramed ;
223+
224+ typedef void __cdecl DumpCodeBlockFramed_t (const CorDisasm * Disasm ,
225+ const uint8_t * Address , const uint8_t * Bytes , size_t Size );
226+ DllIface DumpCodeBlockFramed_t DumpCodeBlockFramed ;
227+
228+ typedef void __cdecl DumpDiffBlocksFramed_t (const CorAsmDiff * AsmDiff ,
229+ const uint8_t * Address1 , const uint8_t * Bytes1 , size_t Size1 ,
230+ const uint8_t * Address2 , const uint8_t * Bytes2 , size_t Size2 );
231+ DllIface DumpDiffBlocksFramed_t DumpDiffBlocksFramed ;
232+
194233// Get a pointer to the buffered output buffer.
195234typedef const char * __cdecl GetOutputBuffer_t ();
196235DllIface GetOutputBuffer_t GetOutputBuffer ;
0 commit comments