comparison graal/Runtime/src/com/sun/hotspot/c1x/HotSpotProxy.java @ 2297:099e697d8934

Renaming c1x4hotspotsrc => graal and HotSpotVM => Runtime
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 22 Apr 2011 15:08:53 +0200
parents
children
comparison
equal deleted inserted replaced
2296:34354e2e40a3 2297:099e697d8934
1 /*
2 * Copyright (c) 2010 Sun Microsystems, Inc. All rights reserved.
3 *
4 * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
5 * that is described in this document. In particular, and without limitation, these intellectual property
6 * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
7 * more additional patents or pending patent applications in the U.S. and in other countries.
8 *
9 * U.S. Government Rights - Commercial software. Government users are subject to the Sun
10 * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
11 * supplements.
12 *
13 * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
14 * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
15 * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
16 * U.S. and other countries.
17 *
18 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
19 * Company, Ltd.
20 */
21 package com.sun.hotspot.c1x;
22
23 /**
24 * Provides methods to classify the HotSpot-internal identifiers.
25 *
26 * @author Lukas Stadler
27 */
28 public final class HotSpotProxy {
29
30 private HotSpotProxy() {
31 }
32
33 private enum CompilerObjectType {
34 // this enum needs to have the same values as the one in c1x_Compiler.hpp
35 STUB(0x100000000000000L),
36 METHOD(0x200000000000000L),
37 CLASS(0x300000000000000L),
38 SYMBOL(0x400000000000000L),
39 CONSTANT_POOL(0x500000000000000L),
40 CONSTANT(0x600000000000000L),
41 TYPE_MASK(0xf00000000000000L),
42 DUMMY_CONSTANT(0x6ffffffffffffffL);
43
44 public final long bits;
45
46 CompilerObjectType(long bits) {
47 this.bits = bits;
48 }
49 }
50
51 public static final Long DUMMY_CONSTANT_OBJ = CompilerObjectType.DUMMY_CONSTANT.bits;
52
53 private static boolean isType(long id, CompilerObjectType type) {
54 return (id & CompilerObjectType.TYPE_MASK.bits) == type.bits;
55 }
56
57 public static boolean isStub(long id) {
58 return isType(id, CompilerObjectType.STUB);
59 }
60
61 public static boolean isMethod(long id) {
62 return isType(id, CompilerObjectType.METHOD);
63 }
64
65 public static boolean isClass(long id) {
66 return isType(id, CompilerObjectType.CLASS);
67 }
68
69 public static boolean isSymbol(long id) {
70 return isType(id, CompilerObjectType.SYMBOL);
71 }
72
73 public static boolean isConstantPool(long id) {
74 return isType(id, CompilerObjectType.CONSTANT_POOL);
75 }
76
77 public static boolean isConstant(long id) {
78 return isType(id, CompilerObjectType.CONSTANT_POOL);
79 }
80
81 public static String toString(long id) {
82 CompilerObjectType type = null;
83 for (CompilerObjectType t : CompilerObjectType.values()) {
84 if ((id & CompilerObjectType.TYPE_MASK.bits) == t.bits) {
85 type = t;
86 }
87 }
88 long num = id & ~CompilerObjectType.TYPE_MASK.bits;
89 return type + " " + num;
90 }
91
92 }