Skip to content
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

Move return buffer handling from interop to the JIT #39294

Merged
merged 82 commits into from
Dec 3, 2020

Commits on Jul 7, 2020

  1. Configuration menu
    Copy the full SHA
    c17d786 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8eecd35 View commit details
    Browse the repository at this point in the history
  3. On Windows non-arm32, unmanaged instance methods have their hidden re…

    …tbuf arg after the `this` parameter, not before.
    jkoritzinsky committed Jul 7, 2020
    Configuration menu
    Copy the full SHA
    c06a040 View commit details
    Browse the repository at this point in the history

Commits on Jul 8, 2020

  1. Teach the JIT to generate a return buffer for reverse P/Invokes for t…

    …hiscall on required platforms. Still need to reorder the emit so the arguments are emitted correctly.
    jkoritzinsky committed Jul 8, 2020
    Configuration menu
    Copy the full SHA
    9448965 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7a26d40 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a75f746 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    4f09a4f View commit details
    Browse the repository at this point in the history
  5. Fix x86 build.

    jkoritzinsky committed Jul 8, 2020
    Configuration menu
    Copy the full SHA
    e4aaf91 View commit details
    Browse the repository at this point in the history
  6. Add enum test.

    jkoritzinsky committed Jul 8, 2020
    Configuration menu
    Copy the full SHA
    3d66e53 View commit details
    Browse the repository at this point in the history
  7. Remove interop-specific handling of x86 thiscall and get non trivial-…

    …primitive-wrapper struct returning thiscall working.
    jkoritzinsky committed Jul 8, 2020
    Configuration menu
    Copy the full SHA
    4eee458 View commit details
    Browse the repository at this point in the history

Commits on Jul 9, 2020

  1. Configuration menu
    Copy the full SHA
    a7e0b52 View commit details
    Browse the repository at this point in the history

Commits on Jul 10, 2020

  1. Don't unwrap single primitive field structs on x86 any more. RyuJIT s…

    …eems to optimize them correctly now. Also this enables the JIT to correctly handle native instance method calls that return single primitive field structs.
    jkoritzinsky committed Jul 10, 2020
    Configuration menu
    Copy the full SHA
    8eb6846 View commit details
    Browse the repository at this point in the history
  2. Pass the retbuf arg on the stack as the first argument (inserted last…

    … since the arguments have already been reversed) on x86.
    jkoritzinsky committed Jul 10, 2020
    Configuration menu
    Copy the full SHA
    110c2ae View commit details
    Browse the repository at this point in the history

Commits on Jul 13, 2020

  1. Remove extra newline

    jkoritzinsky committed Jul 13, 2020
    Configuration menu
    Copy the full SHA
    96336f5 View commit details
    Browse the repository at this point in the history
  2. Enable returning 8-byte structs in multiple registers on x86 and add …

    …a test in interop to validate.
    jkoritzinsky committed Jul 13, 2020
    Configuration menu
    Copy the full SHA
    48e3fce View commit details
    Browse the repository at this point in the history

Commits on Jul 14, 2020

  1. Since the x86 stub linker path emulates the stdcall calling conventio…

    …n for thiscall Reverse P/Invoke stubs, update the stub linker to handle the case where a return value would be an enregistered return on stdcall but is returned via a return buffer for thiscall.
    jkoritzinsky committed Jul 14, 2020
    Configuration menu
    Copy the full SHA
    b83c60a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f3bdf58 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e7b8369 View commit details
    Browse the repository at this point in the history
  4. Apply format patch.

    jkoritzinsky committed Jul 14, 2020
    Configuration menu
    Copy the full SHA
    5324b7e View commit details
    Browse the repository at this point in the history
  5. Don't check IsUmanagedValueTypeReturnedByRef unless the methodtable i…

    …s a value type.
    
    Use a type handle instead of a method table.
    
    Don't check size for enums.
    jkoritzinsky committed Jul 14, 2020
    Configuration menu
    Copy the full SHA
    3c60ca2 View commit details
    Browse the repository at this point in the history

Commits on Jul 15, 2020

  1. Configuration menu
    Copy the full SHA
    f23c291 View commit details
    Browse the repository at this point in the history

Commits on Jul 16, 2020

  1. Configuration menu
    Copy the full SHA
    0a6790b View commit details
    Browse the repository at this point in the history

