comparison graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java @ 17328:c9bb0da795d4

Backed out of changeset 17322:655f3e6b467b
author Doug Simon <doug.simon@oracle.com>
date Fri, 03 Oct 2014 14:19:58 +0200
parents 655f3e6b467b
children a94e85e5256b
comparison
equal deleted inserted replaced
17327:655f3e6b467b 17328:c9bb0da795d4
164 } 164 }
165 165
166 private static String methodName(FrameState frameState, int bci) { 166 private static String methodName(FrameState frameState, int bci) {
167 StringBuilder sb = new StringBuilder(); 167 StringBuilder sb = new StringBuilder();
168 if (frameState.outerFrameState() != null) { 168 if (frameState.outerFrameState() != null) {
169 sb.append(methodName(frameState.outerFrameState(), frameState.outerFrameState().bci())); 169 sb.append(methodName(frameState.outerFrameState(), frameState.outerFrameState().bci));
170 sb.append("->"); 170 sb.append("->");
171 } 171 }
172 sb.append(frameState.method().format("%h.%n")); 172 sb.append(frameState.method().format("%h.%n"));
173 sb.append("@").append(bci); 173 sb.append("@").append(bci);
174 return sb.toString(); 174 return sb.toString();
368 368
369 private static BytecodePosition toBytecodePosition(FrameState fs) { 369 private static BytecodePosition toBytecodePosition(FrameState fs) {
370 if (fs == null) { 370 if (fs == null) {
371 return null; 371 return null;
372 } 372 }
373 return new BytecodePosition(toBytecodePosition(fs.outerFrameState()), fs.method(), fs.bci()); 373 return new BytecodePosition(toBytecodePosition(fs.outerFrameState()), fs.method(), fs.bci);
374 } 374 }
375 375
376 protected static void processFrameStates(Invoke invoke, StructuredGraph inlineGraph, Map<Node, Node> duplicates, FrameState stateAtExceptionEdge, boolean alwaysDuplicateStateAfter) { 376 protected static void processFrameStates(Invoke invoke, StructuredGraph inlineGraph, Map<Node, Node> duplicates, FrameState stateAtExceptionEdge, boolean alwaysDuplicateStateAfter) {
377 FrameState stateAtReturn = invoke.stateAfter(); 377 FrameState stateAtReturn = invoke.stateAfter();
378 FrameState outerFrameState = null; 378 FrameState outerFrameState = null;
379 Kind invokeReturnKind = invoke.asNode().getKind(); 379 Kind invokeReturnKind = invoke.asNode().getKind();
380 for (FrameState original : inlineGraph.getNodes(FrameState.class)) { 380 for (FrameState original : inlineGraph.getNodes(FrameState.class)) {
381 FrameState frameState = (FrameState) duplicates.get(original); 381 FrameState frameState = (FrameState) duplicates.get(original);
382 if (frameState != null && frameState.isAlive()) { 382 if (frameState != null && frameState.isAlive()) {
383 if (frameState.bci() == BytecodeFrame.AFTER_BCI) { 383 if (frameState.bci == BytecodeFrame.AFTER_BCI) {
384 /* 384 /*
385 * pop return kind from invoke's stateAfter and replace with this frameState's 385 * pop return kind from invoke's stateAfter and replace with this frameState's
386 * return value (top of stack) 386 * return value (top of stack)
387 */ 387 */
388 FrameState stateAfterReturn = stateAtReturn; 388 FrameState stateAfterReturn = stateAtReturn;
398 FrameState stateAfterException = stateAtExceptionEdge; 398 FrameState stateAfterException = stateAtExceptionEdge;
399 if (frameState.stackSize() > 0 && stateAtExceptionEdge.stackAt(0) != frameState.stackAt(0)) { 399 if (frameState.stackSize() > 0 && stateAtExceptionEdge.stackAt(0) != frameState.stackAt(0)) {
400 stateAfterException = stateAtExceptionEdge.duplicateModified(Kind.Object, frameState.stackAt(0)); 400 stateAfterException = stateAtExceptionEdge.duplicateModified(Kind.Object, frameState.stackAt(0));
401 } 401 }
402 frameState.replaceAndDelete(stateAfterException); 402 frameState.replaceAndDelete(stateAfterException);
403 } else if (frameState.bci() == BytecodeFrame.UNWIND_BCI || frameState.bci() == BytecodeFrame.AFTER_EXCEPTION_BCI) { 403 } else if (frameState.bci == BytecodeFrame.UNWIND_BCI || frameState.bci == BytecodeFrame.AFTER_EXCEPTION_BCI) {
404 handleMissingAfterExceptionFrameState(frameState); 404 handleMissingAfterExceptionFrameState(frameState);
405 } else { 405 } else {
406 // only handle the outermost frame states 406 // only handle the outermost frame states
407 if (frameState.outerFrameState() == null) { 407 if (frameState.outerFrameState() == null) {
408 assert frameState.bci() != BytecodeFrame.BEFORE_BCI : frameState; 408 assert frameState.bci != BytecodeFrame.BEFORE_BCI : frameState;
409 assert frameState.bci() == BytecodeFrame.INVALID_FRAMESTATE_BCI || frameState.method().equals(inlineGraph.method()); 409 assert frameState.bci == BytecodeFrame.INVALID_FRAMESTATE_BCI || frameState.method().equals(inlineGraph.method());
410 assert frameState.bci() != BytecodeFrame.AFTER_EXCEPTION_BCI && frameState.bci() != BytecodeFrame.BEFORE_BCI && frameState.bci() != BytecodeFrame.AFTER_EXCEPTION_BCI && 410 assert frameState.bci != BytecodeFrame.AFTER_EXCEPTION_BCI && frameState.bci != BytecodeFrame.BEFORE_BCI && frameState.bci != BytecodeFrame.AFTER_EXCEPTION_BCI &&
411 frameState.bci() != BytecodeFrame.UNWIND_BCI : frameState.bci(); 411 frameState.bci != BytecodeFrame.UNWIND_BCI : frameState.bci;
412 if (outerFrameState == null) { 412 if (outerFrameState == null) {
413 outerFrameState = stateAtReturn.duplicateModified(invoke.bci(), stateAtReturn.rethrowException(), invokeReturnKind); 413 outerFrameState = stateAtReturn.duplicateModified(invoke.bci(), stateAtReturn.rethrowException(), invokeReturnKind);
414 outerFrameState.setDuringCall(true); 414 outerFrameState.setDuringCall(true);
415 } 415 }
416 frameState.setOuterFrameState(outerFrameState); 416 frameState.setOuterFrameState(outerFrameState);
419 } 419 }
420 } 420 }
421 } 421 }
422 422
423 private static boolean isStateAfterException(FrameState frameState) { 423 private static boolean isStateAfterException(FrameState frameState) {
424 return frameState.bci() == BytecodeFrame.AFTER_EXCEPTION_BCI || (frameState.bci() == BytecodeFrame.UNWIND_BCI && !frameState.method().isSynchronized()); 424 return frameState.bci == BytecodeFrame.AFTER_EXCEPTION_BCI || (frameState.bci == BytecodeFrame.UNWIND_BCI && !frameState.method().isSynchronized());
425 } 425 }
426 426
427 protected static void handleMissingAfterExceptionFrameState(FrameState nonReplaceableFrameState) { 427 protected static void handleMissingAfterExceptionFrameState(FrameState nonReplaceableFrameState) {
428 Graph graph = nonReplaceableFrameState.graph(); 428 Graph graph = nonReplaceableFrameState.graph();
429 NodeWorkList workList = graph.createNodeWorkList(); 429 NodeWorkList workList = graph.createNodeWorkList();
485 485
486 private static boolean checkContainsOnlyInvalidOrAfterFrameState(Map<Node, Node> duplicates) { 486 private static boolean checkContainsOnlyInvalidOrAfterFrameState(Map<Node, Node> duplicates) {
487 for (Node node : duplicates.values()) { 487 for (Node node : duplicates.values()) {
488 if (node instanceof FrameState) { 488 if (node instanceof FrameState) {
489 FrameState frameState = (FrameState) node; 489 FrameState frameState = (FrameState) node;
490 assert frameState.bci() == BytecodeFrame.AFTER_BCI || frameState.bci() == BytecodeFrame.INVALID_FRAMESTATE_BCI : node.toString(Verbosity.Debugger); 490 assert frameState.bci == BytecodeFrame.AFTER_BCI || frameState.bci == BytecodeFrame.INVALID_FRAMESTATE_BCI : node.toString(Verbosity.Debugger);
491 } 491 }
492 } 492 }
493 return true; 493 return true;
494 } 494 }
495 495