comparison src/share/vm/c1x/c1x_VMEntries.cpp @ 1432:b61a43cd1255

sourcecode formatting
author Lukas Stadler <lukas.stadler@oracle.com>
date Wed, 01 Sep 2010 17:13:38 -0700
parents abc670a709dc
children efba53f86c4f
comparison
equal deleted inserted replaced
1431:c01535d7fcc6 1432:b61a43cd1255
20 * CA 95054 USA or visit www.sun.com if you need additional information or 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions. 21 * have any questions.
22 * 22 *
23 */ 23 */
24 24
25
26 # include "incls/_precompiled.incl" 25 # include "incls/_precompiled.incl"
27 # include "incls/_c1x_VMEntries.cpp.incl" 26 # include "incls/_c1x_VMEntries.cpp.incl"
28
29
30
31 27
32 // public byte[] RiMethod_code(long vmId); 28 // public byte[] RiMethod_code(long vmId);
33 JNIEXPORT jbyteArray JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1code(JNIEnv *env, jobject, jlong vmId) { 29 JNIEXPORT jbyteArray JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1code(JNIEnv *env, jobject, jlong vmId) {
34 methodOop method = VmIds::get<methodOop>(vmId); 30 methodOop method = VmIds::get<methodOop>(vmId);
35 int code_size = method->code_size(); 31 int code_size = method->code_size();
36 jbyteArray result = env->NewByteArray(code_size); 32 jbyteArray result = env->NewByteArray(code_size);
37 env->SetByteArrayRegion(result, 0, code_size, (const jbyte *)method->code_base()); 33 env->SetByteArrayRegion(result, 0, code_size, (const jbyte *) method->code_base());
38 return result; 34 return result;
39 } 35 }
40 36
41 // public int RiMethod_maxStackSize(long vmId); 37 // public int RiMethod_maxStackSize(long vmId);
42 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxStackSize(JNIEnv *, jobject, jlong vmId) { 38 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxStackSize(JNIEnv *, jobject, jlong vmId) {
78 int handler_count = handlers.is_null() ? 0 : handlers->length() / 4; 74 int handler_count = handlers.is_null() ? 0 : handlers->length() / 4;
79 75
80 instanceKlass::cast(HotSpotExceptionHandler::klass())->initialize(CHECK_NULL); 76 instanceKlass::cast(HotSpotExceptionHandler::klass())->initialize(CHECK_NULL);
81 objArrayHandle array = oopFactory::new_objArray(SystemDictionary::RiExceptionHandler_klass(), handler_count, CHECK_NULL); 77 objArrayHandle array = oopFactory::new_objArray(SystemDictionary::RiExceptionHandler_klass(), handler_count, CHECK_NULL);
82 78
83 for (int i=0; i<handler_count; i++) { 79 for (int i = 0; i < handler_count; i++) {
84 // exception handlers are stored as four integers: start bci, end bci, handler bci, catch class constant pool index 80 // exception handlers are stored as four integers: start bci, end bci, handler bci, catch class constant pool index
85 int base = i * 4; 81 int base = i * 4;
86 Handle entry = instanceKlass::cast(HotSpotExceptionHandler::klass())->allocate_instance(CHECK_NULL); 82 Handle entry = instanceKlass::cast(HotSpotExceptionHandler::klass())->allocate_instance(CHECK_NULL);
87 HotSpotExceptionHandler::set_startBci(entry, handlers->int_at(base + 0)); 83 HotSpotExceptionHandler::set_startBci(entry, handlers->int_at(base + 0));
88 HotSpotExceptionHandler::set_endBci(entry, handlers->int_at(base + 1)); 84 HotSpotExceptionHandler::set_endBci(entry, handlers->int_at(base + 1));
92 88
93 if (catch_class_index == 0) { 89 if (catch_class_index == 0) {
94 HotSpotExceptionHandler::set_catchClass(entry, NULL); 90 HotSpotExceptionHandler::set_catchClass(entry, NULL);
95 } else { 91 } else {
96 constantPoolOop cp = instanceKlass::cast(method->method_holder())->constants(); 92 constantPoolOop cp = instanceKlass::cast(method->method_holder())->constants();
97 ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(method->method_holder()); 93 ciInstanceKlass* loading_klass = (ciInstanceKlass *) CURRENT_ENV->get_object(method->method_holder());
98 bool is_accessible = false; 94 bool is_accessible = false;
99 ciKlass *klass = CURRENT_ENV->get_klass_by_index(cp, catch_class_index, is_accessible, loading_klass); 95 ciKlass *klass = CURRENT_ENV->get_klass_by_index(cp, catch_class_index, is_accessible, loading_klass);
100 oop catch_class = C1XCompiler::get_RiType(klass, method->method_holder(), CHECK_NULL); 96 oop catch_class = C1XCompiler::get_RiType(klass, method->method_holder(), CHECK_NULL);
101 97
102 HotSpotExceptionHandler::set_catchClass(entry, catch_class); 98 HotSpotExceptionHandler::set_catchClass(entry, catch_class);
103 } 99 }
104 array->obj_at_put(i, entry()); 100 array->obj_at_put(i, entry());
105 } 101 }
106 102
107 return (jobjectArray)JNIHandles::make_local(array()); 103 return (jobjectArray) JNIHandles::make_local(array());
108 } 104 }
109 105
110 // public RiType RiSignature_lookupType(String returnType, long accessingClassVmId); 106 // public RiType RiSignature_lookupType(String returnType, long accessingClassVmId);
111 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1lookupType(JNIEnv *env, jobject, jstring jname, jlong accessingClassVmId) { 107 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1lookupType(JNIEnv *env, jobject, jstring jname, jlong accessingClassVmId) {
112 VM_ENTRY_MARK; 108 VM_ENTRY_MARK;
114 symbolOop nameSymbol = VmIds::toSymbol(jname); 110 symbolOop nameSymbol = VmIds::toSymbol(jname);
115 Handle name = JNIHandles::resolve(jname); 111 Handle name = JNIHandles::resolve(jname);
116 112
117 oop result; 113 oop result;
118 if (nameSymbol == vmSymbols::int_signature()) { 114 if (nameSymbol == vmSymbols::int_signature()) {
119 result = VMExits::createRiTypePrimitive((int)T_INT, THREAD); 115 result = VMExits::createRiTypePrimitive((int) T_INT, THREAD);
120 } else if (nameSymbol == vmSymbols::long_signature()) { 116 } else if (nameSymbol == vmSymbols::long_signature()) {
121 result = VMExits::createRiTypePrimitive((int)T_LONG, THREAD); 117 result = VMExits::createRiTypePrimitive((int) T_LONG, THREAD);
122 } else if (nameSymbol == vmSymbols::bool_signature()) { 118 } else if (nameSymbol == vmSymbols::bool_signature()) {
123 result = VMExits::createRiTypePrimitive((int)T_BOOLEAN, THREAD); 119 result = VMExits::createRiTypePrimitive((int) T_BOOLEAN, THREAD);
124 } else if (nameSymbol == vmSymbols::char_signature()) { 120 } else if (nameSymbol == vmSymbols::char_signature()) {
125 result = VMExits::createRiTypePrimitive((int)T_CHAR, THREAD); 121 result = VMExits::createRiTypePrimitive((int) T_CHAR, THREAD);
126 } else if (nameSymbol == vmSymbols::short_signature()) { 122 } else if (nameSymbol == vmSymbols::short_signature()) {
127 result = VMExits::createRiTypePrimitive((int)T_SHORT, THREAD); 123 result = VMExits::createRiTypePrimitive((int) T_SHORT, THREAD);
128 } else if (nameSymbol == vmSymbols::byte_signature()) { 124 } else if (nameSymbol == vmSymbols::byte_signature()) {
129 result = VMExits::createRiTypePrimitive((int)T_BYTE, THREAD); 125 result = VMExits::createRiTypePrimitive((int) T_BYTE, THREAD);
130 } else if (nameSymbol == vmSymbols::double_signature()) { 126 } else if (nameSymbol == vmSymbols::double_signature()) {
131 result = VMExits::createRiTypePrimitive((int)T_DOUBLE, THREAD); 127 result = VMExits::createRiTypePrimitive((int) T_DOUBLE, THREAD);
132 } else if (nameSymbol == vmSymbols::float_signature()) { 128 } else if (nameSymbol == vmSymbols::float_signature()) {
133 result = VMExits::createRiTypePrimitive((int)T_FLOAT, THREAD); 129 result = VMExits::createRiTypePrimitive((int) T_FLOAT, THREAD);
134 } else { 130 } else {
135 Handle classloader; 131 Handle classloader;
136 Handle protectionDomain; 132 Handle protectionDomain;
137 if (accessingClassVmId != 0) { 133 if (accessingClassVmId != 0) {
138 classloader = VmIds::get<klassOop>(accessingClassVmId)->klass_part()->class_loader(); 134 classloader = VmIds::get<klassOop>(accessingClassVmId)->klass_part()->class_loader();
179 } 175 }
180 } 176 }
181 result = VMExits::createCiConstantObject(VmIds::add<oop>(string), CHECK_0); 177 result = VMExits::createCiConstantObject(VmIds::add<oop>(string), CHECK_0);
182 } else if (tag.is_klass() || tag.is_unresolved_klass()) { 178 } else if (tag.is_klass() || tag.is_unresolved_klass()) {
183 bool ignore; 179 bool ignore;
184 ciInstanceKlass* accessor = (ciInstanceKlass*)ciEnv::current()->get_object(cp->pool_holder()); 180 ciInstanceKlass* accessor = (ciInstanceKlass*) ciEnv::current()->get_object(cp->pool_holder());
185 ciKlass* klass = ciEnv::current()->get_klass_by_index(cp, index, ignore, accessor); 181 ciKlass* klass = ciEnv::current()->get_klass_by_index(cp, index, ignore, accessor);
186 result = C1XCompiler::get_RiType(klass, cp->pool_holder(), CHECK_NULL); 182 result = C1XCompiler::get_RiType(klass, cp->pool_holder(), CHECK_NULL);
187 } else if (tag.is_object()) { 183 } else if (tag.is_object()) {
188 oop obj = cp->object_at(index); 184 oop obj = cp->object_at(index);
189 assert(obj->is_instance(), "must be an instance"); 185 assert(obj->is_instance(), "must be an instance");
199 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jobject, jlong vmId, jint index, jbyte byteCode) { 195 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jobject, jlong vmId, jint index, jbyte byteCode) {
200 VM_ENTRY_MARK; 196 VM_ENTRY_MARK;
201 197
202 constantPoolHandle cp = VmIds::get<constantPoolOop>(vmId); 198 constantPoolHandle cp = VmIds::get<constantPoolOop>(vmId);
203 199
204 Bytecodes::Code bc = (Bytecodes::Code)(((int)byteCode) & 0xFF); 200 Bytecodes::Code bc = (Bytecodes::Code) (((int) byteCode) & 0xFF);
205 ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); 201 ciInstanceKlass* loading_klass = (ciInstanceKlass *) CURRENT_ENV->get_object(cp->pool_holder());
206 ciMethod *cimethod = CURRENT_ENV->get_method_by_index(cp, index, bc, loading_klass); 202 ciMethod *cimethod = CURRENT_ENV->get_method_by_index(cp, index, bc, loading_klass);
207 if (cimethod->is_loaded()) { 203 if (cimethod->is_loaded()) {
208 methodOop method = (methodOop)cimethod->get_oop(); 204 methodOop method = (methodOop) cimethod->get_oop();
209 Handle name = VmIds::toString<Handle>(method->name(), CHECK_NULL); 205 Handle name = VmIds::toString<Handle>(method->name(), CHECK_NULL);
210 return JNIHandles::make_local(THREAD, VMExits::createRiMethodResolved(VmIds::add<methodOop>(method), name, THREAD)); 206 return JNIHandles::make_local(THREAD, VMExits::createRiMethodResolved(VmIds::add<methodOop>(method), name, THREAD));
211 } else { 207 } else {
212 Handle name = VmIds::toString<Handle>((symbolOop)cimethod->name()->get_oop(), CHECK_NULL); 208 Handle name = VmIds::toString<Handle>((symbolOop) cimethod->name()->get_oop(), CHECK_NULL);
213 Handle signature = VmIds::toString<Handle>((symbolOop)cimethod->signature()->as_symbol()->get_oop(), CHECK_NULL); 209 Handle signature = VmIds::toString<Handle>((symbolOop) cimethod->signature()->as_symbol()->get_oop(), CHECK_NULL);
214 Handle holder = C1XCompiler::get_RiType(cimethod->holder(), cp->klass(), THREAD); 210 Handle holder = C1XCompiler::get_RiType(cimethod->holder(), cp->klass(), THREAD);
215 return JNIHandles::make_local(THREAD, VMExits::createRiMethodUnresolved(name, signature, holder, THREAD)); 211 return JNIHandles::make_local(THREAD, VMExits::createRiMethodUnresolved(name, signature, holder, THREAD));
216 } 212 }
217 } 213 }
218 214
226 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType(JNIEnv *env, jobject, jlong vmId, jint index) { 222 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType(JNIEnv *env, jobject, jlong vmId, jint index) {
227 VM_ENTRY_MARK; 223 VM_ENTRY_MARK;
228 224
229 constantPoolOop cp = VmIds::get<constantPoolOop>(vmId); 225 constantPoolOop cp = VmIds::get<constantPoolOop>(vmId);
230 226
231 ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); 227 ciInstanceKlass* loading_klass = (ciInstanceKlass *) CURRENT_ENV->get_object(cp->pool_holder());
232 bool is_accessible = false; 228 bool is_accessible = false;
233 ciKlass *klass = CURRENT_ENV->get_klass_by_index(cp, index, is_accessible, loading_klass); 229 ciKlass *klass = CURRENT_ENV->get_klass_by_index(cp, index, is_accessible, loading_klass);
234 return JNIHandles::make_local(THREAD, C1XCompiler::get_RiType(klass, cp->klass(), THREAD)); 230 return JNIHandles::make_local(THREAD, C1XCompiler::get_RiType(klass, cp->klass(), THREAD));
235 } 231 }
236 232
238 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jobject, jlong vmId, jint index) { 234 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jobject, jlong vmId, jint index) {
239 VM_ENTRY_MARK; 235 VM_ENTRY_MARK;
240 236
241 constantPoolOop cp = VmIds::get<constantPoolOop>(vmId); 237 constantPoolOop cp = VmIds::get<constantPoolOop>(vmId);
242 238
243 ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); 239 ciInstanceKlass* loading_klass = (ciInstanceKlass *) CURRENT_ENV->get_object(cp->pool_holder());
244 ciField *field = CURRENT_ENV->get_field_by_index(loading_klass, index); 240 ciField *field = CURRENT_ENV->get_field_by_index(loading_klass, index);
245 return JNIHandles::make_local(THREAD, C1XCompiler::get_RiField(field, THREAD)); 241 return JNIHandles::make_local(THREAD, C1XCompiler::get_RiField(field, THREAD));
246 } 242 }
247 243
248 // public RiConstantPool RiType_constantPool(long vmId); 244 // public RiConstantPool RiType_constantPool(long vmId);