Mercurial > hg > graal-jvmci-8
comparison src/share/vm/graal/graalVmIds.hpp @ 3632:136ea96eb7f8
Remove the need for VmId (last usage was the constant pool).
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 14 Nov 2011 22:33:15 +0100 |
parents | f00918f35c7f |
children | 076542d505cd |
comparison
equal
deleted
inserted
replaced
3630:3b18b27b0dd4 | 3632:136ea96eb7f8 |
---|---|
31 | 31 |
32 class VmIds : public AllStatic { | 32 class VmIds : public AllStatic { |
33 | 33 |
34 private: | 34 private: |
35 static GrowableArray<address>* _stubs; | 35 static GrowableArray<address>* _stubs; |
36 static GrowableArray<jobject>* _localHandles; | |
37 | 36 |
38 static oop getObject(jlong id); | 37 static oop getObject(jlong id); |
39 | 38 |
40 public: | 39 public: |
41 // these constants needs to have the same values as the one in HotSpotProxy.java | 40 // these constants needs to have the same values as the one in HotSpotProxy.java |
47 static const jlong TYPE_MASK = 0xf00000000000000LL; | 46 static const jlong TYPE_MASK = 0xf00000000000000LL; |
48 static const jlong DUMMY_CONSTANT = 0x6ffffffffffffffLL; | 47 static const jlong DUMMY_CONSTANT = 0x6ffffffffffffffLL; |
49 | 48 |
50 // Initializes the VmIds for a compilation, by creating the arrays | 49 // Initializes the VmIds for a compilation, by creating the arrays |
51 static void initializeObjects(); | 50 static void initializeObjects(); |
52 // Cleans up after a compilation, by deallocating the arrays | |
53 static void cleanupLocalObjects(); | |
54 | 51 |
55 // Adds a stub address, and returns the corresponding vmId (which is of type STUB) | 52 // Adds a stub address, and returns the corresponding vmId (which is of type STUB) |
56 static jlong addStub(address stub); | 53 static jlong addStub(address stub); |
57 | 54 |
58 // Adds an object, and returns the corresponding vmId (with the given type) | |
59 static jlong add(Handle obj, jlong type); | |
60 | |
61 // Adds an object, and returns the corresponding vmId (the type of which is determined by the template parameter) | |
62 template <typename T> static jlong add(T obj); | |
63 | |
64 | |
65 // Returns the stub address with the given vmId | 55 // Returns the stub address with the given vmId |
66 static address getStub(jlong id); | 56 static address getStub(jlong id); |
57 | |
67 // Returns the stub address with the given vmId taken from a java.lang.Long | 58 // Returns the stub address with the given vmId taken from a java.lang.Long |
68 static address getStub(oop id); | 59 static address getStub(oop id); |
69 | |
70 // Returns the object with the given id, the return type is defined by the template parameter (which must correspond to the actual type of the vmId) | |
71 template <typename T> static T get(jlong id); | |
72 | |
73 | 60 |
74 // Helper function to convert a symbol to a java.lang.String object | 61 // Helper function to convert a symbol to a java.lang.String object |
75 template <typename T> static T toString(Symbol* symbol, TRAPS); | 62 template <typename T> static T toString(Symbol* symbol, TRAPS); |
76 | 63 |
77 // Helper function to convert a java.lang.String object to a symbol (this will return NULL if the symbol doesn't exist in the system) | 64 // Helper function to convert a java.lang.String object to a symbol (this will return NULL if the symbol doesn't exist in the system) |
79 | 66 |
80 // Helper function to get the contents of a java.lang.Long | 67 // Helper function to get the contents of a java.lang.Long |
81 static jlong getBoxedLong(oop obj); | 68 static jlong getBoxedLong(oop obj); |
82 }; | 69 }; |
83 | 70 |
84 | |
85 template <> inline jlong VmIds::add<klassOop>(klassOop obj) { | |
86 assert(obj != NULL, "trying to add NULL<klassOop>"); | |
87 assert(obj->is_klass(), "trying to add mistyped object"); | |
88 return add(Handle(obj), CLASS); | |
89 } | |
90 template <> inline jlong VmIds::add<constantPoolOop>(constantPoolOop obj) { | |
91 assert(obj != NULL, "trying to add NULL<constantPoolOop>"); | |
92 assert(obj->is_constantPool(), "trying to add mistyped object"); | |
93 return add(Handle(obj), CONSTANT_POOL); | |
94 } | |
95 template <> inline jlong VmIds::add<oop>(oop obj) { | |
96 assert(obj != NULL, "trying to add NULL<oop>"); | |
97 assert(obj->is_oop(), "trying to add mistyped object"); | |
98 return add(Handle(obj), CONSTANT); | |
99 } | |
100 | |
101 | |
102 template <> inline klassOop VmIds::get<klassOop>(jlong id) { | |
103 assert((id & TYPE_MASK) == CLASS, "CLASS expected"); | |
104 assert(getObject(id)->is_klass(), "klassOop expected"); | |
105 return (klassOop)getObject(id); | |
106 } | |
107 template <> inline constantPoolOop VmIds::get<constantPoolOop>(jlong id) { | |
108 assert((id & TYPE_MASK) == CONSTANT_POOL, "CONSTANT_POOL expected"); | |
109 assert(getObject(id)->is_constantPool(), "constantPoolOop expected"); | |
110 return (constantPoolOop)getObject(id); | |
111 } | |
112 template <> inline oop VmIds::get<oop>(jlong id) { | |
113 assert((id & TYPE_MASK) == CONSTANT, "CONSTANT expected"); | |
114 assert(getObject(id)->is_oop(true), "oop expected"); | |
115 return (oop)getObject(id); | |
116 } | |
117 | |
118 inline address VmIds::getStub(oop obj) { | 71 inline address VmIds::getStub(oop obj) { |
119 return getStub(getBoxedLong(obj)); | 72 return getStub(getBoxedLong(obj)); |
120 } | 73 } |
121 | 74 |
122 template <> inline Handle VmIds::toString<Handle>(Symbol* symbol, TRAPS) { | 75 template <> inline Handle VmIds::toString<Handle>(Symbol* symbol, TRAPS) { |
123 return java_lang_String::create_from_symbol(symbol, THREAD); | 76 return java_lang_String::create_from_symbol(symbol, THREAD); |
124 } | 77 } |
78 | |
125 template <> inline oop VmIds::toString<oop>(Symbol* symbol, TRAPS) { | 79 template <> inline oop VmIds::toString<oop>(Symbol* symbol, TRAPS) { |
126 return toString<Handle>(symbol, THREAD)(); | 80 return toString<Handle>(symbol, THREAD)(); |
127 } | 81 } |
82 | |
128 template <> inline jstring VmIds::toString<jstring>(Symbol* symbol, TRAPS) { | 83 template <> inline jstring VmIds::toString<jstring>(Symbol* symbol, TRAPS) { |
129 return (jstring)JNIHandles::make_local(toString<oop>(symbol, THREAD)); | 84 return (jstring)JNIHandles::make_local(toString<oop>(symbol, THREAD)); |
130 } | 85 } |
86 | |
131 template <> inline jobject VmIds::toString<jobject>(Symbol* symbol, TRAPS) { | 87 template <> inline jobject VmIds::toString<jobject>(Symbol* symbol, TRAPS) { |
132 return JNIHandles::make_local(toString<oop>(symbol, THREAD)); | 88 return JNIHandles::make_local(toString<oop>(symbol, THREAD)); |
133 } | 89 } |
134 | 90 |
135 inline Symbol* VmIds::toSymbol(jstring string) { | 91 inline Symbol* VmIds::toSymbol(jstring string) { |