Mercurial > hg > truffle
comparison src/share/vm/c1x/c1x_VmIds.hpp @ 1428:695451afc619
refactoring classes into separate files
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Thu, 19 Aug 2010 14:34:52 -0700 |
parents | |
children | abc670a709dc |
comparison
equal
deleted
inserted
replaced
1427:149b1d2316de | 1428:695451afc619 |
---|---|
1 /* | |
2 * Copyright 2000-2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 class VmIds : public AllStatic { | |
26 | |
27 private: | |
28 static GrowableArray<address>* _stubs; | |
29 static GrowableArray<jobject>* _localHandles; | |
30 | |
31 static oop getObject(jlong id); | |
32 | |
33 public: | |
34 // this enum needs to have the same values as the one in HotSpotProxy.java | |
35 enum CompilerObjectType { | |
36 STUB = 0x100000000000000l, | |
37 METHOD = 0x200000000000000l, | |
38 CLASS = 0x300000000000000l, | |
39 SYMBOL = 0x400000000000000l, | |
40 CONSTANT_POOL = 0x500000000000000l, | |
41 CONSTANT = 0x600000000000000l, | |
42 TYPE_MASK = 0xf00000000000000l, | |
43 DUMMY_CONSTANT = 0x6ffffffffffffffl | |
44 }; | |
45 | |
46 static void initializeObjects(); | |
47 static void cleanupLocalObjects(); | |
48 | |
49 static jlong addStub(address stub); | |
50 static jlong add(Handle obj, CompilerObjectType type); | |
51 template <typename T> static jlong add(T obj); | |
52 | |
53 static address getStub(jlong id); | |
54 template <typename T> static T get(jlong id); | |
55 | |
56 template <typename T> static T toString(symbolOop symbol, TRAPS); | |
57 static symbolOop toSymbol(jstring string); | |
58 }; | |
59 | |
60 template <> inline jlong VmIds::add<methodOop>(methodOop obj){ | |
61 assert(obj != NULL && obj->is_method(), "trying to add NULL or mistyped object"); | |
62 return add(Handle(obj), METHOD); | |
63 } | |
64 template <> inline jlong VmIds::add<klassOop>(klassOop obj) { | |
65 assert(obj != NULL && obj->is_klass(), "trying to add NULL or mistyped object"); | |
66 return add(Handle(obj), CLASS); | |
67 } | |
68 template <> inline jlong VmIds::add<symbolOop>(symbolOop obj) { | |
69 assert(obj != NULL && obj->is_symbol(), "trying to add NULL or mistyped object"); | |
70 return add(Handle(obj), SYMBOL); | |
71 } | |
72 template <> inline jlong VmIds::add<constantPoolOop>(constantPoolOop obj) { | |
73 assert(obj != NULL && obj->is_constantPool(), "trying to add NULL or mistyped object"); | |
74 return add(Handle(obj), CONSTANT_POOL); | |
75 } | |
76 template <> inline jlong VmIds::add<oop>(oop obj) { | |
77 assert(obj != NULL && obj->is_oop(), "trying to add NULL or mistyped object"); | |
78 return add(Handle(obj), CONSTANT); | |
79 } | |
80 | |
81 template <> inline methodOop VmIds::get<methodOop>(jlong id){ | |
82 assert((id & TYPE_MASK) == METHOD, "METHOD expected"); | |
83 assert(getObject(id)->is_method(), "methodOop expected"); | |
84 return (methodOop)getObject(id); | |
85 } | |
86 template <> inline klassOop VmIds::get<klassOop>(jlong id) { | |
87 assert((id & TYPE_MASK) == CLASS, "CLASS expected"); | |
88 assert(getObject(id)->is_klass(), "klassOop expected"); | |
89 return (klassOop)getObject(id); | |
90 } | |
91 template <> inline symbolOop VmIds::get<symbolOop>(jlong id) { | |
92 assert((id & TYPE_MASK) == SYMBOL, "SYMBOL expected"); | |
93 assert(getObject(id)->is_symbol(), "symbolOop expected"); | |
94 return (symbolOop)getObject(id); | |
95 } | |
96 template <> inline constantPoolOop VmIds::get<constantPoolOop>(jlong id) { | |
97 assert((id & TYPE_MASK) == CONSTANT_POOL, "CONSTANT_POOL expected"); | |
98 assert(getObject(id)->is_constantPool(), "constantPoolOop expected"); | |
99 return (constantPoolOop)getObject(id); | |
100 } | |
101 template <> inline oop VmIds::get<oop>(jlong id) { | |
102 assert((id & TYPE_MASK) == CONSTANT, "CONSTANT expected"); | |
103 assert(getObject(id)->is_oop(true), "oop expected"); | |
104 return (oop)getObject(id); | |
105 } | |
106 | |
107 template <> inline Handle VmIds::toString<Handle>(symbolOop symbol, TRAPS) { | |
108 return java_lang_String::create_from_symbol(symbol, THREAD); | |
109 } | |
110 template <> inline oop VmIds::toString<oop>(symbolOop symbol, TRAPS) { | |
111 return toString<Handle>(symbol, THREAD)(); | |
112 } | |
113 template <> inline jstring VmIds::toString<jstring>(symbolOop symbol, TRAPS) { | |
114 return (jstring)JNIHandles::make_local(toString<oop>(symbol, THREAD)); | |
115 } | |
116 template <> inline jobject VmIds::toString<jobject>(symbolOop symbol, TRAPS) { | |
117 return JNIHandles::make_local(toString<oop>(symbol, THREAD)); | |
118 } | |
119 | |
120 inline symbolOop VmIds::toSymbol(jstring string) { | |
121 return java_lang_String::as_symbol_or_null(JNIHandles::resolve(string)); | |
122 } | |
123 |