From 474b6da273c7ce6df50a4e51eb9929a77e1611c3 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Tue, 25 Sep 2012 00:20:38 -0700 Subject: Move thread flags and state into 32bits. We need to ensure that transitions to Runnable are atomic wrt to a thread modifying the suspend count. Currently this is achieved by holding the thread_suspend_count_lock_. This change creates a set of bit flags that summarize that the suspend_count_ is raised and also others flags that signify the managed code should go into a slow path. The effect of this change are two-fold: 1) transitions from suspended to runnable can CAS the thread state rather than holding the suspend_count_lock_. This will make JNI transitions cheaper. 2) the exception/suspend/interpreter poll needed for shadow frames can be rolled into a single compare of the bit fields against 0. Change-Id: I589f84e3dca396c3db448bf32d814565acf3d11f --- src/compiler/codegen/GenCommon.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/compiler/codegen/GenCommon.cc') diff --git a/src/compiler/codegen/GenCommon.cc b/src/compiler/codegen/GenCommon.cc index 99a76da007..6868d0bc9a 100644 --- a/src/compiler/codegen/GenCommon.cc +++ b/src/compiler/codegen/GenCommon.cc @@ -1260,6 +1260,20 @@ void genNewInstance(CompilationUnit* cUnit, uint32_t type_idx, RegLocation rlDes storeValue(cUnit, rlDest, rlResult); } +void genMoveException(CompilationUnit* cUnit, RegLocation rlDest) +{ + oatFlushAllRegs(cUnit); /* Everything to home location */ + int funcOffset = ENTRYPOINT_OFFSET(pGetAndClearException); +#if defined(TARGET_X86) + // Runtime helper will load argument for x86. + callRuntimeHelperReg(cUnit, funcOffset, rARG0, false); +#else + callRuntimeHelperReg(cUnit, funcOffset, rSELF, false); +#endif + RegLocation rlResult = oatGetReturn(cUnit, false); + storeValue(cUnit, rlDest, rlResult); +} + void genThrow(CompilationUnit* cUnit, RegLocation rlSrc) { oatFlushAllRegs(cUnit); @@ -2527,7 +2541,7 @@ void genSuspendTest(CompilationUnit* cUnit, int optFlags) newLIR2(cUnit, kThumbSubRI8, rSUSPEND, 1); branch = opCondBranch(cUnit, kCondEq, NULL); #elif defined(TARGET_X86) - newLIR2(cUnit, kX86Cmp32TI8, Thread::SuspendCountOffset().Int32Value(), 0); + newLIR2(cUnit, kX86Cmp16TI8, Thread::ThreadFlagsOffset().Int32Value(), 0); branch = opCondBranch(cUnit, kCondNe, NULL); #else opRegImm(cUnit, kOpSub, rSUSPEND, 1); @@ -2557,7 +2571,7 @@ void genSuspendTestAndBranch(CompilationUnit* cUnit, int optFlags, LIR* target) newLIR2(cUnit, kThumbSubRI8, rSUSPEND, 1); opCondBranch(cUnit, kCondNe, target); #elif defined(TARGET_X86) - newLIR2(cUnit, kX86Cmp32TI8, Thread::SuspendCountOffset().Int32Value(), 0); + newLIR2(cUnit, kX86Cmp16TI8, Thread::ThreadFlagsOffset().Int32Value(), 0); opCondBranch(cUnit, kCondEq, target); #else opRegImm(cUnit, kOpSub, rSUSPEND, 1); -- cgit v1.2.3-59-g8ed1b