-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[Wasm RyuJIT] Wire up GC info encoding/decoding for Wasm #126932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ function(create_standalone_jit) | |
|
|
||
| if(TARGETDETAILS_OS STREQUAL "unix_osx" OR TARGETDETAILS_OS STREQUAL "unix_anyos") | ||
| set(JIT_ARCH_LINK_LIBRARIES gcinfo_unix_${TARGETDETAILS_ARCH}) | ||
| elseif(NOT ${TARGETDETAILS_ARCH} MATCHES "wasm") | ||
| else() | ||
| set(JIT_ARCH_LINK_LIBRARIES gcinfo_${TARGETDETAILS_OS}_${TARGETDETAILS_ARCH}) | ||
| endif() | ||
|
kg marked this conversation as resolved.
|
||
|
|
||
|
|
@@ -292,6 +292,8 @@ set( JIT_RISCV64_SOURCES | |
| ) | ||
|
|
||
| set( JIT_WASM_SOURCES | ||
| gcdecode.cpp | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The more proper way to add these files is by moving them from |
||
| gcencode.cpp | ||
| codegenwasm.cpp | ||
| emitwasm.cpp | ||
| fgwasm.cpp | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -854,7 +854,9 @@ bool CodeGen::genIsSameLocalVar(GenTree* op1, GenTree* op2) | |
| // inline | ||
| void CodeGenInterface::genUpdateRegLife(const LclVarDsc* varDsc, bool isBorn, bool isDying DEBUGARG(GenTree* tree)) | ||
| { | ||
| #if EMIT_GENERATE_GCINFO // The regset being updated here is only needed for codegen-level GCness tracking | ||
| #if EMIT_GENERATE_GCINFO && !defined(TARGET_WASM) | ||
| // The regset being updated here is only needed for codegen-level GCness tracking, | ||
| // and Wasm does not have registers | ||
| regMaskTP regMask = genGetRegMask(varDsc); | ||
|
|
||
| #ifdef DEBUG | ||
|
|
@@ -884,7 +886,7 @@ void CodeGenInterface::genUpdateRegLife(const LclVarDsc* varDsc, bool isBorn, bo | |
| assert(varDsc->IsAlwaysAliveInMemory() || ((regSet.GetMaskVars() & regMask) == 0)); | ||
| regSet.AddMaskVars(regMask); | ||
| } | ||
| #endif // EMIT_GENERATE_GCINFO | ||
| #endif // EMIT_GENERATE_GCINFO && !TARGET_WASM | ||
| } | ||
|
|
||
| #ifndef TARGET_WASM | ||
|
|
@@ -1032,6 +1034,7 @@ void Compiler::compChangeLife(VARSET_VALARG_TP newLife) | |
| bool isByRef = varDsc->TypeIs(TYP_BYREF); | ||
| bool isInReg = varDsc->lvIsInReg(); | ||
| bool isInMemory = !isInReg || varDsc->IsAlwaysAliveInMemory(); | ||
| #ifndef TARGET_WASM | ||
| if (isInReg) | ||
| { | ||
| // TODO-Cleanup: Move the code from compUpdateLifeVar to genUpdateRegLife that updates the | ||
|
|
@@ -1047,7 +1050,8 @@ void Compiler::compChangeLife(VARSET_VALARG_TP newLife) | |
| } | ||
| codeGen->genUpdateRegLife(varDsc, false /*isBorn*/, true /*isDying*/ DEBUGARG(nullptr)); | ||
| } | ||
| // Update the gcVarPtrSetCur if it is in memory. | ||
| #endif // !TARGET_WASM | ||
| // Update the gcVarPtrSetCur if it is in memory. | ||
| if (isInMemory && (isGCRef || isByRef)) | ||
| { | ||
| VarSetOps::RemoveElemD(this, codeGen->gcInfo.gcVarPtrSetCur, deadVarIndex); | ||
|
Comment on lines
+1053
to
1057
|
||
|
|
@@ -1070,6 +1074,7 @@ void Compiler::compChangeLife(VARSET_VALARG_TP newLife) | |
| bool isByRef = varDsc->TypeIs(TYP_BYREF); | ||
| if (varDsc->lvIsInReg()) | ||
| { | ||
| #ifndef TARGET_WASM | ||
| // If this variable is going live in a register, it is no longer live on the stack, | ||
| // unless it is an EH/"spill at single-def" var, which always remains live on the stack. | ||
| if (!varDsc->IsAlwaysAliveInMemory()) | ||
|
|
@@ -1092,6 +1097,7 @@ void Compiler::compChangeLife(VARSET_VALARG_TP newLife) | |
| { | ||
| codeGen->gcInfo.gcRegByrefSetCur |= regMask; | ||
| } | ||
| #endif // !TARGET_WASM | ||
| } | ||
| else if (lvaIsGCTracked(varDsc)) | ||
| { | ||
|
|
@@ -1769,7 +1775,7 @@ void CodeGen::genExitCode(BasicBlock* block) | |
|
|
||
| genIPmappingAdd(IPmappingDscKind::Epilog, DebugInfo(), true); | ||
|
|
||
| #if EMIT_GENERATE_GCINFO && defined(DEBUG) | ||
| #if EMIT_GENERATE_GCINFO && defined(DEBUG) && !defined(TARGET_WASM) | ||
| // For returnining epilogs do some validation that the GC info looks right. | ||
| if (!block->HasFlag(BBF_HAS_JMP)) | ||
| { | ||
|
|
@@ -1791,7 +1797,7 @@ void CodeGen::genExitCode(BasicBlock* block) | |
| } | ||
| } | ||
| } | ||
| #endif // EMIT_GENERATE_GCINFO && defined(DEBUG) | ||
| #endif // EMIT_GENERATE_GCINFO && defined(DEBUG) && !defined(TARGET_WASM) | ||
|
|
||
| if (m_compiler->getNeedsGSSecurityCookie()) | ||
| { | ||
|
|
@@ -7210,7 +7216,7 @@ void CodeGen::genReturn(GenTree* treeNode) | |
| } | ||
| } | ||
|
|
||
| #if EMIT_GENERATE_GCINFO | ||
| #if EMIT_GENERATE_GCINFO && !defined(TARGET_WASM) | ||
| if (treeNode->OperIs(GT_RETURN, GT_SWIFT_ERROR_RET)) | ||
| { | ||
| genMarkReturnGCInfo(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.