Skip to content

Commit

Permalink
Merge pull request #6641 from a7ehuo/static-allocation-defaultvalue-a…
Browse files Browse the repository at this point in the history
…ot-2

Add External Relocation Record TR_StaticDefaultValueInstance
  • Loading branch information
dsouzai committed Aug 9, 2022
2 parents 7fd8722 + c2b24eb commit 325d650
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions compiler/codegen/Relocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ const char *TR::ExternalRelocation::_externalRelocationTargetKindNames[TR_NumExt
"TR_InlinedMethodPointer (108)",
"TR_VMINLMethod (109)",
"TR_ValidateJ2IThunkFromMethod (110)",
"TR_StaticDefaultValueInstance (111)",
};

uintptr_t TR::ExternalRelocation::_globalValueList[TR_NumGlobalValueItems] =
Expand Down
9 changes: 8 additions & 1 deletion compiler/il/OMRSymbol.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2021 IBM Corp. and others
* Copyright (c) 2000, 2022 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -444,6 +444,9 @@ class OMR_EXTENSIBLE Symbol
inline void setDummyResolvedMethod();
inline bool isDummyResolvedMethod();

inline void setStaticDefaultValueInstance();
inline bool isStaticDefaultValueInstance();

/**
* Enum values for _flags field.
*/
Expand Down Expand Up @@ -581,6 +584,10 @@ class OMR_EXTENSIBLE Symbol
* and invokehandle bytecodes.
*/
DummyResolvedMethod = 0x00010000,
/**
* This flag is used to identify the value type default value instance slot address
*/
StaticDefaultValueInstance = 0x00020000,
};

protected:
Expand Down
15 changes: 14 additions & 1 deletion compiler/il/OMRSymbol_inlines.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2021 IBM Corp. and others
* Copyright (c) 2017, 2022 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -756,6 +756,19 @@ OMR::Symbol::isDummyResolvedMethod()
return _flags2.testAny(DummyResolvedMethod);
}

void
OMR::Symbol::setStaticDefaultValueInstance()
{
TR_ASSERT(self()->isStatic(), "Symbol must be static");
_flags2.set(StaticDefaultValueInstance);
}

bool
OMR::Symbol::isStaticDefaultValueInstance()
{
return self()->isStatic() && _flags2.testAny(StaticDefaultValueInstance);
}

TR::RegisterMappedSymbol *
OMR::Symbol::getRegisterMappedSymbol()
{
Expand Down
14 changes: 13 additions & 1 deletion compiler/ras/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ TR_Debug::print(TR::SymbolReference * symRef, TR_PrettyPrinterString& output, bo

numSpaces = getNumSpacesAfterIndex( symRef->getReferenceNumber(), getIntLength(_comp->getSymRefTab()->baseArray.size()) );

symRefNum.appendf("#%d", symRef->getReferenceNumber());
symRefNum.appendf("#%d", symRef->getReferenceNumber());

if (verbose)
{
Expand Down Expand Up @@ -1967,6 +1967,18 @@ TR_Debug::getStaticName(TR::SymbolReference * symRef)
if (sym->isConst())
return "<constant>";

// Value Type default value instance slot address
if (sym->isStaticDefaultValueInstance() && staticAddress)
{
if (_comp->getOption(TR_MaskAddresses))
return "*Masked*";

const uint8_t EXTRA_SPACE = 5;
char * name = (char *)_comp->trMemory()->allocateHeapMemory(TR::Compiler->debug.pointerPrintfMaxLenInChars()+EXTRA_SPACE);
sprintf(name, POINTER_PRINTF_FORMAT, staticAddress);
return name;
}

return getOwningMethod(symRef)->staticName(symRef->getCPIndex(), comp()->trMemory());
}

Expand Down
5 changes: 3 additions & 2 deletions compiler/runtime/Runtime.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2021 IBM Corp. and others
* Copyright (c) 2000, 2022 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -336,7 +336,8 @@ typedef enum
TR_InlinedMethodPointer = 108,
TR_VMINLMethod = 109,
TR_ValidateJ2IThunkFromMethod = 110,
TR_NumExternalRelocationKinds = 111,
TR_StaticDefaultValueInstance = 111,
TR_NumExternalRelocationKinds = 112,
TR_ExternalRelocationTargetKindMask = 0xff,
} TR_ExternalRelocationTargetKind;

Expand Down
2 changes: 2 additions & 0 deletions compiler/x/codegen/OMRX86Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3576,6 +3576,8 @@ TR::AMD64RegImm64SymInstruction::autoSetReloKind()
TR::Symbol *symbol = getSymbolReference()->getSymbol();
if (symbol->isDebugCounter())
setReloKind(TR_DebugCounter);
else if (symbol->isStaticDefaultValueInstance())
setReloKind(TR_StaticDefaultValueInstance);
else if (symbol->isConst() || symbol->isConstantPoolAddress())
setReloKind(TR_ConstantPool);
else if (symbol->isStatic() && !getSymbolReference()->isUnresolved() && !symbol->isClassObject() && !symbol->isNotDataAddress())
Expand Down
1 change: 1 addition & 0 deletions compiler/x/codegen/X86BinaryEncoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2958,6 +2958,7 @@ TR::AMD64RegImm64SymInstruction::addMetaDataForCodeAddress(uint8_t *cursor)
break;

case TR_DataAddress:
case TR_StaticDefaultValueInstance:
{
if (cg()->needRelocationsForStatics())
{
Expand Down

0 comments on commit 325d650

Please sign in to comment.