# HG changeset patch # User morris # Date 1389387248 28800 # Node ID db1ff6781ab4d7aee1665ed4664f786abf0f12f6 # Parent c8907928a976c892a120a8d8828591c2e999202b# Parent 7c0122ed05fb06fce9e8900a40b4bb0f263ff0af Merge diff -r 7c0122ed05fb -r db1ff6781ab4 agent/src/os/linux/symtab.c --- a/agent/src/os/linux/symtab.c Fri Jan 10 06:36:18 2014 +0100 +++ b/agent/src/os/linux/symtab.c Fri Jan 10 12:54:08 2014 -0800 @@ -214,8 +214,10 @@ + 2); strcpy(debug_pathname, name); char *last_slash = strrchr(debug_pathname, '/'); - if (last_slash == NULL) + if (last_slash == NULL) { + free(debug_pathname); return -1; + } /* Look in the same directory as the object. */ strcpy(last_slash+1, debug_filename); diff -r 7c0122ed05fb -r db1ff6781ab4 agent/src/share/classes/sun/jvm/hotspot/jdi/ArrayTypeImpl.java --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/ArrayTypeImpl.java Fri Jan 10 06:36:18 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/ArrayTypeImpl.java Fri Jan 10 12:54:08 2014 -0800 @@ -24,19 +24,29 @@ package sun.jvm.hotspot.jdi; -import com.sun.jdi.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; import sun.jvm.hotspot.oops.ArrayKlass; +import sun.jvm.hotspot.oops.Instance; import sun.jvm.hotspot.oops.InstanceKlass; -import sun.jvm.hotspot.oops.ObjArrayKlass; -import sun.jvm.hotspot.oops.TypeArrayKlass; import sun.jvm.hotspot.oops.Klass; -import sun.jvm.hotspot.oops.Instance; +import sun.jvm.hotspot.oops.ObjArrayKlass; import sun.jvm.hotspot.oops.Symbol; -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; +import sun.jvm.hotspot.oops.TypeArrayKlass; + +import com.sun.jdi.ArrayReference; +import com.sun.jdi.ArrayType; +import com.sun.jdi.ClassLoaderReference; +import com.sun.jdi.ClassNotLoadedException; +import com.sun.jdi.InterfaceType; +import com.sun.jdi.Method; +import com.sun.jdi.PrimitiveType; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.Type; +import com.sun.jdi.VirtualMachine; public class ArrayTypeImpl extends ReferenceTypeImpl implements ArrayType { protected ArrayTypeImpl(VirtualMachine aVm, ArrayKlass aRef) { @@ -75,7 +85,8 @@ } } - void addVisibleMethods(Map methodMap) { + @Override + void addVisibleMethods(Map methodMap, Set handledInterfaces) { // arrays don't have methods } diff -r 7c0122ed05fb -r db1ff6781ab4 agent/src/share/classes/sun/jvm/hotspot/jdi/ClassTypeImpl.java --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/ClassTypeImpl.java Fri Jan 10 06:36:18 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/ClassTypeImpl.java Fri Jan 10 12:54:08 2014 -0800 @@ -24,12 +24,30 @@ package sun.jvm.hotspot.jdi; -import com.sun.jdi.*; -import sun.jvm.hotspot.oops.Klass; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + import sun.jvm.hotspot.oops.InstanceKlass; -import java.util.*; -import java.lang.ref.SoftReference; +import com.sun.jdi.ClassNotLoadedException; +import com.sun.jdi.ClassType; +import com.sun.jdi.Field; +import com.sun.jdi.IncompatibleThreadStateException; +import com.sun.jdi.InterfaceType; +import com.sun.jdi.InvalidTypeException; +import com.sun.jdi.InvocationException; +import com.sun.jdi.Method; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.Value; +import com.sun.jdi.VirtualMachine; public class ClassTypeImpl extends ReferenceTypeImpl implements ClassType @@ -195,22 +213,26 @@ return null; } - void addVisibleMethods(Map methodMap) { + @Override + void addVisibleMethods(Map methodMap, Set seenInterfaces) { /* * Add methods from * parent types first, so that the methods in this class will * overwrite them in the hash table */ - Iterator iter = interfaces().iterator(); + Iterator iter = interfaces().iterator(); while (iter.hasNext()) { InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next(); - interfaze.addVisibleMethods(methodMap); + if (!seenInterfaces.contains(interfaze)) { + interfaze.addVisibleMethods(methodMap, seenInterfaces); + seenInterfaces.add(interfaze); + } } ClassTypeImpl clazz = (ClassTypeImpl)superclass(); if (clazz != null) { - clazz.addVisibleMethods(methodMap); + clazz.addVisibleMethods(methodMap, seenInterfaces); } addToMethodMap(methodMap, methods()); diff -r 7c0122ed05fb -r db1ff6781ab4 agent/src/share/classes/sun/jvm/hotspot/jdi/InterfaceTypeImpl.java --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/InterfaceTypeImpl.java Fri Jan 10 06:36:18 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/InterfaceTypeImpl.java Fri Jan 10 12:54:08 2014 -0800 @@ -24,15 +24,22 @@ package sun.jvm.hotspot.jdi; -import com.sun.jdi.*; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + import sun.jvm.hotspot.oops.InstanceKlass; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.Iterator; -import java.util.Collections; -import java.lang.ref.SoftReference; +import com.sun.jdi.ClassNotPreparedException; +import com.sun.jdi.ClassType; +import com.sun.jdi.InterfaceType; +import com.sun.jdi.Method; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.VirtualMachine; public class InterfaceTypeImpl extends ReferenceTypeImpl implements InterfaceType { @@ -96,16 +103,20 @@ return implementors; } - void addVisibleMethods(Map methodMap) { + @Override + void addVisibleMethods(Map methodMap, Set seenInterfaces) { /* * Add methods from * parent types first, so that the methods in this class will * overwrite them in the hash table */ - Iterator iter = superinterfaces().iterator(); + Iterator iter = superinterfaces().iterator(); while (iter.hasNext()) { InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next(); - interfaze.addVisibleMethods(methodMap); + if (!seenInterfaces.contains(interfaze)) { + interfaze.addVisibleMethods(methodMap, seenInterfaces); + seenInterfaces.add(interfaze); + } } addToMethodMap(methodMap, methods()); diff -r 7c0122ed05fb -r db1ff6781ab4 agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java Fri Jan 10 06:36:18 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java Fri Jan 10 12:54:08 2014 -0800 @@ -24,24 +24,45 @@ package sun.jvm.hotspot.jdi; -import java.io.*; - -import com.sun.jdi.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; import sun.jvm.hotspot.memory.SystemDictionary; +import sun.jvm.hotspot.oops.ArrayKlass; +import sun.jvm.hotspot.oops.DefaultHeapVisitor; import sun.jvm.hotspot.oops.Instance; import sun.jvm.hotspot.oops.InstanceKlass; -import sun.jvm.hotspot.oops.ArrayKlass; import sun.jvm.hotspot.oops.JVMDIClassStatus; import sun.jvm.hotspot.oops.Klass; -import sun.jvm.hotspot.oops.ObjArray; import sun.jvm.hotspot.oops.Oop; import sun.jvm.hotspot.oops.Symbol; -import sun.jvm.hotspot.oops.DefaultHeapVisitor; import sun.jvm.hotspot.utilities.Assert; -import java.util.*; -import java.lang.ref.SoftReference; +import com.sun.jdi.AbsentInformationException; +import com.sun.jdi.ArrayType; +import com.sun.jdi.ClassLoaderReference; +import com.sun.jdi.ClassNotLoadedException; +import com.sun.jdi.ClassNotPreparedException; +import com.sun.jdi.ClassObjectReference; +import com.sun.jdi.Field; +import com.sun.jdi.InterfaceType; +import com.sun.jdi.Method; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.PrimitiveType; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.Type; +import com.sun.jdi.Value; +import com.sun.jdi.VirtualMachine; public abstract class ReferenceTypeImpl extends TypeImpl implements ReferenceType { @@ -421,7 +442,8 @@ } } - abstract void addVisibleMethods(Map methodMap); + abstract void addVisibleMethods(Map methodMap, Set seenInterfaces); + public final List visibleMethods() throws ClassNotPreparedException { checkPrepared(); /* @@ -430,8 +452,8 @@ * concatenation of name and signature. */ //System.out.println("jj: RTI: Calling addVisibleMethods for:" + this); - Map map = new HashMap(); - addVisibleMethods(map); + Map map = new HashMap(); + addVisibleMethods(map, new HashSet()); /* * ... but the hash map destroys order. Methods should be @@ -441,7 +463,7 @@ */ //System.out.println("jj: RTI: Calling allMethods for:" + this); - List list = new ArrayList(allMethods()); + List list = new ArrayList(allMethods()); //System.out.println("jj: allMethods = " + jjstr(list)); //System.out.println("jj: map = " + map.toString()); //System.out.println("jj: map = " + jjstr(map.values())); diff -r 7c0122ed05fb -r db1ff6781ab4 make/bsd/makefiles/mapfile-vers-debug --- a/make/bsd/makefiles/mapfile-vers-debug Fri Jan 10 06:36:18 2014 +0100 +++ b/make/bsd/makefiles/mapfile-vers-debug Fri Jan 10 12:54:08 2014 -0800 @@ -242,11 +242,6 @@ _JVM_Yield _JVM_handle_bsd_signal - # debug _JVM - _JVM_AccessVMBooleanFlag - _JVM_AccessVMIntFlag - _JVM_VMBreakPoint - # miscellaneous functions _jio_fprintf _jio_printf diff -r 7c0122ed05fb -r db1ff6781ab4 make/linux/makefiles/mapfile-vers-debug --- a/make/linux/makefiles/mapfile-vers-debug Fri Jan 10 06:36:18 2014 +0100 +++ b/make/linux/makefiles/mapfile-vers-debug Fri Jan 10 12:54:08 2014 -0800 @@ -244,11 +244,6 @@ JVM_Yield; JVM_handle_linux_signal; - # debug JVM - JVM_AccessVMBooleanFlag; - JVM_AccessVMIntFlag; - JVM_VMBreakPoint; - # miscellaneous functions jio_fprintf; jio_printf; diff -r 7c0122ed05fb -r db1ff6781ab4 make/solaris/makefiles/mapfile-vers-debug --- a/make/solaris/makefiles/mapfile-vers-debug Fri Jan 10 06:36:18 2014 +0100 +++ b/make/solaris/makefiles/mapfile-vers-debug Fri Jan 10 12:54:08 2014 -0800 @@ -28,10 +28,6 @@ SUNWprivate_1.1 { global: - # debug JVM - JVM_AccessVMBooleanFlag; - JVM_AccessVMIntFlag; - JVM_VMBreakPoint; # miscellaneous }; diff -r 7c0122ed05fb -r db1ff6781ab4 make/windows/makefiles/sa.make --- a/make/windows/makefiles/sa.make Fri Jan 10 06:36:18 2014 +0100 +++ b/make/windows/makefiles/sa.make Fri Jan 10 12:54:08 2014 -0800 @@ -94,7 +94,7 @@ SA_LD_FLAGS = bufferoverflowU.lib !endif !else -SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 -Gm $(GX_OPTION) -Od -D "WIN32" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -YX -FD -GZ -c +SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -FD -RTC1 -c !if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1" SA_CFLAGS = $(SA_CFLAGS) -ZI !endif diff -r 7c0122ed05fb -r db1ff6781ab4 src/os/bsd/dtrace/hotspot.d --- a/src/os/bsd/dtrace/hotspot.d Fri Jan 10 06:36:18 2014 +0100 +++ b/src/os/bsd/dtrace/hotspot.d Fri Jan 10 12:54:08 2014 -0800 @@ -47,8 +47,8 @@ probe mem__pool__gc__end( char*, uintptr_t, char*, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); - probe thread__probe__start(char*, uintptr_t, uintptr_t, uintptr_t, uintptr_t); - probe thread__probe__stop(char*, uintptr_t, uintptr_t, uintptr_t, uintptr_t); + probe thread__start(char*, uintptr_t, uintptr_t, uintptr_t, uintptr_t); + probe thread__stop(char*, uintptr_t, uintptr_t, uintptr_t, uintptr_t); probe thread__sleep__begin(long long); probe thread__sleep__end(int); probe thread__yield(); @@ -68,7 +68,7 @@ probe monitor__contended__entered(uintptr_t, uintptr_t, char*, uintptr_t); probe monitor__contended__exit(uintptr_t, uintptr_t, char*, uintptr_t); probe monitor__wait(uintptr_t, uintptr_t, char*, uintptr_t, uintptr_t); - probe monitor__probe__waited(uintptr_t, uintptr_t, char*, uintptr_t); + probe monitor__waited(uintptr_t, uintptr_t, char*, uintptr_t); probe monitor__notify(uintptr_t, uintptr_t, char*, uintptr_t); probe monitor__notifyAll(uintptr_t, uintptr_t, char*, uintptr_t); diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/classfile/classLoaderData.cpp --- a/src/share/vm/classfile/classLoaderData.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/classfile/classLoaderData.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -648,12 +648,12 @@ return array; } -#ifndef PRODUCT -// for debugging and hsfind(x) -bool ClassLoaderDataGraph::contains(address x) { - // I think we need the _metaspace_lock taken here because the class loader - // data graph could be changing while we are walking it (new entries added, - // new entries being unloaded, etc). +// For profiling and hsfind() only. Otherwise, this is unsafe (and slow). This +// is done lock free to avoid lock inversion problems. It is safe because +// new ClassLoaderData are added to the end of the CLDG, and only removed at +// safepoint. The _unloading list can be deallocated concurrently with CMS so +// this doesn't look in metaspace for classes that have been unloaded. +bool ClassLoaderDataGraph::contains(const void* x) { if (DumpSharedSpaces) { // There are only two metaspaces to worry about. ClassLoaderData* ncld = ClassLoaderData::the_null_class_loader_data(); @@ -670,16 +670,11 @@ } } - // Could also be on an unloading list which is okay, ie. still allocated - // for a little while. - for (ClassLoaderData* ucld = _unloading; ucld != NULL; ucld = ucld->next()) { - if (ucld->metaspace_or_null() != NULL && ucld->metaspace_or_null()->contains(x)) { - return true; - } - } + // Do not check unloading list because deallocation can be concurrent. return false; } +#ifndef PRODUCT bool ClassLoaderDataGraph::contains_loader_data(ClassLoaderData* loader_data) { for (ClassLoaderData* data = _head; data != NULL; data = data->next()) { if (loader_data == data) { diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/classfile/classLoaderData.hpp --- a/src/share/vm/classfile/classLoaderData.hpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/classfile/classLoaderData.hpp Fri Jan 10 12:54:08 2014 -0800 @@ -90,9 +90,9 @@ static void dump() { dump_on(tty); } static void verify(); + // expensive test for pointer in metaspace for debugging + static bool contains(const void* x); #ifndef PRODUCT - // expensive test for pointer in metaspace for debugging - static bool contains(address x); static bool contains_loader_data(ClassLoaderData* loader_data); #endif diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/classfile/javaClasses.cpp --- a/src/share/vm/classfile/javaClasses.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/classfile/javaClasses.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -3286,7 +3286,7 @@ sun_reflect_ConstantPool::compute_offsets(); sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets(); } - if (JDK_Version::is_jdk18x_version()) + if (JDK_Version::is_gte_jdk18x_version()) java_lang_reflect_Parameter::compute_offsets(); // generated interpreter code wants to know about the offsets we just computed: diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/code/dependencies.cpp --- a/src/share/vm/code/dependencies.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/code/dependencies.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -655,8 +655,6 @@ } else { o = _deps->oop_recorder()->metadata_at(i); } - assert(o == NULL || o->is_metaspace_object(), - err_msg("Should be metadata " PTR_FORMAT, o)); return o; } diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -2376,25 +2376,6 @@ return blk.result(); } -size_t G1CollectedHeap::unsafe_max_alloc() { - if (free_regions() > 0) return HeapRegion::GrainBytes; - // otherwise, is there space in the current allocation region? - - // We need to store the current allocation region in a local variable - // here. The problem is that this method doesn't take any locks and - // there may be other threads which overwrite the current allocation - // region field. attempt_allocation(), for example, sets it to NULL - // and this can happen *after* the NULL check here but before the call - // to free(), resulting in a SIGSEGV. Note that this doesn't appear - // to be a problem in the optimized build, since the two loads of the - // current allocation region field are optimized away. - HeapRegion* hr = _mutator_alloc_region.get(); - if (hr == NULL) { - return 0; - } - return hr->free(); -} - bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) { switch (cause) { case GCCause::_gc_locker: return GCLockerInvokesConcurrent; diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Fri Jan 10 12:54:08 2014 -0800 @@ -1183,15 +1183,6 @@ // end fields defining the extent of the contiguous allocation region.) // But G1CollectedHeap doesn't yet support this. - // Return an estimate of the maximum allocation that could be performed - // without triggering any collection or expansion activity. In a - // generational collector, for example, this is probably the largest - // allocation that could be supported (without expansion) in the youngest - // generation. It is "unsafe" because no locks are taken; the result - // should be treated as an approximation, not a guarantee, for use in - // heuristic resizing decisions. - virtual size_t unsafe_max_alloc(); - virtual bool is_maximal_no_gc() const { return _g1_storage.uncommitted_size() == 0; } diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -484,10 +484,6 @@ young_gen()->eden_space()->ensure_parsability(); } -size_t ParallelScavengeHeap::unsafe_max_alloc() { - return young_gen()->eden_space()->free_in_bytes(); -} - size_t ParallelScavengeHeap::tlab_capacity(Thread* thr) const { return young_gen()->eden_space()->tlab_capacity(thr); } diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp --- a/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp Fri Jan 10 12:54:08 2014 -0800 @@ -184,8 +184,6 @@ void accumulate_statistics_all_tlabs(); void resize_all_tlabs(); - size_t unsafe_max_alloc(); - bool supports_tlab_allocation() const { return true; } size_t tlab_capacity(Thread* thr) const; diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -466,10 +466,12 @@ } } - GCTraceTime tm("StringTable", false, false, &_gc_timer); - // Unlink any dead interned Strings and process the remaining live ones. - PSScavengeRootsClosure root_closure(promotion_manager); - StringTable::unlink_or_oops_do(&_is_alive_closure, &root_closure); + { + GCTraceTime tm("StringTable", false, false, &_gc_timer); + // Unlink any dead interned Strings and process the remaining live ones. + PSScavengeRootsClosure root_closure(promotion_manager); + StringTable::unlink_or_oops_do(&_is_alive_closure, &root_closure); + } // Finally, flush the promotion_manager's labs, and deallocate its stacks. promotion_failure_occurred = PSPromotionManager::post_scavenge(_gc_tracer); diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/gc_interface/collectedHeap.hpp --- a/src/share/vm/gc_interface/collectedHeap.hpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/gc_interface/collectedHeap.hpp Fri Jan 10 12:54:08 2014 -0800 @@ -389,15 +389,6 @@ // allocation from them and necessitating allocation of new TLABs. virtual void ensure_parsability(bool retire_tlabs); - // Return an estimate of the maximum allocation that could be performed - // without triggering any collection or expansion activity. In a - // generational collector, for example, this is probably the largest - // allocation that could be supported (without expansion) in the youngest - // generation. It is "unsafe" because no locks are taken; the result - // should be treated as an approximation, not a guarantee, for use in - // heuristic resizing decisions. - virtual size_t unsafe_max_alloc() = 0; - // Section on thread-local allocation buffers (TLABs) // If the heap supports thread-local allocation buffers, it should override // the following methods: diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/memory/allocation.cpp --- a/src/share/vm/memory/allocation.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/memory/allocation.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -71,9 +71,8 @@ return MetaspaceShared::is_in_shared_space(this); } - bool MetaspaceObj::is_metaspace_object() const { - return Metaspace::contains((void*)this); + return ClassLoaderDataGraph::contains((void*)this); } void MetaspaceObj::print_address_on(outputStream* st) const { diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/memory/allocation.hpp --- a/src/share/vm/memory/allocation.hpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/memory/allocation.hpp Fri Jan 10 12:54:08 2014 -0800 @@ -264,7 +264,7 @@ class MetaspaceObj { public: - bool is_metaspace_object() const; // more specific test but slower + bool is_metaspace_object() const; bool is_shared() const; void print_address_on(outputStream* st) const; // nonvirtual address printing diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/memory/defNewGeneration.cpp --- a/src/share/vm/memory/defNewGeneration.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/memory/defNewGeneration.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -667,9 +667,6 @@ // for full GC's. AdaptiveSizePolicy* size_policy = gch->gen_policy()->size_policy(); size_policy->reset_gc_overhead_limit_count(); - if (PrintGC && !PrintGCDetails) { - gch->print_heap_change(gch_prev_used); - } assert(!gch->incremental_collection_failed(), "Should be clear"); } else { assert(_promo_failure_scan_stack.is_empty(), "post condition"); @@ -695,6 +692,9 @@ // Reset the PromotionFailureALot counters. NOT_PRODUCT(Universe::heap()->reset_promotion_should_fail();) } + if (PrintGC && !PrintGCDetails) { + gch->print_heap_change(gch_prev_used); + } // set new iteration safe limit for the survivor spaces from()->set_concurrent_iteration_safe_limit(from()->top()); to()->set_concurrent_iteration_safe_limit(to()->top()); diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/memory/genCollectedHeap.cpp --- a/src/share/vm/memory/genCollectedHeap.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/memory/genCollectedHeap.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -673,10 +673,6 @@ return _gens[0]->end_addr(); } -size_t GenCollectedHeap::unsafe_max_alloc() { - return _gens[0]->unsafe_max_alloc_nogc(); -} - // public collection interfaces void GenCollectedHeap::collect(GCCause::Cause cause) { diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/memory/genCollectedHeap.hpp --- a/src/share/vm/memory/genCollectedHeap.hpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/memory/genCollectedHeap.hpp Fri Jan 10 12:54:08 2014 -0800 @@ -166,14 +166,6 @@ HeapWord** top_addr() const; HeapWord** end_addr() const; - // Return an estimate of the maximum allocation that could be performed - // without triggering any collection activity. In a generational - // collector, for example, this is probably the largest allocation that - // could be supported in the youngest generation. It is "unsafe" because - // no locks are taken; the result should be treated as an approximation, - // not a guarantee. - size_t unsafe_max_alloc(); - // Does this heap support heap inspection? (+PrintClassHistogram) virtual bool supports_heap_inspection() const { return true; } diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/memory/metachunk.hpp --- a/src/share/vm/memory/metachunk.hpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/memory/metachunk.hpp Fri Jan 10 12:54:08 2014 -0800 @@ -143,6 +143,8 @@ void set_is_tagged_free(bool v) { _is_tagged_free = v; } #endif + bool contains(const void* ptr) { return bottom() <= ptr && ptr < _top; } + NOT_PRODUCT(void mangle();) void print_on(outputStream* st) const; diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/memory/metaspace.cpp --- a/src/share/vm/memory/metaspace.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/memory/metaspace.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -513,8 +513,6 @@ // Unlink empty VirtualSpaceNodes and free it. void purge(ChunkManager* chunk_manager); - bool contains(const void *ptr); - void print_on(outputStream* st) const; class VirtualSpaceListIterator : public StackObj { @@ -558,7 +556,7 @@ private: - // protects allocations and contains. + // protects allocations Mutex* const _lock; // Type of metadata allocated. @@ -595,7 +593,11 @@ private: // Accessors Metachunk* chunks_in_use(ChunkIndex index) const { return _chunks_in_use[index]; } - void set_chunks_in_use(ChunkIndex index, Metachunk* v) { _chunks_in_use[index] = v; } + void set_chunks_in_use(ChunkIndex index, Metachunk* v) { + // ensure lock-free iteration sees fully initialized node + OrderAccess::storestore(); + _chunks_in_use[index] = v; + } BlockFreelist* block_freelists() const { return (BlockFreelist*) &_block_freelists; @@ -708,6 +710,8 @@ void print_on(outputStream* st) const; void locked_print_chunks_in_use_on(outputStream* st) const; + bool contains(const void *ptr); + void verify(); void verify_chunk_size(Metachunk* chunk); NOT_PRODUCT(void mangle_freed_chunks();) @@ -1159,8 +1163,6 @@ } else { assert(new_entry->reserved_words() == vs_word_size, "Reserved memory size differs from requested memory size"); - // ensure lock-free iteration sees fully initialized node - OrderAccess::storestore(); link_vs(new_entry); return true; } @@ -1287,19 +1289,6 @@ } } -bool VirtualSpaceList::contains(const void *ptr) { - VirtualSpaceNode* list = virtual_space_list(); - VirtualSpaceListIterator iter(list); - while (iter.repeat()) { - VirtualSpaceNode* node = iter.get_next(); - if (node->reserved()->contains(ptr)) { - return true; - } - } - return false; -} - - // MetaspaceGC methods // VM_CollectForMetadataAllocation is the vm operation used to GC. @@ -2392,6 +2381,21 @@ return result; } +// This function looks at the chunks in the metaspace without locking. +// The chunks are added with store ordering and not deleted except for at +// unloading time. +bool SpaceManager::contains(const void *ptr) { + for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) + { + Metachunk* curr = chunks_in_use(i); + while (curr != NULL) { + if (curr->contains(ptr)) return true; + curr = curr->next(); + } + } + return false; +} + void SpaceManager::verify() { // If there are blocks in the dictionary, then // verfication of chunks does not work since @@ -3463,17 +3467,12 @@ } } -bool Metaspace::contains(const void * ptr) { - if (MetaspaceShared::is_in_shared_space(ptr)) { - return true; +bool Metaspace::contains(const void* ptr) { + if (vsm()->contains(ptr)) return true; + if (using_class_space()) { + return class_vsm()->contains(ptr); } - // This is checked while unlocked. As long as the virtualspaces are added - // at the end, the pointer will be in one of them. The virtual spaces - // aren't deleted presently. When they are, some sort of locking might - // be needed. Note, locking this can cause inversion problems with the - // caller in MetaspaceObj::is_metadata() function. - return space_list()->contains(ptr) || - (using_class_space() && class_space_list()->contains(ptr)); + return false; } void Metaspace::verify() { diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/memory/metaspace.hpp --- a/src/share/vm/memory/metaspace.hpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/memory/metaspace.hpp Fri Jan 10 12:54:08 2014 -0800 @@ -225,7 +225,7 @@ MetaWord* expand_and_allocate(size_t size, MetadataType mdtype); - static bool contains(const void *ptr); + bool contains(const void* ptr); void dump(outputStream* const out) const; // Free empty virtualspaces diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/oops/klass.cpp --- a/src/share/vm/oops/klass.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/oops/klass.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -376,8 +376,6 @@ } bool Klass::is_loader_alive(BoolObjectClosure* is_alive) { - assert(ClassLoaderDataGraph::contains((address)this), "is in the metaspace"); - #ifdef ASSERT // The class is alive iff the class loader is alive. oop loader = class_loader(); diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/prims/forte.cpp diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/prims/jni.cpp --- a/src/share/vm/prims/jni.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/prims/jni.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -1804,34 +1804,34 @@ // the runtime type of subword integral basic types is integer DEFINE_CALLMETHODV(jboolean, Boolean, T_BOOLEAN - , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLBOOLEANMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBOOLEANMETHODV_RETURN(_ret_ref)) DEFINE_CALLMETHODV(jbyte, Byte, T_BYTE - , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLBYTEMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBYTEMETHODV_RETURN(_ret_ref)) DEFINE_CALLMETHODV(jchar, Char, T_CHAR - , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLCHARMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLCHARMETHODV_RETURN(_ret_ref)) DEFINE_CALLMETHODV(jshort, Short, T_SHORT - , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLSHORTMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSHORTMETHODV_RETURN(_ret_ref)) DEFINE_CALLMETHODV(jobject, Object, T_OBJECT - , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLOBJECTMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLOBJECTMETHODV_RETURN(_ret_ref)) DEFINE_CALLMETHODV(jint, Int, T_INT, - HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref)) + HOTSPOT_JNI_CALLINTMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLINTMETHODV_RETURN(_ret_ref)) DEFINE_CALLMETHODV(jlong, Long, T_LONG - , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLLONGMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLLONGMETHODV_RETURN(_ret_ref)) // Float and double probes don't return value because dtrace doesn't currently support it DEFINE_CALLMETHODV(jfloat, Float, T_FLOAT - , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLFLOATMETHOD_RETURN()) + , HOTSPOT_JNI_CALLFLOATMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLFLOATMETHODV_RETURN()) DEFINE_CALLMETHODV(jdouble, Double, T_DOUBLE - , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN()) + , HOTSPOT_JNI_CALLDOUBLEMETHODV_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLDOUBLEMETHODV_RETURN()) #define DEFINE_CALLMETHODA(ResultType, Result, Tag \ , EntryProbe, ReturnProbe) \ @@ -1856,34 +1856,34 @@ // the runtime type of subword integral basic types is integer DEFINE_CALLMETHODA(jboolean, Boolean, T_BOOLEAN - , HOTSPOT_JNI_CALLBOOLEANMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLBOOLEANMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLBOOLEANMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBOOLEANMETHODA_RETURN(_ret_ref)) DEFINE_CALLMETHODA(jbyte, Byte, T_BYTE - , HOTSPOT_JNI_CALLBYTEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLBYTEMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLBYTEMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLBYTEMETHODA_RETURN(_ret_ref)) DEFINE_CALLMETHODA(jchar, Char, T_CHAR - , HOTSPOT_JNI_CALLCHARMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLCHARMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLCHARMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLCHARMETHODA_RETURN(_ret_ref)) DEFINE_CALLMETHODA(jshort, Short, T_SHORT - , HOTSPOT_JNI_CALLSHORTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLSHORTMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLSHORTMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLSHORTMETHODA_RETURN(_ret_ref)) DEFINE_CALLMETHODA(jobject, Object, T_OBJECT - , HOTSPOT_JNI_CALLOBJECTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLOBJECTMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLOBJECTMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLOBJECTMETHODA_RETURN(_ret_ref)) DEFINE_CALLMETHODA(jint, Int, T_INT, - HOTSPOT_JNI_CALLINTMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLINTMETHOD_RETURN(_ret_ref)) + HOTSPOT_JNI_CALLINTMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLINTMETHODA_RETURN(_ret_ref)) DEFINE_CALLMETHODA(jlong, Long, T_LONG - , HOTSPOT_JNI_CALLLONGMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLLONGMETHOD_RETURN(_ret_ref)) + , HOTSPOT_JNI_CALLLONGMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLLONGMETHODA_RETURN(_ret_ref)) // Float and double probes don't return value because dtrace doesn't currently support it DEFINE_CALLMETHODA(jfloat, Float, T_FLOAT - , HOTSPOT_JNI_CALLFLOATMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLFLOATMETHOD_RETURN()) + , HOTSPOT_JNI_CALLFLOATMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLFLOATMETHODA_RETURN()) DEFINE_CALLMETHODA(jdouble, Double, T_DOUBLE - , HOTSPOT_JNI_CALLDOUBLEMETHOD_ENTRY(env, obj, (uintptr_t)methodID), - HOTSPOT_JNI_CALLDOUBLEMETHOD_RETURN()) + , HOTSPOT_JNI_CALLDOUBLEMETHODA_ENTRY(env, obj, (uintptr_t)methodID), + HOTSPOT_JNI_CALLDOUBLEMETHODA_RETURN()) DT_VOID_RETURN_MARK_DECL(CallVoidMethod, HOTSPOT_JNI_CALLVOIDMETHOD_RETURN()); DT_VOID_RETURN_MARK_DECL(CallVoidMethodV, HOTSPOT_JNI_CALLVOIDMETHODV_RETURN()); @@ -3145,7 +3145,7 @@ JNI_END DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z - , HOTSPOT_JNI_SETBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t)fieldID, value), + , HOTSPOT_JNI_SETSTATICBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t)fieldID, value), HOTSPOT_JNI_SETBOOLEANFIELD_RETURN()) DEFINE_SETSTATICFIELD(jbyte, byte, Byte, 'B', b , HOTSPOT_JNI_SETSTATICBYTEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value), diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/prims/jvm.cpp --- a/src/share/vm/prims/jvm.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/prims/jvm.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -3971,40 +3971,6 @@ } -// Internal SQE debugging support /////////////////////////////////////////////////////////// - -#ifndef PRODUCT - -extern "C" { - JNIEXPORT jboolean JNICALL JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get); - JNIEXPORT jboolean JNICALL JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get); - JNIEXPORT void JNICALL JVM_VMBreakPoint(JNIEnv *env, jobject obj); -} - -JVM_LEAF(jboolean, JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get)) - JVMWrapper("JVM_AccessBoolVMFlag"); - return is_get ? CommandLineFlags::boolAt((char*) name, (bool*) value) : CommandLineFlags::boolAtPut((char*) name, (bool*) value, Flag::INTERNAL); -JVM_END - -JVM_LEAF(jboolean, JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get)) - JVMWrapper("JVM_AccessVMIntFlag"); - intx v; - jboolean result = is_get ? CommandLineFlags::intxAt((char*) name, &v) : CommandLineFlags::intxAtPut((char*) name, &v, Flag::INTERNAL); - *value = (jint)v; - return result; -JVM_END - - -JVM_ENTRY(void, JVM_VMBreakPoint(JNIEnv *env, jobject obj)) - JVMWrapper("JVM_VMBreakPoint"); - oop the_obj = JNIHandles::resolve(obj); - BREAKPOINT; -JVM_END - - -#endif - - // Method /////////////////////////////////////////////////////////////////////////////////////////// JVM_ENTRY(jobject, JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)) diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/runtime/globals.cpp --- a/src/share/vm/runtime/globals.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/runtime/globals.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -295,7 +295,7 @@ else st->print("%-16s", ""); } - st->print("%-20"); + st->print("%-20s", " "); print_kind(st); if (withComments) { @@ -702,8 +702,6 @@ return true; } -// Contract: Flag will make private copy of the incoming value. -// Outgoing value is always malloc-ed, and caller MUST call free. bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; @@ -726,7 +724,6 @@ return true; } -// Contract: Flag will make private copy of the incoming value. void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) { Flag* faddr = address_of_flag(flag); guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type"); diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/runtime/globals.hpp Fri Jan 10 12:54:08 2014 -0800 @@ -376,6 +376,8 @@ static bool ccstrAt(char* name, size_t len, ccstr* value); static bool ccstrAt(char* name, ccstr* value) { return ccstrAt(name, strlen(name), value); } + // Contract: Flag will make private copy of the incoming value. + // Outgoing value is always malloc-ed, and caller MUST call free. static bool ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin); static bool ccstrAtPut(char* name, ccstr* value, Flag::Flags origin) { return ccstrAtPut(name, strlen(name), value, origin); } diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/runtime/globals_extension.hpp --- a/src/share/vm/runtime/globals_extension.hpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/runtime/globals_extension.hpp Fri Jan 10 12:54:08 2014 -0800 @@ -201,6 +201,7 @@ static void uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin); static void uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin); static void doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin); + // Contract: Flag will make private copy of the incoming value static void ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin); static bool is_default(CommandLineFlag flag); diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/runtime/os.cpp --- a/src/share/vm/runtime/os.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/runtime/os.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -1081,7 +1081,6 @@ } -#ifndef PRODUCT // Check if in metaspace. if (ClassLoaderDataGraph::contains((address)addr)) { // Use addr->print() from the debugger instead (not here) @@ -1089,7 +1088,6 @@ " is pointing into metadata", addr); return; } -#endif // Try an OS specific find if (os::find(addr, st)) { diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/runtime/perfMemory.cpp --- a/src/share/vm/runtime/perfMemory.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/runtime/perfMemory.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -155,7 +155,7 @@ void PerfMemory::destroy() { - assert(_prologue != NULL, "prologue pointer must be initialized"); + if (_prologue == NULL) return; if (_start != NULL && _prologue->overflow != 0) { diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/runtime/synchronizer.cpp --- a/src/share/vm/runtime/synchronizer.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/runtime/synchronizer.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -119,7 +119,7 @@ } \ } -#define HOTSPOT_MONITOR_PROBE_waited HOTSPOT_MONITOR_PROBE_WAITED +#define HOTSPOT_MONITOR_PROBE_waited HOTSPOT_MONITOR_WAITED #define DTRACE_MONITOR_PROBE(probe, monitor, obj, thread) \ { \ diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/runtime/thread.cpp --- a/src/share/vm/runtime/thread.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/runtime/thread.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -135,8 +135,8 @@ #else /* USDT2 */ -#define HOTSPOT_THREAD_PROBE_start HOTSPOT_THREAD_PROBE_START -#define HOTSPOT_THREAD_PROBE_stop HOTSPOT_THREAD_PROBE_STOP +#define HOTSPOT_THREAD_PROBE_start HOTSPOT_THREAD_START +#define HOTSPOT_THREAD_PROBE_stop HOTSPOT_THREAD_STOP #define DTRACE_THREAD_PROBE(probe, javathread) \ { \ diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/services/attachListener.cpp --- a/src/share/vm/services/attachListener.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/services/attachListener.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -451,15 +451,39 @@ } } +bool AttachListener::has_init_error(TRAPS) { + if (HAS_PENDING_EXCEPTION) { + tty->print_cr("Exception in VM (AttachListener::init) : "); + java_lang_Throwable::print(PENDING_EXCEPTION, tty); + tty->cr(); + + CLEAR_PENDING_EXCEPTION; + + return true; + } else { + return false; + } +} + // Starts the Attach Listener thread void AttachListener::init() { EXCEPTION_MARK; - Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK); + Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, THREAD); + if (has_init_error(THREAD)) { + return; + } + instanceKlassHandle klass (THREAD, k); - instanceHandle thread_oop = klass->allocate_instance_handle(CHECK); + instanceHandle thread_oop = klass->allocate_instance_handle(THREAD); + if (has_init_error(THREAD)) { + return; + } const char thread_name[] = "Attach Listener"; - Handle string = java_lang_String::create_from_str(thread_name, CHECK); + Handle string = java_lang_String::create_from_str(thread_name, THREAD); + if (has_init_error(THREAD)) { + return; + } // Initialize thread_oop to put it into the system threadGroup Handle thread_group (THREAD, Universe::system_thread_group()); @@ -472,13 +496,7 @@ string, THREAD); - if (HAS_PENDING_EXCEPTION) { - tty->print_cr("Exception in VM (AttachListener::init) : "); - java_lang_Throwable::print(PENDING_EXCEPTION, tty); - tty->cr(); - - CLEAR_PENDING_EXCEPTION; - + if (has_init_error(THREAD)) { return; } @@ -490,14 +508,7 @@ vmSymbols::thread_void_signature(), thread_oop, // ARG 1 THREAD); - - if (HAS_PENDING_EXCEPTION) { - tty->print_cr("Exception in VM (AttachListener::init) : "); - java_lang_Throwable::print(PENDING_EXCEPTION, tty); - tty->cr(); - - CLEAR_PENDING_EXCEPTION; - + if (has_init_error(THREAD)) { return; } diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/services/attachListener.hpp --- a/src/share/vm/services/attachListener.hpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/services/attachListener.hpp Fri Jan 10 12:54:08 2014 -0800 @@ -94,6 +94,9 @@ // dequeue the next operation static AttachOperation* dequeue(); #endif // !INCLUDE_SERVICES + + private: + static bool has_init_error(TRAPS); }; #if INCLUDE_SERVICES diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/services/jmm.h --- a/src/share/vm/services/jmm.h Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/services/jmm.h Fri Jan 10 12:54:08 2014 -0800 @@ -153,6 +153,7 @@ JMM_VMGLOBAL_ORIGIN_ENVIRON_VAR = 4, /* Set via environment variables */ JMM_VMGLOBAL_ORIGIN_CONFIG_FILE = 5, /* Set via config file (such as .hotspotrc) */ JMM_VMGLOBAL_ORIGIN_ERGONOMIC = 6, /* Set via ergonomic */ + JMM_VMGLOBAL_ORIGIN_ATTACH_ON_DEMAND = 7, /* Set via attach */ JMM_VMGLOBAL_ORIGIN_OTHER = 99 /* Set via some other mechanism */ } jmmVMGlobalOrigin; diff -r 7c0122ed05fb -r db1ff6781ab4 src/share/vm/services/management.cpp --- a/src/share/vm/services/management.cpp Fri Jan 10 06:36:18 2014 +0100 +++ b/src/share/vm/services/management.cpp Fri Jan 10 12:54:08 2014 -0800 @@ -1724,6 +1724,9 @@ case Flag::ERGONOMIC: global->origin = JMM_VMGLOBAL_ORIGIN_ERGONOMIC; break; + case Flag::ATTACH_ON_DEMAND: + global->origin = JMM_VMGLOBAL_ORIGIN_ATTACH_ON_DEMAND; + break; default: global->origin = JMM_VMGLOBAL_ORIGIN_OTHER; } @@ -1821,7 +1824,7 @@ "This flag is not writeable."); } - bool succeed; + bool succeed = false; if (flag->is_bool()) { bool bvalue = (new_value.z == JNI_TRUE ? true : false); succeed = CommandLineFlags::boolAtPut(name, &bvalue, Flag::MANAGEMENT); @@ -1841,6 +1844,9 @@ } ccstr svalue = java_lang_String::as_utf8_string(str); succeed = CommandLineFlags::ccstrAtPut(name, &svalue, Flag::MANAGEMENT); + if (succeed) { + FREE_C_HEAP_ARRAY(char, svalue, mtInternal); + } } assert(succeed, "Setting flag should succeed"); JVM_END diff -r 7c0122ed05fb -r db1ff6781ab4 test/gc/defnew/HeapChangeLogging.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/gc/defnew/HeapChangeLogging.java Fri Jan 10 12:54:08 2014 -0800 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test HeapChangeLogging.java + * @bug 8027440 + * @library /testlibrary + * @build HeapChangeLogging + * @summary Allocate to get a promotion failure and verify that that heap change logging is present. + * @run main HeapChangeLogging + * + * Test the output of G1SummarizeRSetStats in conjunction with G1SummarizeRSetStatsPeriod. + */ + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.oracle.java.testlibrary.*; + +public class HeapChangeLogging { + public static void main(String[] args) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128m", "-Xmn100m", "-XX:+UseSerialGC", "-XX:+PrintGC", "HeapFiller"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + String stdout = output.getStdout(); + System.out.println(stdout); + Matcher stdoutMatcher = Pattern.compile("\\[GC .Allocation Failure.*K->.*K\\(.*K\\), .* secs\\]", Pattern.MULTILINE).matcher(stdout); + if (!stdoutMatcher.find()) { + throw new RuntimeException("No proper GC log line found"); + } + output.shouldHaveExitValue(0); + } +} + +class HeapFiller { + public static Entry root; + private static final int PAYLOAD_SIZE = 1000; + + public static void main(String[] args) { + root = new Entry(PAYLOAD_SIZE, null); + Entry current = root; + try { + while (true) { + Entry newEntry = new Entry(PAYLOAD_SIZE, current); + current = newEntry; + } + } catch (OutOfMemoryError e) { + root = null; + } + + } +} + +class Entry { + public Entry previous; + public byte[] payload; + + Entry(int payloadSize, Entry previous) { + payload = new byte[payloadSize]; + this.previous = previous; + } +} \ No newline at end of file diff -r 7c0122ed05fb -r db1ff6781ab4 test/runtime/NMT/CommandLineDetail.java --- a/test/runtime/NMT/CommandLineDetail.java Fri Jan 10 06:36:18 2014 +0100 +++ b/test/runtime/NMT/CommandLineDetail.java Fri Jan 10 12:54:08 2014 -0800 @@ -24,7 +24,7 @@ /* * @test * @key nmt - * @summary Running with NMT detail should not result in an error or warning + * @summary Running with NMT detail should not result in an error * @library /testlibrary */ @@ -39,7 +39,6 @@ "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("error"); - output.shouldNotContain("warning"); output.shouldHaveExitValue(0); } } diff -r 7c0122ed05fb -r db1ff6781ab4 test/runtime/NMT/CommandLineSummary.java --- a/test/runtime/NMT/CommandLineSummary.java Fri Jan 10 06:36:18 2014 +0100 +++ b/test/runtime/NMT/CommandLineSummary.java Fri Jan 10 12:54:08 2014 -0800 @@ -24,7 +24,7 @@ /* * @test * @key nmt - * @summary Running with NMT summary should not result in an error or warning + * @summary Running with NMT summary should not result in an error * @library /testlibrary */ @@ -39,7 +39,6 @@ "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("error"); - output.shouldNotContain("warning"); output.shouldHaveExitValue(0); } } diff -r 7c0122ed05fb -r db1ff6781ab4 test/runtime/NMT/CommandLineTurnOffNMT.java --- a/test/runtime/NMT/CommandLineTurnOffNMT.java Fri Jan 10 06:36:18 2014 +0100 +++ b/test/runtime/NMT/CommandLineTurnOffNMT.java Fri Jan 10 12:54:08 2014 -0800 @@ -24,7 +24,7 @@ /* * @test * @key nmt - * @summary Turning off NMT should not result in an error or warning + * @summary Turning off NMT should not result in an error * @library /testlibrary */ @@ -38,7 +38,6 @@ "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("error"); - output.shouldNotContain("warning"); output.shouldHaveExitValue(0); } } diff -r 7c0122ed05fb -r db1ff6781ab4 test/runtime/NMT/PrintNMTStatistics.java --- a/test/runtime/NMT/PrintNMTStatistics.java Fri Jan 10 06:36:18 2014 +0100 +++ b/test/runtime/NMT/PrintNMTStatistics.java Fri Jan 10 12:54:08 2014 -0800 @@ -64,7 +64,6 @@ OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Java Heap (reserved="); output.shouldNotContain("error"); - output.shouldNotContain("warning"); output.shouldHaveExitValue(0); } } diff -r 7c0122ed05fb -r db1ff6781ab4 test/runtime/PerfMemDestroy/PerfMemDestroy.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/runtime/PerfMemDestroy/PerfMemDestroy.java Fri Jan 10 12:54:08 2014 -0800 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8030955 + * @summary Allow multiple calls to PerfMemory::destroy() without asserting. + * @library /testlibrary + * @run main PerfMemDestroy + */ + +import java.io.File; +import java.util.Map; +import com.oracle.java.testlibrary.*; + +public class PerfMemDestroy { + public static void main(String args[]) throws Throwable { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PerfAllowAtExitRegistration", "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + } +} diff -r 7c0122ed05fb -r db1ff6781ab4 test/runtime/XCheckJniJsig/XCheckJSig.java --- a/test/runtime/XCheckJniJsig/XCheckJSig.java Fri Jan 10 06:36:18 2014 +0100 +++ b/test/runtime/XCheckJniJsig/XCheckJSig.java Fri Jan 10 12:54:08 2014 -0800 @@ -22,7 +22,6 @@ */ /* - * @ignore 8023735 * @test * @bug 7051189 8023393 * @summary Need to suppress info message if -Xcheck:jni is used with libjsig.so @@ -30,7 +29,8 @@ * @run main XCheckJSig */ -import java.util.*; +import java.io.File; +import java.util.Map; import com.oracle.java.testlibrary.*; public class XCheckJSig { @@ -47,33 +47,36 @@ String libjsig; String env_var; if (Platform.isOSX()) { - libjsig = jdk_path + "/jre/lib/server/libjsig.dylib"; env_var = "DYLD_INSERT_LIBRARIES"; + libjsig = jdk_path + "/jre/lib/libjsig.dylib"; // jdk location + if (!(new File(libjsig).exists())) { + libjsig = jdk_path + "/lib/libjsig.dylib"; // jre location + } } else { - libjsig = jdk_path + "/jre/lib/" + os_arch + "/libjsig.so"; env_var = "LD_PRELOAD"; - } - String java_program; - if (Platform.isSolaris()) { - // On Solaris, need to call the 64-bit Java directly in order for - // LD_PRELOAD to work because libjsig.so is 64-bit. - java_program = jdk_path + "/jre/bin/" + os_arch + "/java"; - } else { - java_program = JDKToolFinder.getJDKTool("java"); + libjsig = jdk_path + "/jre/lib/" + os_arch + "/libjsig.so"; // jdk location + if (!(new File(libjsig).exists())) { + libjsig = jdk_path + "/lib/" + os_arch + "/libjsig.so"; // jre location + } } // If this test fails, these might be useful to know. System.out.println("libjsig: " + libjsig); System.out.println("osArch: " + os_arch); - System.out.println("java_program: " + java_program); - ProcessBuilder pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-version"); + // Make sure the libjsig file exists. + if (!(new File(libjsig).exists())) { + System.out.println("File " + libjsig + " not found, skipping"); + return; + } + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xcheck:jni", "-version"); Map env = pb.environment(); env.put(env_var, libjsig); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("libjsig is activated"); output.shouldHaveExitValue(0); - pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-verbose:jni", "-version"); + pb = ProcessTools.createJavaProcessBuilder("-Xcheck:jni", "-verbose:jni", "-version"); env = pb.environment(); env.put(env_var, libjsig); output = new OutputAnalyzer(pb.start());