Skip to content

Commit

Permalink
Remove redundant/unneeded stack map and atlas methods
Browse files Browse the repository at this point in the history
Fixes #2619

Removed redundant / unneeded stack map and atlas  methods from JitBuilder's FrontEnd and fvtest

Signed-off-by: Nidhi Gupta <itsnidhi16@gmail.com>
  • Loading branch information
nidhi1605 committed Jun 14, 2019
1 parent 04a104b commit c9ddb76
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 406 deletions.
175 changes: 0 additions & 175 deletions fvtest/compilertest/env/FrontEnd.cpp
Expand Up @@ -77,183 +77,8 @@ FrontEnd::methodTrampolineLookup(TR::Compilation *comp, TR::SymbolReference *sym

// -----------------------------------------------------------------------------

void
FrontEnd::encodeStackMap(
TR_GCStackMap *map,
uint8_t *location,
bool encodeFourByteOffsets,
uint32_t bytesPerStackMap,
TR::Compilation *comp)
{
TR::CodeGenerator *cg = comp->cg();
uint32_t lowCode = map->getLowestCodeOffset();

// Encode lowest code offset of this map
//
if (encodeFourByteOffsets)
{
*(uint32_t *)location = lowCode;
location += 4;
}
else
{
*(uint16_t *)location = lowCode;
location += 2;
}

// Encode stack map
//
int32_t mapSize = map->getMapSizeInBytes();
if (mapSize)
{
memcpy(location, map->getMapBits(), mapSize);
}

}


bool
FrontEnd::mapsAreIdentical(
TR_GCStackMap *mapCursor,
TR_GCStackMap *nextMapCursor,
TR::GCStackAtlas *stackAtlas,
TR::Compilation *comp)
{
if (nextMapCursor && nextMapCursor != stackAtlas->getParameterMap() &&
mapCursor != stackAtlas->getParameterMap() &&
mapCursor->getMapSizeInBytes() == nextMapCursor->getMapSizeInBytes() &&
mapCursor->getRegisterMap() == nextMapCursor->getRegisterMap() &&
!memcmp(mapCursor->getMapBits(), nextMapCursor->getMapBits(), mapCursor->getMapSizeInBytes()))
{
return true;
}
else
{
return false;
}
}


uint8_t *
FrontEnd::createStackAtlas(
bool encodeFourByteOffsets,
uint32_t numberOfSlotsMapped,
uint32_t bytesPerStackMap,
uint8_t *encodedAtlasBaseAddress,
uint32_t atlasSizeInBytes,
TR::Compilation *comp)
{
TR::CodeGenerator *cg = comp->cg();
TR::GCStackAtlas *stackAtlas = cg->getStackAtlas();

stackAtlas->setAtlasBits(encodedAtlasBaseAddress);

// Calculate the size of each individual map in the atlas. The fixed
// portion of the map contains:
//
// Low Code Offset (2 or 4)
// Stack map (depends on # of mapped parms/locals)
//
uint32_t sizeOfEncodedCodeOffsetInBytes = encodeFourByteOffsets ? 4 : 2;

uint32_t sizeOfSingleEncodedMapInBytes = sizeOfEncodedCodeOffsetInBytes;
sizeOfSingleEncodedMapInBytes += bytesPerStackMap;

// Encode the atlas
//
OMR::StackAtlasPOD *pyAtlas = (OMR::StackAtlasPOD *)encodedAtlasBaseAddress;
pyAtlas->numberOfMaps = stackAtlas->getNumberOfMaps();
pyAtlas->bytesPerStackMap = bytesPerStackMap;

// Offset to the MAPPED pyFrameObject parameter
//
pyAtlas->frameObjectParmOffset = 0;

// Lowest stack offset where MAPPED locals begin.
//
pyAtlas->localBaseOffset = stackAtlas->getLocalBaseOffset();

// Abort if we have overflowed the fields in pyAtlas.
//
if (bytesPerStackMap > USHRT_MAX ||
stackAtlas->getNumberOfMaps() > USHRT_MAX ||
stackAtlas->getNumberOfParmSlotsMapped() > USHRT_MAX ||
stackAtlas->getParmBaseOffset() < SHRT_MIN || stackAtlas->getParmBaseOffset() > SHRT_MAX ||
stackAtlas->getLocalBaseOffset() < SHRT_MIN || stackAtlas->getLocalBaseOffset() > SHRT_MAX)
{
comp->failCompilation<TR::CompilationException>("Overflowed the fields in pyAtlas");
}

// Maps are in reverse order in list from what we want in the atlas
// so advance to the address where the last map should go and start
// building the maps moving back toward the beginning of the atlas.
//
uint8_t *cursorInEncodedAtlas = encodedAtlasBaseAddress + atlasSizeInBytes;

ListIterator<TR_GCStackMap> mapIterator(&stackAtlas->getStackMapList());
TR_GCStackMap *mapCursor = mapIterator.getFirst();

while (mapCursor != NULL)
{
// Move back from the end of the atlas till the current map can be fit in,
// then pass the cursor to the routine that actually creates and fills in
// the stack map
//
TR_GCStackMap *nextMapCursor = mapIterator.getNext();

if (!mapsAreIdentical(mapCursor, nextMapCursor, stackAtlas, comp))
{
cursorInEncodedAtlas -= sizeOfSingleEncodedMapInBytes;
encodeStackMap(mapCursor, cursorInEncodedAtlas, encodeFourByteOffsets, bytesPerStackMap, comp);
}

mapCursor = nextMapCursor;
}

return encodedAtlasBaseAddress;
}


uint32_t
FrontEnd::calculateSizeOfStackAtlas(
bool encodeFourByteOffsets,
uint32_t numberOfSlotsMapped,
uint32_t bytesPerStackMap,
TR::Compilation *comp)
{
TR::CodeGenerator *cg = comp->cg();
TR::GCStackAtlas * stackAtlas = cg->getStackAtlas();

// Calculate the size of each individual map in the atlas. The fixed
// portion of the map contains:
//
// Low Code Offset (2 or 4)
// Stack map (depends on # of mapped parms/locals)
//
uint32_t sizeOfEncodedCodeOffsetInBytes = encodeFourByteOffsets ? 4 : 2;
uint32_t sizeOfSingleEncodedMapInBytes = sizeOfEncodedCodeOffsetInBytes;
sizeOfSingleEncodedMapInBytes += bytesPerStackMap;

// Calculate the atlas size
//
uint32_t atlasSize = sizeof(OMR::StackAtlasPOD);

ListIterator<TR_GCStackMap> mapIterator(&stackAtlas->getStackMapList());
TR_GCStackMap *mapCursor = mapIterator.getFirst();

while (mapCursor != NULL)
{
TR_GCStackMap *nextMapCursor = mapIterator.getNext();

if (!mapsAreIdentical(mapCursor, nextMapCursor, stackAtlas, comp))
{
atlasSize += sizeOfSingleEncodedMapInBytes;
}

mapCursor = nextMapCursor;
}

return atlasSize;
}

} //namespace TestCompiler
27 changes: 0 additions & 27 deletions fvtest/compilertest/env/FrontEnd.hpp
Expand Up @@ -67,33 +67,6 @@ class FrontEnd : public TR::FEBase<FrontEnd>
TR_ResolvedMethod * owningMethod, TR_OpaqueClassBlock *classForNewInstance);


void encodeStackMap(
TR_GCStackMap *map,
uint8_t *location,
bool encodeFourByteOffsets,
uint32_t bytesPerStackMap,
TR::Compilation *comp);

bool mapsAreIdentical(
TR_GCStackMap *mapCursor,
TR_GCStackMap *nextMapCursor,
TR::GCStackAtlas *stackAtlas,
TR::Compilation *comp);

uint8_t *createStackAtlas(
bool encodeFourByteOffsets,
uint32_t numberOfSlotsMapped,
uint32_t bytesPerStackMap,
uint8_t *encodedAtlasBaseAddress,
uint32_t atlasSizeInBytes,
TR::Compilation *comp);

uint32_t
calculateSizeOfStackAtlas(
bool encodeFourByteOffsets,
uint32_t numberOfSlotsMapped,
uint32_t bytesPerStackMap,
TR::Compilation *comp);

};

Expand Down

0 comments on commit c9ddb76

Please sign in to comment.