void TR_Debug::print(TR::FILE *pOutFile, TR::PPCHelperCallSnippet * snippet) { uint8_t *cursor = snippet->getSnippetLabel()->getCodeLocation(); TR::LabelSymbol *restartLabel = snippet->getRestartLabel(); if (snippet->getKind() == TR::Snippet::IsArrayCopyCall) { cursor = print(pOutFile, (TR::PPCArrayCopyCallSnippet *)snippet, cursor); } else { printSnippetLabel(pOutFile, snippet->getSnippetLabel(), cursor, "Helper Call Snippet"); } char *info = ""; int32_t distance; if (isBranchToTrampoline(snippet->getDestination(), cursor, distance)) info = " Through trampoline"; printPrefix(pOutFile, NULL, cursor, 4); distance = *((int32_t *) cursor) & 0x03fffffc; distance = (distance << 6) >> 6; // sign extend trfprintf(pOutFile, "%s \t" POINTER_PRINTF_FORMAT "\t\t; %s %s", restartLabel ? "bl" : "b", (intptrj_t)cursor + distance, getName(snippet->getDestination()), info); if (restartLabel) { cursor += 4; printPrefix(pOutFile, NULL, cursor, 4); distance = *((int32_t *) cursor) & 0x03fffffc; distance = (distance << 6) >> 6; // sign extend trfprintf(pOutFile, "b \t" POINTER_PRINTF_FORMAT "\t\t; Restart", (intptrj_t)cursor + distance); } }
size_t DebugClass::write(uint8_t c) { if (started) { if (newDebugLine) { newDebugLine = false; printPrefix(); } if (c == '\n') { newDebugLine = true; } if (debugOut.debugDelegate) { debugOut.debugDelegate(c); return 1; } if (debugOut.debugStream) { debugOut.debugStream->write(c); return 1; } } return 0; }
void showLineLayoutForFlow(const RenderBlockFlow& flow, const Layout& layout, int depth) { int printedCharacters = 0; printPrefix(printedCharacters, depth); fprintf(stderr, "SimpleLineLayout (%u lines, %u runs) (%p)\n", layout.lineCount(), layout.runCount(), &layout); ++depth; auto resolver = runResolver(flow, layout); for (auto it = resolver.begin(), end = resolver.end(); it != end; ++it) { const auto& run = *it; LayoutRect r = run.rect(); printPrefix(printedCharacters, depth); fprintf(stderr, "line %u run(%u, %u) (%.2f, %.2f) (%.2f, %.2f) \"%s\"\n", run.lineIndex(), run.start(), run.end(), r.x().toFloat(), r.y().toFloat(), r.width().toFloat(), r.height().toFloat(), run.text().toStringWithoutCopying().utf8().data()); } }
int32_t TR_Debug::printRestartJump(TR::FILE *pOutFile, TR::X86RestartSnippet * snippet, uint8_t *bufferPos, int32_t branchOp, const char *branchOpName) { int32_t size = snippet->estimateRestartJumpLength((TR_X86OpCodes) branchOp, bufferPos - (uint8_t*)snippet->cg()->getBinaryBufferStart()); printPrefix(pOutFile, NULL, bufferPos, size); printLabelInstruction(pOutFile, branchOpName, snippet->getRestartLabel()); return size; }
int32_t TR_Debug::printRestartJump(TR::FILE *pOutFile, TR::AMD64WriteBarrierSnippet * snippet, uint8_t *bufferPos) { int32_t size = snippet->estimateRestartJumpLength(JMP4, bufferPos - (uint8_t*)snippet->cg()->getBinaryBufferStart()); printPrefix(pOutFile, NULL, bufferPos, size); printLabelInstruction(pOutFile, "jmp", snippet->getRestartLabel()); return size; }
void SyntaxTree::printPrefix(NimbleSyntax* theNode) { if(theNode != 0) { print(theNode); printPrefix(theNode->getLeft()); printPostfix(theNode->getRight()); } }
void showLineLayoutForFlow(const RenderBlockFlow& flow, const Layout& layout, int depth) { int printedCharacters = 0; printPrefix(printedCharacters, depth); fprintf(stderr, "SimpleLineLayout (%u lines, %u runs) (%p)\n", layout.lineCount(), layout.runCount(), &layout); ++depth; for (auto run : runResolver(flow, layout)) { FloatRect rect = run.rect(); printPrefix(printedCharacters, depth); if (run.start() < run.end()) { fprintf(stderr, "line %u run(%u, %u) (%.2f, %.2f) (%.2f, %.2f) \"%s\"\n", run.lineIndex(), run.start(), run.end(), rect.x(), rect.y(), rect.width(), rect.height(), run.text().toStringWithoutCopying().utf8().data()); } else { ASSERT(run.start() == run.end()); fprintf(stderr, "line break %u run(%u, %u) (%.2f, %.2f) (%.2f, %.2f)\n", run.lineIndex(), run.start(), run.end(), rect.x(), rect.y(), rect.width(), rect.height()); } } }
void TR_Debug::print(TR::FILE *pOutFile, TR::S390WarmToColdTrampolineSnippet *snippet) { uint8_t * buffer = snippet->getSnippetLabel()->getCodeLocation(); printSnippetLabel(pOutFile, snippet->getSnippetLabel(), buffer, "Warm To Cold Trampoline"); printPrefix(pOutFile, NULL, buffer, 6); trfprintf(pOutFile, "BRCL 0xF, targetLabel(%p)", snippet->getTargetLabel()->getCodeLocation()); buffer += 6; }
void TR_Debug::print(TR::FILE *pOutFile, TR::S390HelperCallSnippet * snippet) { if (pOutFile == NULL) { return; } TR::SymbolReference * helperSymRef = snippet->getHelperSymRef(); uint8_t * bufferPos = snippet->getSnippetLabel()->getCodeLocation(); printSnippetLabel(pOutFile, snippet->getSnippetLabel(), bufferPos, "Helper Call Snippet", getName(helperSymRef)); bufferPos = printLoadVMThreadInstruction(pOutFile, bufferPos); bufferPos = printRuntimeInstrumentationOnOffInstruction(pOutFile, bufferPos, false); // RIOFF if ( snippet->alwaysExcept()) { printPrefix(pOutFile, NULL, bufferPos, 6); trfprintf(pOutFile, "BRASL \tGPR14, <%p>\t# Branch to Helper Method %s", snippet->getSnippetDestAddr(), snippet->usedTrampoline()?"- Trampoline Used.":""); bufferPos += 6; } else { printPrefix(pOutFile, NULL, bufferPos, 6); trfprintf(pOutFile, "LARL \tGPR14, <%p>\t# Return Addr of Main Line.", (intptrj_t) snippet->getReStartLabel()->getCodeLocation()); bufferPos += 6; printPrefix(pOutFile, NULL, bufferPos, 6); trfprintf(pOutFile, "BRCL \t<%p>\t# Branch to Helper Method %s", snippet->getSnippetDestAddr(), snippet->usedTrampoline()?"- Trampoline Used.":""); bufferPos += 6; } }
uint8_t* TR_Debug::print(TR::FILE *pOutFile, TR::PPCArrayCopyCallSnippet *snippet, uint8_t *cursor) { printSnippetLabel(pOutFile, snippet->getSnippetLabel(), cursor, "ArrayCopy Helper Call Snippet"); TR::RealRegister *lengthReg = _cg->machine()->getRealRegister(snippet->getLengthRegNum()); printPrefix(pOutFile, NULL, cursor, 4); trfprintf(pOutFile, "li \t%s, %d", getName(lengthReg), *((int32_t *) cursor) & 0x0000ffff); cursor += 4; return cursor; }
void TR_Debug::print(TR::FILE *pOutFile, TR::X86FPConvertToLongSnippet * snippet) { if (pOutFile == NULL) return; uint8_t *bufferPos = snippet->getSnippetLabel()->getCodeLocation(); uint8_t action = TR::X86FPConvertToLongSnippet::_registerActions[snippet->getAction() & 0x7f ]; printSnippetLabel(pOutFile, snippet->getSnippetLabel(), bufferPos, getName(snippet)); if (snippet->getAction() & snippet->kNeedFXCH) { printPrefix(pOutFile, NULL, bufferPos, 2); trfprintf(pOutFile, "fxch\t"); print(pOutFile, snippet->getDoubleRegister(), TR_FloatReg); trfprintf(pOutFile, "\t\t%s register to convert", commentString()); bufferPos += 2; } if (action & snippet->kPreserveEAX) { printPrefix(pOutFile, NULL, bufferPos, 1); trfprintf(pOutFile, "push\teax\t\t%s preserve eax", commentString()); bufferPos++; } if (action & snippet->kPreserveEDX) { printPrefix(pOutFile, NULL, bufferPos, 1); trfprintf(pOutFile, "push\tedx\t\t%s preserve eax", commentString()); bufferPos++; } printPrefix(pOutFile, NULL, bufferPos, 5); trfprintf(pOutFile, "call\t%s", getName(snippet->getHelperSymRef())); bufferPos += 5; if (action & snippet->kMOVLow) { printPrefix(pOutFile, NULL, bufferPos, 2); trfprintf(pOutFile, "mov\t"); print(pOutFile, snippet->getLowRegister(), TR_WordReg); trfprintf(pOutFile, ", eax\t%s result register (low)", commentString()); bufferPos += 2; } if (action & snippet->kMOVHigh) { printPrefix(pOutFile, NULL, bufferPos, 2); trfprintf(pOutFile, "mov\t"); print(pOutFile, snippet->getHighRegister(), TR_WordReg); trfprintf(pOutFile, ", edx\t%s result register (high)", commentString()); bufferPos += 2; } if (action & snippet->kXCHG) { printPrefix(pOutFile, NULL, bufferPos, 1); trfprintf(pOutFile, "xchg\teax, edx"); bufferPos += 1; } if (action & snippet->kPreserveEDX) { printPrefix(pOutFile, NULL, bufferPos, 1); trfprintf(pOutFile, "pop\tedx\t\t%s restore edx", commentString()); bufferPos += 1; } if (action & snippet->kPreserveEAX) { printPrefix(pOutFile, NULL, bufferPos, 1); trfprintf(pOutFile, "pop\teax\t\t%s restore eax", commentString()); bufferPos += 1; } if (snippet->getAction() & snippet->kNeedFXCH) { printPrefix(pOutFile, NULL, bufferPos, 2); trfprintf(pOutFile, "fxch\t"); print(pOutFile, snippet->getDoubleRegister(), TR_FloatReg); bufferPos += 2; } printRestartJump(pOutFile, snippet, bufferPos); }
void TR_Debug::print(TR::FILE *pOutFile, TR::X86FPConvertToIntSnippet * snippet) { if (pOutFile == NULL) return; uint8_t *bufferPos = snippet->getSnippetLabel()->getCodeLocation(); printSnippetLabel(pOutFile, snippet->getSnippetLabel(), bufferPos, getName(snippet)); TR::RealRegister *targetRegister = toRealRegister(snippet->getConvertInstruction()->getTargetRegister()); uint8_t reg = targetRegister->getRegisterNumber(); if (reg != TR::RealRegister::eax) { printPrefix(pOutFile, NULL, bufferPos, 2); trfprintf(pOutFile, "mov\t"); print(pOutFile, targetRegister, TR_WordReg); trfprintf(pOutFile, ", eax\t\t%s preserve helper return reg", commentString()); bufferPos += 2; } printPrefix(pOutFile, NULL, bufferPos, 3); trfprintf(pOutFile, "sub\tesp, 4\t\t%s push parameter", commentString()); bufferPos += 3; TR::X86RegRegInstruction *instr = snippet->getConvertInstruction()->getIA32RegRegInstruction(); if (instr) { printPrefix(pOutFile, NULL, bufferPos, 5); trfprintf(pOutFile, "movss\t dword ptr [esp], "); print(pOutFile, toRealRegister(instr->getSourceRegister()), TR_QuadWordReg); bufferPos += 5; } else { printPrefix(pOutFile, NULL, bufferPos, 3); trfprintf(pOutFile, "fst\tdword ptr [esp]"); bufferPos += 3; } printPrefix(pOutFile, NULL, bufferPos, 5); trfprintf(pOutFile, "call\t%s", getName(snippet->getHelperSymRef())); bufferPos += 5; printPrefix(pOutFile, NULL, bufferPos, 3); trfprintf(pOutFile, "add\tesp, 4\t\t%s pop parameter", commentString()); bufferPos += 3; if (reg != TR::RealRegister::eax) { printPrefix(pOutFile, NULL, bufferPos, 1); trfprintf(pOutFile, "xchg\teax, "); print(pOutFile, targetRegister, TR_WordReg); trfprintf(pOutFile, "\t\t%s restore eax", commentString()); bufferPos++; } printRestartJump(pOutFile, snippet, bufferPos); }
void TR_Debug::print(TR::FILE *pOutFile, TR::S390CallSnippet * snippet) { uint8_t * bufferPos = snippet->getSnippetLabel()->getCodeLocation(); TR::Node * callNode = snippet->getNode(); TR::SymbolReference * methodSymRef = snippet->getRealMethodSymbolReference(); if(!methodSymRef) methodSymRef = callNode->getSymbolReference(); TR::MethodSymbol * methodSymbol = methodSymRef->getSymbol()->castToMethodSymbol(); TR::SymbolReference * glueRef; int8_t padbytes = snippet->getPadBytes(); printSnippetLabel(pOutFile, snippet->getSnippetLabel(), bufferPos, methodSymRef->isUnresolved() ? "Unresolved Call Snippet" : "Call Snippet"); bufferPos = printS390ArgumentsFlush(pOutFile, callNode, bufferPos, snippet->getSizeOfArguments()); if (methodSymRef->isUnresolved() || _comp->compileRelocatableCode()) { if (methodSymbol->isSpecial()) { glueRef = _cg->getSymRef(TR_S390interpreterUnresolvedSpecialGlue); } else if (methodSymbol->isStatic()) { glueRef = _cg->getSymRef(TR_S390interpreterUnresolvedStaticGlue); } else { glueRef = _cg->getSymRef(TR_S390interpreterUnresolvedDirectVirtualGlue); } } else { bool synchronised = methodSymbol->isSynchronised(); if ((methodSymbol->isVMInternalNative() || methodSymbol->isJITInternalNative())) { glueRef = _cg->getSymRef(TR_S390nativeStaticHelper); } else { switch (callNode->getDataType()) { case TR::NoType: if (synchronised) { glueRef = _cg->getSymRef(TR_S390interpreterSyncVoidStaticGlue); } else { glueRef = _cg->getSymRef(TR_S390interpreterVoidStaticGlue); } break; case TR::Int8: case TR::Int16: case TR::Int32: if (synchronised) { glueRef = _cg->getSymRef(TR_S390interpreterSyncIntStaticGlue); } else { glueRef = _cg->getSymRef(TR_S390interpreterIntStaticGlue); } break; case TR::Address: if (TR::Compiler->target.is64Bit()) { if (synchronised) { glueRef = _cg->getSymRef(TR_S390interpreterSyncLongStaticGlue); } else { glueRef = _cg->getSymRef(TR_S390interpreterLongStaticGlue); } } else { if (synchronised) { glueRef = _cg->getSymRef(TR_S390interpreterSyncIntStaticGlue); } else { glueRef = _cg->getSymRef(TR_S390interpreterIntStaticGlue); } } break; case TR::Int64: if (synchronised) { glueRef = _cg->getSymRef(TR_S390interpreterSyncLongStaticGlue); } else { glueRef = _cg->getSymRef(TR_S390interpreterLongStaticGlue); } break; case TR::Float: if (synchronised) { glueRef = _cg->getSymRef(TR_S390interpreterSyncFloatStaticGlue); } else { glueRef = _cg->getSymRef(TR_S390interpreterFloatStaticGlue); } break; case TR::Double: if (synchronised) { glueRef = _cg->getSymRef(TR_S390interpreterSyncDoubleStaticGlue); } else { glueRef = _cg->getSymRef(TR_S390interpreterDoubleStaticGlue); } break; default: TR_ASSERT(0, "Bad return data type for a call node. DataType was %s\n", getName(callNode->getDataType())); } } } bufferPos = printRuntimeInstrumentationOnOffInstruction(pOutFile, bufferPos, false); // RIOFF if (snippet->getKind() == TR::Snippet::IsUnresolvedCall) { int lengthOfLoad = (TR::Compiler->target.is64Bit())?6:4; printPrefix(pOutFile, NULL, bufferPos, 6); trfprintf(pOutFile, "LARL \tGPR14, *+%d <%p>\t# Start of Data Const.", 8 + lengthOfLoad + padbytes, bufferPos + 8 + lengthOfLoad + padbytes); bufferPos += 6; if (TR::Compiler->target.is64Bit()) { printPrefix(pOutFile, NULL, bufferPos, 6); trfprintf(pOutFile, "LG \tGPR_EP, 0(,GPR14)"); bufferPos += 6; } else { printPrefix(pOutFile, NULL, bufferPos, 4); trfprintf(pOutFile, "L \tGPR_EP, 0(,GPR14)"); bufferPos += 4; } printPrefix(pOutFile, NULL, bufferPos, 2); trfprintf(pOutFile, "BCR \tGPR_EP"); bufferPos += 2; } else { printPrefix(pOutFile, NULL, bufferPos, 6); trfprintf(pOutFile, "BRASL \tGPR14, <%p>\t# Branch to Helper Method %s", snippet->getSnippetDestAddr(), snippet->usedTrampoline()?"- Trampoline Used.":""); bufferPos += 6; } if (padbytes == 2) { printPrefix(pOutFile, NULL, bufferPos, 2); trfprintf(pOutFile, "DC \t0x0000 \t\t\t# 2-bytes padding for alignment"); bufferPos += 2; } else if (padbytes == 4) { printPrefix(pOutFile, NULL, bufferPos, 4) ; trfprintf(pOutFile, "DC \t0x00000000 \t\t# 4-bytes padding for alignment"); bufferPos += 4; } else if (padbytes == 6) { printPrefix(pOutFile, NULL, bufferPos, 6) ; trfprintf(pOutFile, "DC \t0x000000000000 \t\t# 6-bytes padding for alignment"); bufferPos += 6; } printPrefix(pOutFile, NULL, bufferPos, sizeof(intptrj_t)); trfprintf(pOutFile, "DC \t%p \t\t# Method Address", glueRef->getMethodAddress()); bufferPos += sizeof(intptrj_t); printPrefix(pOutFile, NULL, bufferPos, sizeof(intptrj_t)); trfprintf(pOutFile, "DC \t%p \t\t# Call Site RA", snippet->getCallRA()); bufferPos += sizeof(intptrj_t); if (methodSymRef->isUnresolved()) { printPrefix(pOutFile, NULL, bufferPos, 0); } else { printPrefix(pOutFile, NULL, bufferPos, sizeof(intptrj_t)); } trfprintf(pOutFile, "DC \t%p \t\t# Method Pointer", methodSymRef->isUnresolved() ? 0 : methodSymbol->getMethodAddress()); }
void Posixino::printPrefix() { printPrefix(""); } // printPrefix(void)
void Posixino::printErrorPrefix() { printPrefix(" error"); } // printErrorPrefix()
void TR_Debug::print(TR::FILE *pOutFile, TR::AMD64FPConversionSnippet * snippet) { if (pOutFile == NULL) return; uint8_t *bufferPos = snippet->getSnippetLabel()->getCodeLocation(); printSnippetLabel(pOutFile, snippet->getSnippetLabel(), bufferPos, getName(snippet)); TR::Machine *machine = _cg->machine(); TR::RealRegister *sourceRegister = toRealRegister(snippet->getConvertInstruction()->getSourceRegister()); TR::RealRegister *targetRegister = toRealRegister(snippet->getConvertInstruction()->getTargetRegister()); uint8_t sreg = sourceRegister->getRegisterNumber(); uint8_t treg = targetRegister->getRegisterNumber(); TR::ILOpCodes opCode = snippet->getConvertInstruction()->getNode()->getOpCodeValue(); TR_RegisterSizes size = TR_DoubleWordReg; if (treg != TR::RealRegister::eax) { int instrSize = IS_REX(*bufferPos)? 3 : 2; printPrefix(pOutFile, NULL, bufferPos, instrSize); trfprintf(pOutFile, "mov \t"); print(pOutFile, targetRegister, size); trfprintf(pOutFile, ", "); print(pOutFile, machine->getX86RealRegister(TR::RealRegister::eax), size); trfprintf(pOutFile, "\t%s preserve helper return reg", commentString()); bufferPos += instrSize; } if (sreg != TR::RealRegister::xmm0) { printPrefix(pOutFile, NULL, bufferPos, 4); trfprintf(pOutFile, "sub \trsp, 8"); printPrefix(pOutFile, NULL, bufferPos, 5); trfprintf(pOutFile, "movsd\t[rsp], xmm0\t%s save xmm0", commentString()); bufferPos += 9; int instrSize = IS_REX(*bufferPos)? 5 : 4; printPrefix(pOutFile, NULL, bufferPos, instrSize); trfprintf(pOutFile, "movsd\txmm0, "); print(pOutFile, sourceRegister, TR_QuadWordReg); trfprintf(pOutFile, "\t%s load parameter", commentString()); bufferPos += instrSize; } printPrefix(pOutFile, NULL, bufferPos, 5); trfprintf(pOutFile, "call\t%s", getName(snippet->getHelperSymRef())); bufferPos += 5; if (sreg != TR::RealRegister::xmm0) { printPrefix(pOutFile, NULL, bufferPos, 5); trfprintf(pOutFile, "movsd\txmm0, [rsp]\t%s restore xmm0", commentString()); printPrefix(pOutFile, NULL, bufferPos, 4); trfprintf(pOutFile, "add \trsp, 8"); bufferPos += 9; } if (treg != TR::RealRegister::eax) { int instrSize = IS_REX(*bufferPos)? 2 : 1; printPrefix(pOutFile, NULL, bufferPos, instrSize); trfprintf(pOutFile, "xchg\t"); print(pOutFile, targetRegister, size); trfprintf(pOutFile, ", "); print(pOutFile, machine->getX86RealRegister(TR::RealRegister::eax), size); trfprintf(pOutFile, "\t%s restore result reg & put result in target reg", commentString()); bufferPos += instrSize; } printRestartJump(pOutFile, snippet, bufferPos); }