From f58dd175c4648860bee310c36c082c4f36b2f0d4 Mon Sep 17 00:00:00 2001 From: Rahul Kumar Date: Mon, 15 Aug 2016 18:32:59 -0700 Subject: [PATCH] update GC shadow heap as part of writebarrier jit helper Commit migrated from https://github.com/dotnet/coreclr/commit/607816f034c9a09effb4831959e767dc2d11baa6 --- src/coreclr/src/vm/arm64/asmhelpers.asm | 51 +++++++++++++++++++++++++++++++++ src/coreclr/src/vm/arm64/asmmacros.h | 9 ++++++ 2 files changed, 60 insertions(+) diff --git a/src/coreclr/src/vm/arm64/asmhelpers.asm b/src/coreclr/src/vm/arm64/asmhelpers.asm index 1b67915..2dcfe91 100644 --- a/src/coreclr/src/vm/arm64/asmhelpers.asm +++ b/src/coreclr/src/vm/arm64/asmhelpers.asm @@ -43,6 +43,14 @@ IMPORT g_card_table IMPORT g_TrapReturningThreads IMPORT g_dispatch_cache_chain_success_counter +#ifdef WRITE_BARRIER_CHECK + SETALIAS g_GCShadow, ?g_GCShadow@@3PEAEEA + SETALIAS g_GCShadowEnd, ?g_GCShadowEnd@@3PEAEEA + + IMPORT g_lowest_address + IMPORT $g_GCShadow + IMPORT $g_GCShadowEnd +#endif // WRITE_BARRIER_CHECK TEXTAREA @@ -301,6 +309,49 @@ NotInHeap dmb ST str x15, [x14] +#ifdef WRITE_BARRIER_CHECK + ; Update GC Shadow Heap + + ; need temporary registers. Save them before using. + stp x12, x13, [sp, #-16]! + + ; Compute address of shadow heap location: + ; pShadow = $g_GCShadow + (x14 - g_lowest_address) + adrp x12, g_lowest_address + ldr x12, [x12, g_lowest_address] + sub x12, x14, x12 + adrp x13, $g_GCShadow + ldr x13, [x13, $g_GCShadow] + add x12, x13, x12 + + ; if (pShadow >= $g_GCShadowEnd) goto end + adrp x13, $g_GCShadowEnd + ldr x13, [x13, $g_GCShadowEnd] + cmp x12, x13 + bhs shadowupdateend + + ; *pShadow = x15 + str x15, [x12] + + ; Ensure that the write to the shadow heap occurs before the read from the GC heap so that race + ; conditions are caught by INVALIDGCVALUE. + dmb sy + + ; if ([x14] == x15) goto end + ldr x13, [x14] + cmp x13, x15 + beq shadowupdateend + + ; *pShadow = INVALIDGCVALUE (0xcccccccd) + mov x13, #0 + movk x13, #0xcccd + movk x13, #0xcccc, LSL #16 + str x13, [x12] + +shadowupdateend + ldp x12, x13, [sp],#16 +#endif + ; Branch to Exit if the reference is not in the Gen0 heap ; adrp x12, g_ephemeral_low diff --git a/src/coreclr/src/vm/arm64/asmmacros.h b/src/coreclr/src/vm/arm64/asmmacros.h index b24c0fd..74613da 100644 --- a/src/coreclr/src/vm/arm64/asmmacros.h +++ b/src/coreclr/src/vm/arm64/asmmacros.h @@ -9,6 +9,15 @@ ;; ==--== ;----------------------------------------------------------------------------- +; Macro used to assign an alternate name to a symbol containing characters normally disallowed in a symbol +; name (e.g. C++ decorated names). + MACRO + SETALIAS $name, $symbol + GBLS $name +$name SETS "|$symbol|" + MEND + +;----------------------------------------------------------------------------- ; Basic extension of Assembler Macros- For Consistency MACRO -- 2.7.4