< prev index next >

src/hotspot/share/oops/klassVtable.cpp

Print this page

        

*** 255,265 **** // add miranda methods; it will also return the updated initialized // Interfaces do not need interface methods in their vtables // This includes miranda methods and during later processing, default methods if (!ik()->is_interface()) { ! initialized = fill_in_mirandas(initialized); } // In class hierarchies where the accessibility is not increasing (i.e., going from private -> // package_private -> public/protected), the vtable might actually be smaller than our initial // calculation, for classfile versions for which we do not do transitive override --- 255,265 ---- // add miranda methods; it will also return the updated initialized // Interfaces do not need interface methods in their vtables // This includes miranda methods and during later processing, default methods if (!ik()->is_interface()) { ! initialized = fill_in_mirandas(initialized, THREAD); } // In class hierarchies where the accessibility is not increasing (i.e., going from private -> // package_private -> public/protected), the vtable might actually be smaller than our initial // calculation, for classfile versions for which we do not do transitive override
*** 362,372 **** // Only called for InstanceKlass's, i.e. not for arrays // If that changed, could not use _klass as handle for klass bool klassVtable::update_inherited_vtable(InstanceKlass* klass, const methodHandle& target_method, int super_vtable_len, int default_index, bool checkconstraints, TRAPS) { ! ResourceMark rm; bool allocate_new = true; assert(klass->is_instance_klass(), "must be InstanceKlass"); Array<int>* def_vtable_indices = NULL; bool is_default = false; --- 362,372 ---- // Only called for InstanceKlass's, i.e. not for arrays // If that changed, could not use _klass as handle for klass bool klassVtable::update_inherited_vtable(InstanceKlass* klass, const methodHandle& target_method, int super_vtable_len, int default_index, bool checkconstraints, TRAPS) { ! ResourceMark rm(THREAD); bool allocate_new = true; assert(klass->is_instance_klass(), "must be InstanceKlass"); Array<int>* def_vtable_indices = NULL; bool is_default = false;
*** 900,918 **** // Discover miranda methods ("miranda" = "interface abstract, no binding"), // and append them into the vtable starting at index initialized, // return the new value of initialized. // Miranda methods use vtable entries, but do not get assigned a vtable_index // The vtable_index is discovered by searching from the end of the vtable ! int klassVtable::fill_in_mirandas(int initialized) { GrowableArray<Method*> mirandas(20); get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(), ik()->default_methods(), ik()->local_interfaces(), klass()->is_interface()); for (int i = 0; i < mirandas.length(); i++) { if (log_develop_is_enabled(Trace, vtables)) { Method* meth = mirandas.at(i); - ResourceMark rm(Thread::current()); LogTarget(Trace, vtables) lt; LogStream ls(lt); if (meth != NULL) { char* sig = meth->name_and_sig_as_C_string(); ls.print("fill in mirandas with %s index %d, flags: ", --- 900,918 ---- // Discover miranda methods ("miranda" = "interface abstract, no binding"), // and append them into the vtable starting at index initialized, // return the new value of initialized. // Miranda methods use vtable entries, but do not get assigned a vtable_index // The vtable_index is discovered by searching from the end of the vtable ! int klassVtable::fill_in_mirandas(int initialized, TRAPS) { ! ResourceMark rm(THREAD); GrowableArray<Method*> mirandas(20); get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(), ik()->default_methods(), ik()->local_interfaces(), klass()->is_interface()); for (int i = 0; i < mirandas.length(); i++) { if (log_develop_is_enabled(Trace, vtables)) { Method* meth = mirandas.at(i); LogTarget(Trace, vtables) lt; LogStream ls(lt); if (meth != NULL) { char* sig = meth->name_and_sig_as_C_string(); ls.print("fill in mirandas with %s index %d, flags: ",
*** 1083,1093 **** // Initialization void klassItable::initialize_itable(bool checkconstraints, TRAPS) { if (_klass->is_interface()) { // This needs to go after vtable indices are assigned but // before implementors need to know the number of itable indices. ! assign_itable_indices_for_interface(_klass); } // Cannot be setup doing bootstrapping, interfaces don't have // itables, and klass with only ones entry have empty itables if (Universe::is_bootstrapping() || --- 1083,1093 ---- // Initialization void klassItable::initialize_itable(bool checkconstraints, TRAPS) { if (_klass->is_interface()) { // This needs to go after vtable indices are assigned but // before implementors need to know the number of itable indices. ! assign_itable_indices_for_interface(_klass, THREAD); } // Cannot be setup doing bootstrapping, interfaces don't have // itables, and klass with only ones entry have empty itables if (Universe::is_bootstrapping() ||
*** 1096,1105 **** --- 1096,1106 ---- // There's alway an extra itable entry so we can null-terminate it. guarantee(size_offset_table() >= 1, "too small"); int num_interfaces = size_offset_table() - 1; if (num_interfaces > 0) { + ResourceMark rm(THREAD); log_develop_debug(itables)("%3d: Initializing itables for %s", ++initialize_count, _klass->name()->as_C_string()); // Iterate through all interfaces
*** 1128,1139 **** // e.g., CharSequence.toString (from initialize_vtable) // if (m->has_vtable_index()) return false; // NO! return true; } ! int klassItable::assign_itable_indices_for_interface(Klass* klass) { // an interface does not have an itable, but its methods need to be numbered log_develop_debug(itables)("%3d: Initializing itable indices for interface %s", ++initialize_count, klass->name()->as_C_string()); Array<Method*>* methods = InstanceKlass::cast(klass)->methods(); int nof_methods = methods->length(); int ime_num = 0; --- 1129,1141 ---- // e.g., CharSequence.toString (from initialize_vtable) // if (m->has_vtable_index()) return false; // NO! return true; } ! int klassItable::assign_itable_indices_for_interface(Klass* klass, TRAPS) { // an interface does not have an itable, but its methods need to be numbered + ResourceMark rm(THREAD); log_develop_debug(itables)("%3d: Initializing itable indices for interface %s", ++initialize_count, klass->name()->as_C_string()); Array<Method*>* methods = InstanceKlass::cast(klass)->methods(); int nof_methods = methods->length(); int ime_num = 0;
*** 1141,1151 **** Method* m = methods->at(i); if (interface_method_needs_itable_index(m)) { assert(!m->is_final_method(), "no final interface methods"); // If m is already assigned a vtable index, do not disturb it. if (log_develop_is_enabled(Trace, itables)) { - ResourceMark rm; LogTarget(Trace, itables) lt; LogStream ls(lt); assert(m != NULL, "methods can never be null"); const char* sig = m->name_and_sig_as_C_string(); if (m->has_vtable_index()) { --- 1143,1152 ----
*** 1505,1514 **** --- 1506,1516 ---- _verify_count = Universe::verify_count(); #endif oop* end_of_obj = (oop*)_klass + _klass->size(); oop* end_of_vtable = (oop *)&table()[_length]; if (end_of_vtable > end_of_obj) { + ResourceMark rm; fatal("klass %s: klass object too short (vtable extends beyond end)", _klass->internal_name()); } for (int i = 0; i < _length; i++) table()[i].verify(this, st);
< prev index next >