changeset 21262:3aea74e5ada2

Merge
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Wed, 06 May 2015 12:14:30 -0700
parents 8bae587f0efe (diff) 0927730ed87f (current diff)
children 4154f4842bf0 5e09292fb017
files
diffstat 6 files changed, 166 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Wed May 06 17:14:04 2015 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Wed May 06 12:14:30 2015 -0700
@@ -436,8 +436,8 @@
 
     protected static class Result {
 
-        final Object returnValue;
-        final Throwable exception;
+        public final Object returnValue;
+        public final Throwable exception;
 
         public Result(Object returnValue, Throwable exception) {
             this.returnValue = returnValue;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TestCopyOfVirtualization.java	Wed May 06 12:14:30 2015 -0700
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2015, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.graal.compiler.test;
+
+import java.util.*;
+
+import org.junit.*;
+
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
+
+public class TestCopyOfVirtualization extends GraalCompilerTest {
+
+    @Override
+    protected boolean checkMidTierGraph(StructuredGraph graph) {
+        assertTrue(graph.getNodes().filter(node -> node instanceof NewArrayNode).count() == 0, "shouldn't require allocation in %s", graph);
+        return super.checkMidTierGraph(graph);
+    }
+
+    public byte byteCopyOfVirtualization(int index) {
+        byte[] array = new byte[]{1, 2, 3, 4};
+        return Arrays.copyOf(array, array.length)[index];
+    }
+
+    public short shortCopyOfVirtualization(int index) {
+        short[] array = new short[]{1, 2, 3, 4};
+        return Arrays.copyOf(array, array.length)[index];
+    }
+
+    public char charCopyOfVirtualization(int index) {
+        char[] array = new char[]{1, 2, 3, 4};
+        return Arrays.copyOf(array, array.length)[index];
+    }
+
+    public int intCopyOfVirtualization(int index) {
+        int[] array = new int[]{1, 2, 3, 4};
+        return Arrays.copyOf(array, array.length)[index];
+    }
+
+    public long longCopyOfVirtualization(int index) {
+        long[] array = new long[]{1, 2, 3, 4};
+        return Arrays.copyOf(array, array.length)[index];
+    }
+
+    public float floatCopyOfVirtualization(int index) {
+        float[] array = new float[]{1, 2, 3, 4};
+        return Arrays.copyOf(array, array.length)[index];
+    }
+
+    public double doubleCopyOfVirtualization(int index) {
+        double[] array = new double[]{1, 2, 3, 4};
+        return Arrays.copyOf(array, array.length)[index];
+    }
+
+    public Object objectCopyOfVirtualization(int index) {
+        Object[] array = new Object[]{1, 2, 3, 4};
+        return Arrays.copyOf(array, array.length)[index];
+    }
+
+    // @Test
+    public void testCopyOfVirtualization() {
+        test("byteCopyOfVirtualization", 3);
+        test("shortCopyOfVirtualization", 3);
+        test("charCopyOfVirtualization", 3);
+        test("intCopyOfVirtualization", 3);
+        test("longCopyOfVirtualization", 3);
+        test("floatCopyOfVirtualization", 3);
+        test("doubleCopyOfVirtualization", 3);
+        test("objectCopyOfVirtualization", 3);
+    }
+
+    static final byte[] byteArray = new byte[]{1, 2, 3, 4};
+
+    public byte byteCopyOfVirtualizableAllocation() {
+        return Arrays.copyOf(byteArray, byteArray.length)[3];
+    }
+
+    static final short[] shortArray = new short[]{1, 2, 3, 4};
+
+    public short shortCopyOfVirtualizableAllocation() {
+        return Arrays.copyOf(shortArray, shortArray.length)[3];
+    }
+
+    static final char[] charArray = new char[]{1, 2, 3, 4};
+
+    public char charCopyOfVirtualizableAllocation() {
+        return Arrays.copyOf(charArray, charArray.length)[3];
+    }
+
+    static final int[] intArray = new int[]{1, 2, 3, 4};
+
+    public int intCopyOfVirtualizableAllocation() {
+        return Arrays.copyOf(intArray, intArray.length)[3];
+    }
+
+    static final long[] longArray = new long[]{1, 2, 3, 4};
+
+    public long longCopyOfVirtualizableAllocation() {
+        return Arrays.copyOf(longArray, longArray.length)[3];
+    }
+
+    static final float[] floatArray = new float[]{1, 2, 3, 4};
+
+    public float floatCopyOfVirtualizableAllocation() {
+        return Arrays.copyOf(floatArray, floatArray.length)[3];
+    }
+
+    static final double[] doubleArray = new double[]{1, 2, 3, 4};
+
+    public double doubleCopyOfVirtualizableAllocation() {
+        return Arrays.copyOf(doubleArray, doubleArray.length)[3];
+    }
+
+    static final Object[] objectArray = new Object[]{1, 2, 3, 4};
+
+    public Object objectCopyOfVirtualizableAllocation() {
+        return Arrays.copyOf(objectArray, objectArray.length)[3];
+    }
+
+    @Test
+    public void testCopyOfVirtualizableAllocation() {
+        test("byteCopyOfVirtualizableAllocation");
+        test("shortCopyOfVirtualizableAllocation");
+        test("charCopyOfVirtualizableAllocation");
+        test("intCopyOfVirtualizableAllocation");
+        test("longCopyOfVirtualizableAllocation");
+        test("floatCopyOfVirtualizableAllocation");
+        test("doubleCopyOfVirtualizableAllocation");
+        test("objectCopyOfVirtualizableAllocation");
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassGetHubNode.java	Wed May 06 17:14:04 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassGetHubNode.java	Wed May 06 12:14:30 2015 -0700
@@ -75,7 +75,7 @@
             }
             if (clazz instanceof GetClassNode) {
                 GetClassNode getClass = (GetClassNode) clazz;
-                return new LoadHubNode(KlassPointerStamp.klass(), getClass.getObject(), null);
+                return new LoadHubNode(KlassPointerStamp.klassNonNull(), getClass.getObject(), null);
             }
             if (clazz instanceof HubGetClassNode) {
                 // replace _klass._java_mirror._klass -> _klass
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java	Wed May 06 17:14:04 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java	Wed May 06 12:14:30 2015 -0700
@@ -38,6 +38,7 @@
 import com.oracle.graal.debug.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.framemap.*;
+import com.oracle.graal.options.*;
 
 /**
  * Fills in a {@link CompilationResult} as its code is being assembled.
@@ -46,6 +47,11 @@
  */
 public class CompilationResultBuilder {
 
+    // @formatter:off
+    @Option(help = "Include the LIR as comments with the final assembly.", type = OptionType.Debug)
+    public static final OptionValue<Boolean> PrintLIRWithAssembly = new OptionValue<>(false);
+    // @formatter:on
+
     private static class ExceptionInfo {
 
         public final int codeOffset;
@@ -353,12 +359,12 @@
     }
 
     private void emitBlock(AbstractBlockBase<?> block) {
-        if (Debug.isDumpEnabled()) {
+        if (Debug.isDumpEnabled() || PrintLIRWithAssembly.getValue()) {
             blockComment(String.format("block B%d %s", block.getId(), block.getLoop()));
         }
 
         for (LIRInstruction op : lir.getLIRforBlock(block)) {
-            if (Debug.isDumpEnabled()) {
+            if (Debug.isDumpEnabled() || PrintLIRWithAssembly.getValue()) {
                 blockComment(String.format("%d %s", op.id(), op));
             }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java	Wed May 06 17:14:04 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java	Wed May 06 12:14:30 2015 -0700
@@ -65,7 +65,7 @@
 
     @Override
     public void lower(LoweringTool tool) {
-        if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) {
+        if (tool.getLoweringStage() != LoweringTool.StandardLoweringStage.LOW_TIER) {
             return;
         }
         tool.getLowerer().lower(this, tool);
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/PEGraphDecoder.java	Wed May 06 17:14:04 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/PEGraphDecoder.java	Wed May 06 12:14:30 2015 -0700
@@ -484,7 +484,8 @@
             registerNode(loopScope, invokeData.exceptionOrderId, exceptionValue, true, true);
         }
         if (inlineScope.exceptionPlaceholderNode != null) {
-            inlineScope.exceptionPlaceholderNode.replaceAndDelete(exceptionValue);
+            inlineScope.exceptionPlaceholderNode.replaceAtUsages(exceptionValue);
+            inlineScope.exceptionPlaceholderNode.safeDelete();
         }
         deleteInvoke(invoke);