Mercurial > hg > truffle
comparison src/share/vm/graal/graalCompilerToVM.cpp @ 13259:b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
author | twisti |
---|---|
date | Sun, 08 Dec 2013 11:13:26 -0800 |
parents | fdd6ef90d66d |
children | f795de8d8b71 |
comparison
equal
deleted
inserted
replaced
13258:fdd6ef90d66d | 13259:b16fb0b7479b |
---|---|
192 method->set_guaranteed_monitor_matching(); | 192 method->set_guaranteed_monitor_matching(); |
193 } | 193 } |
194 return true; | 194 return true; |
195 C2V_END | 195 C2V_END |
196 | 196 |
197 // XXX getMetaspaceMethodBySlot | |
197 C2V_VMENTRY(jlong, getMetaspaceMethod, (JNIEnv *, jobject, jobject reflection_method_handle, jobject resultHolder)) | 198 C2V_VMENTRY(jlong, getMetaspaceMethod, (JNIEnv *, jobject, jobject reflection_method_handle, jobject resultHolder)) |
198 oop reflection_method = JNIHandles::resolve(reflection_method_handle); | 199 oop reflection_method = JNIHandles::resolve(reflection_method_handle); |
199 oop reflection_holder = java_lang_reflect_Method::clazz(reflection_method); | 200 oop reflection_holder = java_lang_reflect_Method::clazz(reflection_method); |
200 int slot = java_lang_reflect_Method::slot(reflection_method); | 201 int slot = java_lang_reflect_Method::slot(reflection_method); |
201 Klass* holder = java_lang_Class::as_Klass(reflection_holder); | 202 Klass* holder = java_lang_Class::as_Klass(reflection_holder); |
203 Handle type = GraalCompiler::createHotSpotResolvedObjectType(method, CHECK_0); | 204 Handle type = GraalCompiler::createHotSpotResolvedObjectType(method, CHECK_0); |
204 objArrayOop(JNIHandles::resolve(resultHolder))->obj_at_put(0, type()); | 205 objArrayOop(JNIHandles::resolve(resultHolder))->obj_at_put(0, type()); |
205 return (jlong) (address) method(); | 206 return (jlong) (address) method(); |
206 } | 207 } |
207 | 208 |
209 // XXX getMetaspaceConstructorBySlot | |
208 C2V_VMENTRY(jlong, getMetaspaceConstructor, (JNIEnv *, jobject, jobject reflection_ctor_handle, jobject resultHolder)) | 210 C2V_VMENTRY(jlong, getMetaspaceConstructor, (JNIEnv *, jobject, jobject reflection_ctor_handle, jobject resultHolder)) |
209 oop reflection_ctor = JNIHandles::resolve(reflection_ctor_handle); | 211 oop reflection_ctor = JNIHandles::resolve(reflection_ctor_handle); |
210 oop reflection_holder = java_lang_reflect_Constructor::clazz(reflection_ctor); | 212 oop reflection_holder = java_lang_reflect_Constructor::clazz(reflection_ctor); |
211 int slot = java_lang_reflect_Constructor::slot(reflection_ctor); | 213 int slot = java_lang_reflect_Constructor::slot(reflection_ctor); |
212 Klass* holder = java_lang_Class::as_Klass(reflection_holder); | 214 Klass* holder = java_lang_Class::as_Klass(reflection_holder); |
329 } | 331 } |
330 | 332 |
331 return JNIHandles::make_local(THREAD, result); | 333 return JNIHandles::make_local(THREAD, result); |
332 C2V_END | 334 C2V_END |
333 | 335 |
334 C2V_VMENTRY(jobject, lookupConstantInPool, (JNIEnv *env, jobject, jobject type, jint index)) | 336 C2V_VMENTRY(jobject, lookupConstantInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) |
335 ConstantPool* cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type)))->constants(); | 337 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; |
336 oop result = NULL; | 338 oop result = NULL; |
337 constantTag tag = cp->tag_at(index); | 339 constantTag tag = cp->tag_at(index); |
338 switch (tag.value()) { | 340 switch (tag.value()) { |
339 case JVM_CONSTANT_String: | 341 case JVM_CONSTANT_String: |
340 result = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL); | 342 result = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL); |
349 fatal(err_msg_res("unknown constant pool tag %s at cpi %d in %s", tag.internal_name(), index, cp->pool_holder()->name()->as_C_string())); | 351 fatal(err_msg_res("unknown constant pool tag %s at cpi %d in %s", tag.internal_name(), index, cp->pool_holder()->name()->as_C_string())); |
350 } | 352 } |
351 return JNIHandles::make_local(THREAD, result); | 353 return JNIHandles::make_local(THREAD, result); |
352 C2V_END | 354 C2V_END |
353 | 355 |
354 C2V_VMENTRY(jobject, lookupAppendixInPool, (JNIEnv *env, jobject, jobject type, jint index, jbyte opcode)) | 356 C2V_VMENTRY(jobject, lookupAppendixInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode)) |
355 Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); | 357 Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); |
356 index = GraalCompiler::to_cp_index(index, bc); | 358 index = GraalCompiler::to_cp_index(index, bc); |
357 constantPoolHandle cpool(InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type)))->constants()); | 359 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; |
358 oop appendix_oop = ConstantPool::appendix_at_if_loaded(cpool, index); | 360 oop appendix_oop = ConstantPool::appendix_at_if_loaded(cp, index); |
359 return JNIHandles::make_local(THREAD, appendix_oop); | 361 return JNIHandles::make_local(THREAD, appendix_oop); |
360 C2V_END | 362 C2V_END |
361 | 363 |
362 C2V_VMENTRY(jobject, lookupMethodInPool, (JNIEnv *env, jobject, jobject type, jint index, jbyte opcode)) | 364 C2V_VMENTRY(jobject, lookupMethodInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode)) |
363 constantPoolHandle cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type)))->constants(); | 365 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; |
364 instanceKlassHandle pool_holder(cp->pool_holder()); | 366 instanceKlassHandle pool_holder(cp->pool_holder()); |
365 | 367 |
366 Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); | 368 Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); |
367 int cp_index = GraalCompiler::to_cp_index(index, bc); | 369 int cp_index = GraalCompiler::to_cp_index(index, bc); |
368 | 370 |
383 } | 385 } |
384 return JNIHandles::make_local(THREAD, VMToCompiler::createUnresolvedJavaMethod(name, signature, type, THREAD)); | 386 return JNIHandles::make_local(THREAD, VMToCompiler::createUnresolvedJavaMethod(name, signature, type, THREAD)); |
385 } | 387 } |
386 C2V_END | 388 C2V_END |
387 | 389 |
388 C2V_VMENTRY(jobject, lookupTypeInPool, (JNIEnv *env, jobject, jobject type, jint index)) | 390 C2V_VMENTRY(jobject, lookupTypeInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index)) |
389 ConstantPool* cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type)))->constants(); | 391 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; |
390 Handle result = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL); | 392 Handle result = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL); |
391 return JNIHandles::make_local(THREAD, result()); | 393 return JNIHandles::make_local(THREAD, result()); |
392 C2V_END | 394 C2V_END |
393 | 395 |
394 C2V_VMENTRY(void, lookupReferencedTypeInPool, (JNIEnv *env, jobject, jobject type, jint index, jbyte op)) | 396 C2V_VMENTRY(void, lookupReferencedTypeInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte op)) |
395 ConstantPool* cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(type)))->constants(); | 397 ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; |
396 Bytecodes::Code bc = (Bytecodes::Code) (((int) op) & 0xFF); | 398 Bytecodes::Code bc = (Bytecodes::Code) (((int) op) & 0xFF); |
397 if (bc != Bytecodes::_checkcast && bc != Bytecodes::_instanceof && bc != Bytecodes::_new && bc != Bytecodes::_anewarray | 399 if (bc != Bytecodes::_checkcast && bc != Bytecodes::_instanceof && bc != Bytecodes::_new && bc != Bytecodes::_anewarray |
398 && bc != Bytecodes::_multianewarray && bc != Bytecodes::_ldc && bc != Bytecodes::_ldc_w && bc != Bytecodes::_ldc2_w) | 400 && bc != Bytecodes::_multianewarray && bc != Bytecodes::_ldc && bc != Bytecodes::_ldc_w && bc != Bytecodes::_ldc2_w) |
399 { | 401 { |
400 index = cp->remap_instruction_operand_from_cache(GraalCompiler::to_cp_index(index, bc)); | 402 index = cp->remap_instruction_operand_from_cache(GraalCompiler::to_cp_index(index, bc)); |
411 InstanceKlass::cast(klass)->initialize(CHECK); | 413 InstanceKlass::cast(klass)->initialize(CHECK); |
412 } | 414 } |
413 } | 415 } |
414 C2V_END | 416 C2V_END |
415 | 417 |
416 C2V_VMENTRY(jobject, lookupFieldInPool, (JNIEnv *env, jobject, jobject constantPoolHolder, jint index, jbyte opcode)) | 418 C2V_VMENTRY(jobject, lookupFieldInPool, (JNIEnv *env, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode)) |
417 ResourceMark rm; | 419 ResourceMark rm; |
418 | 420 |
419 int cp_index = GraalCompiler::to_cp_index_u2(index); | 421 int cp_index = GraalCompiler::to_cp_index_u2(index); |
420 constantPoolHandle cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(constantPoolHolder)))->constants(); | 422 constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; |
421 | 423 |
422 int nt_index = cp->name_and_type_ref_index_at(cp_index); | 424 int nt_index = cp->name_and_type_ref_index_at(cp_index); |
423 int sig_index = cp->signature_ref_index_at(nt_index); | 425 int sig_index = cp->signature_ref_index_at(nt_index); |
424 Symbol* signature = cp->symbol_at(sig_index); | 426 Symbol* signature = cp->symbol_at(sig_index); |
425 int name_index = cp->name_ref_index_at(nt_index); | 427 int name_index = cp->name_ref_index_at(nt_index); |
987 #define HS_COMPILED_CODE "Lcom/oracle/graal/hotspot/HotSpotCompiledCode;" | 989 #define HS_COMPILED_CODE "Lcom/oracle/graal/hotspot/HotSpotCompiledCode;" |
988 #define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;" | 990 #define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;" |
989 #define HS_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotMethod;" | 991 #define HS_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotMethod;" |
990 #define HS_INSTALLED_CODE "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;" | 992 #define HS_INSTALLED_CODE "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;" |
991 #define METASPACE_METHOD "J" | 993 #define METASPACE_METHOD "J" |
994 #define METASPACE_CONSTANT_POOL "J" | |
992 | 995 |
993 JNINativeMethod CompilerToVM_methods[] = { | 996 JNINativeMethod CompilerToVM_methods[] = { |
994 {CC"initializeBytecode", CC"("METASPACE_METHOD"[B)[B", FN_PTR(initializeBytecode)}, | 997 {CC"initializeBytecode", CC"("METASPACE_METHOD"[B)[B", FN_PTR(initializeBytecode)}, |
995 {CC"initializeExceptionHandlers", CC"("METASPACE_METHOD EXCEPTION_HANDLERS")"EXCEPTION_HANDLERS, FN_PTR(initializeExceptionHandlers)}, | 998 {CC"initializeExceptionHandlers", CC"("METASPACE_METHOD EXCEPTION_HANDLERS")"EXCEPTION_HANDLERS, FN_PTR(initializeExceptionHandlers)}, |
996 {CC"hasBalancedMonitors", CC"("METASPACE_METHOD")Z", FN_PTR(hasBalancedMonitors)}, | 999 {CC"hasBalancedMonitors", CC"("METASPACE_METHOD")Z", FN_PTR(hasBalancedMonitors)}, |
1000 {CC"initializeMethod", CC"("METASPACE_METHOD HS_RESOLVED_METHOD")V", FN_PTR(initializeMethod)}, | 1003 {CC"initializeMethod", CC"("METASPACE_METHOD HS_RESOLVED_METHOD")V", FN_PTR(initializeMethod)}, |
1001 {CC"doNotInlineOrCompile", CC"("METASPACE_METHOD")V", FN_PTR(doNotInlineOrCompile)}, | 1004 {CC"doNotInlineOrCompile", CC"("METASPACE_METHOD")V", FN_PTR(doNotInlineOrCompile)}, |
1002 {CC"isMethodCompilable", CC"("METASPACE_METHOD")Z", FN_PTR(isMethodCompilable)}, | 1005 {CC"isMethodCompilable", CC"("METASPACE_METHOD")Z", FN_PTR(isMethodCompilable)}, |
1003 {CC"getCompiledCodeSize", CC"("METASPACE_METHOD")I", FN_PTR(getCompiledCodeSize)}, | 1006 {CC"getCompiledCodeSize", CC"("METASPACE_METHOD")I", FN_PTR(getCompiledCodeSize)}, |
1004 {CC"lookupType", CC"("STRING HS_RESOLVED_TYPE"Z)"TYPE, FN_PTR(lookupType)}, | 1007 {CC"lookupType", CC"("STRING HS_RESOLVED_TYPE"Z)"TYPE, FN_PTR(lookupType)}, |
1005 {CC"lookupConstantInPool", CC"("HS_RESOLVED_TYPE"I)"OBJECT, FN_PTR(lookupConstantInPool)}, | 1008 {CC"lookupConstantInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(lookupConstantInPool)}, |
1006 {CC"lookupAppendixInPool", CC"("HS_RESOLVED_TYPE"IB)"OBJECT, FN_PTR(lookupAppendixInPool)}, | 1009 {CC"lookupAppendixInPool", CC"("METASPACE_CONSTANT_POOL"IB)"OBJECT, FN_PTR(lookupAppendixInPool)}, |
1007 {CC"lookupMethodInPool", CC"("HS_RESOLVED_TYPE"IB)"METHOD, FN_PTR(lookupMethodInPool)}, | 1010 {CC"lookupMethodInPool", CC"("METASPACE_CONSTANT_POOL"IB)"METHOD, FN_PTR(lookupMethodInPool)}, |
1008 {CC"lookupTypeInPool", CC"("HS_RESOLVED_TYPE"I)"TYPE, FN_PTR(lookupTypeInPool)}, | 1011 {CC"lookupTypeInPool", CC"("METASPACE_CONSTANT_POOL"I)"TYPE, FN_PTR(lookupTypeInPool)}, |
1009 {CC"lookupReferencedTypeInPool", CC"("HS_RESOLVED_TYPE"IB)V", FN_PTR(lookupReferencedTypeInPool)}, | 1012 {CC"lookupReferencedTypeInPool", CC"("METASPACE_CONSTANT_POOL"IB)V", FN_PTR(lookupReferencedTypeInPool)}, |
1010 {CC"lookupFieldInPool", CC"("HS_RESOLVED_TYPE"IB)"FIELD, FN_PTR(lookupFieldInPool)}, | 1013 {CC"lookupFieldInPool", CC"("METASPACE_CONSTANT_POOL"IB)"FIELD, FN_PTR(lookupFieldInPool)}, |
1011 {CC"resolveMethod", CC"("HS_RESOLVED_TYPE STRING STRING")"METHOD, FN_PTR(resolveMethod)}, | 1014 {CC"resolveMethod", CC"("HS_RESOLVED_TYPE STRING STRING")"METHOD, FN_PTR(resolveMethod)}, |
1012 {CC"getInstanceFields", CC"("HS_RESOLVED_TYPE")["HS_RESOLVED_FIELD, FN_PTR(getInstanceFields)}, | 1015 {CC"getInstanceFields", CC"("HS_RESOLVED_TYPE")["HS_RESOLVED_FIELD, FN_PTR(getInstanceFields)}, |
1013 {CC"getMethods", CC"("HS_RESOLVED_TYPE")["HS_RESOLVED_METHOD, FN_PTR(getMethods)}, | 1016 {CC"getMethods", CC"("HS_RESOLVED_TYPE")["HS_RESOLVED_METHOD, FN_PTR(getMethods)}, |
1014 {CC"hasFinalizableSubclass", CC"("HS_RESOLVED_TYPE")Z", FN_PTR(hasFinalizableSubclass)}, | 1017 {CC"hasFinalizableSubclass", CC"("HS_RESOLVED_TYPE")Z", FN_PTR(hasFinalizableSubclass)}, |
1015 {CC"initializeType", CC"("HS_RESOLVED_TYPE")V", FN_PTR(initializeType)}, | 1018 {CC"initializeType", CC"("HS_RESOLVED_TYPE")V", FN_PTR(initializeType)}, |