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

Implement GcInfo v2 #6522

Merged
merged 1 commit into from
Aug 5, 2016
Merged

Conversation

swaroop-sridhar
Copy link

@swaroop-sridhar swaroop-sridhar commented Jul 29, 2016

Ref #4379

This change implements GcInfo version 2 for all platforms that use the
GcInfo library (all architectures other than X86).

Changes are:

  1. Defines ReturnKind enumeration for all platforms
  2. Change the GcInfo encoder library to encode the ReturnKind and ReversePInvokeFrame slot
  3. Change the CM's GcInfo decoder to encode the ReturnKind and ReversePInvokeFrame slot for GCINFO_VERSION 2
  4. Some corrections to GCINFO_MEASUREments
  5. Changes to RYU Jit to provide the correct information to the encoder
  6. Changes to the VM to use the ReturnKind information while hijacking a thread
  • If ReturnKind is available from GcInfo, new hijack routines are used
  • Otherwise, fall back to old method (for compatibility)
    7) Rework and simplify the thread hijack routines by scanning HijackFrames directly for gcroots
    8) Supporting code to implement the above features.

Returning Structs in multiple registers

Hijacking for StructInRegs is currently only implemented for
Unix SystemV ABI Multi-reg struct returns. However, the hijack-workers that use
ReturnKind are ready to handle other platforms (ex: ARM/ARM64 Windows)
once the corresponding HijackTripThread() assembly routines are defined.

The New feature flag: FEATURE_MULTIREG_RETURN is set for platforms where a struct value
can be returned in multiple registers [ex: Windows/Unix ARM/ARM64, Unix-AMD64]
FEATURE_UNIX_AMD64_STRUCT_PASSING is a specific kind of FEATURE_MULTIREG_RETURN
specified by SystemV ABI for AMD64

Compatibility with other JITs

  • All new GCInfo generated by RYU Jit is in GcInfo version 2
  • All Ngen images must be regenerated with the new GcInfo version.
  • Ready-to-run images with old GcInfo will continue to work.
  • Jit64/X64 uses the GcInfo library, so it generates GcInfo version 2.
    However, it doesn't (yet) provide the data to encode the correct ReturnKind
    Similar is the case for ARM32 code running on JIT32, and any other JITs
    that may be using GcInfo library but not yet modified to use the new API.
    So, compatibility is achived using RT_Unset flag.

When ReturnKind is RT_Unset, it means that the JIT did not set
the ReturnKind in the GCInfo, and therefore the VM cannot rely on it,
and must use other mechanisms (similar to GcInfo ver 1) to determine
the Return type's GC information.

Implement GC root scanning for Hijack-frames

This change implements GCScanRoots() method for Hijacke-frames
based on the ReturnKind information available from the GcInfo.
If the exact ReturnKind is not available in the GcInfo, the
thread-suspension logic will compute the ReturnKind based on
the method-signature.

As a result of this change, several hijack-helpers in the VM
are cleaned up. There's only one implementation of HijackWorker()
which handles all returnKinds, and one assembly helper for handling
all methods that return a GC value.

ARM64

Only GcIndfo v2 is reliably supported for ARM64 platform.
The changes to thread-hijack mechanism fixes #6494 for ARM64.

No measurable change in JIT throughput, performance or native-image
size from this change.

@swaroop-sridhar swaroop-sridhar added the * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) label Jul 29, 2016
@swaroop-sridhar swaroop-sridhar force-pushed the gcinfov2 branch 2 times, most recently from a5a1877 to 8f71f63 Compare July 29, 2016 04:30
@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT amd64 checked gcstress0xc

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT amd64 checked gcstress0xc

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 checked

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 checked gcstress0xc

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 checked

1 similar comment
@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 checked

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT gcstress0xc

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Ubuntu gcstress0xc

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 checked pri1r2r

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 checked

@swaroop-sridhar swaroop-sridhar removed the * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) label Aug 1, 2016
@swaroop-sridhar
Copy link
Author

@jkotas please review.
CC: @dotnet/jit-contrib

@@ -9440,7 +9440,7 @@ void NativeImageDumper::DumpReadyToRunMethod(PCODE pEntryPoint, PTR_RUNTIME_FUNC
GCDump gcDump(GCINFO_VERSION);
gcDump.gcPrintf = stringOutFn;
#if !defined(_TARGET_X86_) && defined(USE_GC_INFO_DECODER)
GcInfoDecoder gcInfoDecoder({ curGCInfoPtr, GCINFO_VERSION }, DECODE_CODE_LENGTH, 0);
GcInfoDecoder gcInfoDecoder({ curGCInfoPtr, GCINFO_VERSION }, DECODE_CODE_LENGTH);
Copy link
Member

Choose a reason for hiding this comment

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

This is dumping method in R2R image. Should this take the version that matches the file format version?

(It is not crucial to fix this because of it is nidump ... if it is hard to do, comment would be nice at least.)

@janvorli
Copy link
Member

janvorli commented Aug 4, 2016

LGTM

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Ubuntu gcstress0xc

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT gcstress0xc
@dotnet-bot test Ubuntu gcstress0xc
@dotnet-bot test Windows_NT arm64 Checked
@dotnet-bot test Windows_NT arm64 checked pri1r2r
@dotnet-bot test Windows_NT arm64 Release
@dotnet-bot test Windows_NT arm64 checked gcstress0xc

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 Checked
@dotnet-bot test Windows_NT arm64 checked gcstress0xc

@swaroop-sridhar
Copy link
Author

@dotnet-bot test OSX x64 Checked Build and Test

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Ubuntu x64 Checked Build and Test

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Linux ARM Emulator Cross Debug Build

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 Checked

}
}
ReturnKind structReturnKind = GetStructReturnKind(regKinds[0], regKinds[1]);
return structReturnKind;
Copy link

