-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add NativeAOT WebAssembly object writer #132032
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
Draft
jtschuster
wants to merge
13
commits into
dotnet:wasm-writer-shared-implementation
Choose a base branch
from
jtschuster:wasm-naot-writer-stacked
base: wasm-writer-shared-implementation
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0a3293c
Fix NativeAOT warnings in wasm code
jtschuster baaecb0
Add reproZero project
jtschuster f1057e9
Create a NativeAOT wasm objectwriter
jtschuster 4c4b00e
Merge work from 131556
jtschuster 9df520e
Fix rebase issues
jtschuster a322ac9
Introduce WebCIL object writer type
jtschuster ac94805
Keep WebCIL alignment with WebCIL writer
jtschuster dab07be
Move shared WASM logic to base writer
jtschuster ed2a945
Fix NativeAOT warnings in wasm code
jtschuster 163025c
Fix merge issue
jtschuster c1c242f
WIP - nearly validated wasm output
jtschuster dee7864
Add alias tracking to WasmSymbolManager
jtschuster 238d28a
Stack NativeAOT WASM writer on shared writer
jtschuster 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
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
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 |
|---|---|---|
|
|
@@ -66,22 +66,28 @@ void Lowering::LowerPEPCall(GenTreeCall* call) | |
| JITDUMP("Begin lowering PEP call\n"); | ||
| DISPTREERANGE(BlockRange(), call); | ||
|
|
||
| // PEP call must always have a control expression | ||
| assert(call->gtControlExpr != nullptr); | ||
| LIR::Use callTargetUse(BlockRange(), &call->gtControlExpr, call); | ||
| GenTree* callTargetForArg; | ||
| if (call->gtControlExpr != nullptr) | ||
|
Member
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 method is called |
||
| { | ||
| LIR::Use callTargetUse(BlockRange(), &call->gtControlExpr, call); | ||
|
|
||
| JITDUMP("Creating new local variable for PEP"); | ||
| unsigned int callTargetLclNum = callTargetUse.ReplaceWithLclVar(m_compiler); | ||
| GenTreeLclVar* callTargetLclForArg = m_compiler->gtNewLclvNode(callTargetLclNum, TYP_I_IMPL); | ||
| JITDUMP("Creating new local variable for PEP"); | ||
| unsigned int callTargetLclNum = callTargetUse.ReplaceWithLclVar(m_compiler); | ||
| callTargetForArg = m_compiler->gtNewLclvNode(callTargetLclNum, TYP_I_IMPL); | ||
| } | ||
| else | ||
| { | ||
| assert(call->gtDirectCallAddress != nullptr); | ||
| callTargetForArg = AddrGen(call->gtDirectCallAddress); | ||
| } | ||
| DISPTREE(call); | ||
|
|
||
| JITDUMP("Add new arg to call arg list corresponding to PEP target"); | ||
| NewCallArg pepTargetArg = | ||
| NewCallArg::Primitive(callTargetLclForArg).WellKnown(WellKnownArg::WasmPortableEntryPoint); | ||
| CallArg* pepArg = call->gtArgs.PushBack(m_compiler, pepTargetArg); | ||
| NewCallArg pepTargetArg = NewCallArg::Primitive(callTargetForArg).WellKnown(WellKnownArg::WasmPortableEntryPoint); | ||
| CallArg* pepArg = call->gtArgs.PushBack(m_compiler, pepTargetArg); | ||
|
|
||
| pepArg->SetEarlyNode(nullptr); | ||
| pepArg->SetLateNode(callTargetLclForArg); | ||
| pepArg->SetLateNode(callTargetForArg); | ||
| call->gtArgs.PushLateBack(pepArg); | ||
|
|
||
| // Set up ABI information for this arg; PEP's should be passed as the last param to a wasm function | ||
|
|
@@ -90,12 +96,18 @@ void Lowering::LowerPEPCall(GenTreeCall* call) | |
| pepArg->AbiInfo = | ||
| ABIPassingInformation::FromSegmentByValue(m_compiler, | ||
| ABIPassingSegment::InRegister(pepReg, 0, TARGET_POINTER_SIZE)); | ||
| BlockRange().InsertBefore(call, callTargetLclForArg); | ||
| BlockRange().InsertBefore(call, callTargetForArg); | ||
|
|
||
| // Lower the new PEP arg now that the call abi info is updated and lcl var is inserted | ||
| LowerArg(call, pepArg); | ||
| DISPTREE(call); | ||
|
|
||
| if (call->gtControlExpr == nullptr) | ||
| { | ||
| JITDUMP("Finished lowering direct PEP call\n"); | ||
| return; | ||
| } | ||
|
|
||
| JITDUMP("Rewrite PEP call's control expression to indirect through the new local variable\n"); | ||
|
|
||
| // Rewrite the call's control expression to have an additional load from the PEP local | ||
|
|
||
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP-specific logic should be gated by
JitFlags::JIT_FLAG_PORTABLE_ENTRY_POINTScheck