diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.GenericLookups.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.GenericLookups.cs index 5b5aa5de4a6..7540667e7f8 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.GenericLookups.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/NodeFactory.GenericLookups.cs @@ -224,7 +224,7 @@ public GenericLookupResult ObjectAllocator(TypeDesc type) private NodeCache _arrayAllocators; - public GenericLookupResult ArrayAlloctor(TypeDesc type) + public GenericLookupResult ArrayAllocator(TypeDesc type) { return _arrayAllocators.GetOrAdd(type); } diff --git a/src/Native/Runtime/RHCodeMan.cpp b/src/Native/Runtime/RHCodeMan.cpp index 0628dae008e..67fbfb83aca 100644 --- a/src/Native/Runtime/RHCodeMan.cpp +++ b/src/Native/Runtime/RHCodeMan.cpp @@ -989,12 +989,14 @@ bool EECodeManager::UnwindStackFrame(GCInfoHeader * pInfoHeader, } PTR_UIntNative RSP = (PTR_UIntNative)rawRSP; + bool restoredIP = false; if (ebpFrame) { pContext->pFP = RSP++; pContext->SetAddrOfIP((PTR_PCODE)RSP); // save off the return address location pContext->SetIP(*RSP++); // pop the return address + restoredIP = true; } if (!pInfoHeader->AreFPLROnTop()) @@ -1013,6 +1015,7 @@ bool EECodeManager::UnwindStackFrame(GCInfoHeader * pInfoHeader, ASSERT_MSG(!ebpFrame, "Chained frame cannot have CSR_MASK_LR mask set"); pContext->SetAddrOfIP((PTR_PCODE)RSP); // save off the return address location pContext->SetIP(*RSP++); // pop the return address + restoredIP = true; } if (regMask & CSR_MASK_X19) { pContext->pX19 = RSP++; } if (regMask & CSR_MASK_X20) { pContext->pX20 = RSP++; } @@ -1027,6 +1030,12 @@ bool EECodeManager::UnwindStackFrame(GCInfoHeader * pInfoHeader, if (regMask & CSR_MASK_FP ) { ASSERT(!ebpFrame); pContext->pFP = RSP++; } } + if (!restoredIP) + { + pContext->SetAddrOfIP((PTR_PCODE)pContext->pLR); + pContext->SetIP(*pContext->pLR); + } + UInt8 vfpRegMask = (UInt8)pInfoHeader->GetVfpRegsPushedMask(); if (vfpRegMask) { diff --git a/src/Native/Runtime/arm64/ExceptionHandling.asm b/src/Native/Runtime/arm64/ExceptionHandling.asm index ff6d5bbedaf..e08118516b9 100644 --- a/src/Native/Runtime/arm64/ExceptionHandling.asm +++ b/src/Native/Runtime/arm64/ExceptionHandling.asm @@ -8,29 +8,39 @@ #define STACKSIZEOF_ExInfo ((SIZEOF__ExInfo + 15)&(~15)) +#define HARDWARE_EXCEPTION 1 +#define SOFTWARE_EXCEPTION 0 + ;; ----------------------------------------------------------------------------- ;; Macro used to create frame of exception throwing helpers (RhpThrowEx, RhpThrowHwEx) MACRO - ALLOC_THROW_FRAME + ALLOC_THROW_FRAME $exceptionType + + PROLOG_NOP mov x3, sp ;; Setup a PAL_LIMITED_CONTEXT on the stack { - PROLOG_SAVE_REG_PAIR fp, lr, #-SIZEOF__PAL_LIMITED_CONTEXT! - PROLOG_NOP stp x0, x1, [sp, #0x10] + PROLOG_STACK_ALLOC 0x50 + IF $exceptionType == HARDWARE_EXCEPTION + PROLOG_NOP stp x3, x1, [sp] ; x3 is the SP and x1 is the IP of the fault site + PROLOG_PUSH_MACHINE_FRAME + ELSE + PROLOG_NOP stp x3, lr, [sp] ; x3 is the SP and lr is the IP of the fault site + ENDIF + PROLOG_NOP stp d8, d9, [sp, #0x10] + PROLOG_NOP stp d10, d11, [sp, #0x20] + PROLOG_NOP stp d12, d13, [sp, #0x30] + PROLOG_NOP stp d14, d15, [sp, #0x40] + PROLOG_SAVE_REG_PAIR fp, lr, #-0x70! + PROLOG_NOP stp xzr, xzr, [sp, #0x10] ; locations reserved for return value, not used for exception handling PROLOG_SAVE_REG_PAIR x19, x20, #0x20 PROLOG_SAVE_REG_PAIR x21, x22, #0x30 PROLOG_SAVE_REG_PAIR x23, x24, #0x40 PROLOG_SAVE_REG_PAIR x25, x26, #0x50 PROLOG_SAVE_REG_PAIR x27, x28, #0x60 - PROLOG_NOP stp x0, lr, [sp, #0x70] ; x0 is the SP and lr is the IP of the fault site - ; in case of software exception x0 is the exception object address - PROLOG_NOP stp d8, d9, [sp, #0x80] - PROLOG_NOP stp d10, d11, [sp, #0x90] - PROLOG_NOP stp d12, d13, [sp, #0xA0] - PROLOG_NOP stp d14, d15, [sp, #0xB0] ;; } end PAL_LIMITED_CONTEXT - + PROLOG_STACK_ALLOC STACKSIZEOF_ExInfo - MEND + MEND ;; ----------------------------------------------------------------------------- ;; Macro used to create frame of funclet calling helpers (RhpCallXXXXFunclet) @@ -200,19 +210,7 @@ #define rsp_offsetof_ExInfo 0 #define rsp_offsetof_Context STACKSIZEOF_ExInfo - PROLOG_NOP mov w2, w0 ;; save exception code into x2 - PROLOG_NOP mov x0, sp ;; get SP of fault site - - PROLOG_NOP mov lr, x1 ;; set IP of fault site - - ALLOC_THROW_FRAME - - ; x0: SP of fault site - ; x1: IP of fault site - ; x2: exception code of fault - ; lr: IP of fault site (as a 'return address') - - mov w0, w2 ;; w0 <- exception code of fault + ALLOC_THROW_FRAME HARDWARE_EXCEPTION ;; x2 = GetThread(), TRASHES x1 INLINE_GETTHREAD x2, x1 @@ -257,11 +255,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NESTED_ENTRY RhpThrowEx - ALLOC_THROW_FRAME - - ;; Compute and save SP at callsite. - add x1, sp, #(STACKSIZEOF_ExInfo + SIZEOF__PAL_LIMITED_CONTEXT) - str x1, [sp, #(rsp_offsetof_Context + OFFSETOF__PAL_LIMITED_CONTEXT__SP)] + ALLOC_THROW_FRAME SOFTWARE_EXCEPTION ;; x2 = GetThread(), TRASHES x1 INLINE_GETTHREAD x2, x1 @@ -352,11 +346,7 @@ NotHijacked ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; NESTED_ENTRY RhpRethrow - ALLOC_THROW_FRAME - - ;; Compute and save SP at callsite. - add x1, sp, #(STACKSIZEOF_ExInfo + SIZEOF__PAL_LIMITED_CONTEXT) - str x1, [sp, #(rsp_offsetof_Context + OFFSETOF__PAL_LIMITED_CONTEXT__SP)] + ALLOC_THROW_FRAME SOFTWARE_EXCEPTION ;; x2 = GetThread(), TRASHES x1 INLINE_GETTHREAD x2, x1 diff --git a/src/Native/Runtime/arm64/GcProbe.asm b/src/Native/Runtime/arm64/GcProbe.asm index 135188b4534..051b4158dc7 100644 --- a/src/Native/Runtime/arm64/GcProbe.asm +++ b/src/Native/Runtime/arm64/GcProbe.asm @@ -564,7 +564,7 @@ EXTRA_SAVE_SIZE equ (28*8) #endif ;; FEATURE_GC_STRESS -#if 0 ;; used by the binder only +#if 0 // used by the binder only ;; ;; The following functions are _jumped_ to when we need to transfer control from one method to another for EH ;; dispatch. These are needed to properly coordinate with the GC hijacking logic. We are essentially replacing diff --git a/src/Native/Runtime/arm64/PInvoke.asm b/src/Native/Runtime/arm64/PInvoke.asm index c05328314bd..01decb3c50e 100644 --- a/src/Native/Runtime/arm64/PInvoke.asm +++ b/src/Native/Runtime/arm64/PInvoke.asm @@ -23,12 +23,13 @@ ;; FP and LR registers PROLOG_SAVE_REG_PAIR fp, lr, #-0xA0! ;; Push down stack pointer and store FP and LR - ;; Need to save argument registers x0-x7 and the return buffer register x8 (twice just for 16B alignment) + ;; Need to save argument registers x0-x7 and the return buffer register x8 + ;; Also save x9 which may be used for saving indirect call target stp x0, x1, [sp, #0x10] stp x2, x3, [sp, #0x20] stp x4, x5, [sp, #0x30] stp x6, x7, [sp, #0x40] - stp x8, x8, [sp, #0x50] + stp x8, x9, [sp, #0x50] ;; Save float argument registers as well since they're volatile stp d0, d1, [sp, #0x60] @@ -49,7 +50,7 @@ ldp x2, x3, [sp, #0x20] ldp x4, x5, [sp, #0x30] ldp x6, x7, [sp, #0x40] - ldr x8, [sp, #0x50] + ldp x8, x9, [sp, #0x50] ;; Restore FP and LR registers, and free the allocated stack block EPILOG_RESTORE_REG_PAIR fp, lr, #0xA0! diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/FieldInfos/RuntimeFieldInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/FieldInfos/RuntimeFieldInfo.cs index 392f6db9e3c..31de164abb1 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/FieldInfos/RuntimeFieldInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/FieldInfos/RuntimeFieldInfo.cs @@ -89,7 +89,13 @@ public sealed override Type FieldType { get { - return this.FieldRuntimeType; + Type fieldType = _lazyFieldType; + if (fieldType == null) + { + _lazyFieldType = fieldType = this.FieldRuntimeType; + } + + return fieldType; } } @@ -292,6 +298,8 @@ protected RuntimeFieldInfo WithDebugName() private volatile FieldAccessor _lazyFieldAccessor = null; + private volatile Type _lazyFieldType = null; + private String _debugName; } } diff --git a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/PropertyInfos/RuntimePropertyInfo.cs b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/PropertyInfos/RuntimePropertyInfo.cs index 7691902beb1..b8623f72c44 100644 --- a/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/PropertyInfos/RuntimePropertyInfo.cs +++ b/src/System.Private.Reflection.Core/src/System/Reflection/Runtime/PropertyInfos/RuntimePropertyInfo.cs @@ -187,8 +187,14 @@ public sealed override Type PropertyType ReflectionTrace.PropertyInfo_PropertyType(this); #endif - TypeContext typeContext = ContextTypeInfo.TypeContext; - return PropertyTypeHandle.Resolve(typeContext); + Type propertyType = _lazyPropertyType; + if (propertyType == null) + { + TypeContext typeContext = ContextTypeInfo.TypeContext; + _lazyPropertyType = propertyType = PropertyTypeHandle.Resolve(typeContext); + } + + return propertyType; } } @@ -402,6 +408,8 @@ private object GetConstantValue(bool raw) private volatile ParameterInfo[] _lazyIndexParameters; + private volatile Type _lazyPropertyType; + private String _debugName; } }