diff options
author | Sergey <shallowstack@gmail.com> | 2017-09-30 02:16:44 +0300 |
---|---|---|
committer | Sean Gillespie <segilles@microsoft.com> | 2017-09-29 16:16:44 -0700 |
commit | 5b10f0eb85d8e8ccdcf9b5e38e5dd372e241e24e (patch) | |
tree | 33cc1ab7a1ad56da4cc11ce983e0f0a379f9766a /src/vm/i386 | |
parent | 32c46737c396afa05ab748fbcc243de7512c11ec (diff) | |
download | coreclr-5b10f0eb85d8e8ccdcf9b5e38e5dd372e241e24e.tar.gz coreclr-5b10f0eb85d8e8ccdcf9b5e38e5dd372e241e24e.tar.bz2 coreclr-5b10f0eb85d8e8ccdcf9b5e38e5dd372e241e24e.zip |
StompWriteBarrier initialization path refactoring (#14105)
* refactored arm, arm64, amd64 and x86 to signal about icache flush and ee restarts
* refactored gc init stage to stomp write barrier (hence flush icache) only once
* review fixes, care taken of icache invalidation during StompResize
* fixed heap boundaries initialization bug introduced after refactoring gc.cpp
* stylistic review fixe
* global variable rename
* global variable rename once more
Diffstat (limited to 'src/vm/i386')
-rw-r--r-- | src/vm/i386/jitinterfacex86.cpp | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/src/vm/i386/jitinterfacex86.cpp b/src/vm/i386/jitinterfacex86.cpp index 66911e87f5..8463b084ac 100644 --- a/src/vm/i386/jitinterfacex86.cpp +++ b/src/vm/i386/jitinterfacex86.cpp @@ -1675,21 +1675,21 @@ void ValidateWriteBarrierHelpers() // When a GC happens, the upper and lower bounds of the ephemeral // generation change. This routine updates the WriteBarrier thunks // with the new values. -void StompWriteBarrierEphemeral(bool /* isRuntimeSuspended */) +int StompWriteBarrierEphemeral(bool /* isRuntimeSuspended */) { CONTRACTL { NOTHROW; GC_NOTRIGGER; } CONTRACTL_END; + int stompWBCompleteActions = SWB_PASS; + #ifdef WRITE_BARRIER_CHECK // Don't do the fancy optimization if we are checking write barrier if (((BYTE *)JIT_WriteBarrierEAX)[0] == 0xE9) // we are using slow write barrier - return; + return stompWBCompleteActions; #endif // WRITE_BARRIER_CHECK - BOOL flushICache = FALSE; - // Update the lower bound. for (int iBarrier = 0; iBarrier < NUM_WRITE_BARRIERS; iBarrier++) { @@ -1703,7 +1703,7 @@ void StompWriteBarrierEphemeral(bool /* isRuntimeSuspended */) //avoid trivial self modifying code if (*pfunc != (size_t) g_ephemeral_low) { - flushICache = TRUE; + stompWBCompleteActions |= SWB_ICACHE_FLUSH; *pfunc = (size_t) g_ephemeral_low; } if (!WriteBarrierIsPreGrow()) @@ -1716,15 +1716,13 @@ void StompWriteBarrierEphemeral(bool /* isRuntimeSuspended */) //avoid trivial self modifying code if (*pfunc != (size_t) g_ephemeral_high) { - flushICache = TRUE; + stompWBCompleteActions |= SWB_ICACHE_FLUSH; *pfunc = (size_t) g_ephemeral_high; } } } - if (flushICache) - FlushInstructionCache(GetCurrentProcess(), (void *)JIT_PatchedWriteBarrierGroup, - (BYTE*)JIT_PatchedWriteBarrierGroup_End - (BYTE*)JIT_PatchedWriteBarrierGroup); + return stompWBCompleteActions; } /*********************************************************************/ @@ -1733,24 +1731,24 @@ void StompWriteBarrierEphemeral(bool /* isRuntimeSuspended */) // to the PostGrow thunk that checks both upper and lower bounds. // regardless we need to update the thunk with the // card_table - lowest_address. -void StompWriteBarrierResize(bool isRuntimeSuspended, bool bReqUpperBoundsCheck) +int StompWriteBarrierResize(bool isRuntimeSuspended, bool bReqUpperBoundsCheck) { CONTRACTL { NOTHROW; if (GetThread()) {GC_TRIGGERS;} else {GC_NOTRIGGER;} } CONTRACTL_END; + int stompWBCompleteActions = SWB_PASS; + #ifdef WRITE_BARRIER_CHECK // Don't do the fancy optimization if we are checking write barrier if (((BYTE *)JIT_WriteBarrierEAX)[0] == 0xE9) // we are using slow write barrier - return; + return stompWBCompleteActions; #endif // WRITE_BARRIER_CHECK bool bWriteBarrierIsPreGrow = WriteBarrierIsPreGrow(); bool bStompWriteBarrierEphemeral = false; - BOOL bEESuspendedHere = FALSE; - for (int iBarrier = 0; iBarrier < NUM_WRITE_BARRIERS; iBarrier++) { BYTE * pBuf = (BYTE *)c_rgWriteBarriers[iBarrier]; @@ -1765,9 +1763,9 @@ void StompWriteBarrierResize(bool isRuntimeSuspended, bool bReqUpperBoundsCheck) if (bReqUpperBoundsCheck) { GCX_MAYBE_COOP_NO_THREAD_BROKEN((GetThread()!=NULL)); - if( !isRuntimeSuspended && !bEESuspendedHere) { + if( !isRuntimeSuspended && !(stompWBCompleteActions & SWB_EE_RESTART) ) { ThreadSuspend::SuspendEE(ThreadSuspend::SUSPEND_FOR_GC_PREP); - bEESuspendedHere = TRUE; + stompWBCompleteActions |= SWB_EE_RESTART; } pfunc = (size_t *) JIT_WriteBarrierReg_PostGrow; @@ -1855,16 +1853,15 @@ void StompWriteBarrierResize(bool isRuntimeSuspended, bool bReqUpperBoundsCheck) if (bStompWriteBarrierEphemeral) { - _ASSERTE(isRuntimeSuspended || bEESuspendedHere); - StompWriteBarrierEphemeral(true); - } - else - { - FlushInstructionCache(GetCurrentProcess(), (void *)JIT_PatchedWriteBarrierGroup, - (BYTE*)JIT_PatchedWriteBarrierGroup_End - (BYTE*)JIT_PatchedWriteBarrierGroup); + _ASSERTE(isRuntimeSuspended || (stompWBCompleteActions & SWB_EE_RESTART)); + stompWBCompleteActions |= StompWriteBarrierEphemeral(true); } + return stompWBCompleteActions; +} - if(bEESuspendedHere) - ThreadSuspend::RestartEE(FALSE, TRUE); +void FlushWriteBarrierInstructionCache() +{ + FlushInstructionCache(GetCurrentProcess(), (void *)JIT_PatchedWriteBarrierGroup, + (BYTE*)JIT_PatchedWriteBarrierGroup_End - (BYTE*)JIT_PatchedWriteBarrierGroup); } |