Skip to content

Commit

Permalink
Merge pull request #7549 from 0xdaryl/maskaddresses
Browse files Browse the repository at this point in the history
Remove compiler ras address masking
  • Loading branch information
dsouzai authored Nov 19, 2024
2 parents ef89b64 + a39eaca commit d626d17
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 155 deletions.
7 changes: 1 addition & 6 deletions compiler/compile/OMRCompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2496,13 +2496,8 @@ void OMR::Compilation::diagnosticImplVA(const char *s, va_list ap)
{
if (self()->getOutFile() != NULL)
{
va_list copy;
va_copy(copy, ap);
char buffer[256];
TR::IO::vfprintf(self()->getOutFile(), self()->getDebug()->getDiagnosticFormat(s, buffer, sizeof(buffer)/sizeof(char)),
copy);
TR::IO::vfprintf(self()->getOutFile(), s, ap);
trfflush(self()->getOutFile());
va_end(copy);
}
}

Expand Down
1 change: 0 additions & 1 deletion compiler/control/OMROptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,6 @@ TR::OptionTable OMR::Options::_jitOptions[] = {
{"lowerCountsForAotCold", "M\tLower counts for cold aot runs", SET_OPTION_BIT(TR_LowerCountsForAotCold), "F", NOT_IN_SUBSET},
{"lowOpt", "O\tdeprecated; equivalent to optLevel=cold",
TR::Options::set32BitValue, offsetof(OMR::Options, _optLevel), cold},
{"maskAddresses", "D\tremove addresses from trace file", SET_OPTION_BIT(TR_MaskAddresses), "F" },
{"maxBytesToLeaveAllocatedInSharedPool=","R<nnn>\tnumber of memory segments to leave allocated",
TR::Options::setStaticNumeric, (intptr_t)&OMR::Options::_maxBytesToLeaveAllocatedInSharedPool, 0, "F%d", NOT_IN_SUBSET},
{"maxInlinedCalls=", "O<nnn>\tmaximum number of calls to be inlined",
Expand Down
2 changes: 1 addition & 1 deletion compiler/control/OMROptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ enum TR_CompilationOptions
TR_DisableDynamicLoopTransfer = 0x00200000 + 3,
TR_TraceNodeFlags = 0x00400000 + 3,
TR_DisableNewBVA = 0x00800000 + 3,
TR_MaskAddresses = 0x01000000 + 3,
// Available = 0x01000000 + 3,
TR_BreakBBStart = 0x02000000 + 3,
TR_DisableRXusage = 0x04000000 + 3,
TR_EnableInliningOfUnsafeForArraylets = 0x08000000 + 3,
Expand Down
148 changes: 18 additions & 130 deletions compiler/ras/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,70 +400,6 @@ TR_Debug::addInstructionComment(TR::Instruction *instr, char * comment, ...)
}
}

const char *
TR_Debug::getDiagnosticFormat(const char *format, char *buffer, int32_t length)
{
if (!_comp->getOption(TR_MaskAddresses))
return format;

bool allowedToWrite = true;
bool sawPercentP = false;

int32_t j = 0;
const char *c = format;
for (; *c; c++, j++)
{
if (j >= length)
allowedToWrite = false;
if (allowedToWrite)
buffer[j] = *c;

if (*c == '%')
{
++c; ++j;
const char *base = c;
while (*c == '*' || (*c >= '0' && *c <= '9'))
c++;

if (*c == 'p')
{
char s[] = ".0s*Masked*";
int32_t slen = sizeof(s)/sizeof(char);
if (j+slen >= length)
allowedToWrite = false;
if (allowedToWrite)
memcpy(&buffer[j], s, slen);
j+=slen-2;
sawPercentP = true;
}
else
{
if (j+c-base+1 >= length)
allowedToWrite = false;
if (allowedToWrite)
memcpy(&buffer[j], base, c-base+1);
j+=static_cast<int32_t>(c-base);
}
}
}

if (j >= length)
allowedToWrite = false;
if (allowedToWrite)
buffer[j] = 0; // null terminate
j++;


if (!sawPercentP)
return format;
if (allowedToWrite)
return buffer;

// allocate a jitMalloc buffer of the correct size
buffer = (char *) _comp->trMemory()->allocateHeapMemory(j);
return getDiagnosticFormat(format, buffer, j);
}

