-
Couldn't load subscription status.
- Fork 5.2k
Fix unboxing stubs on wasm #120153
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
Merged
radekdoulik
merged 13 commits into
dotnet:main
from
radekdoulik:clr-interp-wasm-unboxing-stubs
Sep 28, 2025
Merged
Fix unboxing stubs on wasm #120153
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b5e6231
Fix unboxing stubs on wasm
radekdoulik 88777fa
Apply suggestions from code review
radekdoulik 70cc75d
Feedback
radekdoulik 87fe2ec
Feedback
radekdoulik 4c0b8aa
Do not double free
radekdoulik 160dca1
Add thunk for the IL stub
radekdoulik 17770d5
Update src/coreclr/vm/wasm/helpers.cpp
radekdoulik 48c6e7f
Update src/coreclr/vm/prestub.cpp
radekdoulik 952c185
Finish the feedback
radekdoulik 5b7f342
Feedback
radekdoulik f5483a5
Feedback
radekdoulik 7012a06
Feedback
radekdoulik 5e8de55
Feedback
radekdoulik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1459,7 +1459,7 @@ void MethodDesc::CreateDerivedTargetSigWithExtraParams(MetaSig& msig, SigBuilder | |||||
|
|
||||||
| #ifdef FEATURE_INSTANTIATINGSTUB_AS_IL | ||||||
|
|
||||||
| Stub * CreateUnboxingILStubForSharedGenericValueTypeMethods(MethodDesc* pTargetMD) | ||||||
| Stub * CreateUnboxingILStubForValueTypeMethods(MethodDesc* pTargetMD) | ||||||
| { | ||||||
|
|
||||||
| CONTRACT(Stub*) | ||||||
|
|
@@ -1510,13 +1510,16 @@ Stub * CreateUnboxingILStubForSharedGenericValueTypeMethods(MethodDesc* pTargetM | |||||
| } | ||||||
| #endif | ||||||
|
|
||||||
| // Push the hidden context param | ||||||
| // The context is going to be captured from the thisptr | ||||||
| pCode->EmitLoadThis(); | ||||||
| pCode->EmitLDFLDA(tokRawData); | ||||||
| pCode->EmitLDC(Object::GetOffsetOfFirstField()); | ||||||
| pCode->EmitSUB(); | ||||||
| pCode->EmitLDIND_I(); | ||||||
| if (pTargetMD->RequiresInstMethodTableArg()) | ||||||
| { | ||||||
| // Push the hidden context param | ||||||
| // The context is going to be captured from the thisptr | ||||||
| pCode->EmitLoadThis(); | ||||||
| pCode->EmitLDFLDA(tokRawData); | ||||||
| pCode->EmitLDC(Object::GetOffsetOfFirstField()); | ||||||
| pCode->EmitSUB(); | ||||||
| pCode->EmitLDIND_I(); | ||||||
| } | ||||||
jkotas marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| #ifndef TARGET_X86 | ||||||
| if (msig.HasAsyncContinuation()) | ||||||
|
|
@@ -1727,13 +1730,16 @@ Stub * MakeUnboxingStubWorker(MethodDesc *pMD) | |||||
| else | ||||||
| #endif | ||||||
| { | ||||||
| #ifdef FEATURE_PORTABLE_ENTRYPOINTS | ||||||
| pstub = CreateUnboxingILStubForValueTypeMethods(pUnboxedMD); | ||||||
| #else // !FEATURE_PORTABLE_ENTRYPOINTS | ||||||
| #ifdef FEATURE_INSTANTIATINGSTUB_AS_IL | ||||||
| #ifndef FEATURE_PORTABLE_SHUFFLE_THUNKS | ||||||
| if (pUnboxedMD->RequiresInstMethodTableArg()) | ||||||
| #endif // !FEATURE_PORTABLE_SHUFFLE_THUNKS | ||||||
| { | ||||||
| _ASSERTE(pUnboxedMD->RequiresInstMethodTableArg()); | ||||||
| pstub = CreateUnboxingILStubForSharedGenericValueTypeMethods(pUnboxedMD); | ||||||
| pstub = CreateUnboxingILStubForValueTypeMethods(pUnboxedMD); | ||||||
| } | ||||||
| #ifndef FEATURE_PORTABLE_SHUFFLE_THUNKS | ||||||
| else | ||||||
|
|
@@ -1746,6 +1752,7 @@ Stub * MakeUnboxingStubWorker(MethodDesc *pMD) | |||||
| pstub = sl.Link(pMD->GetLoaderAllocator()->GetStubHeap(), NEWSTUB_FL_NONE, "UnboxingStub"); | ||||||
| } | ||||||
| #endif // !FEATURE_PORTABLE_SHUFFLE_THUNKS | ||||||
| #endif // FEATURE_PORTABLE_ENTRYPOINTS | ||||||
| } | ||||||
| RETURN pstub; | ||||||
| } | ||||||
|
|
@@ -2377,6 +2384,15 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo | |||||
| } | ||||||
| else | ||||||
| { | ||||||
| #ifdef FEATURE_PORTABLE_ENTRYPOINTS | ||||||
| pCode = pStub->GetEntryPoint(); | ||||||
| pStub->DecRef(); | ||||||
|
|
||||||
| void* ilStubInterpData = PortableEntryPoint::GetInterpreterData(pCode); | ||||||
| _ASSERTE(ilStubInterpData != NULL); | ||||||
| SetInterpreterCode((InterpByteCodeStart*)ilStubInterpData); | ||||||
| SetCodeEntryPoint(pCode); | ||||||
jkotas marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| #else | ||||||
|
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.
Suggested change
|
||||||
| if (!GetOrCreatePrecode()->SetTargetInterlocked(pStub->GetEntryPoint())) | ||||||
radekdoulik marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| { | ||||||
| if (pStub->HasExternalEntryPoint()) | ||||||
|
|
@@ -2396,12 +2412,12 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo | |||||
| // need to free the Stub allocation now. | ||||||
| pStub->DecRef(); | ||||||
| } | ||||||
| #endif // !FEATURE_PORTABLE_ENTRYPOINTS | ||||||
|
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.
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| _ASSERTE(!IsPointingToPrestub()); | ||||||
| _ASSERTE(HasStableEntryPoint()); | ||||||
|
|
||||||
|
|
||||||
| pCode = DoBackpatch(pMT, pDispatchingMT, FALSE); | ||||||
|
|
||||||
| Return: | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.