1 /* 2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 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 com.oracle.graal.hotspot.meta; 24 25 import com.oracle.graal.api.meta.*; 26 import com.oracle.graal.bytecode.*; 27 import com.oracle.graal.hotspot.*; 28 29 /** 30 * Implementation of {@link ConstantPool} for HotSpot. 31 */ 32 public class HotSpotConstantPool extends CompilerObject implements ConstantPool { 33 34 private static final long serialVersionUID = -5443206401485234850L; 35 36 private final HotSpotResolvedObjectType type; 37 38 public HotSpotConstantPool(HotSpotResolvedObjectType type) { 39 this.type = type; 40 } 41 42 @Override 43 public int length() { 44 return HotSpotGraalRuntime.getInstance().getCompilerToVM().constantPoolLength(type); 45 } 46 47 @Override 48 public Object lookupConstant(int cpi) { 49 assert cpi != 0; 50 Object constant = HotSpotGraalRuntime.getInstance().getCompilerToVM().lookupConstantInPool(type, cpi); 51 return constant; 52 } 53 54 @Override 55 public Signature lookupSignature(int cpi) { 56 throw new UnsupportedOperationException(); 57 } 58 59 @Override 60 public Object lookupAppendix(int cpi, int opcode) { 61 assert Bytecodes.isInvoke(opcode); 62 return HotSpotGraalRuntime.getInstance().getCompilerToVM().lookupAppendixInPool(type, cpi, (byte) opcode); 63 } 64 65 @Override 66 public JavaMethod lookupMethod(int cpi, int opcode) { 67 return HotSpotGraalRuntime.getInstance().getCompilerToVM().lookupMethodInPool(type, cpi, (byte) opcode); 68 } 69 70 @Override 71 public JavaType lookupType(int cpi, int opcode) { 72 return HotSpotGraalRuntime.getInstance().getCompilerToVM().lookupTypeInPool(type, cpi); 73 } 74 75 @Override 76 public JavaField lookupField(int cpi, int opcode) { 77 return HotSpotGraalRuntime.getInstance().getCompilerToVM().lookupFieldInPool(type, cpi, (byte) opcode); 78 } 79 80 @Override 81 public void loadReferencedType(int cpi, int opcode) { 82 HotSpotGraalRuntime.getInstance().getCompilerToVM().lookupReferencedTypeInPool(type, cpi, (byte) opcode); 83 } 84 }