Skip to content

Commit

Permalink
Merge pull request #3291 from fjeremic/remove-shrink-wrapping-part-iii
Browse files Browse the repository at this point in the history
Deprecate ShrinkWrapping - Part III
  • Loading branch information
0xdaryl committed Oct 17, 2018
2 parents 84966ab + 19913fe commit 48a60b6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import static com.ibm.j9ddr.vm29.structure.J9StackWalkConstants.J9SW_POTENTIAL_SAVED_REGISTERS;
import static com.ibm.j9ddr.vm29.structure.J9StackWalkConstants.J9SW_REGISTER_MAP_MASK;
import static com.ibm.j9ddr.vm29.structure.MethodMetaDataConstants.INTERNAL_PTR_REG_MASK;
import static com.ibm.j9ddr.vm29.structure.MethodMetaDataConstants.J9TR_SHRINK_WRAP;
import static com.ibm.j9ddr.vm29.structure.J9JITExceptionTable.*;

import java.util.LinkedList;
Expand Down Expand Up @@ -432,13 +431,11 @@ public void jitAddSpilledRegisters(WalkState walkState, VoidPointer stackMap) th
//UDATA ** mapCursor = (UDATA **) &(walkState->registerEAs);
int mapCursor = 0;
J9JITExceptionTablePointer md = walkState.jitInfo;
UDATA registerSaveDescription = getJitRegisterSaveDescription(walkState, stackMap);
UDATA registerSaveDescription = walkState.jitInfo.registerSaveDescription();