bool
TR_Debug::performTransformationImpl(bool canOmitTransformation, const char * format, ...)
{
Expand Down Expand Up @@ -563,13 +499,10 @@ TR_Debug::performTransformationImpl(bool canOmitTransformation, const char * for
else
trfprintf(_file, " ");


char buffer[200];

va_list args;
va_start(args,format);

TR::IO::vfprintf(_file, getDiagnosticFormat(format, buffer, sizeof(buffer)/sizeof(char)), args);
TR::IO::vfprintf(_file, format, args);
va_end(args);
trfflush(_file);

Expand All @@ -595,14 +528,13 @@ TR_Debug::vtrace(const char * format, va_list args)
{
if (_file != NULL)
{
char buffer[256];
if ((0 != TR::Options::_traceFileLength) &&
(static_cast<int64_t>(TR::IO::ftell(_file)) > (static_cast<int64_t>(TR::Options::_traceFileLength) << 20)))
{
TR::IO::fseek(_file, 0, SEEK_SET); // rewind the trace file
TR::IO::fprintf(_file, "Rewind trace file ...\n\n\n");
}
TR::IO::vfprintf(_file, getDiagnosticFormat(format, buffer, sizeof(buffer)), args);
TR::IO::vfprintf(_file, format, args);
trfflush(_file);
}
}
Expand Down Expand Up @@ -717,20 +649,10 @@ TR_Debug::printPrefix(TR::FILE *pOutFile, TR::Instruction *instr, uint8_t *curso
int codeByteColumnWidth = TR::Compiler->debug.codeByteColumnWidth();
int prefixWidth = addressFieldWidth * 2 + codeByteColumnWidth + 12; // 8 bytes of offsets, 2 spaces, and opening and closing brackets

if (_comp->getOption(TR_MaskAddresses))
{
if (instr)
sprintf(prefix, "%*s %08x [%s]", addressFieldWidth, "*Masked*", offset, getName(instr));
else
sprintf(prefix, "%*s %08x %*s", addressFieldWidth, "*Masked*", offset, addressFieldWidth + 2, " ");
}
if (instr)
sprintf(prefix, POINTER_PRINTF_FORMAT " %08x [%s]", cursor, offset, getName(instr));
else
{
if (instr)
sprintf(prefix, POINTER_PRINTF_FORMAT " %08x [%s]", cursor, offset, getName(instr));
else
sprintf(prefix, POINTER_PRINTF_FORMAT " %08x %*s", cursor, offset, addressFieldWidth + 2, " ");
}
sprintf(prefix, POINTER_PRINTF_FORMAT " %08x %*s", cursor, offset, addressFieldWidth + 2, " ");

char *p0 = prefix;
char *p1 = prefix + strlen(prefix);
Expand Down Expand Up @@ -796,14 +718,8 @@ TR_Debug::printSnippetLabel(TR::FILE *pOutFile, TR::LabelSymbol *label, uint8_t

uint32_t offset = static_cast<uint32_t>(cursor - _comp->cg()->getCodeStart());

if (_comp->getOption(TR_MaskAddresses))
{
trfprintf(pOutFile, "\n\n%*s %08x %*s", TR::Compiler->debug.hexAddressFieldWidthInChars(), "*Masked*", offset, addressFieldWidth + codeByteColumnWidth + 2, " ");
}
else
{
trfprintf(pOutFile, "\n\n" POINTER_PRINTF_FORMAT " %08x %*s", cursor, offset, addressFieldWidth + codeByteColumnWidth + 2, " ");
}
trfprintf(pOutFile, "\n\n" POINTER_PRINTF_FORMAT " %08x %*s", cursor, offset, addressFieldWidth + codeByteColumnWidth + 2, " ");

print(pOutFile, label);
trfprintf(pOutFile, ":");
if (comment1)
Expand Down Expand Up @@ -1357,19 +1273,13 @@ TR_Debug::getName(void * address, const char * prefix, uint32_t nextNumber, bool
}

char *buf = (char *)_comp->trMemory()->allocateHeapMemory(20 + TR::Compiler->debug.pointerPrintfMaxLenInChars());
if (_comp->getOption(TR_MaskAddresses))
{
sprintf(buf, "%*s", TR::Compiler->debug.hexAddressFieldWidthInChars(), "*Masked*");
return buf;
}

if (address)
sprintf(buf, POINTER_PRINTF_FORMAT, address);
else
{
if (address)
sprintf(buf, POINTER_PRINTF_FORMAT, address);
else
sprintf(buf, "%0*d", TR::Compiler->debug.hexAddressWidthInChars(), 0);
return buf;
}
sprintf(buf, "%0*d", TR::Compiler->debug.hexAddressWidthInChars(), 0);
return buf;

}

const char *
Expand Down Expand Up @@ -1447,10 +1357,6 @@ TR_Debug::getName(TR::CFGNode * node)
{
sprintf(buf, "block_%d", node->getNumber());
}
else if (_comp->getOption(TR_MaskAddresses))
{
sprintf(buf, "%*s", TR::Compiler->debug.hexAddressWidthInChars(), "*Masked*");
}
else
{
sprintf(buf, POINTER_PRINTF_FORMAT, node);
Expand Down Expand Up @@ -1502,15 +1408,9 @@ TR_Debug::getName(TR::LabelSymbol *labelSymbol)
char *buf = (char *)_comp->trMemory()->allocateHeapMemory(20+TR::Compiler->debug.pointerPrintfMaxLenInChars());

if (labelSymbol->getSnippet())
if (_comp->getOption(TR_MaskAddresses))
sprintf(buf, "Snippet Label [*Masked*]");
else
sprintf(buf, "Snippet Label [" POINTER_PRINTF_FORMAT "]", labelSymbol);
sprintf(buf, "Snippet Label [" POINTER_PRINTF_FORMAT "]", labelSymbol);
else
if (_comp->getOption(TR_MaskAddresses))
sprintf(buf, "Label [*Masked*]");
else
sprintf(buf, "Label [" POINTER_PRINTF_FORMAT "]", labelSymbol);
sprintf(buf, "Label [" POINTER_PRINTF_FORMAT "]", labelSymbol);

_comp->getToStringMap().Add((void *)labelSymbol, buf);
return buf;
Expand Down Expand Up @@ -1791,10 +1691,7 @@ TR_Debug::getAutoName(TR::SymbolReference * symRef)
else
sprintf(symName, "#SPILL%zu_%d", symRef->getSymbol()->getSize(), symRef->getReferenceNumber());

if (_comp->getOption(TR_MaskAddresses))
sprintf(name, "<%s *Masked*>", symName);
else
sprintf(name, "<%s " POINTER_PRINTF_FORMAT ">", symName, symRef->getSymbol());
sprintf(name, "<%s " POINTER_PRINTF_FORMAT ">", symName, symRef->getSymbol());
}
else if (symRef->isTempVariableSizeSymRef())
{
Expand Down Expand Up @@ -2019,9 +1916,6 @@ TR_Debug::getStaticName(TR::SymbolReference * symRef)
// 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);
Expand Down Expand Up @@ -2058,10 +1952,7 @@ TR_Debug::getStaticName(TR::SymbolReference * symRef)
if (staticAddress)
{
char * name = (char *)_comp->trMemory()->allocateHeapMemory(TR::Compiler->debug.pointerPrintfMaxLenInChars()+5);
if (_comp->getOption(TR_MaskAddresses))
sprintf(name, "*Masked*");
else
sprintf(name, POINTER_PRINTF_FORMAT, staticAddress);
sprintf(name, POINTER_PRINTF_FORMAT, staticAddress);
return name;
}

Expand Down Expand Up @@ -3039,10 +2930,7 @@ TR_Debug::getName(TR::Register *reg, TR_RegisterSizes size)
else
{
char *buf = (char *)_comp->trMemory()->allocateHeapMemory(maxPrefixSize + 6 + TR::Compiler->debug.pointerPrintfMaxLenInChars() + 1);
if (_comp->getOption(TR_MaskAddresses))
sprintf(buf, "%s%s_*Masked*", prefix, getRegisterKindName(reg->getKind()));
else
sprintf(buf, "%s%s_" POINTER_PRINTF_FORMAT, prefix, getRegisterKindName(reg->getKind()), reg);
sprintf(buf, "%s%s_" POINTER_PRINTF_FORMAT, prefix, getRegisterKindName(reg->getKind()), reg);
_comp->getToStringMap().Add((void *)reg, buf);
return buf;
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/ras/Debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,6 @@ class TR_Debug

virtual void printInstruction(TR::Instruction*);

virtual const char * getDiagnosticFormat(const char *, char *, int32_t);

virtual void dumpGlobalRegisterTable();
virtual void dumpSimulatedNode(TR::Node *node, char tagChar);

Expand Down
10 changes: 3 additions & 7 deletions compiler/ras/Tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ TR_Debug::printLoadConst(TR::Node *node, TR_PrettyPrinterString& output)
case TR::Address:
if (node->getAddress() == 0)
output.appends(" NULL");
else if (_comp->getOption(TR_MaskAddresses))
output.appends(" *Masked*");
else
output.appendf(" " UINT64_PRINTF_FORMAT_HEX, node->getAddress());
if (node->isClassPointerConstant())
Expand Down Expand Up @@ -1571,11 +1569,9 @@ TR_Debug::printNodeInfo(TR::Node * node, TR_PrettyPrinterString& output, bool pr
else
output.appends(" Relative [");

if (!_comp->getOption(TR_MaskAddresses))
{
for (auto i = 0U; i < node->getNumRelocations(); ++i)
output.appendf(" " POINTER_PRINTF_FORMAT, node->getRelocationDestination(i));
}
for (auto i = 0U; i < node->getNumRelocations(); ++i)
output.appendf(" " POINTER_PRINTF_FORMAT, node->getRelocationDestination(i));

output.appends(" ]");
}
}
Expand Down
8 changes: 3 additions & 5 deletions compiler/x/codegen/X86Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,9 @@ TR_Debug::print(TR::FILE *pOutFile, TR::X86FenceInstruction * instr)
else
trfprintf(pOutFile, " Relative [");

if (!_comp->getOption(TR_MaskAddresses))
{
for (auto i = 0U; i < instr->getFenceNode()->getNumRelocations(); ++i)
trfprintf(pOutFile," " POINTER_PRINTF_FORMAT, instr->getFenceNode()->getRelocationDestination(i));
}
for (auto i = 0U; i < instr->getFenceNode()->getNumRelocations(); ++i)
trfprintf(pOutFile," " POINTER_PRINTF_FORMAT, instr->getFenceNode()->getRelocationDestination(i));

trfprintf(pOutFile, " ]");
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/z/codegen/S390Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,7 @@ TR_Debug::print(TR::FILE *pOutFile, TR::S390PseudoInstruction * instr)
}
for (int32_t i = 0; i < instr->getFenceNode()->getNumRelocations(); ++i)
{
if (!_comp->getOption(TR_MaskAddresses))
trfprintf(pOutFile, " %p", instr->getFenceNode()->getRelocationDestination(i));
trfprintf(pOutFile, " %p", instr->getFenceNode()->getRelocationDestination(i));
}
trfprintf(pOutFile, " ]");

Expand Down
1 change: 0 additions & 1 deletion doc/compiler/CompilerOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ options, etc).
| debugOnEntry | invoke the debugger at the entry of a method |
| exclude=<em>xxx</em> | do not compile methods beginning with <em>xxx</em> |
| limit=<em>xxx</em> | only compile methods beginning with <em>xxx</em> |
| maskAddresses | remove addresses from trace file |
| noRecompile | do not recompile even when counts allow it |
| stopOnFailure | stop compilation if exceed memory threshold |
| tlhPrefetch | enable software prefetch on allocation for X86 |
Expand Down

0 comments on commit d626d17

Please sign in to comment.