@briansull briansull Aug 4, 2016

Choose a reason for hiding this comment

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

You told me that this section is there for GC info v1]

Can you add a comment so that we can understand why there is no ARM64 section here.

Copy link
Author

Choose a reason for hiding this comment

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

This code only exists to support GcInfo v1 images, which are not supported for ARM64.
I'll add a comment about it.
ARM64 struct-in-regs scanning happens in HijackFrame::GcScanRoots()

@briansull
Copy link

briansull commented Aug 4, 2016

LGTM

@swaroop-sridhar
Copy link
Author

You mean the ARM64 work for struct-in-regs return, right?
There's and issue for it #6494. and it'll be fixed by this change.

@swaroop-sridhar
Copy link
Author

Windows NT GCStress 0xC:
The two failures look like they are pre-existing:

  1. Random failure writing to protected memory in Console.WriteLine()
  2. Failure in GetGenerationWR2.exe
    Here is the last week's run for comparison.

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 Checked

1 similar comment
@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 Checked

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Linux ARM Emulator Cross Debug Build

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 Checked

1 similar comment
@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 Checked

@swaroop-sridhar
Copy link
Author

@dotnet-bot Details Linux ARM Emulator Cross Debug Build

@swaroop-sridhar
Copy link
Author

@dotnet-bot test Windows_NT arm64 checked

Ref #4379

This change implements GcInfo version 2 for all platforms that use the
GcInfo library (all architectures other than X86).

Changes are:
1) Defines ReturnKind enumeration for all platforms
2) Change the GcInfo encoder library to encode the ReturnKind and ReversePInvokeFrame slot
3) Change the CM's GcInfo decoder to encode the ReturnKind and ReversePInvokeFrame slot for GCINFO_VERSION 2
4) Some corrections to GCINFO_MEASUREments
5) Changes to RYU Jit to provide the correct information to the encoder
6) Changes to the VM to use the ReturnKind information while hijacking a thread
   - If ReturnKind is available from GcInfo, new hijack routines are used
   - Otherwise, fall back to old method (for compatibility)
7) Rework and simplify the thread hijack routines by scanning HijackFrames directly for gcroots
8) Supporting code to implement the above features.

Returning Structs in multiple registers

Hijacking for StructInRegs is currently only implemented for
Unix SystemV ABI Multi-reg struct returns. However, the hijack-workers that use
ReturnKind are ready to handle other platforms (ex: ARM/ARM64 Windows)
once the corresponding HijackTripThread() assembly routines are defined.

The New feature flag: FEATURE_MULTIREG_RETURN is set for platforms where a struct value
can be returned in multiple registers [ex: Windows/Unix ARM/ARM64, Unix-AMD64]
FEATURE_UNIX_AMD64_STRUCT_PASSING is a specific kind of FEATURE_MULTIREG_RETURN
specified by SystemV ABI for AMD64

Compatibility with other JITs

- All new GCInfo generated by RYU Jit is in GcInfo version 2
- All Ngen images must be regenerated with the new GcInfo version.
- Ready-to-run images with old GcInfo will continue to work.
- Jit64/X64 uses the GcInfo library, so it generates GcInfo version 2.
  However, it doesn't (yet) provide the data to encode the correct ReturnKind
  Similar is the case for ARM32 code running on JIT32, and any other JITs
  that may be using GcInfo library but not yet modified to use the new API.
  So, compatibility is achived using RT_Unset flag.

When ReturnKind is RT_Unset, it means that the JIT did not set
the ReturnKind in the GCInfo, and therefore the VM cannot rely on it,
and must use other mechanisms (similar to GcInfo ver 1) to determine
the Return type's GC information.

Implement GC root scanning for Hijack-frames

This change implements GCScanRoots() method for Hijacke-frames
based on the ReturnKind information available from the GcInfo.
If the exact ReturnKind is not available in the GcInfo, the
thread-suspension logic will compute the ReturnKind based on
the method-signature.

As a result of this change, several hijack-helpers in the VM
are cleaned up. There's only one implementation of HijackWorker()
to handle all returnKinds.

This change also simplifies the thread-hijack logic by using a
single assembly helper OnHijackTripThread() in most cases.
The only other helper used is for X86 floating point return values
for save/restoring the top of the FP stack.

ARM64

Only GcIndfo v2 is reliably supported for ARM64 platform.
The changes to thread-hijack mechanism fixes #6494 for ARM64.

No measurable change in JIT throughput, performance or native-image
size from this change.
@swaroop-sridhar swaroop-sridhar merged commit 6bd9557 into dotnet:master Aug 5, 2016
jashook pushed a commit to jashook/coreclr that referenced this pull request Aug 8, 2016
PR dotnet#6522 changed from OnHijackScalarTripThread to OnHijackTripThread; however,
missed changing this definition for arm windows.
jashook pushed a commit to jashook/coreclr that referenced this pull request Aug 8, 2016
PR dotnet#6522 changed from OnHijackScalarTripThread to OnHijackTripThread; however,
missed changing this definition for arm windows.
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
PR dotnet/coreclr#6522 changed from OnHijackScalarTripThread to OnHijackTripThread; however,
missed changing this definition for arm windows.


Commit migrated from dotnet/coreclr@49b8766
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need Hijack Handlers for ARM64 StructInRegs
5 participants