Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Merge nmirror to master #5401

Merged
merged 7 commits into from
Feb 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public GenericLookupResult ObjectAllocator(TypeDesc type)

private NodeCache<TypeDesc, GenericLookupResult> _arrayAllocators;

public GenericLookupResult ArrayAlloctor(TypeDesc type)
public GenericLookupResult ArrayAllocator(TypeDesc type)
{
return _arrayAllocators.GetOrAdd(type);
}
Expand Down
9 changes: 9 additions & 0 deletions src/Native/Runtime/RHCodeMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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++; }
Expand All @@ -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)
{
Expand Down
58 changes: 24 additions & 34 deletions src/Native/Runtime/arm64/ExceptionHandling.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Native/Runtime/arm64/GcProbe.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/Native/Runtime/arm64/PInvoke.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -292,6 +298,8 @@ protected RuntimeFieldInfo WithDebugName()

private volatile FieldAccessor _lazyFieldAccessor = null;

private volatile Type _lazyFieldType = null;

private String _debugName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -402,6 +408,8 @@ private object GetConstantValue(bool raw)

private volatile ParameterInfo[] _lazyIndexParameters;

private volatile Type _lazyPropertyType;

private String _debugName;
}
}
Expand Down