if (TRBuildFlags.host_X86) {
UDATA prologuePushes = new UDATA(getJitProloguePushes(walkState.jitInfo));
U8 i = new U8(1);
UDATA registersShrinkWrapped = md.registerSaveDescription();
registersShrinkWrapped = registersShrinkWrapped.bitAnd(new I16(0xFFFF));

if (! prologuePushes.eq(0)) {
saveCursor = walkState.bp.sub( new UDATA(getJitScalarTempSlots(walkState.jitInfo)).add(new UDATA(getJitObjectTempSlots(walkState.jitInfo)).add(prologuePushes)) );
Expand All @@ -451,43 +448,23 @@ public void jitAddSpilledRegisters(WalkState walkState, VoidPointer stackMap) th
walkState.registerEAs[mapCursor] = saveCursor;
saveCursor = saveCursor.add(1);
}
else if (md.registerSaveDescription().bitAnd(0xFFFF0000L).eq(new UDATA(J9TR_SHRINK_WRAP).bitAnd(new UDATA(0xFFFFFFFFL)))) /* mask for 32-bit compare */
{
/* preserved registers:
* rbx [2], r9-r15 [10-16] on 64-bit
* ebx [2], ecx [3], esi [6] on 32-bit
*/

/* make sure the stack slots are checked in lockstep
* and bump the saveCursor only if the register is marked
*/
if (registersShrinkWrapped.anyBitsIn(1))
saveCursor = saveCursor.add(1);
}
i = i.add(1);
++mapCursor;
registerSaveDescription = registerSaveDescription.rightShift(1);
registersShrinkWrapped = registersShrinkWrapped.rightShift(1);
}
while (! registerSaveDescription.eq(0));
}
} else if (TRBuildFlags.host_POWER || TRBuildFlags.host_MIPS) {
if (TRBuildFlags.host_POWER) {
if (true) { /*defined(TR_SHRINK_WRAP)*/
/*
* see PPCLinkage for a description of the RSD
* the save offset is located from bits 18-32
* so first mask it off to get the bit vector
* corresponding to the saved GPRS
*/
savedGPRs = registerSaveDescription.bitAnd(new UDATA(0x1FFFFL));
saveOffset = registerSaveDescription.rightShift(17).bitAnd(new UDATA(0xFFFFL));
lowestRegister = new UDATA(15); /* gpr15 is the first saved GPR, so move 15 spaces */
} else {
savedGPRs = registerSaveDescription.bitAnd(new UDATA(31));
saveOffset = registerSaveDescription.rightShift(11);
lowestRegister = new UDATA(32).sub(savedGPRs);
}
/*
* see PPCLinkage for a description of the RSD
* the save offset is located from bits 18-32
* so first mask it off to get the bit vector
* corresponding to the saved GPRS
*/
savedGPRs = registerSaveDescription.bitAnd(new UDATA(0x1FFFFL));
saveOffset = registerSaveDescription.rightShift(17).bitAnd(new UDATA(0xFFFFL));
lowestRegister = new UDATA(15); /* gpr15 is the first saved GPR, so move 15 spaces */
} else if (TRBuildFlags.host_MIPS) {
savedGPRs = registerSaveDescription.bitAnd(31);
saveOffset = registerSaveDescription.rightShift(13);
Expand All @@ -496,7 +473,7 @@ else if (md.registerSaveDescription().bitAnd(0xFFFF0000L).eq(new UDATA(J9TR_SHRI
}
saveCursor = walkState.bp.subOffset(saveOffset);

if (TRBuildFlags.host_POWER) { /*defined(TR_SHRINK_WRAP)*/
if (TRBuildFlags.host_POWER) {
mapCursor += lowestRegister.intValue(); /* access gpr15 in the vm register state */
U8 i = new U8(lowestRegister.add(1));
do
Expand All @@ -506,16 +483,6 @@ else if (md.registerSaveDescription().bitAnd(0xFFFF0000L).eq(new UDATA(J9TR_SHRI
saveCursor = saveCursor.add(1);
}

/* get the first preserved register thats saved in the prologue
* this information is encoded as the last byte of the rsd
* hung off the method's metadata (1 byte = 256 registers)
* */
else if ((md.registerSaveDescription().bitAnd(0xFFFF0000L)).eq(new UDATA(J9TR_SHRINK_WRAP).bitAnd(0xFFFFFFFFL)))
{
/* check the stack slots in lockstep */
if (i.gte(md.registerSaveDescription().bitAnd(0xFF)) && i.lte(new UDATA(32)))
saveCursor = saveCursor.add(1);
}
i = i.add(1);
++mapCursor;
savedGPRs = savedGPRs.rightShift(1);
Expand Down Expand Up @@ -546,12 +513,6 @@ else if ((md.registerSaveDescription().bitAnd(0xFFFF0000L)).eq(new UDATA(J9TR_SH
walkState.registerEAs[mapCursor] = saveCursor;
saveCursor = saveCursor.add(1);
}
else if ((md.registerSaveDescription().bitAnd(0xFFFF0000L)).eq(new UDATA(J9TR_SHRINK_WRAP).bitAnd(0xFFFFFFFFL)))
{
if (i.gte(md.registerSaveDescription().bitAnd(0xFF)) && i.lte(new UDATA(13))) {
saveCursor = saveCursor.add(1);
}
}
i = i.add(1);
++mapCursor;
savedGPRs = savedGPRs.rightShift(1);
Expand All @@ -562,22 +523,6 @@ else if ((md.registerSaveDescription().bitAnd(0xFFFF0000L)).eq(new UDATA(J9TR_SH

jitPrintRegisterMapArray(walkState, "Frame");
}

private UDATA getJitRegisterSaveDescription(WalkState walkState, VoidPointer stackMap) throws CorruptDataException
{
J9JITExceptionTablePointer md = walkState.jitInfo;
UDATA registerSaveDescription = md.registerSaveDescription();
if ((registerSaveDescription.bitAnd(new UDATA(0xFFFF0000))).eq(new UDATA(J9TR_SHRINK_WRAP).bitAnd(new UDATA(0xFFFFFFFFL))))
{
if (stackMap.isNull())
{
U8Pointer searchPC = walkState.pc;
stackMap = getStackMapFromJitPC(walkState.walkThread.javaVM(), md, UDATA.cast(searchPC));
}
registerSaveDescription = new UDATA(U32Pointer.cast(GET_REGISTER_SAVE_DESCRIPTION_CURSOR(HAS_FOUR_BYTE_OFFSET(md), stackMap)).at(0));
}
return registerSaveDescription;
}

private U8Pointer GET_REGISTER_SAVE_DESCRIPTION_CURSOR(boolean fourByteOffset, VoidPointer stackMap)
{
Expand Down
67 changes: 4 additions & 63 deletions runtime/compiler/runtime/MethodMetaData.c
Original file line number Diff line number Diff line change
Expand Up @@ -1672,13 +1672,11 @@ void jitAddSpilledRegisters(J9StackWalkState * walkState, void * stackMap)
UDATA savedGPRs = 0, saveOffset = 0, * saveCursor = 0, lowestRegister = 0;
UDATA ** mapCursor = (UDATA **) &(walkState->registerEAs);
J9TR_MethodMetaData * md = walkState->jitInfo;
UDATA registerSaveDescription = getJitRegisterSaveDescription(walkState, stackMap);
UDATA registerSaveDescription = walkState->jitInfo->registerSaveDescription;

#if defined(TR_HOST_X86)
UDATA prologuePushes = (UDATA) getJitProloguePushes(walkState->jitInfo);
U_8 i = 1;
UDATA registersShrinkWrapped = md->registerSaveDescription;
registersShrinkWrapped &= 0xFFFF;

if (prologuePushes)
{
Expand All @@ -1691,29 +1689,14 @@ void jitAddSpilledRegisters(J9StackWalkState * walkState, void * stackMap)
{
*mapCursor = saveCursor++;
}
else if ((md->registerSaveDescription & 0xFFFF0000) == (J9TR_SHRINK_WRAP & 0xFFFFFFFF)) /* mask for 32-bit compare */
{
/* preserved registers:
* rbx [2], r9-r15 [10-16] on 64-bit
* ebx [2], ecx [3], esi [6] on 32-bit
*/

/* make sure the stack slots are checked in lockstep
* and bump the saveCursor only if the register is marked
*/
if (registersShrinkWrapped & 1)
++saveCursor;
}
++i;
++mapCursor;
registerSaveDescription >>= 1;
registersShrinkWrapped >>= 1;
}
while (registerSaveDescription);
}
#elif defined(TR_HOST_POWER)

#if 1 /*defined(TR_SHRINK_WRAP)*/
/*
* see PPCLinkage for a description of the RSD
* the save offset is located from bits 18-32
Expand All @@ -1723,11 +1706,6 @@ void jitAddSpilledRegisters(J9StackWalkState * walkState, void * stackMap)
savedGPRs = registerSaveDescription & 0x1FFFF;
saveOffset = (registerSaveDescription >> 17) & 0x7FFF;
lowestRegister = 15; /* gpr15 is the first saved GPR, so move 15 spaces */
#else
savedGPRs = registerSaveDescription & 31;
saveOffset = registerSaveDescription >> 11;
lowestRegister = 32 - savedGPRs;
#endif

saveCursor = (UDATA *) (((U_8 *) walkState->bp) - saveOffset);

Expand All @@ -1736,18 +1714,10 @@ void jitAddSpilledRegisters(J9StackWalkState * walkState, void * stackMap)
do
{
if (savedGPRs & 1)
*mapCursor = saveCursor++;

/* get the first preserved register thats saved in the prologue
* this information is encoded as the last byte of the rsd
* hung off the method's metadata (1 byte = 256 registers)
* */
else if ((md->registerSaveDescription & 0xFFFF0000) == (J9TR_SHRINK_WRAP & 0xFFFFFFFF))
{
/* check the stack slots in lockstep */
if (i >= (md->registerSaveDescription & 0xFF) && i <= 32)
++saveCursor;
*mapCursor = saveCursor++;
}

++i;
++mapCursor;
savedGPRs >>= 1;
Expand All @@ -1769,11 +1739,7 @@ void jitAddSpilledRegisters(J9StackWalkState * walkState, void * stackMap)
{
*mapCursor = saveCursor++;
}
else if ((md->registerSaveDescription & 0xFFFF0000) == (J9TR_SHRINK_WRAP & 0xFFFFFFFF))
{
if (i >= (md->registerSaveDescription & 0xFF) && i <= 13)
++saveCursor;
}

++i;
++mapCursor;
savedGPRs >>= 1;
Expand Down Expand Up @@ -1850,31 +1816,6 @@ JITINLINE I_32 getJitExceptionTableSize(J9TR_MethodMetaData * md)
return md->size;
}

UDATA getJitRegisterSaveDescription(J9StackWalkState * walkState, void * stackMap)
{
J9TR_MethodMetaData * md = walkState->jitInfo;
UDATA registerSaveDescription = md->registerSaveDescription;
if ((registerSaveDescription & 0xFFFF0000) == (J9TR_SHRINK_WRAP & 0xFFFFFFFF))
{
if (stackMap == NULL)
{
U_8 * searchPC = walkState->pc;
stackMap = getStackMapFromJitPC(walkState->walkThread->javaVM, md, (UDATA) searchPC);

/* This is an edge case where there's NPE location early in a method and we
don't have a map for the instruction. We don't need a map if the NPE is not
caught inside the method where it's thrown.
The code below will crash if the stackMap returned is NULL.
*/
if (stackMap == NULL)
return 0;
}
registerSaveDescription = *((U_32*)GET_REGISTER_SAVE_DESCRIPTION_CURSOR(HAS_FOUR_BYTE_OFFSET(md), stackMap));
}
return registerSaveDescription;
}

void * getJitGCStackAtlas(J9TR_MethodMetaData * md)
{
return md->gcStackAtlas;
Expand Down
3 changes: 0 additions & 3 deletions runtime/compiler/runtime/MethodMetaData.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
#define getJitTempOffset getJitTempOffsetVerbose
#define getJitNumberOfExceptionRanges getJitNumberOfExceptionRangesVerbose
#define getJitExceptionTableSize getJitExceptionTableSizeVerbose
#define getJitRegisterSaveDescription getJitRegisterSaveDescriptionVerbose
#define getJitGCStackAtlas getJitGCStackAtlasVerbose
#define getJitInlinedCallInfo getJitInlinedCallInfoVerbose
#define getJitInternalPointerMap getJitInternalPointerMapVerbose
Expand Down Expand Up @@ -214,7 +213,6 @@ typedef struct TR_MapIterator
#define INTERNAL_PTR_REG_MASK 0x80000000
#endif

#define J9TR_SHRINK_WRAP 0xDEAD0000
#define GET_BYTECODEINFO_VALUE(fourByteOffset, stackMap) (*((U_32 *)((U_8 *)stackMap + SIZEOF_MAP_OFFSET(fourByteOffset))))

#ifdef TR_HOST_S390
Expand Down Expand Up @@ -309,7 +307,6 @@ JITINLINE U_16 getJitProloguePushes(J9TR_MethodMetaData * md);
JITINLINE I_16 getJitTempOffset(J9TR_MethodMetaData * md);
JITINLINE U_16 getJitNumberOfExceptionRanges(J9TR_MethodMetaData * md);
JITINLINE I_32 getJitExceptionTableSize(J9TR_MethodMetaData * md);
JITINLINE UDATA getJitRegisterSaveDescription(J9StackWalkState * walkState, void * stackMap);
void * getJitGCStackAtlas(J9TR_MethodMetaData * md);
void * getJitInlinedCallInfo(J9TR_MethodMetaData * md);

Expand Down

0 comments on commit 48a60b6

Please sign in to comment.