Skip to content

Commit 6d4fe42

Browse files
authored
Implement Swift lowering algorithm in the CoreCLR type system (#99438)
1 parent 64a061f commit 6d4fe42

File tree

4 files changed

+412
-3
lines changed

4 files changed

+412
-3
lines changed

src/coreclr/inc/corinfo.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ enum CorInfoHelpFunc
574574
CORINFO_HELP_MEMSET, // Init block of memory
575575
CORINFO_HELP_MEMZERO, // Init block of memory with zeroes
576576
CORINFO_HELP_MEMCPY, // Copy block of memory
577-
CORINFO_HELP_NATIVE_MEMSET, // Init block of memory using native memset (not safe for pDst being null,
577+
CORINFO_HELP_NATIVE_MEMSET, // Init block of memory using native memset (not safe for pDst being null,
578578
// not safe for unbounded size, does not trigger GC)
579579

580580
CORINFO_HELP_RUNTIMEHANDLE_METHOD, // determine a type/field/method handle at run-time
@@ -1982,6 +1982,16 @@ enum class GetTypeLayoutResult
19821982
Failure,
19831983
};
19841984

1985+
#define MAX_SWIFT_LOWERED_ELEMENTS 4
1986+
1987+
struct CORINFO_SWIFT_LOWERING
1988+
{
1989+
bool byReference;
1990+
CorInfoType loweredElements[MAX_SWIFT_LOWERED_ELEMENTS];
1991+
uint32_t offsets[MAX_SWIFT_LOWERED_ELEMENTS];
1992+
size_t numLoweredElements;
1993+
};
1994+
19851995
#define SIZEOF__CORINFO_Object TARGET_POINTER_SIZE /* methTable */
19861996

19871997
#define CORINFO_Array_MaxLength 0x7FFFFFC7
@@ -2061,7 +2071,7 @@ class ICorStaticInfo
20612071
// Example of a scenario addressed by notifyMethodInfoUsage:
20622072
// 1) Crossgen (with --opt-cross-module=MyLib) attempts to inline a call from MyLib.dll into MyApp.dll
20632073
// and realizes that the call always throws.
2064-
// 2) JIT aborts the inlining attempt and marks the call as no-return instead. The code that follows the call is
2074+
// 2) JIT aborts the inlining attempt and marks the call as no-return instead. The code that follows the call is
20652075
// replaced with a breakpoint instruction that is expected to be unreachable.
20662076
// 3) MyLib is updated to a new version so it's no longer within the same version bubble with MyApp.dll
20672077
// and the new version of the call no longer throws and does some work.

src/coreclr/tools/Common/JitInterface/SwiftPhysicalLowering.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ private List<FieldLayoutInterval> CreateConsolidatedIntervals()
199199
}
200200
else
201201
{
202+
loweredTypes.Add((CorInfoType.CORINFO_TYPE_BYTE, opaqueIntervalStart));
202203
opaqueIntervalStart++;
203204
remainingIntervalSize--;
204-
loweredTypes.Add((CorInfoType.CORINFO_TYPE_BYTE, opaqueIntervalStart));
205205
}
206206
}
207207
}

0 commit comments

Comments
 (0)