From 832066084613e148310e6abcfd6941d097602513 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Tue, 7 May 2013 09:46:15 -0400 Subject: [PATCH 1/7] 8013063: nsk/jvmti/RetransformClasses/retransform001 failed debug version on os::free Clear out class_file_bytes so they aren't deallocated twice Reviewed-by: dcubed, sspitsyn --- hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp index 4e8e8c0e097..d7c6b8855b6 100644 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp @@ -3366,6 +3366,10 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass, } #endif + // NULL out in scratch class to not delete twice. The class to be redefined + // always owns these bytes. + scratch_class->set_cached_class_file(NULL, 0); + // Replace inner_classes Array* old_inner_classes = the_class->inner_classes(); the_class->set_inner_classes(scratch_class->inner_classes()); From 32df114e2a3c9aaf63dd06f937e2539795a07260 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Tue, 7 May 2013 18:51:31 -0400 Subject: [PATCH 2/7] 8014024: NPG: keep compiled ic methods from being deallocated in redefine classes Walk the compiledIC relocation records to keep Method* from being deallocated. Reviewed-by: dlong, kvn --- hotspot/src/share/vm/code/nmethod.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 60bc88b7734..597a7ac548e 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -1794,6 +1794,19 @@ void nmethod::metadata_do(void f(Metadata*)) { Metadata* md = r->metadata_value(); f(md); } + } else if (iter.type() == relocInfo::virtual_call_type) { + // Check compiledIC holders associated with this nmethod + CompiledIC *ic = CompiledIC_at(iter.reloc()); + if (ic->is_icholder_call()) { + CompiledICHolder* cichk = ic->cached_icholder(); + f(cichk->holder_method()); + f(cichk->holder_klass()); + } else { + Metadata* ic_oop = ic->cached_metadata(); + if (ic_oop != NULL) { + f(ic_oop); + } + } } } } @@ -1804,6 +1817,7 @@ void nmethod::metadata_do(void f(Metadata*)) { Metadata* md = *p; f(md); } + // Call function Method*, not embedded in these other places. if (_method != NULL) f(_method); } From dc96e028d2078f52246c13090b911922d2818c16 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Wed, 8 May 2013 08:20:45 -0400 Subject: [PATCH 3/7] 8007018: RFE: -XX:+UseLargePages does not work with CDS Remove command line restriction. It should just work. Reviewed-by: ctornqvi, coleenp, dholmes --- hotspot/src/share/vm/runtime/arguments.cpp | 45 +++++++++------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index b2ff4e5f9d2..a23a3b52323 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -3084,36 +3084,27 @@ jint Arguments::parse_options_environment_variable(const char* name, SysClassPat } void Arguments::set_shared_spaces_flags() { - const bool must_share = DumpSharedSpaces || RequireSharedSpaces; - const bool might_share = must_share || UseSharedSpaces; +#ifdef _LP64 + const bool must_share = DumpSharedSpaces || RequireSharedSpaces; - // CompressedOops cannot be used with CDS. The offsets of oopmaps and - // static fields are incorrect in the archive. With some more clever - // initialization, this restriction can probably be lifted. - // ??? UseLargePages might be okay now - const bool cannot_share = UseCompressedOops || - (UseLargePages && FLAG_IS_CMDLINE(UseLargePages)); - if (cannot_share) { - if (must_share) { - warning("disabling large pages %s" - "because of %s", "" LP64_ONLY("and compressed oops "), - DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on"); - FLAG_SET_CMDLINE(bool, UseLargePages, false); - LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedOops, false)); - LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedKlassPointers, false)); - } else { - // Prefer compressed oops and large pages to class data sharing - if (UseSharedSpaces && Verbose) { - warning("turning off use of shared archive because of large pages%s", - "" LP64_ONLY(" and/or compressed oops")); + // CompressedOops cannot be used with CDS. The offsets of oopmaps and + // static fields are incorrect in the archive. With some more clever + // initialization, this restriction can probably be lifted. + if (UseCompressedOops) { + if (must_share) { + warning("disabling compressed oops because of %s", + DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on"); + FLAG_SET_CMDLINE(bool, UseCompressedOops, false); + FLAG_SET_CMDLINE(bool, UseCompressedKlassPointers, false); + } else { + // Prefer compressed oops to class data sharing + if (UseSharedSpaces && Verbose) { + warning("turning off use of shared archive because of compressed oops"); + } + no_shared_spaces(); } - no_shared_spaces(); } - } else if (UseLargePages && might_share) { - // Disable large pages to allow shared spaces. This is sub-optimal, since - // there may not even be a shared archive to use. - FLAG_SET_DEFAULT(UseLargePages, false); - } +#endif if (DumpSharedSpaces) { if (RequireSharedSpaces) { From 7a1ccbc48afa4db971d001b171118dd389cede0b Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Wed, 8 May 2013 15:37:18 +0200 Subject: [PATCH 4/7] 8013591: compiler/ciReplay/TestSA.sh fails in nightly Reviewed-by: coleenp, rbackman, dholmes --- .../classes/sun/jvm/hotspot/ci/ciMethod.java | 4 +- .../classes/sun/jvm/hotspot/oops/Method.java | 38 +++++++++++-------- .../sun/jvm/hotspot/oops/MethodData.java | 4 +- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java index 3468b0d6514..d50e36c2a74 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java @@ -97,8 +97,8 @@ public class ciMethod extends ciMetadata { holder.getName().asString() + " " + OopUtilities.escapeString(method.getName().asString()) + " " + method.getSignature().asString() + " " + - method.getInvocationCounter() + " " + - method.getBackedgeCounter() + " " + + method.getInvocationCount() + " " + + method.getBackedgeCount() + " " + interpreterInvocationCount() + " " + interpreterThrowoutCount() + " " + instructionsSize()); diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java index c61d58dc429..e039470f801 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java @@ -24,15 +24,21 @@ package sun.jvm.hotspot.oops; -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.code.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.interpreter.*; -import sun.jvm.hotspot.memory.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; +import java.io.PrintStream; +import java.util.Observable; +import java.util.Observer; + +import sun.jvm.hotspot.code.NMethod; +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.interpreter.OopMapCacheEntry; +import sun.jvm.hotspot.runtime.SignatureConverter; +import sun.jvm.hotspot.runtime.VM; +import sun.jvm.hotspot.runtime.VMObjectFactory; +import sun.jvm.hotspot.types.AddressField; +import sun.jvm.hotspot.types.Type; +import sun.jvm.hotspot.types.TypeDataBase; +import sun.jvm.hotspot.types.WrongTypeException; +import sun.jvm.hotspot.utilities.Assert; // A Method represents a Java method @@ -132,11 +138,13 @@ public class Method extends Metadata { public long getAccessFlags() { return accessFlags.getValue(this); } public long getCodeSize() { return getConstMethod().getCodeSize(); } public long getVtableIndex() { return vtableIndex.getValue(this); } - public long getInvocationCounter() { - return getMethodCounters().getInvocationCounter(); + public long getInvocationCount() { + MethodCounters mc = getMethodCounters(); + return mc == null ? 0 : mc.getInvocationCounter(); } - public long getBackedgeCounter() { - return getMethodCounters().getBackedgeCounter(); + public long getBackedgeCount() { + MethodCounters mc = getMethodCounters(); + return mc == null ? 0 : mc.getBackedgeCounter(); } // get associated compiled native method, if available, else return null. @@ -349,8 +357,8 @@ public class Method extends Metadata { holder.getName().asString() + " " + OopUtilities.escapeString(getName().asString()) + " " + getSignature().asString() + " " + - getInvocationCounter() + " " + - getBackedgeCounter() + " " + + getInvocationCount() + " " + + getBackedgeCount() + " " + interpreterInvocationCount() + " " + interpreterThrowoutCount() + " " + code_size); diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java index a397ec353ac..eb643483fe5 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java @@ -316,8 +316,8 @@ public class MethodData extends Metadata { int iic = method.interpreterInvocationCount(); if (mileage < iic) mileage = iic; - long ic = method.getInvocationCounter(); - long bc = method.getBackedgeCounter(); + long ic = method.getInvocationCount(); + long bc = method.getBackedgeCount(); long icval = ic >> 3; if ((ic & 4) != 0) icval += CompileThreshold; From 6b031570b63dac00aec04ea782071d71e6ef132c Mon Sep 17 00:00:00 2001 From: Bharadwaj Yadavalli Date: Wed, 8 May 2013 14:18:03 -0700 Subject: [PATCH 5/7] 8013875: Incorrect vtable index being set during methodHandle creation for static Set vtable index as appropriate for static interface methods and for interface methods invoked via invokespecial. To be improved in a later enhancement to CallInfo. Reviewed-by: jrose, twisti --- hotspot/src/share/vm/prims/methodHandles.cpp | 32 ++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/hotspot/src/share/vm/prims/methodHandles.cpp b/hotspot/src/share/vm/prims/methodHandles.cpp index 34104985237..a1dba8dc8bf 100644 --- a/hotspot/src/share/vm/prims/methodHandles.cpp +++ b/hotspot/src/share/vm/prims/methodHandles.cpp @@ -193,19 +193,15 @@ oop MethodHandles::init_method_MemberName(Handle mname, Method* m, bool do_dispa flags |= IS_CONSTRUCTOR | (JVM_REF_invokeSpecial << REFERENCE_KIND_SHIFT); } else if (mods.is_static()) { flags |= IS_METHOD | (JVM_REF_invokeStatic << REFERENCE_KIND_SHIFT); - // Get vindex from itable if method holder is an interface. - if (m->method_holder()->is_interface()) { - vmindex = klassItable::compute_itable_index(m); - } } else if (receiver_limit != mklass && !receiver_limit->is_subtype_of(mklass)) { return NULL; // bad receiver limit - } else if (receiver_limit->is_interface() && + } else if (do_dispatch && receiver_limit->is_interface() && mklass->is_interface()) { flags |= IS_METHOD | (JVM_REF_invokeInterface << REFERENCE_KIND_SHIFT); receiver_limit = mklass; // ignore passed-in limit; interfaces are interconvertible vmindex = klassItable::compute_itable_index(m); - } else if (mklass != receiver_limit && mklass->is_interface()) { + } else if (do_dispatch && mklass != receiver_limit && mklass->is_interface()) { flags |= IS_METHOD | (JVM_REF_invokeVirtual << REFERENCE_KIND_SHIFT); // it is a miranda method, so m->vtable_index is not what we want ResourceMark rm; @@ -250,10 +246,25 @@ Handle MethodHandles::init_method_MemberName(Handle mname, CallInfo& info, TRAPS } methodHandle m = info.resolved_method(); KlassHandle defc = info.resolved_klass(); - int vmindex = -1; + int vmindex = Method::invalid_vtable_index; if (defc->is_interface() && m->method_holder()->is_interface()) { - // LinkResolver does not report itable indexes! (fix this?) - vmindex = klassItable::compute_itable_index(m()); + // static interface methods do not reference vtable or itable + if (m->is_static()) { + vmindex = Method::nonvirtual_vtable_index; + } + // interface methods invoked via invokespecial also + // do not reference vtable or itable. + int ref_kind = ((java_lang_invoke_MemberName::flags(mname()) >> + REFERENCE_KIND_SHIFT) & REFERENCE_KIND_MASK); + if (ref_kind == JVM_REF_invokeSpecial) { + vmindex = Method::nonvirtual_vtable_index; + } + // If neither m is static nor ref_kind is invokespecial, + // set it to itable index. + if (vmindex == Method::invalid_vtable_index) { + // LinkResolver does not report itable indexes! (fix this?) + vmindex = klassItable::compute_itable_index(m()); + } } else if (m->can_be_statically_bound()) { // LinkResolver reports vtable index even for final methods! vmindex = Method::nonvirtual_vtable_index; @@ -665,11 +676,9 @@ Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) { case IS_METHOD: { CallInfo result; - bool do_dispatch = true; // default, neutral setting { assert(!HAS_PENDING_EXCEPTION, ""); if (ref_kind == JVM_REF_invokeStatic) { - //do_dispatch = false; // no need, since statics are never dispatched LinkResolver::resolve_static_call(result, defc, name, type, KlassHandle(), false, false, THREAD); } else if (ref_kind == JVM_REF_invokeInterface) { @@ -680,7 +689,6 @@ Handle MethodHandles::resolve_MemberName(Handle mname, TRAPS) { LinkResolver::resolve_handle_call(result, defc, name, type, KlassHandle(), THREAD); } else if (ref_kind == JVM_REF_invokeSpecial) { - do_dispatch = false; // force non-virtual linkage LinkResolver::resolve_special_call(result, defc, name, type, KlassHandle(), false, THREAD); } else if (ref_kind == JVM_REF_invokeVirtual) { From c24b224166c5923fb8a7b06e8bae3f1d627b5c45 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 8 May 2013 19:28:54 -0400 Subject: [PATCH 6/7] 8006997: ContendedPaddingWidth should be range-checked Constrain between zero and 8K Reviewed-by: dholmes, rbackman --- hotspot/src/share/vm/runtime/arguments.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index b2ff4e5f9d2..249baba1609 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -2088,6 +2088,26 @@ bool Arguments::check_vm_args_consistency() { #endif } + // Need to limit the extent of the padding to reasonable size. + // 8K is well beyond the reasonable HW cache line size, even with the + // aggressive prefetching, while still leaving the room for segregating + // among the distinct pages. + if (ContendedPaddingWidth < 0 || ContendedPaddingWidth > 8192) { + jio_fprintf(defaultStream::error_stream(), + "ContendedPaddingWidth=" INTX_FORMAT " must be the between %d and %d\n", + ContendedPaddingWidth, 0, 8192); + status = false; + } + + // Need to enforce the padding not to break the existing field alignments. + // It is sufficient to check against the largest type size. + if ((ContendedPaddingWidth % BytesPerLong) != 0) { + jio_fprintf(defaultStream::error_stream(), + "ContendedPaddingWidth=" INTX_FORMAT " must be the multiple of %d\n", + ContendedPaddingWidth, BytesPerLong); + status = false; + } + return status; } From 654953bc9a4bef79154a81fc6e3bc8518568e9c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rickard=20B=C3=A4ckman?= Date: Wed, 8 May 2013 11:21:56 +0200 Subject: [PATCH 7/7] 8008255: jvmtiExport.cpp::post_to_env() does not check malloc() return Reviewed-by: coleenp, dholmes, sla --- hotspot/src/share/vm/prims/jvmtiExport.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp index ab66dca33d6..1e430e96b9a 100644 --- a/hotspot/src/share/vm/prims/jvmtiExport.cpp +++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp @@ -619,6 +619,9 @@ class JvmtiClassFileLoadHookPoster : public StackObj { // data has been changed by the new retransformable agent // and it hasn't already been cached, cache it *_cached_data_ptr = (unsigned char *)os::malloc(_curr_len, mtInternal); + if (*_cached_data_ptr == NULL) { + vm_exit_out_of_memory(_curr_len, OOM_MALLOC_ERROR, "unable to allocate cached copy of original class bytes"); + } memcpy(*_cached_data_ptr, _curr_data, _curr_len); *_cached_length_ptr = _curr_len; }