# HG changeset patch # User Roland Schatz # Date 1394098800 -3600 # Node ID af84c0b2e74f5970fca9ebe203f91c0f06d5f466 # Parent 40fac3ef157d3c74e98c48182014f2cae3522a71 Don't remove UnboxNode if the incoming type is wrong. diff -r 40fac3ef157d -r af84c0b2e74f graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java Wed Mar 05 21:13:51 2014 -0800 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java Thu Mar 06 10:40:00 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,7 +58,11 @@ public void virtualize(VirtualizerTool tool) { State state = tool.getObjectState(value); if (state != null && state.getState() == EscapeState.Virtual) { - tool.replaceWithValue(state.getEntry(0)); + ResolvedJavaType objectType = state.getVirtualObject().type(); + ResolvedJavaType expectedType = tool.getMetaAccessProvider().lookupJavaType(boxingKind.toBoxedJavaClass()); + if (objectType == expectedType) { + tool.replaceWithValue(state.getEntry(0)); + } } } @@ -90,7 +94,10 @@ } } } else if (value instanceof BoxNode) { - return ((BoxNode) value).getValue(); + BoxNode box = (BoxNode) value; + if (boxingKind == box.getBoxingKind()) { + return box.getValue(); + } } if (usages().isEmpty()) { return null;