changeset 5885:d172b68e7762

allow array length canonicalization on InitializeArrayNode
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 17 Aug 2012 14:12:39 +0200
parents 347fad1ea1d0
children 62f215a79657
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeArrayNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewArrayNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/ArrayLengthProvider.java
diffstat 4 files changed, 36 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeArrayNode.java	Fri Aug 17 14:12:00 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeArrayNode.java	Fri Aug 17 14:12:39 2012 +0200
@@ -33,7 +33,7 @@
  * if the memory address it is given is zero/null (e.g. due to
  * {@linkplain TLABAllocateNode TLAB allocation} failing).
  */
-public final class InitializeArrayNode extends FixedWithNextNode implements Lowerable {
+public final class InitializeArrayNode extends FixedWithNextNode implements Lowerable, ArrayLengthProvider {
 
     @Input private final ValueNode memory;
     @Input private final ValueNode length;
@@ -52,6 +52,7 @@
         return memory;
     }
 
+    @Override
     public ValueNode length() {
         return length;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java	Fri Aug 17 14:12:00 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java	Fri Aug 17 14:12:39 2012 +0200
@@ -45,8 +45,8 @@
 
     @Override
     public ValueNode canonical(CanonicalizerTool tool) {
-        if (array() instanceof NewArrayNode) {
-            ValueNode length = ((NewArrayNode) array()).dimension(0);
+        if (array() instanceof ArrayLengthProvider) {
+            ValueNode length = ((ArrayLengthProvider) array()).length();
             assert length != null;
             return length;
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewArrayNode.java	Fri Aug 17 14:12:00 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewArrayNode.java	Fri Aug 17 14:12:39 2012 +0200
@@ -36,13 +36,14 @@
 /**
  * The {@code NewArrayNode} class is the base of all instructions that allocate arrays.
  */
-public abstract class NewArrayNode extends FixedWithNextNode implements Lowerable, EscapeAnalyzable, TypeFeedbackProvider {
+public abstract class NewArrayNode extends FixedWithNextNode implements Lowerable, EscapeAnalyzable, TypeFeedbackProvider, ArrayLengthProvider {
 
     @Input private ValueNode length;
     private final ResolvedJavaType elementType;
 
     public static final int MaximumEscapeAnalysisArrayLength = 32;
 
+    @Override
     public ValueNode length() {
         return length;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/ArrayLengthProvider.java	Fri Aug 17 14:12:39 2012 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2012, 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.nodes.spi;
+
+import com.oracle.graal.nodes.*;
+
+public interface ArrayLengthProvider {
+
+    ValueNode length();
+}