Skip to content

Source gen adjustments to deal with GCX_PREEMP - #123

Merged
mrvoorhe merged 1 commit into
unity-mainfrom
native-gen-adjustment
Mar 15, 2023
Merged

Source gen adjustments to deal with GCX_PREEMP#123
mrvoorhe merged 1 commit into
unity-mainfrom
native-gen-adjustment

Conversation

@mrvoorhe

Copy link
Copy Markdown
Collaborator

Some of the embedding apis don't have GCX_PREEMP. Previously the generator always wrote them.

Only write this call if the method already includes it.

As an alternative, I thought about refactoring the NoNativeWrapperAttribute into a NativeWrapperOptionsAttribute that accepted a NativeWrapperOptions enum. Then adding NoWrapper and NoGCX_PREEMP options. I didn't go that route because I thought it would be nice to auto detect so I don't forget to add it.

Based on the comment after the GCX_PREEMP calls, I suspect that this logic is going to be revisited anyways. I figured this is good enough for now.

Some of the embedding apis don't have GCX_PREEMP. Previously the generator always wrote them.
Only write this call if the method already includes it.
@mrvoorhe
mrvoorhe requested a review from UnityAlexMarch 14, 2023 18:36
@joncham

Copy link
Copy Markdown
Member

Based on the comment after the GCX_PREEMP calls, I suspect that this logic is going to be revisited anyways. I figured this is good enough for now.

Yes, this is just a hack as IIRC some embedding API call other embedding APIs which is not expected/handled ATM.

@mrvoorhe
mrvoorhe merged commit a4567fe into unity-mainMar 15, 2023
@mrvoorhe
mrvoorhe deleted the native-gen-adjustment branch March 15, 2023 13:13
mrvoorhe pushed a commit that referenced this pull request Mar 19, 2025
* JIT: Introduce `LclVarDsc::lvIsMultiRegDest`
With recent work to expand returned promoted locals into `FIELD_LIST`
the only "whole references" of promoted locals we should see is when
stored from a multi-reg node. This is the only knowledge the backend
should need for correctness purposes, so introduce a bit to track this
property, and switch the backend to check this instead.
The existing `lvIsMultiRegRet` is essentially this + whether the local
is returned. We should be able to remove this, but it is currently used
for some heuristics in old promotion, so keep it around for now.
* JIT: Add some more constant folding in lowering
Add folding for shifts and certain binops that are now getting produced
late due to returned `FIELD_LIST` nodes.
win-arm64 example:
```csharp
[MethodImpl(MethodImplOptions.NoInlining)]
static ValueTask<byte> Foo()
{
return new ValueTask<byte>(123);
}
```
```diff
G_M17084_IG02: ;; offset=0x0008
mov x0, xzr
- mov w1, #1
- mov w2, wzr
- mov w3, #123
- orr w2, w2, w3, LSL #16
- orr w1, w2, w1, LSL #24
- ;; size=24 bbWeight=1 PerfScore 4.00
+ mov w1, #0x17B0000
+ ;; size=8 bbWeight=1 PerfScore 1.00
```
* Feedback
mrvoorhe pushed a commit that referenced this pull request Apr 17, 2026
This adds command line and test support for feature switches. And enables them in descriptors.
Some tests added, no properties/events as our descriptor parsing doesn't support properties/events yet.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@mrvoorhe@joncham@UnityAlex