Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e93e57d
Revert wasm method stub method in crossgen to allow invoking the actu…
adamperlin Dec 9, 2025
4b991da
WIP add args as locals to the beginning of method epilog in Wasm codegen
adamperlin Dec 10, 2025
5933e67
Multiple fixes for emitting local declarations for incoming args
adamperlin Dec 11, 2025
7b8e339
jit-format
adamperlin Dec 11, 2025
78b7c70
Merge branch 'main' of github.com:dotnet/runtime into adamperlin/wasm…
adamperlin Dec 11, 2025
9fbfb86
Generate locals only for non-args
adamperlin Dec 11, 2025
7d12af0
Update src/coreclr/jit/emit.h
adamperlin Dec 11, 2025
4b91b3a
Update src/coreclr/jit/emitfmtswasm.h
adamperlin Dec 11, 2025
183851f
Update src/coreclr/jit/codegencommon.cpp
adamperlin Dec 11, 2025
c9d3046
Update src/coreclr/jit/emitwasm.cpp
adamperlin Dec 11, 2025
0482ee3
Remove incorrect noway_asserts
adamperlin Dec 11, 2025
dfb0627
Remove empty ifdef block
adamperlin Dec 11, 2025
b237c17
Apply some copilot review suggestions
adamperlin Dec 11, 2025
19c9eaf
Address some review feedback
adamperlin Dec 12, 2025
76a15f2
Finish addressing review feedback
adamperlin Dec 12, 2025
d32f695
Fix instGen placement
adamperlin Dec 12, 2025
f3e2f82
Add block->IsLast() guard for emitting end instruction in Wasm genFnE…
adamperlin Dec 13, 2025
0820a24
Emit correct local count for current state of Wasm codegen
adamperlin Dec 13, 2025
78945a3
Address some more review feedback
adamperlin Dec 16, 2025
9a3c21a
Merge branch 'main' of github.com:dotnet/runtime into wasm-arg-initia…
adamperlin Dec 16, 2025
ddb4801
Address additional review feedback
adamperlin Dec 17, 2025
704a4a7
Merge branch 'main' of github.com:dotnet/runtime into wasm-arg-initia…
adamperlin Dec 17, 2025
7bb7cfc
Apply suggestion from @SingleAccretion
adamperlin Dec 17, 2025
06207d5
Address additional review feedback; properly guard access to wasm-spe…
adamperlin Dec 17, 2025
c52da98
Address additional review feedback
adamperlin Dec 17, 2025
9373181
Fix condition for `end` generation in src/coreclr/jit/codegenwasm.cpp
adamperlin Dec 17, 2025
29a82df
Update src/coreclr/jit/codegenwasm.cpp
adamperlin Dec 17, 2025
afc4638
Update src/coreclr/jit/emit.h
adamperlin Dec 17, 2025
5a32a13
Address additional review feedback
adamperlin Dec 17, 2025
ef2c690
Fix bug in jitutil.py determine_jit_name logic (cherry-pick from #122…
adamperlin Dec 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address additional review feedback
  • Loading branch information
adamperlin committed Dec 17, 2025
commit 5a32a13d3b43bae495b83a2f78d6468c0f36cba9
6 changes: 3 additions & 3 deletions src/coreclr/jit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -2349,15 +2349,15 @@ class emitter
struct instrDescLclVarDecl : instrDesc
{
instrDescLclVarDecl() = delete;
cnsval_ssize_t lclCnt;
WasmValueType lclType;
unsigned int lclCnt;
WasmValueType lclType;

void idLclType(WasmValueType type)
{
lclType = type;
}

void idLclCnt(cnsval_ssize_t cnt)
void idLclCnt(unsigned int cnt)
{
lclCnt = cnt;
}
Expand Down
36 changes: 17 additions & 19 deletions src/coreclr/jit/emitwasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ bool emitter::emitInsIsStore(instruction ins)
// Notes:
// `lclOffset` is stored as debug info attached to the instruction,
// so the offset will only be used if m_debugInfoSize > 0
emitter::instrDesc* emitter::emitNewInstrLclVarDecl(emitAttr attr,
cnsval_ssize_t localCount,
WasmValueType type,
int lclOffset)
emitter::instrDesc* emitter::emitNewInstrLclVarDecl(emitAttr attr,
unsigned int localCount,
WasmValueType type,
int lclOffset)
{
instrDescLclVarDecl* id = static_cast<instrDescLclVarDecl*>(emitAllocAnyInstr(sizeof(instrDescLclVarDecl), attr));
id->idLclCnt(localCount);
Expand All @@ -156,7 +156,7 @@ emitter::instrDesc* emitter::emitNewInstrLclVarDecl(emitAttr attr,
// imm - immediate value (local count)
// valType - value type of the local variable
// offs - local variable offset (= count of preceding locals) for debug info
void emitter::emitIns_I_Ty(instruction ins, cnsval_ssize_t imm, WasmValueType valType, int offs)
void emitter::emitIns_I_Ty(instruction ins, unsigned int imm, WasmValueType valType, int offs)
{
instrDesc* id = emitNewInstrLclVarDecl(EA_8BYTE, imm, valType, offs);
insFormat fmt = emitInsFormat(ins);
Expand All @@ -168,16 +168,16 @@ void emitter::emitIns_I_Ty(instruction ins, cnsval_ssize_t imm, WasmValueType va
appendToCurIG(id);
}

WasmValueType emitter::emitGetLclVarDeclType(instrDesc* id)
WasmValueType emitter::emitGetLclVarDeclType(const instrDesc* id)
{
assert(id->idIsLclVarDecl());
return static_cast<instrDescLclVarDecl*>(id)->lclType;
return static_cast<const instrDescLclVarDecl*>(id)->lclType;
}

cnsval_ssize_t emitter::emitGetLclVarDeclCount(instrDesc* id)
unsigned int emitter::emitGetLclVarDeclCount(const instrDesc* id)
{
assert(id->idIsLclVarDecl());
return static_cast<instrDescLclVarDecl*>(id)->lclCnt;
return static_cast<const instrDescLclVarDecl*>(id)->lclCnt;
}

emitter::insFormat emitter::emitInsFormat(instruction ins)
Expand Down Expand Up @@ -292,9 +292,8 @@ unsigned emitter::instrDesc::idCodeSize() const
case IF_LOCAL_DECL:
{
assert(idIsLclVarDecl());
instrDescLclVarDecl* idl = static_cast<instrDescLclVarDecl*>(const_cast<instrDesc*>(this));
uint8_t typeCode = GetWasmValueTypeCode(idl->lclType);
size = SizeOfULEB128(idl->lclCnt) + sizeof(typeCode);
uint8_t typeCode = GetWasmValueTypeCode(emitGetLclVarDeclType(this));
size = SizeOfULEB128(emitGetLclVarDeclCount(this)) + sizeof(typeCode);
break;
}
case IF_ULEB128:
Expand Down Expand Up @@ -584,28 +583,27 @@ void emitter::emitDispIns(

case IF_LOCAL_DECL:
{
cnsval_ssize_t count = emitGetLclVarDeclCount(id);
WasmValueType valType = emitGetLclVarDeclType(id);
int offs = id->idDebugOnlyInfo()->lclOffset;
unsigned int count = emitGetLclVarDeclCount(id);
WasmValueType valType = emitGetLclVarDeclType(id);
assert(count > 0); // we should not be declaring a local entry with zero count

if (m_debugInfoSize > 0)
{
// With debug info: print the local offsets being declared
int offs = id->idDebugOnlyInfo()->lclOffset;
if (count > 1)
{
printf("[%llu..%llu] type=%s", offs, offs + (uint64_t)count - 1, WasmValueTypeName(valType));
printf("[%u..%u] type=%s", offs, offs + count - 1, WasmValueTypeName(valType));
}
else // single local case
{
printf("[%llu] type=%s", offs, WasmValueTypeName(valType));
printf("[%u] type=%s", offs, WasmValueTypeName(valType));
}
}
else
{
// No debug info case: just print the count and type of the locals
printf(" count=%llu type=%s", (uint64_t)count, WasmValueTypeName(valType));
break;
printf(" count=%u type=%s", count, WasmValueTypeName(valType));
}
}
break;
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/jit/emitwasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void emitDispInst(instruction ins);
public:
void emitIns(instruction ins);
void emitIns_I(instruction ins, emitAttr attr, cnsval_ssize_t imm);
void emitIns_I_Ty(instruction ins, cnsval_ssize_t imm, WasmValueType valType, int offs);
void emitIns_I_Ty(instruction ins, unsigned int imm, WasmValueType valType, int offs);
void emitIns_J(instruction ins, emitAttr attr, cnsval_ssize_t imm, BasicBlock* tgtBlock);
void emitIns_S(instruction ins, emitAttr attr, int varx, int offs);
void emitIns_R(instruction ins, emitAttr attr, regNumber reg);
Expand All @@ -34,9 +34,9 @@ static unsigned SizeOfSLEB128(int64_t value);

static unsigned emitGetAlignHintLog2(const instrDesc* id);

instrDesc* emitNewInstrLclVarDecl(emitAttr attr, cnsval_ssize_t localCount, WasmValueType type, int lclOffset);
static WasmValueType emitGetLclVarDeclType(instrDesc* id);
static cnsval_ssize_t emitGetLclVarDeclCount(instrDesc* id);
instrDesc* emitNewInstrLclVarDecl(emitAttr attr, unsigned int localCount, WasmValueType type, int lclOffset);
static WasmValueType emitGetLclVarDeclType(const instrDesc* id);
static unsigned int emitGetLclVarDeclCount(const instrDesc* id);

/************************************************************************/
/* Private members that deal with target-dependent instr. descriptors */
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/instrswasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
//
INST(invalid, "INVALID", 0, IF_NONE, BAD_CODE)
INST(unreachable, "unreachable", 0, IF_OPCODE, 0x00)
INST(label, "label", 0, IF_RAW_ULEB128, 0x00)
INST(label, "label", 0, IF_RAW_ULEB128, 0x00)
INST(local_cnt, "local.cnt", 0, IF_RAW_ULEB128, 0x00)
INST(local_decl, "local", 0, IF_LOCAL_DECL, 0x00)
INST(local_decl, "local", 0, IF_LOCAL_DECL, 0x00)
INST(nop, "nop", 0, IF_OPCODE, 0x01)
INST(block, "block", 0, IF_BLOCK, 0x02)
INST(loop, "loop", 0, IF_BLOCK, 0x03)
Expand Down
Loading