# HG changeset patch # User drchase # Date 1383836548 18000 # Node ID 53662b2f1d6862a80d5c7cfd702032ac65c95bb7 # Parent 04df110c8655419439f882ceaf9bfbe45fcb7248# Parent be525e91f65b388864cb46caf9049a6682ba95c9 Merge diff -r be525e91f65b -r 53662b2f1d68 src/cpu/x86/vm/interp_masm_x86_32.cpp --- a/src/cpu/x86/vm/interp_masm_x86_32.cpp Wed Nov 06 06:51:24 2013 -0800 +++ b/src/cpu/x86/vm/interp_masm_x86_32.cpp Thu Nov 07 10:02:28 2013 -0500 @@ -196,7 +196,7 @@ void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp(Register reg, int bcp_offset) { assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode"); - movl(reg, Address(rsi, bcp_offset)); + load_unsigned_short(reg, Address(rsi, bcp_offset)); bswapl(reg); shrl(reg, 16); } diff -r be525e91f65b -r 53662b2f1d68 src/cpu/x86/vm/interp_masm_x86_64.cpp --- a/src/cpu/x86/vm/interp_masm_x86_64.cpp Wed Nov 06 06:51:24 2013 -0800 +++ b/src/cpu/x86/vm/interp_masm_x86_64.cpp Thu Nov 07 10:02:28 2013 -0500 @@ -192,7 +192,7 @@ Register reg, int bcp_offset) { assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode"); - movl(reg, Address(r13, bcp_offset)); + load_unsigned_short(reg, Address(r13, bcp_offset)); bswapl(reg); shrl(reg, 16); } diff -r be525e91f65b -r 53662b2f1d68 src/cpu/x86/vm/templateTable_x86_32.cpp --- a/src/cpu/x86/vm/templateTable_x86_32.cpp Wed Nov 06 06:51:24 2013 -0800 +++ b/src/cpu/x86/vm/templateTable_x86_32.cpp Thu Nov 07 10:02:28 2013 -0500 @@ -558,7 +558,7 @@ void TemplateTable::locals_index_wide(Register reg) { - __ movl(reg, at_bcp(2)); + __ load_unsigned_short(reg, at_bcp(2)); __ bswapl(reg); __ shrl(reg, 16); __ negptr(reg); @@ -1552,7 +1552,11 @@ InvocationCounter::counter_offset(); // Load up EDX with the branch displacement - __ movl(rdx, at_bcp(1)); + if (is_wide) { + __ movl(rdx, at_bcp(1)); + } else { + __ load_signed_short(rdx, at_bcp(1)); + } __ bswapl(rdx); if (!is_wide) __ sarl(rdx, 16); LP64_ONLY(__ movslq(rdx, rdx)); diff -r be525e91f65b -r 53662b2f1d68 src/cpu/x86/vm/templateTable_x86_64.cpp --- a/src/cpu/x86/vm/templateTable_x86_64.cpp Wed Nov 06 06:51:24 2013 -0800 +++ b/src/cpu/x86/vm/templateTable_x86_64.cpp Thu Nov 07 10:02:28 2013 -0500 @@ -568,7 +568,7 @@ } void TemplateTable::locals_index_wide(Register reg) { - __ movl(reg, at_bcp(2)); + __ load_unsigned_short(reg, at_bcp(2)); __ bswapl(reg); __ shrl(reg, 16); __ negptr(reg); @@ -1575,7 +1575,11 @@ InvocationCounter::counter_offset(); // Load up edx with the branch displacement - __ movl(rdx, at_bcp(1)); + if (is_wide) { + __ movl(rdx, at_bcp(1)); + } else { + __ load_signed_short(rdx, at_bcp(1)); + } __ bswapl(rdx); if (!is_wide) { diff -r be525e91f65b -r 53662b2f1d68 src/share/vm/classfile/defaultMethods.cpp --- a/src/share/vm/classfile/defaultMethods.cpp Wed Nov 06 06:51:24 2013 -0800 +++ b/src/share/vm/classfile/defaultMethods.cpp Thu Nov 07 10:02:28 2013 -0500 @@ -392,10 +392,16 @@ } GrowableArray qualified_methods; + int num_defaults = 0; + int default_index = -1; for (int i = 0; i < _members.length(); ++i) { Pair entry = _members.at(i); if (entry.second == QUALIFIED) { qualified_methods.append(entry.first); + default_index++; + if (entry.first->is_default_method()) { + num_defaults++; + } } } @@ -408,6 +414,9 @@ if (!method->is_abstract()) { _selected_target = qualified_methods.at(0); } + // If only one qualified method is default, select that + } else if (num_defaults == 1) { + _selected_target = qualified_methods.at(default_index); } else { _exception_message = generate_conflicts_message(&qualified_methods,CHECK); _exception_name = vmSymbols::java_lang_IncompatibleClassChangeError(); diff -r be525e91f65b -r 53662b2f1d68 src/share/vm/classfile/metadataOnStackMark.cpp --- a/src/share/vm/classfile/metadataOnStackMark.cpp Wed Nov 06 06:51:24 2013 -0800 +++ b/src/share/vm/classfile/metadataOnStackMark.cpp Thu Nov 07 10:02:28 2013 -0500 @@ -27,6 +27,7 @@ #include "code/codeCache.hpp" #include "compiler/compileBroker.hpp" #include "oops/metadata.hpp" +#include "prims/jvmtiImpl.hpp" #include "runtime/synchronizer.hpp" #include "runtime/thread.hpp" #include "utilities/growableArray.hpp" @@ -48,6 +49,7 @@ Threads::metadata_do(Metadata::mark_on_stack); CodeCache::alive_nmethods_do(nmethod::mark_on_stack); CompileBroker::mark_on_stack(); + JvmtiCurrentBreakpoints::metadata_do(Metadata::mark_on_stack); } MetadataOnStackMark::~MetadataOnStackMark() { diff -r be525e91f65b -r 53662b2f1d68 src/share/vm/memory/metaspace.cpp --- a/src/share/vm/memory/metaspace.cpp Wed Nov 06 06:51:24 2013 -0800 +++ b/src/share/vm/memory/metaspace.cpp Thu Nov 07 10:02:28 2013 -0500 @@ -2869,7 +2869,7 @@ Universe::set_narrow_klass_base(lower_base); - if ((uint64_t)(higher_address - lower_base) < UnscaledClassSpaceMax) { + if ((uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax) { Universe::set_narrow_klass_shift(0); } else { assert(!UseSharedSpaces, "Cannot shift with UseSharedSpaces"); @@ -2885,7 +2885,7 @@ address lower_base = MIN2((address)metaspace_base, cds_base); address higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()), (address)(metaspace_base + compressed_class_space_size())); - return ((uint64_t)(higher_address - lower_base) < UnscaledClassSpaceMax); + return ((uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax); } // Try to allocate the metaspace at the requested addr. diff -r be525e91f65b -r 53662b2f1d68 src/share/vm/prims/jvmtiImpl.cpp --- a/src/share/vm/prims/jvmtiImpl.cpp Wed Nov 06 06:51:24 2013 -0800 +++ b/src/share/vm/prims/jvmtiImpl.cpp Thu Nov 07 10:02:28 2013 -0500 @@ -210,6 +210,14 @@ } } +void GrowableCache::metadata_do(void f(Metadata*)) { + int len = _elements->length(); + for (int i=0; iat(i); + e->metadata_do(f); + } +} + void GrowableCache::gc_epilogue() { int len = _elements->length(); for (int i=0; imethod_holder()->class_loader_data()->class_loader(); + _class_holder = _method->method_holder()->klass_holder(); #ifdef CHECK_UNHANDLED_OOPS - // _class_loader can't be wrapped in a Handle, because JvmtiBreakpoint:s are - // eventually allocated on the heap. + // _class_holder can't be wrapped in a Handle, because JvmtiBreakpoints are + // sometimes allocated on the heap. // - // The code handling JvmtiBreakpoint:s allocated on the stack can't be - // interrupted by a GC until _class_loader is reachable by the GC via the + // The code handling JvmtiBreakpoints allocated on the stack can't be + // interrupted by a GC until _class_holder is reachable by the GC via the // oops_do method. - Thread::current()->allow_unhandled_oop(&_class_loader); + Thread::current()->allow_unhandled_oop(&_class_holder); #endif // CHECK_UNHANDLED_OOPS assert(_method != NULL, "_method != NULL"); _bci = (int) location; @@ -247,7 +255,7 @@ void JvmtiBreakpoint::copy(JvmtiBreakpoint& bp) { _method = bp._method; _bci = bp._bci; - _class_loader = bp._class_loader; + _class_holder = bp._class_holder; } bool JvmtiBreakpoint::lessThan(JvmtiBreakpoint& bp) { @@ -365,6 +373,13 @@ } } +void VM_ChangeBreakpoints::metadata_do(void f(Metadata*)) { + // Walk metadata in breakpoints to keep from being deallocated with RedefineClasses + if (_bp != NULL) { + _bp->metadata_do(f); + } +} + // // class JvmtiBreakpoints // @@ -381,6 +396,10 @@ _bps.oops_do(f); } +void JvmtiBreakpoints::metadata_do(void f(Metadata*)) { + _bps.metadata_do(f); +} + void JvmtiBreakpoints::gc_epilogue() { _bps.gc_epilogue(); } @@ -499,6 +518,12 @@ } } +void JvmtiCurrentBreakpoints::metadata_do(void f(Metadata*)) { + if (_jvmti_breakpoints != NULL) { + _jvmti_breakpoints->metadata_do(f); + } +} + void JvmtiCurrentBreakpoints::gc_epilogue() { if (_jvmti_breakpoints != NULL) { _jvmti_breakpoints->gc_epilogue(); diff -r be525e91f65b -r 53662b2f1d68 src/share/vm/prims/jvmtiImpl.hpp --- a/src/share/vm/prims/jvmtiImpl.hpp Wed Nov 06 06:51:24 2013 -0800 +++ b/src/share/vm/prims/jvmtiImpl.hpp Thu Nov 07 10:02:28 2013 -0500 @@ -69,6 +69,7 @@ virtual bool lessThan(GrowableElement *e)=0; virtual GrowableElement *clone() =0; virtual void oops_do(OopClosure* f) =0; + virtual void metadata_do(void f(Metadata*)) =0; }; class GrowableCache VALUE_OBJ_CLASS_SPEC { @@ -115,6 +116,8 @@ void clear(); // apply f to every element and update the cache void oops_do(OopClosure* f); + // walk metadata to preserve for RedefineClasses + void metadata_do(void f(Metadata*)); // update the cache after a full gc void gc_epilogue(); }; @@ -148,6 +151,7 @@ void remove (int index) { _cache.remove(index); } void clear() { _cache.clear(); } void oops_do(OopClosure* f) { _cache.oops_do(f); } + void metadata_do(void f(Metadata*)) { _cache.metadata_do(f); } void gc_epilogue() { _cache.gc_epilogue(); } }; @@ -169,7 +173,7 @@ Method* _method; int _bci; Bytecodes::Code _orig_bytecode; - oop _class_loader; + oop _class_holder; // keeps _method memory from being deallocated public: JvmtiBreakpoint(); @@ -191,9 +195,15 @@ bool lessThan(GrowableElement* e) { Unimplemented(); return false; } bool equals(GrowableElement* e) { return equals((JvmtiBreakpoint&) *e); } void oops_do(OopClosure* f) { - // Mark the method loader as live - f->do_oop(&_class_loader); + // Mark the method loader as live so the Method* class loader doesn't get + // unloaded and Method* memory reclaimed. + f->do_oop(&_class_holder); } + void metadata_do(void f(Metadata*)) { + // walk metadata to preserve for RedefineClasses + f(_method); + } + GrowableElement *clone() { JvmtiBreakpoint *bp = new JvmtiBreakpoint(); bp->copy(*this); @@ -239,6 +249,7 @@ int length(); void oops_do(OopClosure* f); + void metadata_do(void f(Metadata*)); void print(); int set(JvmtiBreakpoint& bp); @@ -288,6 +299,7 @@ static inline bool is_breakpoint(address bcp); static void oops_do(OopClosure* f); + static void metadata_do(void f(Metadata*)); static void gc_epilogue(); }; @@ -332,6 +344,7 @@ VMOp_Type type() const { return VMOp_ChangeBreakpoints; } void doit(); void oops_do(OopClosure* f); + void metadata_do(void f(Metadata*)); };