< prev index next >

src/share/vm/jvmci/jvmciCompilerToVM.cpp

Print this page




 582     }
 583 
 584     if (len > 1) {
 585       // Restore the big-endian constant pool indexes.
 586       // Cf. Rewriter::scan_method
 587       switch (code) {
 588         case Bytecodes::_getstatic:
 589         case Bytecodes::_putstatic:
 590         case Bytecodes::_getfield:
 591         case Bytecodes::_putfield:
 592         case Bytecodes::_invokevirtual:
 593         case Bytecodes::_invokespecial:
 594         case Bytecodes::_invokestatic:
 595         case Bytecodes::_invokeinterface:
 596         case Bytecodes::_invokehandle: {
 597           int cp_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1));
 598           Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index);
 599           break;
 600         }
 601 
 602         case Bytecodes::_invokedynamic:
 603           int cp_index = Bytes::get_native_u4((address) reconstituted_code->byte_at_addr(bci + 1));
 604           Bytes::put_Java_u4((address) reconstituted_code->byte_at_addr(bci + 1), (u4) cp_index);
 605           break;
 606       }
 607 




 608       // Not all ldc byte code are rewritten.
 609       switch (raw_code) {
 610         case Bytecodes::_fast_aldc: {
 611           int cpc_index = reconstituted_code->byte_at(bci + 1) & 0xff;
 612           int cp_index = method->constants()->object_to_cp_index(cpc_index);
 613           assert(cp_index < method->constants()->length(), "sanity check");
 614           reconstituted_code->byte_at_put(bci + 1, (jbyte) cp_index);
 615           break;
 616         }
 617 
 618         case Bytecodes::_fast_aldc_w: {
 619           int cpc_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1));
 620           int cp_index = method->constants()->object_to_cp_index(cpc_index);
 621           assert(cp_index < method->constants()->length(), "sanity check");
 622           Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index);
 623           break;
 624         }



 625       }
 626     }
 627   }
 628 
 629   return (jbyteArray) JNIHandles::make_local(THREAD, reconstituted_code);
 630 C2V_END
 631 
 632 C2V_VMENTRY(jint, getExceptionTableLength, (JNIEnv *, jobject, jobject jvmci_method))
 633   ResourceMark rm;
 634   methodHandle method = CompilerToVM::asMethod(jvmci_method);
 635   return method->exception_table_length();
 636 C2V_END
 637 
 638 C2V_VMENTRY(jlong, getExceptionTableStart, (JNIEnv *, jobject, jobject jvmci_method))
 639   ResourceMark rm;
 640   methodHandle method = CompilerToVM::asMethod(jvmci_method);
 641   if (method->exception_table_length() == 0) {
 642     return 0L;
 643   }
 644   return (jlong) (address) method->exception_table_start();


 947 
 948 C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_type, jobject jvmci_method, jobject caller_jvmci_type))
 949   Klass* recv_klass = CompilerToVM::asKlass(receiver_jvmci_type);
 950   Klass* caller_klass = CompilerToVM::asKlass(caller_jvmci_type);
 951   methodHandle method = CompilerToVM::asMethod(jvmci_method);
 952 
 953   Klass* resolved     = method->method_holder();
 954   Symbol* h_name      = method->name();
 955   Symbol* h_signature = method->signature();
 956 
 957   if (MethodHandles::is_signature_polymorphic_method(method())) {
 958       // Signature polymorphic methods are already resolved, JVMCI just returns NULL in this case.
 959       return NULL;
 960   }
 961 
 962   LinkInfo link_info(resolved, h_name, h_signature, caller_klass);
 963   methodHandle m;
 964   // Only do exact lookup if receiver klass has been linked.  Otherwise,
 965   // the vtable has not been setup, and the LinkResolver will fail.
 966   if (recv_klass->is_array_klass() ||
 967       InstanceKlass::cast(recv_klass)->is_linked() && !recv_klass->is_interface()) {
 968     if (resolved->is_interface()) {
 969       m = LinkResolver::resolve_interface_call_or_null(recv_klass, link_info);
 970     } else {
 971       m = LinkResolver::resolve_virtual_call_or_null(recv_klass, link_info);
 972     }
 973   }
 974 
 975   if (m.is_null()) {
 976     // Return NULL if there was a problem with lookup (uninitialized class, etc.)
 977     return NULL;
 978   }
 979 
 980   oop result = CompilerToVM::get_jvmci_method(m, CHECK_NULL);
 981   return JNIHandles::make_local(THREAD, result);
 982 C2V_END
 983 
 984 C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject jvmci_type))
 985   Klass* klass = CompilerToVM::asKlass(jvmci_type);
 986   assert(klass != NULL, "method must not be called for primitive types");
 987   return Dependencies::find_finalizable_subclass(klass) != NULL;


