926 |
926 |
927 // invariant: cp->symbol_at_put is preceded by a refcount increment (more usually a lookup) |
927 // invariant: cp->symbol_at_put is preceded by a refcount increment (more usually a lookup) |
928 name->increment_refcount(); |
928 name->increment_refcount(); |
929 signature->increment_refcount(); |
929 signature->increment_refcount(); |
930 |
930 |
|
931 // record non-BCP method types in the constant pool |
|
932 GrowableArray<KlassHandle>* extra_klasses = NULL; |
|
933 for (int i = -1, len = java_lang_invoke_MethodType::ptype_count(method_type()); i < len; i++) { |
|
934 oop ptype = (i == -1 |
|
935 ? java_lang_invoke_MethodType::rtype(method_type()) |
|
936 : java_lang_invoke_MethodType::ptype(method_type(), i)); |
|
937 klassOop klass = check_non_bcp_klass(java_lang_Class::as_klassOop(ptype)); |
|
938 if (klass != NULL) { |
|
939 if (extra_klasses == NULL) |
|
940 extra_klasses = new GrowableArray<KlassHandle>(len+1); |
|
941 bool dup = false; |
|
942 for (int j = 0; j < extra_klasses->length(); j++) { |
|
943 if (extra_klasses->at(j) == klass) { dup = true; break; } |
|
944 } |
|
945 if (!dup) |
|
946 extra_klasses->append(KlassHandle(THREAD, klass)); |
|
947 } |
|
948 } |
|
949 |
|
950 int extra_klass_count = (extra_klasses == NULL ? 0 : extra_klasses->length()); |
|
951 int cp_length = _imcp_limit + extra_klass_count; |
931 constantPoolHandle cp; |
952 constantPoolHandle cp; |
932 { |
953 { |
933 constantPoolOop cp_oop = oopFactory::new_constantPool(_imcp_limit, IsSafeConc, CHECK_(empty)); |
954 constantPoolOop cp_oop = oopFactory::new_constantPool(cp_length, IsSafeConc, CHECK_(empty)); |
934 cp = constantPoolHandle(THREAD, cp_oop); |
955 cp = constantPoolHandle(THREAD, cp_oop); |
935 } |
956 } |
936 cp->symbol_at_put(_imcp_invoke_name, name); |
957 cp->symbol_at_put(_imcp_invoke_name, name); |
937 cp->symbol_at_put(_imcp_invoke_signature, signature); |
958 cp->symbol_at_put(_imcp_invoke_signature, signature); |
938 cp->string_at_put(_imcp_method_type_value, Universe::the_null_string()); |
959 cp->string_at_put(_imcp_method_type_value, Universe::the_null_string()); |
|
960 for (int j = 0; j < extra_klass_count; j++) { |
|
961 KlassHandle klass = extra_klasses->at(j); |
|
962 cp->klass_at_put(_imcp_limit + j, klass()); |
|
963 } |
|
964 cp->set_preresolution(); |
939 cp->set_pool_holder(holder()); |
965 cp->set_pool_holder(holder()); |
940 |
966 |
941 // set up the fancy stuff: |
967 // set up the fancy stuff: |
942 cp->pseudo_string_at_put(_imcp_method_type_value, method_type()); |
968 cp->pseudo_string_at_put(_imcp_method_type_value, method_type()); |
943 methodHandle m; |
969 methodHandle m; |
982 m->print_on(tty); |
1008 m->print_on(tty); |
983 |
1009 |
984 return m; |
1010 return m; |
985 } |
1011 } |
986 |
1012 |
|
1013 klassOop methodOopDesc::check_non_bcp_klass(klassOop klass) { |
|
1014 if (klass != NULL && Klass::cast(klass)->class_loader() != NULL) { |
|
1015 if (Klass::cast(klass)->oop_is_objArray()) |
|
1016 klass = objArrayKlass::cast(klass)->bottom_klass(); |
|
1017 return klass; |
|
1018 } |
|
1019 return NULL; |
|
1020 } |
987 |
1021 |
988 |
1022 |
989 methodHandle methodOopDesc:: clone_with_new_data(methodHandle m, u_char* new_code, int new_code_length, |
1023 methodHandle methodOopDesc:: clone_with_new_data(methodHandle m, u_char* new_code, int new_code_length, |
990 u_char* new_compressed_linenumber_table, int new_compressed_linenumber_size, TRAPS) { |
1024 u_char* new_compressed_linenumber_table, int new_compressed_linenumber_size, TRAPS) { |
991 // Code below does not work for native methods - they should never get rewritten anyway |
1025 // Code below does not work for native methods - they should never get rewritten anyway |