Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Report registers as dead in GCInfo before the RhpPInvoke helper.#14664

Merged
jkotas merged 3 commits intodotnet:masterfrom
sandreenko:coreRT4676
Oct 24, 2017
Merged

Report registers as dead in GCInfo before the RhpPInvoke helper.#14664
jkotas merged 3 commits intodotnet:masterfrom
sandreenko:coreRT4676

Conversation

@sandreenko
Copy link

@sandreenko sandreenko commented Oct 24, 2017

CORINFO_HELP_JIT_PINVOKE_BEGIN makes transition to preemptive mode before a P/Invoke, so it requires GC pointer state to be cleared before the helper.

I checked other occurrences of IsUnmanaged() and looks like they already consider or do not need to consider this helper case.

If opts.ShouldUsePInvokeHelpers() is enabled, than the state before the P/Invoke must be clean, so we can rewrite it as:

if (opts.ShouldUsePInvokeHelpers())
{
    if (call->gtCallMethHnd == eeFindHelper(CORINFO_HELP_JIT_PINVOKE_BEGIN))
    {
        return true;
    }
    else if (call->IsUnmanaged())
    {
       assert that the state has been cleared already.
       return false;
    }
}
else if (call->IsUnmanaged())
{
    return true;
}

but it doesn't harm to return true for unmanaged calls always.

Fix dotnet/corert#4676 .

Checked that it fixes the original test.

Sergey Andreenko added 3 commits October 23, 2017 16:48
It makes it accessible from codegen.
It terminates live of GCRefs before RhpPInvoke.
@sandreenko
Copy link
Author

PTAL @jkotas , @dotnet/jit-contrib

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link

@briansull briansull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good

@jkotas jkotas merged commit 2207dad into dotnet:master Oct 24, 2017
@sandreenko sandreenko deleted the coreRT4676 branch October 24, 2017 03:55
MichalStrehovsky added a commit to MichalStrehovsky/corert that referenced this pull request Oct 24, 2017
jkotas pushed a commit to dotnet/corert that referenced this pull request Oct 24, 2017
A-And pushed a commit to A-And/corert that referenced this pull request Oct 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simple/Threading test is crashing intermittently on Linux/OSX Release

4 participants