# HG changeset patch # User Thomas Wuerthinger # Date 1367093034 -7200 # Node ID 0f4041cc6be16b9f3f2557b60c0b434b25efb7c6 # Parent ee75b4f569ed905b287c658eea6106771a71fcbf First draft of node for loading a method from the vtable of a hub. diff -r ee75b4f569ed -r 0f4041cc6be1 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Sat Apr 27 21:41:44 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Sat Apr 27 22:03:54 2013 +0200 @@ -674,6 +674,18 @@ ReadNode hub = graph.add(new ReadNode(object, location, StampFactory.forKind(wordKind()))); tool.createNullCheckGuard(hub.dependencies(), object); graph.replaceFixed(loadHub, hub); + } else if (n instanceof LoadMethodNode) { + LoadMethodNode loadMethodNode = (LoadMethodNode) n; + HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) loadMethodNode.getMethod(); + assert !hsMethod.getDeclaringClass().isInterface(); + + int vtableEntryOffset = hsMethod.vtableEntryOffset(); + assert vtableEntryOffset > 0; + // We use LocationNode.ANY_LOCATION for the reads that access the vtable + // entry as HotSpot does not guarantee that this is a final value. + ReadNode metaspaceMethod = graph.add(new ReadNode(loadMethodNode.getHub(), ConstantLocationNode.create(LocationNode.ANY_LOCATION, wordKind, vtableEntryOffset, graph), + StampFactory.forKind(wordKind()))); + graph.replaceFixed(loadMethodNode, metaspaceMethod); } else if (n instanceof FixedGuardNode) { FixedGuardNode node = (FixedGuardNode) n; ValueAnchorNode newAnchor = graph.add(new ValueAnchorNode(tool.createGuard(node.condition(), node.getReason(), node.getAction(), node.isNegated()))); diff -r ee75b4f569ed -r 0f4041cc6be1 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadMethodNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadMethodNode.java Sat Apr 27 22:03:54 2013 +0200 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013, 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.extended; + +import java.lang.reflect.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +/** + * Loads a method from the virtual method table of a given hub. + */ +public final class LoadMethodNode extends FixedWithNextNode implements Lowerable { + + @Input private ValueNode hub; + private final ResolvedJavaMethod method; + + public ValueNode getHub() { + return hub; + } + + public LoadMethodNode(ResolvedJavaMethod method, ValueNode hub, Kind kind) { + super(kind == Kind.Object ? StampFactory.objectNonNull() : StampFactory.forKind(kind)); + this.hub = hub; + this.method = method; + assert !Modifier.isAbstract(method.getModifiers()) : "Cannot load abstract method from a hub"; + assert !Modifier.isStatic(method.getModifiers()) : "Cannot load a static method from a hub"; + } + + @Override + public void lower(LoweringTool tool, LoweringType loweringType) { + tool.getRuntime().lower(this, tool); + } + + public ResolvedJavaMethod getMethod() { + return method; + } +}