# HG changeset patch # User Josef Eisl # Date 1396280847 -7200 # Node ID b4d069921b5fb15b772a000d4ea27b0734073eed # Parent be4c28683c08424ddebb3216010d8fa6324ad0b9 BytecodeParseHelper clean up. diff -r be4c28683c08 -r b4d069921b5f graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParseHelper.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParseHelper.java Mon Mar 31 14:28:12 2014 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeParseHelper.java Mon Mar 31 17:47:27 2014 +0200 @@ -743,17 +743,6 @@ } } -// public static class ExceptionInfo { -// -// public final FixedWithNextNode exceptionEdge; -// public final T exception; -// -// public ExceptionInfo(FixedWithNextNode exceptionEdge, T exception) { -// this.exceptionEdge = exceptionEdge; -// this.exception = exception; -// } -// } - protected abstract void emitNullCheck(T receiver); protected static final ArrayIndexOutOfBoundsException cachedArrayIndexOutOfBoundsException = new ArrayIndexOutOfBoundsException(); @@ -835,29 +824,6 @@ protected abstract void genInvokeSpecial(JavaMethod target); -// -// protected MethodCallTargetNode createMethodCallTarget(InvokeKind invokeKind, ResolvedJavaMethod -// targetMethod, T[] args, JavaType returnType) { -// return new MethodCallTargetNode(invokeKind, targetMethod, args, returnType); -// } -// -// protected InvokeNode createInvoke(CallTargetNode callTarget, Kind resultType) { -// InvokeNode invoke = append(new InvokeNode(callTarget, bci())); -// frameState.pushReturn(resultType, invoke); -// return invoke; -// } -// -// protected InvokeWithExceptionNode createInvokeWithException(CallTargetNode callTarget, Kind -// resultType) { -// DispatchBeginNode exceptionEdge = handleException(null, bci()); -// InvokeWithExceptionNode invoke = append(new InvokeWithExceptionNode(callTarget, exceptionEdge, -// bci())); -// frameState.pushReturn(resultType, invoke); -// BciBlock nextBlock = currentBlock.getSuccessor(0); -// invoke.setStateAfter(frameState.create(nextBlock.startBci)); -// return invoke; -// } - protected abstract void genReturn(T x); protected abstract T genMonitorEnter(T x); @@ -1000,212 +966,10 @@ protected abstract void processBlock(BciBlock block); -// private void connectLoopEndToBegin() { -// for (LoopBeginNode begin : currentGraph.getNodes(LoopBeginNode.class)) { -// if (begin.loopEnds().isEmpty()) { -// // @formatter:off -// // Remove loop header without loop ends. -// // This can happen with degenerated loops like this one: -// // for (;;) { -// // try { -// // break; -// // } catch (UnresolvedException iioe) { -// // } -// // } -// // @formatter:on -// assert begin.forwardEndCount() == 1; -// currentGraph.reduceDegenerateLoopBegin(begin); -// } else { -// GraphUtil.normalizeLoopBegin(begin); -// } -// } -// } - -// private void createUnwind() { -// assert frameState.stackSize() == 1 : frameState; -// T exception = frameState.apop(); -// append(new FixedGuardNode(currentGraph.unique(new IsNullNode(exception)), NullCheckException, -// InvalidateReprofile, true)); -// synchronizedEpilogue(FrameState.AFTER_EXCEPTION_BCI, null); -// append(new UnwindNode(exception)); -// } -// -// private void synchronizedEpilogue(int bci, T returnValue) { -// if (Modifier.isSynchronized(method.getModifiers())) { -// MonitorExitNode monitorExit = genMonitorExit(methodSynchronizedObject, returnValue); -// if (returnValue != null) { -// frameState.push(returnValue.getKind(), returnValue); -// } -// monitorExit.setStateAfter(frameState.create(bci)); -// assert !frameState.rethrowException(); -// } -// } -// -// private void createExceptionDispatch(ExceptionDispatchBlock block) { -// assert frameState.stackSize() == 1 : frameState; -// if (block.handler.isCatchAll()) { -// assert block.getSuccessorCount() == 1; -// appendGoto(createTarget(block.getSuccessor(0), frameState)); -// return; -// } -// -// JavaType catchType = block.handler.getCatchType(); -// if (graphBuilderConfig.eagerResolving()) { -// catchType = lookupType(block.handler.catchTypeCPI(), INSTANCEOF); -// } -// boolean initialized = (catchType instanceof ResolvedJavaType); -// if (initialized && graphBuilderConfig.getSkippedExceptionTypes() != null) { -// ResolvedJavaType resolvedCatchType = (ResolvedJavaType) catchType; -// for (ResolvedJavaType skippedType : graphBuilderConfig.getSkippedExceptionTypes()) { -// if (skippedType.isAssignableFrom(resolvedCatchType)) { -// BciBlock nextBlock = block.getSuccessorCount() == 1 ? unwindBlock(block.deoptBci) : -// block.getSuccessor(1); -// T exception = frameState.stackAt(0); -// FixedNode trueSuccessor = currentGraph.add(new DeoptimizeNode(InvalidateReprofile, -// UnreachedCode)); -// FixedNode nextDispatch = createTarget(nextBlock, frameState); -// append(new IfNode(currentGraph.unique(new InstanceOfNode((ResolvedJavaType) catchType, exception, -// null)), trueSuccessor, nextDispatch, 0)); -// return; -// } -// } -// } -// -// if (initialized) { -// BciBlock nextBlock = block.getSuccessorCount() == 1 ? unwindBlock(block.deoptBci) : -// block.getSuccessor(1); -// T exception = frameState.stackAt(0); -// CheckCastNode checkCast = currentGraph.add(new CheckCastNode((ResolvedJavaType) catchType, -// exception, null, false)); -// frameState.apop(); -// frameState.push(Kind.Object, checkCast); -// FixedNode catchSuccessor = createTarget(block.getSuccessor(0), frameState); -// frameState.apop(); -// frameState.push(Kind.Object, exception); -// FixedNode nextDispatch = createTarget(nextBlock, frameState); -// checkCast.setNext(catchSuccessor); -// append(new IfNode(currentGraph.unique(new InstanceOfNode((ResolvedJavaType) catchType, exception, -// null)), checkCast, nextDispatch, 0.5)); -// } else { -// handleUnresolvedExceptionType(Representation.ObjectHub, catchType); -// } -// } - protected abstract void appendGoto(T target); protected abstract void iterateBytecodesForBlock(BciBlock block); -// private void iterateBytecodesForBlock(BciBlock block) { -// if (block.isLoopHeader) { -// // Create the loop header block, which later will merge the backward branches of the -// // loop. -// AbstractEndNode preLoopEnd = currentGraph.add(new EndNode()); -// LoopBeginNode loopBegin = currentGraph.add(new LoopBeginNode()); -// lastInstr.setNext(preLoopEnd); -// // Add the single non-loop predecessor of the loop header. -// loopBegin.addForwardEnd(preLoopEnd); -// lastInstr = loopBegin; -// -// // Create phi functions for all local variables and operand stack slots. -// frameState.insertLoopPhis(loopBegin); -// loopBegin.setStateAfter(frameState.create(block.startBci)); -// -// /* -// * We have seen all forward branches. All subsequent backward branches will merge to the -// * loop header. This ensures that the loop header has exactly one non-loop predecessor. -// */ -// block.firstInstruction = loopBegin; -// /* -// * We need to preserve the frame state builder of the loop header so that we can merge -// * values for phi functions, so make a copy of it. -// */ -// block.entryState = frameState.copy(); -// -// Debug.log(" created loop header %s", loopBegin); -// } -// assert lastInstr.next() == null : "instructions already appended at block " + block; -// Debug.log(" frameState: %s", frameState); -// -// int endBCI = stream.endBCI(); -// -// stream.setBCI(block.startBci); -// int bci = block.startBci; -// BytecodesParsed.add(block.endBci - bci); -// -// while (bci < endBCI) { -// if (graphBuilderConfig.eagerInfopointMode() && lnt != null) { -// currentLineNumber = lnt.getLineNumber(bci); -// if (currentLineNumber != previousLineNumber) { -// append(new InfopointNode(InfopointReason.LINE_NUMBER, frameState.create(bci))); -// previousLineNumber = currentLineNumber; -// } -// } -// -// // read the opcode -// int opcode = stream.currentBC(); -// traceState(); -// traceInstruction(bci, opcode, bci == block.startBci); -// if (bci == entryBCI) { -// if (block.jsrScope != JsrScope.EMPTY_SCOPE) { -// throw new BailoutException("OSR into a JSR scope is not supported"); -// } -// EntryMarkerNode x = append(new EntryMarkerNode()); -// frameState.insertProxies(x); -// x.setStateAfter(frameState.create(bci)); -// } -// parseHelper.processBytecode(bci, opcode); -// -// if (lastInstr == null || isBlockEnd(lastInstr) || lastInstr.next() != null) { -// break; -// } -// -// stream.next(); -// bci = stream.currentBCI(); -// -// if (bci > block.endBci) { -// frameState.clearNonLiveLocals(currentBlock, liveness, false); -// } -// if (lastInstr instanceof StateSplit) { -// if (lastInstr.getClass() == AbstractBeginNode.class) { -// // BeginNodes do not need a frame state -// } else { -// StateSplit stateSplit = (StateSplit) lastInstr; -// if (stateSplit.stateAfter() == null) { -// stateSplit.setStateAfter(frameState.create(bci)); -// } -// } -// } -// if (bci < endBCI) { -// if (bci > block.endBci) { -// assert !block.getSuccessor(0).isExceptionEntry; -// assert block.numNormalSuccessors() == 1; -// // we fell through to the next block, add a goto and break -// appendGoto(createTarget(block.getSuccessor(0), frameState)); -// break; -// } -// } -// } -// } - -// private final int traceLevel = Options.TraceBytecodeParserLevel.getValue(); -// -// private void traceState() { -// if (traceLevel >= TRACELEVEL_STATE && Debug.isLogEnabled()) { -// Debug.log(String.format("| state [nr locals = %d, stack depth = %d, method = %s]", -// frameState.localsSize(), frameState.stackSize(), method)); -// for (int i = 0; i < frameState.localsSize(); ++i) { -// T value = frameState.localAt(i); -// Debug.log(String.format("| local[%d] = %-8s : %s", i, value == null ? "bogus" : -// value.getKind().getJavaName(), value)); -// } -// for (int i = 0; i < frameState.stackSize(); ++i) { -// T value = frameState.stackAt(i); -// Debug.log(String.format("| stack[%d] = %-8s : %s", i, value == null ? "bogus" : -// value.getKind().getJavaName(), value)); -// } -// } -// } - public void processBytecode(int bci, int opcode) { int cpi; diff -r be4c28683c08 -r b4d069921b5f graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Mon Mar 31 14:28:12 2014 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Mon Mar 31 17:47:27 2014 +0200 @@ -1277,7 +1277,7 @@ protected void iterateBytecodesForBlock(BciBlock block) { if (block.isLoopHeader) { // Create the loop header block, which later will merge the backward branches of -// the + // the // loop. AbstractEndNode preLoopEnd = currentGraph.add(new EndNode()); LoopBeginNode loopBegin = currentGraph.add(new LoopBeginNode());