1222   if (jap.get_ret_type() == T_VOID) {
1223     return NULL;
1224   } else if (jap.get_ret_type() == T_OBJECT || jap.get_ret_type() == T_ARRAY) {
1225     return JNIHandles::make_local(THREAD, (oop) result.get_jobject());
1226   } else {
1227     jvalue *value = (jvalue *) result.get_value_addr();
1228     // Narrow the value down if required (Important on big endian machines)
1229     switch (jap.get_ret_type()) {
1230       case T_BOOLEAN:
1231        value->z = (jboolean) value->i;
1232        break;
1233       case T_BYTE:
1234        value->b = (jbyte) value->i;
1235        break;
1236       case T_CHAR:
1237        value->c = (jchar) value->i;
1238        break;
1239       case T_SHORT:
1240        value->s = (jshort) value->i;
1241        break;


1242      }
1243     oop o = java_lang_boxing_object::create(jap.get_ret_type(), value, CHECK_NULL);
1244     return JNIHandles::make_local(THREAD, o);
1245   }
1246 C2V_END
1247 
1248 C2V_VMENTRY(jlongArray, getLineNumberTable, (JNIEnv *, jobject, jobject jvmci_method))
1249   Method* method = CompilerToVM::asMethod(jvmci_method);
1250   if (!method->has_linenumber_table()) {
1251     return NULL;
1252   }
1253   u2 num_entries = 0;
1254   CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table());
1255   while (streamForSize.read_pair()) {
1256     num_entries++;
1257   }
1258 
1259   CompressedLineNumberReadStream stream(method->compressed_linenumber_table());
1260   typeArrayOop result = oopFactory::new_longArray(2 * num_entries, CHECK_NULL);
1261 




 582     }
 583 
 584     if (len > 1) {
 585       // Restore the big-endian constant pool indexes.
 586       // Cf. Rewriter::scan_method
 587       switch (code) {
 588         case Bytecodes::_getstatic:
 589         case Bytecodes::_putstatic:
 590         case Bytecodes::_getfield:
 591         case Bytecodes::_putfield:
 592         case Bytecodes::_invokevirtual:
 593         case Bytecodes::_invokespecial:
 594         case Bytecodes::_invokestatic:
 595         case Bytecodes::_invokeinterface:
 596         case Bytecodes::_invokehandle: {
 597           int cp_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1));
 598           Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index);
 599           break;
 600         }
 601 
 602         case Bytecodes::_invokedynamic: {
 603           int cp_index = Bytes::get_native_u4((address) reconstituted_code->byte_at_addr(bci + 1));
 604           Bytes::put_Java_u4((address) reconstituted_code->byte_at_addr(bci + 1), (u4) cp_index);
 605           break;
 606         }
 607 
 608         default:
 609           break;
 610       }
 611 
 612       // Not all ldc byte code are rewritten.
 613       switch (raw_code) {
 614         case Bytecodes::_fast_aldc: {
 615           int cpc_index = reconstituted_code->byte_at(bci + 1) & 0xff;
 616           int cp_index = method->constants()->object_to_cp_index(cpc_index);
 617           assert(cp_index < method->constants()->length(), "sanity check");
 618           reconstituted_code->byte_at_put(bci + 1, (jbyte) cp_index);
 619           break;
 620         }
 621 
 622         case Bytecodes::_fast_aldc_w: {
 623           int cpc_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1));
 624           int cp_index = method->constants()->object_to_cp_index(cpc_index);
 625           assert(cp_index < method->constants()->length(), "sanity check");
 626           Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index);
 627           break;
 628         }
 629 
 630         default:
 631           break;
 632       }
 633     }
 634   }
 635 
 636   return (jbyteArray) JNIHandles::make_local(THREAD, reconstituted_code);
 637 C2V_END
 638 
 639 C2V_VMENTRY(jint, getExceptionTableLength, (JNIEnv *, jobject, jobject jvmci_method))
 640   ResourceMark rm;
 641   methodHandle method = CompilerToVM::asMethod(jvmci_method);
 642   return method->exception_table_length();
 643 C2V_END
 644 
 645 C2V_VMENTRY(jlong, getExceptionTableStart, (JNIEnv *, jobject, jobject jvmci_method))
 646   ResourceMark rm;
 647   methodHandle method = CompilerToVM::asMethod(jvmci_method);
 648   if (method->exception_table_length() == 0) {
 649     return 0L;
 650   }
 651   return (jlong) (address) method->exception_table_start();


 954 
 955 C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_type, jobject jvmci_method, jobject caller_jvmci_type))
 956   Klass* recv_klass = CompilerToVM::asKlass(receiver_jvmci_type);
 957   Klass* caller_klass = CompilerToVM::asKlass(caller_jvmci_type);
 958   methodHandle method = CompilerToVM::asMethod(jvmci_method);
 959 
 960   Klass* resolved     = method->method_holder();
 961   Symbol* h_name      = method->name();
 962   Symbol* h_signature = method->signature();
 963 
 964   if (MethodHandles::is_signature_polymorphic_method(method())) {
 965       // Signature polymorphic methods are already resolved, JVMCI just returns NULL in this case.
 966       return NULL;
 967   }
 968 
 969   LinkInfo link_info(resolved, h_name, h_signature, caller_klass);
 970   methodHandle m;
 971   // Only do exact lookup if receiver klass has been linked.  Otherwise,
 972   // the vtable has not been setup, and the LinkResolver will fail.
 973   if (recv_klass->is_array_klass() ||
 974       (InstanceKlass::cast(recv_klass)->is_linked() && !recv_klass->is_interface())) {
 975     if (resolved->is_interface()) {
 976       m = LinkResolver::resolve_interface_call_or_null(recv_klass, link_info);
 977     } else {
 978       m = LinkResolver::resolve_virtual_call_or_null(recv_klass, link_info);
 979     }
 980   }
 981 
 982   if (m.is_null()) {
 983     // Return NULL if there was a problem with lookup (uninitialized class, etc.)
 984     return NULL;
 985   }
 986 
 987   oop result = CompilerToVM::get_jvmci_method(m, CHECK_NULL);
 988   return JNIHandles::make_local(THREAD, result);
 989 C2V_END
 990 
 991 C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject jvmci_type))
 992   Klass* klass = CompilerToVM::asKlass(jvmci_type);
 993   assert(klass != NULL, "method must not be called for primitive types");
 994   return Dependencies::find_finalizable_subclass(klass) != NULL;


