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 jdk.vm.ci.hotspot;
24
25 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
26 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
27 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
28 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
29
30 import java.lang.annotation.Annotation;
31 import java.lang.reflect.Executable;
32 import java.lang.reflect.InvocationTargetException;
33 import java.lang.reflect.Method;
34 import java.lang.reflect.Modifier;
35 import java.lang.reflect.Type;
36 import java.util.HashMap;
37 import java.util.Map;
38
39 import jdk.vm.ci.common.JVMCIError;
40 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option;
41 import jdk.vm.ci.meta.Constant;
42 import jdk.vm.ci.meta.ConstantPool;
43 import jdk.vm.ci.meta.DefaultProfilingInfo;
44 import jdk.vm.ci.meta.ExceptionHandler;
45 import jdk.vm.ci.meta.JavaConstant;
46 import jdk.vm.ci.meta.JavaMethod;
47 import jdk.vm.ci.meta.JavaType;
48 import jdk.vm.ci.meta.LineNumberTable;
49 import jdk.vm.ci.meta.LineNumberTableImpl;
50 import jdk.vm.ci.meta.Local;
51 import jdk.vm.ci.meta.LocalImpl;
52 import jdk.vm.ci.meta.LocalVariableTable;
53 import jdk.vm.ci.meta.LocalVariableTableImpl;
54 import jdk.vm.ci.meta.ModifiersProvider;
55 import jdk.vm.ci.meta.ProfilingInfo;
56 import jdk.vm.ci.meta.ResolvedJavaMethod;
57 import jdk.vm.ci.meta.ResolvedJavaType;
58 import jdk.vm.ci.meta.Signature;
59 import jdk.vm.ci.meta.SpeculationLog;
597 String localType = getConstantPool().lookupUtf8(typeCpIndex);
598
599 locals[i] = new LocalImpl(localName, runtime().lookupType(localType, holder, false), startBci, endBci, slot);
600
601 // Go to the next LocalVariableTableElement
602 localVariableTableElement += config.localVariableTableElementSize;
603 }
604
605 return new LocalVariableTableImpl(locals);
606 }
607
608 /**
609 * Returns the offset of this method into the v-table. The method must have a v-table entry as
610 * indicated by {@link #isInVirtualMethodTable(ResolvedJavaType)}, otherwise an exception is
611 * thrown.
612 *
613 * @return the offset of this method into the v-table
614 */
615 public int vtableEntryOffset(ResolvedJavaType resolved) {
616 if (!isInVirtualMethodTable(resolved)) {
617 throw new JVMCIError("%s does not have a vtable entry in type %s", this, resolved);
618 }
619 HotSpotVMConfig config = config();
620 final int vtableIndex = getVtableIndex((HotSpotResolvedObjectTypeImpl) resolved);
621 return config.klassVtableStartOffset + vtableIndex * config.vtableEntrySize + config.vtableEntryMethodOffset;
622 }
623
624 @Override
625 public boolean isInVirtualMethodTable(ResolvedJavaType resolved) {
626 if (resolved instanceof HotSpotResolvedObjectTypeImpl) {
627 HotSpotResolvedObjectTypeImpl hotspotResolved = (HotSpotResolvedObjectTypeImpl) resolved;
628 int vtableIndex = getVtableIndex(hotspotResolved);
629 return vtableIndex >= 0 && vtableIndex < hotspotResolved.getVtableLength();
630 }
631 return false;
632 }
633
634 private int getVtableIndex(HotSpotResolvedObjectTypeImpl resolved) {
635 if (!holder.isLinked()) {
636 return config().invalidVtableIndex;
637 }
|
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 jdk.vm.ci.hotspot;
24
25 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
26 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
27 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
28 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
29
30 import java.lang.annotation.Annotation;
31 import java.lang.reflect.Executable;
32 import java.lang.reflect.InvocationTargetException;
33 import java.lang.reflect.Method;
34 import java.lang.reflect.Modifier;
35 import java.lang.reflect.Type;
36 import java.util.HashMap;
37 import java.util.Map;
38
39 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option;
40 import jdk.vm.ci.meta.Constant;
41 import jdk.vm.ci.meta.ConstantPool;
42 import jdk.vm.ci.meta.DefaultProfilingInfo;
43 import jdk.vm.ci.meta.ExceptionHandler;
44 import jdk.vm.ci.meta.JavaConstant;
45 import jdk.vm.ci.meta.JavaMethod;
46 import jdk.vm.ci.meta.JavaType;
47 import jdk.vm.ci.meta.LineNumberTable;
48 import jdk.vm.ci.meta.LineNumberTableImpl;
49 import jdk.vm.ci.meta.Local;
50 import jdk.vm.ci.meta.LocalImpl;
51 import jdk.vm.ci.meta.LocalVariableTable;
52 import jdk.vm.ci.meta.LocalVariableTableImpl;
53 import jdk.vm.ci.meta.ModifiersProvider;
54 import jdk.vm.ci.meta.ProfilingInfo;
55 import jdk.vm.ci.meta.ResolvedJavaMethod;
56 import jdk.vm.ci.meta.ResolvedJavaType;
57 import jdk.vm.ci.meta.Signature;
58 import jdk.vm.ci.meta.SpeculationLog;
596 String localType = getConstantPool().lookupUtf8(typeCpIndex);
597
598 locals[i] = new LocalImpl(localName, runtime().lookupType(localType, holder, false), startBci, endBci, slot);
599
600 // Go to the next LocalVariableTableElement
601 localVariableTableElement += config.localVariableTableElementSize;
602 }
603
604 return new LocalVariableTableImpl(locals);
605 }
606
607 /**
608 * Returns the offset of this method into the v-table. The method must have a v-table entry as
609 * indicated by {@link #isInVirtualMethodTable(ResolvedJavaType)}, otherwise an exception is
610 * thrown.
611 *
612 * @return the offset of this method into the v-table
613 */
614 public int vtableEntryOffset(ResolvedJavaType resolved) {
615 if (!isInVirtualMethodTable(resolved)) {
616 throw new InternalError(String.format("%s does not have a vtable entry in type %s", this, resolved));
617 }
618 HotSpotVMConfig config = config();
619 final int vtableIndex = getVtableIndex((HotSpotResolvedObjectTypeImpl) resolved);
620 return config.klassVtableStartOffset + vtableIndex * config.vtableEntrySize + config.vtableEntryMethodOffset;
621 }
622
623 @Override
624 public boolean isInVirtualMethodTable(ResolvedJavaType resolved) {
625 if (resolved instanceof HotSpotResolvedObjectTypeImpl) {
626 HotSpotResolvedObjectTypeImpl hotspotResolved = (HotSpotResolvedObjectTypeImpl) resolved;
627 int vtableIndex = getVtableIndex(hotspotResolved);
628 return vtableIndex >= 0 && vtableIndex < hotspotResolved.getVtableLength();
629 }
630 return false;
631 }
632
633 private int getVtableIndex(HotSpotResolvedObjectTypeImpl resolved) {
634 if (!holder.isLinked()) {
635 return config().invalidVtableIndex;
636 }
|