Commits on Sep 14, 2020

  1. Configuration menu
    Copy the full SHA
    925ec02 View commit details
    Browse the repository at this point in the history

Commits on Sep 30, 2020

  1. Configuration menu
    Copy the full SHA
    47553e5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    779708a View commit details
    Browse the repository at this point in the history

Commits on Oct 1, 2020

  1. Propogate calling convention through the JIT so it can determine stru…

    …ct return type based on calling convention. Update runtime side to not assume that the JIT enregisters 8-byte struct returns on Windows x86 (since it doesn't).
    jkoritzinsky committed Oct 1, 2020
    Configuration menu
    Copy the full SHA
    4b8870b View commit details
    Browse the repository at this point in the history
  2. Remove now-unused code for multireg struct returns in the x86 reverse…

    … P/Invoke stub linker.
    
    Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
    jkoritzinsky committed Oct 1, 2020
    Configuration menu
    Copy the full SHA
    6c56bc8 View commit details
    Browse the repository at this point in the history

Commits on Oct 2, 2020

  1. Treat RuntimeArgumentHandle and RuntimeMethodHandleInternal as ELEMEN…

    …T_TYPE_I when jitting on all platforms.
    
    When I removed the struct normalization code from x86, I inadvertantly broke treating these types as ELEMENT_TYPE_I. On all platforms other than x86, this was handled at an earlier point in the code. Remove the if-def and make this happen on all platforms.
    jkoritzinsky committed Oct 2, 2020
    Configuration menu
    Copy the full SHA
    3897473 View commit details
    Browse the repository at this point in the history

Commits on Oct 3, 2020

  1. Treat RuntimeFieldHandleInternal as an ELEMENT_TYPE_I since it is use…

    …d similarly to RuntimeMethodHandleInternal across the FCall boundary
    jkoritzinsky committed Oct 3, 2020
    Configuration menu
    Copy the full SHA
    426b0f3 View commit details
    Browse the repository at this point in the history
  2. Apply format patch.

    Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
    jkoritzinsky committed Oct 3, 2020
    Configuration menu
    Copy the full SHA
    cc73336 View commit details
    Browse the repository at this point in the history
  3. Use enum value instead of 0.

    Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
    jkoritzinsky committed Oct 3, 2020
    Configuration menu
    Copy the full SHA
    a825b8a View commit details
    Browse the repository at this point in the history
  4. Update comments.

    Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
    jkoritzinsky committed Oct 3, 2020
    Configuration menu
    Copy the full SHA
    9c0cbb1 View commit details
    Browse the repository at this point in the history

Commits on Oct 5, 2020

  1. Fix stack imbalance in x86 ThisCall reverse tests where native has a …

    …return buffer but the managed calling convention doesn't.
    jkoritzinsky committed Oct 5, 2020
    Configuration menu
    Copy the full SHA
    63507b7 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b72dcb4 View commit details
    Browse the repository at this point in the history

Commits on Oct 7, 2020

  1. Configuration menu
    Copy the full SHA
    1262c27 View commit details
    Browse the repository at this point in the history
  2. Fix instance call P/Invoke's on Windows ARM64.

    Make better usage of canReturnInRegister to avoid a struct that has been marked as byref being marked as ByValueAsHfa.
    
    Instance call return buffers on Windows ARM64 don't use the standard return buffer register, so don't use use it in that case.
    jkoritzinsky committed Oct 7, 2020
    Configuration menu
    Copy the full SHA
    ef2adac View commit details
    Browse the repository at this point in the history

Commits on Oct 8, 2020

  1. Fix the reverse P/Invoke case for instance methods on ARM64.

    Treat the return buffer as a normal arg and don't use the special retbuf register. Implicitly return the return buffer argument from the function to satisfy the C++ compiler's dependence on the implicit behavior (similar to Windows x64).
    jkoritzinsky committed Oct 8, 2020
    Configuration menu
    Copy the full SHA
    5c2a9bc View commit details
    Browse the repository at this point in the history
  2. Update src/coreclr/src/vm/dllimportcallback.cpp

    Co-authored-by: Jan Kotas <jkotas@microsoft.com>
    jkoritzinsky and jkotas committed Oct 8, 2020
    Configuration menu
    Copy the full SHA
    dd44e32 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1056c44 View commit details
    Browse the repository at this point in the history
  4. Merge branches 'retbuf-move-to-jit' and 'retbuf-move-to-jit' of githu…

    …b.com:jkoritzinsky/runtime into retbuf-move-to-jit
    jkoritzinsky committed Oct 8, 2020
    Configuration menu
    Copy the full SHA
    a0218a1 View commit details
    Browse the repository at this point in the history
  5. Fix typo.

    Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
    jkoritzinsky committed Oct 8, 2020
    Configuration menu
    Copy the full SHA
    47bf6aa View commit details
    Browse the repository at this point in the history

Commits on Oct 9, 2020

  1. For x86 reverse P/Invokes where the return is an 8-byte struct, handl…

    …e the case where native expects the returned struct in EAX:EDX but the managed call expects to return the result in a return buffer.
    
    Now that interop isn't bashing the return value to long and we aren't changing the x86 managed calling convention to support returning arbitrary 8-byte structs in EAX:EDX, the managed calling convention expects to return an arbitrary 8-byte struct in a return buffer.
    Since in this case, native code expects the return to be enregistered, we need to introduce a return buffer into the stack while executing the stub so the managed calling convention can point to the stub correctly.
    jkoritzinsky committed Oct 9, 2020
    Configuration menu
    Copy the full SHA
    a1bb21c View commit details
    Browse the repository at this point in the history
  2. Flip EAX/EDX slots in the x86 reverse P/Invoke stub. Now that they ma…

    …tch the order that a return buffer uses, we can remove creation of our custom return buffer and instead point the return buffer directly into the EAX/EDX slots so our EAX/EDX restore path automatically handles the "native enregistered return, managed retrun buffer return" case.
    jkoritzinsky committed Oct 9, 2020
    Configuration menu
    Copy the full SHA
    254063b View commit details
    Browse the repository at this point in the history

Commits on Oct 12, 2020

  1. Apply format patch.

    jkoritzinsky committed Oct 12, 2020
    Configuration menu
    Copy the full SHA
    71adacb View commit details
    Browse the repository at this point in the history
  2. Disable test on Win ARM32 to avoid blocking CI.

    Not fixing the test since we don't officially support Windows ARM32 anyway and this scenario is already a corner case.
    
    Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
    jkoritzinsky committed Oct 12, 2020
    Configuration menu
    Copy the full SHA
    195713b View commit details
    Browse the repository at this point in the history

Commits on Oct 14, 2020

  1. Configuration menu
    Copy the full SHA
    8833b06 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7e2c1f9 View commit details
    Browse the repository at this point in the history
  3. Explicitly validate size for this optimization.

    Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
    jkoritzinsky committed Oct 14, 2020
    Configuration menu
    Copy the full SHA
    382113f View commit details
    Browse the repository at this point in the history
  4. Fix typo

    Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
    jkoritzinsky committed Oct 14, 2020
    Configuration menu
    Copy the full SHA
    bd4022a View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    c4acc94 View commit details
    Browse the repository at this point in the history

Commits on Oct 15, 2020

  1. Configuration menu
    Copy the full SHA
    1694da8 View commit details
    Browse the repository at this point in the history

Commits on Oct 16, 2020

  1. Configuration menu
    Copy the full SHA
    5dd9031 View commit details
    Browse the repository at this point in the history
  2. Fixed passing a trivial struct in registers to a fast tail call (that…

    … generates a direct jmp instruction).
    jkoritzinsky committed Oct 16, 2020
    Configuration menu
    Copy the full SHA
    7182ad0 View commit details
    Browse the repository at this point in the history

Commits on Oct 19, 2020

  1. Fix formatting

    jkoritzinsky committed Oct 19, 2020
    Configuration menu
    Copy the full SHA
    e329242 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    94f6a1d View commit details
    Browse the repository at this point in the history

Commits on Oct 23, 2020

  1. Configuration menu
    Copy the full SHA
    cfce1d7 View commit details
    Browse the repository at this point in the history

Commits on Oct 27, 2020

  1. Fix license headers.

    jkoritzinsky committed Oct 27, 2020
    Configuration menu
    Copy the full SHA
    0368407 View commit details
    Browse the repository at this point in the history
  2. Remove the old validation that relates only to the old x86 struct nor…

    …malization model. The new model normalizes within the JIT, so the interop IL stubs don't need to account for it.
    
    Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
    jkoritzinsky committed Oct 27, 2020
    Configuration menu
    Copy the full SHA
    a4286f3 View commit details
    Browse the repository at this point in the history

Commits on Oct 28, 2020

  1. Apply suggestions from code review

    Co-authored-by: Carol Eidt <carol.eidt@microsoft.com>
    jkoritzinsky and CarolEidt committed Oct 28, 2020
    Configuration menu
    Copy the full SHA
    bae4165 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    77d6bf6 View commit details
    Browse the repository at this point in the history
  3. introduce a CORINFO_UNMANAGED_CALLCONV_MANAGED enum member to represe…

    …nt the managed calling convention.
    
    Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
    jkoritzinsky committed Oct 28, 2020
    Configuration menu
    Copy the full SHA
    9e965f8 View commit details
    Browse the repository at this point in the history
  4. Fix formatting

    jkoritzinsky committed Oct 28, 2020
    Configuration menu
    Copy the full SHA
    c28925e View commit details
    Browse the repository at this point in the history

Commits on Oct 30, 2020

  1. Apply suggestions from code review

    Co-authored-by: Sergey Andreenko <seandree@microsoft.com>
    jkoritzinsky and Sergey Andreenko committed Oct 30, 2020
    Configuration menu
    Copy the full SHA
    e5212cb View commit details
    Browse the repository at this point in the history

Commits on Nov 2, 2020

  1. PR feedback.

    jkoritzinsky committed Nov 2, 2020
    Configuration menu
    Copy the full SHA
    e020165 View commit details
    Browse the repository at this point in the history
  2. Fix comparison.

    jkoritzinsky committed Nov 2, 2020
    Configuration menu
    Copy the full SHA
    90cfcef View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    41b21a5 View commit details
    Browse the repository at this point in the history
  4. Fix build break.

    jkoritzinsky committed Nov 2, 2020
    Configuration menu
    Copy the full SHA
    f6eeddf View commit details
    Browse the repository at this point in the history
  5. Use a union with the tailCalInfo pointer to store the unmanaged calli…

    …ng convention since native calls cannot be tail calls.
    jkoritzinsky committed Nov 2, 2020
    Configuration menu
    Copy the full SHA
    71c9032 View commit details
    Browse the repository at this point in the history

Commits on Nov 3, 2020

  1. Fix formatting.

    jkoritzinsky committed Nov 3, 2020
    Configuration menu
    Copy the full SHA
    b334b37 View commit details
    Browse the repository at this point in the history

Commits on Nov 23, 2020

  1. Update src/coreclr/src/jit/importer.cpp

    Co-authored-by: Andy Ayers <andya@microsoft.com>
    jkoritzinsky and AndyAyersMS committed Nov 23, 2020
    Configuration menu
    Copy the full SHA
    28b1d48 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    aab5ca0 View commit details
    Browse the repository at this point in the history

Commits on Nov 24, 2020

  1. Add some comments around CorInfoUnmanagedCallConv

    Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
    jkoritzinsky committed Nov 24, 2020
    Configuration menu
    Copy the full SHA
    96081a0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0ef4948 View commit details
    Browse the repository at this point in the history

Commits on Nov 30, 2020

  1. PR feedback.

    jkoritzinsky committed Nov 30, 2020
    Configuration menu
    Copy the full SHA
    6ee4a82 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3c89d74 View commit details
    Browse the repository at this point in the history
  3. Fix formatting.

    jkoritzinsky committed Nov 30, 2020
    Configuration menu
    Copy the full SHA
    2ce4270 View commit details
    Browse the repository at this point in the history
  4. Fix compMethodReturnsRetBufAddr

    Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
    jkoritzinsky committed Nov 30, 2020
    Configuration menu
    Copy the full SHA
    fb00bc9 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    8f9478a View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    68d4081 View commit details
    Browse the repository at this point in the history

Commits on Dec 1, 2020

  1. Configuration menu
    Copy the full SHA
    e26c36d View commit details
    Browse the repository at this point in the history
  2. Fix formatting

    jkoritzinsky committed Dec 1, 2020
    Configuration menu
    Copy the full SHA
    c1040aa View commit details
    Browse the repository at this point in the history

Commits on Dec 2, 2020

  1. Configuration menu
    Copy the full SHA
    fa2f2aa View commit details
    Browse the repository at this point in the history