# HG changeset patch # User Lukas Stadler # Date 1345205559 -7200 # Node ID d172b68e77626e1e11ea5b33bd972c600fa9ab9e # Parent 347fad1ea1d0ee87c7f613996caadf5cb15cb2d1 allow array length canonicalization on InitializeArrayNode diff -r 347fad1ea1d0 -r d172b68e7762 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/InitializeArrayNode.java --- 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; } diff -r 347fad1ea1d0 -r d172b68e7762 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java --- 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; } diff -r 347fad1ea1d0 -r d172b68e7762 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewArrayNode.java --- 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; } diff -r 347fad1ea1d0 -r d172b68e7762 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/ArrayLengthProvider.java --- /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(); +}