1229   if (jap.get_ret_type() == T_VOID) {
1230     return NULL;
1231   } else if (jap.get_ret_type() == T_OBJECT || jap.get_ret_type() == T_ARRAY) {
1232     return JNIHandles::make_local(THREAD, (oop) result.get_jobject());
1233   } else {
1234     jvalue *value = (jvalue *) result.get_value_addr();
1235     // Narrow the value down if required (Important on big endian machines)
1236     switch (jap.get_ret_type()) {
1237       case T_BOOLEAN:
1238        value->z = (jboolean) value->i;
1239        break;
1240       case T_BYTE:
1241        value->b = (jbyte) value->i;
1242        break;
1243       case T_CHAR:
1244        value->c = (jchar) value->i;
1245        break;
1246       case T_SHORT:
1247        value->s = (jshort) value->i;
1248        break;
1249       default:
1250         break;
1251     }
1252     oop o = java_lang_boxing_object::create(jap.get_ret_type(), value, CHECK_NULL);
1253     return JNIHandles::make_local(THREAD, o);
1254   }
1255 C2V_END
1256 
1257 C2V_VMENTRY(jlongArray, getLineNumberTable, (JNIEnv *, jobject, jobject jvmci_method))
1258   Method* method = CompilerToVM::asMethod(jvmci_method);
1259   if (!method->has_linenumber_table()) {
1260     return NULL;
1261   }
1262   u2 num_entries = 0;
1263   CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table());
1264   while (streamForSize.read_pair()) {
1265     num_entries++;
1266   }
1267 
1268   CompressedLineNumberReadStream stream(method->compressed_linenumber_table());
1269   typeArrayOop result = oopFactory::new_longArray(2 * num_entries, CHECK_NULL);
1270 


< prev index next >