src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/java/DynamicNewInstanceNode.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/java

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/java/DynamicNewInstanceNode.java

Print this page




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.nodes.java;
  24 
  25 import java.lang.reflect.Modifier;
  26 

  27 import org.graalvm.compiler.core.common.type.StampFactory;
  28 import org.graalvm.compiler.graph.Node;
  29 import org.graalvm.compiler.graph.NodeClass;
  30 import org.graalvm.compiler.graph.spi.Canonicalizable;
  31 import org.graalvm.compiler.graph.spi.CanonicalizerTool;
  32 import org.graalvm.compiler.nodeinfo.NodeInfo;
  33 import org.graalvm.compiler.nodes.FrameState;
  34 import org.graalvm.compiler.nodes.ValueNode;
  35 
  36 import jdk.vm.ci.meta.MetaAccessProvider;
  37 import jdk.vm.ci.meta.ResolvedJavaType;
  38 
  39 @NodeInfo
  40 public class DynamicNewInstanceNode extends AbstractNewObjectNode implements Canonicalizable {
  41     public static final NodeClass<DynamicNewInstanceNode> TYPE = NodeClass.create(DynamicNewInstanceNode.class);
  42 
  43     @Input ValueNode clazz;
  44 
  45     /**
  46      * Class pointer to class.class needs to be exposed earlier than this node is lowered so that it
  47      * can be replaced by the AOT machinery. If it's not needed for lowering this input can be
  48      * ignored.
  49      */
  50     @OptionalInput ValueNode classClass;
  51 
  52     public DynamicNewInstanceNode(ValueNode clazz, boolean fillContents) {
  53         this(TYPE, clazz, fillContents, null);
  54     }
  55 
  56     protected DynamicNewInstanceNode(NodeClass<? extends DynamicNewInstanceNode> c, ValueNode clazz, boolean fillContents, FrameState stateBefore) {
  57         super(c, StampFactory.objectNonNull(), fillContents, stateBefore);
  58         this.clazz = clazz;

  59     }
  60 
  61     public ValueNode getInstanceType() {
  62         return clazz;
  63     }
  64 
  65     @Override
  66     public Node canonical(CanonicalizerTool tool) {
  67         if (clazz.isConstant()) {
  68             ResolvedJavaType type = tool.getConstantReflection().asJavaType(clazz.asConstant());
  69             if (type != null && type.isInitialized() && !throwsInstantiationException(type, tool.getMetaAccess())) {
  70                 return createNewInstanceNode(type);
  71             }
  72         }
  73         return this;
  74     }
  75 
  76     /** Hook for subclasses to instantiate a subclass of {@link NewInstanceNode}. */
  77     protected NewInstanceNode createNewInstanceNode(ResolvedJavaType type) {
  78         return new NewInstanceNode(type, fillContents(), stateBefore());


   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.nodes.java;
  24 
  25 import java.lang.reflect.Modifier;
  26 
  27 import org.graalvm.compiler.core.common.type.ObjectStamp;
  28 import org.graalvm.compiler.core.common.type.StampFactory;
  29 import org.graalvm.compiler.graph.Node;
  30 import org.graalvm.compiler.graph.NodeClass;
  31 import org.graalvm.compiler.graph.spi.Canonicalizable;
  32 import org.graalvm.compiler.graph.spi.CanonicalizerTool;
  33 import org.graalvm.compiler.nodeinfo.NodeInfo;
  34 import org.graalvm.compiler.nodes.FrameState;
  35 import org.graalvm.compiler.nodes.ValueNode;
  36 
  37 import jdk.vm.ci.meta.MetaAccessProvider;
  38 import jdk.vm.ci.meta.ResolvedJavaType;
  39 
  40 @NodeInfo
  41 public class DynamicNewInstanceNode extends AbstractNewObjectNode implements Canonicalizable {
  42     public static final NodeClass<DynamicNewInstanceNode> TYPE = NodeClass.create(DynamicNewInstanceNode.class);
  43 
  44     @Input ValueNode clazz;
  45 
  46     /**
  47      * Class pointer to class.class needs to be exposed earlier than this node is lowered so that it
  48      * can be replaced by the AOT machinery. If it's not needed for lowering this input can be
  49      * ignored.
  50      */
  51     @OptionalInput ValueNode classClass;
  52 
  53     public DynamicNewInstanceNode(ValueNode clazz, boolean fillContents) {
  54         this(TYPE, clazz, fillContents, null);
  55     }
  56 
  57     protected DynamicNewInstanceNode(NodeClass<? extends DynamicNewInstanceNode> c, ValueNode clazz, boolean fillContents, FrameState stateBefore) {
  58         super(c, StampFactory.objectNonNull(), fillContents, stateBefore);
  59         this.clazz = clazz;
  60         assert ((ObjectStamp) clazz.stamp()).nonNull();
  61     }
  62 
  63     public ValueNode getInstanceType() {
  64         return clazz;
  65     }
  66 
  67     @Override
  68     public Node canonical(CanonicalizerTool tool) {
  69         if (clazz.isConstant()) {
  70             ResolvedJavaType type = tool.getConstantReflection().asJavaType(clazz.asConstant());
  71             if (type != null && type.isInitialized() && !throwsInstantiationException(type, tool.getMetaAccess())) {
  72                 return createNewInstanceNode(type);
  73             }
  74         }
  75         return this;
  76     }
  77 
  78     /** Hook for subclasses to instantiate a subclass of {@link NewInstanceNode}. */
  79     protected NewInstanceNode createNewInstanceNode(ResolvedJavaType type) {
  80         return new NewInstanceNode(type, fillContents(), stateBefore());
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/java/DynamicNewInstanceNode.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File