comparison src/share/vm/oops/methodOop.cpp @ 3464:be4ca325525a

Merge.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Jul 2011 17:32:44 -0700
parents 9b8f30608e62 81d815b05abb
children 04b9a2566eec
comparison
equal deleted inserted replaced
3239:7c4b4daac19b 3464:be4ca325525a
697 } 697 }
698 698
699 // Called when the method_holder is getting linked. Setup entrypoints so the method 699 // Called when the method_holder is getting linked. Setup entrypoints so the method
700 // is ready to be called from interpreter, compiler, and vtables. 700 // is ready to be called from interpreter, compiler, and vtables.
701 void methodOopDesc::link_method(methodHandle h_method, TRAPS) { 701 void methodOopDesc::link_method(methodHandle h_method, TRAPS) {
702 assert(_i2i_entry == NULL, "should only be called once"); 702 // If the code cache is full, we may reenter this function for the
703 // leftover methods that weren't linked.
704 if (_i2i_entry != NULL) return;
705
703 assert(_adapter == NULL, "init'd to NULL" ); 706 assert(_adapter == NULL, "init'd to NULL" );
704 assert( _code == NULL, "nothing compiled yet" ); 707 assert( _code == NULL, "nothing compiled yet" );
705 708
706 // Setup interpreter entrypoint 709 // Setup interpreter entrypoint
707 assert(this == h_method(), "wrong h_method()" ); 710 assert(this == h_method(), "wrong h_method()" );
929 932
930 // invariant: cp->symbol_at_put is preceded by a refcount increment (more usually a lookup) 933 // invariant: cp->symbol_at_put is preceded by a refcount increment (more usually a lookup)
931 name->increment_refcount(); 934 name->increment_refcount();
932 signature->increment_refcount(); 935 signature->increment_refcount();
933 936
937 // record non-BCP method types in the constant pool
938 GrowableArray<KlassHandle>* extra_klasses = NULL;
939 for (int i = -1, len = java_lang_invoke_MethodType::ptype_count(method_type()); i < len; i++) {
940 oop ptype = (i == -1
941 ? java_lang_invoke_MethodType::rtype(method_type())
942 : java_lang_invoke_MethodType::ptype(method_type(), i));
943 klassOop klass = check_non_bcp_klass(java_lang_Class::as_klassOop(ptype));
944 if (klass != NULL) {
945 if (extra_klasses == NULL)
946 extra_klasses = new GrowableArray<KlassHandle>(len+1);
947 bool dup = false;
948 for (int j = 0; j < extra_klasses->length(); j++) {
949 if (extra_klasses->at(j) == klass) { dup = true; break; }
950 }
951 if (!dup)
952 extra_klasses->append(KlassHandle(THREAD, klass));
953 }
954 }
955
956 int extra_klass_count = (extra_klasses == NULL ? 0 : extra_klasses->length());
957 int cp_length = _imcp_limit + extra_klass_count;
934 constantPoolHandle cp; 958 constantPoolHandle cp;
935 { 959 {
936 constantPoolOop cp_oop = oopFactory::new_constantPool(_imcp_limit, IsSafeConc, CHECK_(empty)); 960 constantPoolOop cp_oop = oopFactory::new_constantPool(cp_length, IsSafeConc, CHECK_(empty));
937 cp = constantPoolHandle(THREAD, cp_oop); 961 cp = constantPoolHandle(THREAD, cp_oop);
938 } 962 }
939 cp->symbol_at_put(_imcp_invoke_name, name); 963 cp->symbol_at_put(_imcp_invoke_name, name);
940 cp->symbol_at_put(_imcp_invoke_signature, signature); 964 cp->symbol_at_put(_imcp_invoke_signature, signature);
941 cp->string_at_put(_imcp_method_type_value, Universe::the_null_string()); 965 cp->string_at_put(_imcp_method_type_value, Universe::the_null_string());
966 for (int j = 0; j < extra_klass_count; j++) {
967 KlassHandle klass = extra_klasses->at(j);
968 cp->klass_at_put(_imcp_limit + j, klass());
969 }
970 cp->set_preresolution();
942 cp->set_pool_holder(holder()); 971 cp->set_pool_holder(holder());
943 972
944 // set up the fancy stuff: 973 // set up the fancy stuff:
945 cp->pseudo_string_at_put(_imcp_method_type_value, method_type()); 974 cp->pseudo_string_at_put(_imcp_method_type_value, method_type());
946 methodHandle m; 975 methodHandle m;
985 m->print_on(tty); 1014 m->print_on(tty);
986 1015
987 return m; 1016 return m;
988 } 1017 }
989 1018
1019 klassOop methodOopDesc::check_non_bcp_klass(klassOop klass) {
1020 if (klass != NULL && Klass::cast(klass)->class_loader() != NULL) {
1021 if (Klass::cast(klass)->oop_is_objArray())
1022 klass = objArrayKlass::cast(klass)->bottom_klass();
1023 return klass;
1024 }
1025 return NULL;
1026 }
990 1027
991 1028
992 methodHandle methodOopDesc:: clone_with_new_data(methodHandle m, u_char* new_code, int new_code_length, 1029 methodHandle methodOopDesc:: clone_with_new_data(methodHandle m, u_char* new_code, int new_code_length,
993 u_char* new_compressed_linenumber_table, int new_compressed_linenumber_size, TRAPS) { 1030 u_char* new_compressed_linenumber_table, int new_compressed_linenumber_size, TRAPS) {
994 // Code below does not work for native methods - they should never get rewritten anyway 1031 // Code below does not work for native methods - they should never get rewritten anyway