use of jdk.vm.ci.code.site.ExceptionHandler in project graal by oracle.
the class HexCodeFileDisassemblerProvider method addExceptionHandlersComment.
private static void addExceptionHandlersComment(CompilationResult compResult, HexCodeFile hcf) {
if (!compResult.getExceptionHandlers().isEmpty()) {
String nl = HexCodeFile.NEW_LINE;
StringBuilder buf = new StringBuilder("------ Exception Handlers ------").append(nl);
for (ExceptionHandler e : compResult.getExceptionHandlers()) {
buf.append(" ").append(e.pcOffset).append(" -> ").append(e.handlerPos).append(nl);
hcf.addComment(e.pcOffset, "[exception -> " + e.handlerPos + "]");
hcf.addComment(e.handlerPos, "[exception handler for " + e.pcOffset + "]");
}
hcf.addComment(0, buf.toString());
}
}
use of jdk.vm.ci.code.site.ExceptionHandler in project graal by oracle.
the class CollectingObjectReferenceVisitor method addMethod.
public void addMethod(SharedMethod method, CompilationResult compilation, int compilationOffset) {
int totalFrameSize = compilation.getTotalFrameSize();
/* Mark the method start and register the frame size. */
IPData startEntry = makeEntry(compilationOffset);
startEntry.frameSizeEncoding = encodeFrameSize(totalFrameSize, true);
/* Register the frame size for all entries that are starting points for the index. */
long entryIP = CodeInfoDecoder.lookupEntryIP(CodeInfoDecoder.indexGranularity() + compilationOffset);
while (entryIP <= CodeInfoDecoder.lookupEntryIP(compilation.getTargetCodeSize() + compilationOffset)) {
IPData entry = makeEntry(entryIP);
entry.frameSizeEncoding = encodeFrameSize(totalFrameSize, false);
entryIP += CodeInfoDecoder.indexGranularity();
}
/* Make entries for all calls and deoptimization entry points of the method. */
for (Infopoint infopoint : compilation.getInfopoints()) {
final DebugInfo debugInfo = infopoint.debugInfo;
if (debugInfo != null) {
final int offset = getEntryOffset(infopoint);
if (offset >= 0) {
IPData entry = makeEntry(offset + compilationOffset);
assert entry.referenceMap == null && entry.frameData == null;
entry.referenceMap = (ReferenceMapEncoder.Input) debugInfo.getReferenceMap();
entry.frameData = frameInfoEncoder.addDebugInfo(method, infopoint, totalFrameSize);
}
}
}
/* Make entries for all exception handlers. */
for (ExceptionHandler handler : compilation.getExceptionHandlers()) {
final IPData entry = makeEntry(handler.pcOffset + compilationOffset);
assert entry.exceptionOffset == 0;
entry.exceptionOffset = handler.handlerPos - handler.pcOffset;
}
ImageSingletons.lookup(Counters.class).methodCount.inc();
ImageSingletons.lookup(Counters.class).codeSize.add(compilation.getTargetCodeSize());
}
use of jdk.vm.ci.code.site.ExceptionHandler in project graal by oracle.
the class CollectingObjectReferenceVisitor method verifyMethod.
protected void verifyMethod(CompilationResult compilation, int compilationOffset) {
for (int relativeIP = 0; relativeIP < compilation.getTargetCodeSize(); relativeIP++) {
int totalIP = relativeIP + compilationOffset;
CodeInfoQueryResult codeInfo = new CodeInfoQueryResult();
lookupCodeInfo(totalIP, codeInfo);
assert codeInfo.getTotalFrameSize() == compilation.getTotalFrameSize();
assert lookupTotalFrameSize(totalIP) == codeInfo.getTotalFrameSize();
assert lookupExceptionOffset(totalIP) == codeInfo.getExceptionOffset();
assert lookupReferenceMapIndex(totalIP) == codeInfo.getReferenceMapIndex();
assert getReferenceMapEncoding() == codeInfo.getReferenceMapEncoding();
}
for (Infopoint infopoint : compilation.getInfopoints()) {
if (infopoint.debugInfo != null) {
int offset = CodeInfoEncoder.getEntryOffset(infopoint);
if (offset >= 0) {
assert offset < compilation.getTargetCodeSize();
CodeInfoQueryResult codeInfo = new CodeInfoQueryResult();
lookupCodeInfo(offset + compilationOffset, codeInfo);
CollectingObjectReferenceVisitor visitor = new CollectingObjectReferenceVisitor();
ReferenceMapDecoder.walkOffsetsFromPointer(WordFactory.zero(), codeInfo.getReferenceMapEncoding(), codeInfo.getReferenceMapIndex(), visitor);
ReferenceMapEncoder.Input expected = (ReferenceMapEncoder.Input) infopoint.debugInfo.getReferenceMap();
assert expected.equals(visitor.result);
if (codeInfo.frameInfo != CodeInfoQueryResult.NO_FRAME_INFO) {
verifyFrame(compilation, infopoint.debugInfo.frame(), codeInfo.frameInfo, new BitSet());
}
}
}
}
for (ExceptionHandler handler : compilation.getExceptionHandlers()) {
int offset = handler.pcOffset;
assert offset >= 0 && offset < compilation.getTargetCodeSize();
long actual = lookupExceptionOffset(offset + compilationOffset);
long expected = handler.handlerPos - handler.pcOffset;
assert expected != 0;
assert expected == actual;
}
}
use of jdk.vm.ci.code.site.ExceptionHandler in project graal by oracle.
the class CompilationResult method recordExceptionHandler.
/**
* Records an exception handler for this method.
*
* @param codePos the position in the code that is covered by the handler
* @param handlerPos the position of the handler
*/
public void recordExceptionHandler(int codePos, int handlerPos) {
checkOpen();
assert validateExceptionHandlerAdd(codePos, handlerPos) : String.format("Duplicate exception handler for pc 0x%x handlerPos 0x%x", codePos, handlerPos);
exceptionHandlers.add(new ExceptionHandler(codePos, handlerPos));
}
Aggregations