# HG changeset patch # User jwilhelm # Date 1368763270 -7200 # Node ID 2958af1d8c5a8aa2807f300db9b1a4b75d623890 # Parent 513a5298c1dd7d4ba2ba28f654aa53aa512f4c1f# Parent acac2b03a07fa27e62f84173ca6f32a0f6b22e54 Merge diff -r acac2b03a07f -r 2958af1d8c5a agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java --- a/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java Thu May 16 23:51:51 2013 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java Fri May 17 06:01:10 2013 +0200 @@ -97,8 +97,8 @@ holder.getName().asString() + " " + OopUtilities.escapeString(method.getName().asString()) + " " + method.getSignature().asString() + " " + - method.getInvocationCounter() + " " + - method.getBackedgeCounter() + " " + + method.getInvocationCount() + " " + + method.getBackedgeCount() + " " + interpreterInvocationCount() + " " + interpreterThrowoutCount() + " " + instructionsSize()); diff -r acac2b03a07f -r 2958af1d8c5a agent/src/share/classes/sun/jvm/hotspot/oops/Method.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java Thu May 16 23:51:51 2013 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java Fri May 17 06:01:10 2013 +0200 @@ -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 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 @@ holder.getName().asString() + " " + OopUtilities.escapeString(getName().asString()) + " " + getSignature().asString() + " " + - getInvocationCounter() + " " + - getBackedgeCounter() + " " + + getInvocationCount() + " " + + getBackedgeCount() + " " + interpreterInvocationCount() + " " + interpreterThrowoutCount() + " " + code_size); diff -r acac2b03a07f -r 2958af1d8c5a agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java Thu May 16 23:51:51 2013 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java Fri May 17 06:01:10 2013 +0200 @@ -316,8 +316,8 @@ 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; diff -r acac2b03a07f -r 2958af1d8c5a make/bsd/makefiles/fastdebug.make --- a/make/bsd/makefiles/fastdebug.make Thu May 16 23:51:51 2013 +0200 +++ b/make/bsd/makefiles/fastdebug.make Fri May 17 06:01:10 2013 +0200 @@ -58,6 +58,6 @@ # Linker mapfile MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug -VERSION = optimized +VERSION = fastdebug SYSDEFS += -DASSERT PICFLAGS = DEFAULT diff -r acac2b03a07f -r 2958af1d8c5a make/bsd/makefiles/vm.make --- a/make/bsd/makefiles/vm.make Thu May 16 23:51:51 2013 +0200 +++ b/make/bsd/makefiles/vm.make Fri May 17 06:01:10 2013 +0200 @@ -144,6 +144,9 @@ ifeq ($(OS_VENDOR), Darwin) LIBJVM = lib$(JVM).dylib CFLAGS += -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE + ifeq (${VERSION}, $(filter ${VERSION}, debug fastdebug)) + CFLAGS += -DALLOW_OPERATOR_NEW_USAGE + endif else LIBJVM = lib$(JVM).so endif diff -r acac2b03a07f -r 2958af1d8c5a src/os/windows/vm/os_windows.cpp --- a/src/os/windows/vm/os_windows.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/os/windows/vm/os_windows.cpp Fri May 17 06:01:10 2013 +0200 @@ -3307,7 +3307,7 @@ assert(ret != SYS_THREAD_ERROR, "StartThread failed"); // should propagate back } -class HighResolutionInterval { +class HighResolutionInterval : public CHeapObj { // The default timer resolution seems to be 10 milliseconds. // (Where is this written down?) // If someone wants to sleep for only a fraction of the default, diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/c1/c1_Runtime1.cpp --- a/src/share/vm/c1/c1_Runtime1.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/c1/c1_Runtime1.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -1261,7 +1261,7 @@ if (length == 0) return ac_ok; if (src->is_typeArray()) { - Klass* const klass_oop = src->klass(); + Klass* klass_oop = src->klass(); if (klass_oop != dst->klass()) return ac_failed; TypeArrayKlass* klass = TypeArrayKlass::cast(klass_oop); const int l2es = klass->log2_element_size(); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/ci/ciReplay.cpp --- a/src/share/vm/ci/ciReplay.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/ci/ciReplay.cpp Fri May 17 06:01:10 2013 +0200 @@ -492,7 +492,9 @@ } Klass* k = parse_klass(CHECK); rec->oops_offsets[i] = offset; - rec->oops_handles[i] = (jobject)(new KlassHandle(THREAD, k)); + KlassHandle *kh = NEW_C_HEAP_OBJ(KlassHandle, mtCompiler); + ::new ((void*)kh) KlassHandle(THREAD, k); + rec->oops_handles[i] = (jobject)kh; } } diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/classfile/altHashing.cpp --- a/src/share/vm/classfile/altHashing.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/classfile/altHashing.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -242,8 +242,8 @@ void AltHashing::testMurmur3_32_ByteArray() { // printf("testMurmur3_32_ByteArray\n"); - jbyte* vector = new jbyte[256]; - jbyte* hashes = new jbyte[4 * 256]; + jbyte vector[256]; + jbyte hashes[4 * 256]; for (int i = 0; i < 256; i++) { vector[i] = (jbyte) i; diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/classfile/classFileParser.cpp --- a/src/share/vm/classfile/classFileParser.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/classfile/classFileParser.cpp Fri May 17 06:01:10 2013 +0200 @@ -3114,9 +3114,6 @@ // Field size and offset computation int nonstatic_field_size = _super_klass() == NULL ? 0 : _super_klass()->nonstatic_field_size(); -#ifndef PRODUCT - int orig_nonstatic_field_size = 0; -#endif int next_static_oop_offset; int next_static_double_offset; int next_static_word_offset; @@ -3201,25 +3198,6 @@ first_nonstatic_oop_offset = 0; // will be set for first oop field -#ifndef PRODUCT - if( PrintCompactFieldsSavings ) { - next_nonstatic_double_offset = next_nonstatic_field_offset + - (nonstatic_oop_count * heapOopSize); - if ( nonstatic_double_count > 0 ) { - next_nonstatic_double_offset = align_size_up(next_nonstatic_double_offset, BytesPerLong); - } - next_nonstatic_word_offset = next_nonstatic_double_offset + - (nonstatic_double_count * BytesPerLong); - next_nonstatic_short_offset = next_nonstatic_word_offset + - (nonstatic_word_count * BytesPerInt); - next_nonstatic_byte_offset = next_nonstatic_short_offset + - (nonstatic_short_count * BytesPerShort); - next_nonstatic_type_offset = align_size_up((next_nonstatic_byte_offset + - nonstatic_byte_count ), heapOopSize ); - orig_nonstatic_field_size = nonstatic_field_size + - ((next_nonstatic_type_offset - first_nonstatic_field_offset)/heapOopSize); - } -#endif bool compact_fields = CompactFields; int allocation_style = FieldsAllocationStyle; if( allocation_style < 0 || allocation_style > 2 ) { // Out of range? @@ -3593,21 +3571,6 @@ first_nonstatic_oop_offset); #ifndef PRODUCT - if( PrintCompactFieldsSavings ) { - ResourceMark rm; - if( nonstatic_field_size < orig_nonstatic_field_size ) { - tty->print("[Saved %d of %d bytes in %s]\n", - (orig_nonstatic_field_size - nonstatic_field_size)*heapOopSize, - orig_nonstatic_field_size*heapOopSize, - _class_name); - } else if( nonstatic_field_size > orig_nonstatic_field_size ) { - tty->print("[Wasted %d over %d bytes in %s]\n", - (nonstatic_field_size - orig_nonstatic_field_size)*heapOopSize, - orig_nonstatic_field_size*heapOopSize, - _class_name); - } - } - if (PrintFieldLayout) { print_field_layout(_class_name, _fields, diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/classfile/dictionary.cpp --- a/src/share/vm/classfile/dictionary.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/classfile/dictionary.cpp Fri May 17 06:01:10 2013 +0200 @@ -253,22 +253,6 @@ } } - -// All classes, and their class loaders -// (added for helpers that use HandleMarks and ResourceMarks) -// Don't iterate over placeholders -void Dictionary::classes_do(void f(Klass*, ClassLoaderData*, TRAPS), TRAPS) { - for (int index = 0; index < table_size(); index++) { - for (DictionaryEntry* probe = bucket(index); - probe != NULL; - probe = probe->next()) { - Klass* k = probe->klass(); - f(k, probe->loader_data(), CHECK); - } - } -} - - // All classes, and their class loaders // Don't iterate over placeholders void Dictionary::classes_do(void f(Klass*, ClassLoaderData*)) { diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/classfile/dictionary.hpp --- a/src/share/vm/classfile/dictionary.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/classfile/dictionary.hpp Fri May 17 06:01:10 2013 +0200 @@ -90,7 +90,6 @@ void classes_do(void f(Klass*)); void classes_do(void f(Klass*, TRAPS), TRAPS); void classes_do(void f(Klass*, ClassLoaderData*)); - void classes_do(void f(Klass*, ClassLoaderData*, TRAPS), TRAPS); void methods_do(void f(Method*)); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/classfile/systemDictionary.cpp --- a/src/share/vm/classfile/systemDictionary.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/classfile/systemDictionary.cpp Fri May 17 06:01:10 2013 +0200 @@ -1747,13 +1747,6 @@ dictionary()->classes_do(f); } -// All classes, and their class loaders -// (added for helpers that use HandleMarks and ResourceMarks) -// Don't iterate over placeholders -void SystemDictionary::classes_do(void f(Klass*, ClassLoaderData*, TRAPS), TRAPS) { - dictionary()->classes_do(f, CHECK); -} - void SystemDictionary::placeholders_do(void f(Symbol*)) { placeholders()->entries_do(f); } diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/classfile/systemDictionary.hpp --- a/src/share/vm/classfile/systemDictionary.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/classfile/systemDictionary.hpp Fri May 17 06:01:10 2013 +0200 @@ -313,10 +313,7 @@ static void classes_do(void f(Klass*, TRAPS), TRAPS); // All classes, and their class loaders static void classes_do(void f(Klass*, ClassLoaderData*)); - // All classes, and their class loaders - // (added for helpers that use HandleMarks and ResourceMarks) - static void classes_do(void f(Klass*, ClassLoaderData*, TRAPS), TRAPS); - // All entries in the placeholder table and their class loaders + static void placeholders_do(void f(Symbol*)); // Iterate over all methods in all klasses in dictionary diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/classfile/verifier.cpp --- a/src/share/vm/classfile/verifier.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/classfile/verifier.cpp Fri May 17 06:01:10 2013 +0200 @@ -362,7 +362,7 @@ } #endif -void ErrorContext::details(outputStream* ss, Method* method) const { +void ErrorContext::details(outputStream* ss, const Method* method) const { if (is_valid()) { ss->print_cr(""); ss->print_cr("Exception Details:"); @@ -435,7 +435,7 @@ ss->print_cr(""); } -void ErrorContext::location_details(outputStream* ss, Method* method) const { +void ErrorContext::location_details(outputStream* ss, const Method* method) const { if (_bci != -1 && method != NULL) { streamIndentor si(ss); const char* bytecode_name = ""; @@ -470,7 +470,7 @@ } } -void ErrorContext::bytecode_details(outputStream* ss, Method* method) const { +void ErrorContext::bytecode_details(outputStream* ss, const Method* method) const { if (method != NULL) { streamIndentor si(ss); ss->indent().print_cr("Bytecode:"); @@ -479,7 +479,7 @@ } } -void ErrorContext::handler_details(outputStream* ss, Method* method) const { +void ErrorContext::handler_details(outputStream* ss, const Method* method) const { if (method != NULL) { streamIndentor si(ss); ExceptionTable table(method); @@ -494,7 +494,7 @@ } } -void ErrorContext::stackmap_details(outputStream* ss, Method* method) const { +void ErrorContext::stackmap_details(outputStream* ss, const Method* method) const { if (method != NULL && method->has_stackmap_table()) { streamIndentor si(ss); ss->indent().print_cr("Stackmap Table:"); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/classfile/verifier.hpp --- a/src/share/vm/classfile/verifier.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/classfile/verifier.hpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -224,7 +224,7 @@ _expected.reset_frame(); } - void details(outputStream* ss, Method* method) const; + void details(outputStream* ss, const Method* method) const; #ifdef ASSERT void print_on(outputStream* str) const { @@ -237,12 +237,12 @@ #endif private: - void location_details(outputStream* ss, Method* method) const; + void location_details(outputStream* ss, const Method* method) const; void reason_details(outputStream* ss) const; void frame_details(outputStream* ss) const; - void bytecode_details(outputStream* ss, Method* method) const; - void handler_details(outputStream* ss, Method* method) const; - void stackmap_details(outputStream* ss, Method* method) const; + void bytecode_details(outputStream* ss, const Method* method) const; + void handler_details(outputStream* ss, const Method* method) const; + void stackmap_details(outputStream* ss, const Method* method) const; }; // A new instance of this class is created for each class being verified diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/code/nmethod.cpp --- a/src/share/vm/code/nmethod.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/code/nmethod.cpp Fri May 17 06:01:10 2013 +0200 @@ -1794,6 +1794,19 @@ 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 @@ Metadata* md = *p; f(md); } + // Call function Method*, not embedded in these other places. if (_method != NULL) f(_method); } diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp --- a/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -52,7 +52,7 @@ } void ConcurrentMarkSweepPolicy::initialize_generations() { - _generations = new GenerationSpecPtr[number_of_generations()]; + _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, 0, AllocFailStrategy::RETURN_NULL); if (_generations == NULL) vm_exit_during_initialization("Unable to allocate gen spec"); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp --- a/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -282,7 +282,8 @@ _fine_eviction_stride = _max_fine_entries / _fine_eviction_sample_size; } - _fine_grain_regions = new PerRegionTablePtr[_max_fine_entries]; + _fine_grain_regions = NEW_C_HEAP_ARRAY3(PerRegionTablePtr, _max_fine_entries, + mtGC, 0, AllocFailStrategy::RETURN_NULL); if (_fine_grain_regions == NULL) { vm_exit_out_of_memory(sizeof(void*)*_max_fine_entries, OOM_MALLOC_ERROR, diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -213,7 +213,7 @@ int random_seed = 17; do { while (ParCompactionManager::steal_objarray(which, &random_seed, task)) { - ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass(); + ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass(); k->oop_follow_contents(cm, task.obj(), task.index()); cm->follow_marking_stacks(); } diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -187,11 +187,8 @@ // Process ObjArrays one at a time to avoid marking stack bloat. ObjArrayTask task; - if (_objarray_stack.pop_overflow(task)) { - ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass(); - k->oop_follow_contents(this, task.obj(), task.index()); - } else if (_objarray_stack.pop_local(task)) { - ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass(); + if (_objarray_stack.pop_overflow(task) || _objarray_stack.pop_local(task)) { + ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass(); k->oop_follow_contents(this, task.obj(), task.index()); } } while (!marking_stacks_empty()); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/gc_implementation/shared/markSweep.cpp --- a/src/share/vm/gc_implementation/shared/markSweep.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/gc_implementation/shared/markSweep.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -95,7 +95,7 @@ // Process ObjArrays one at a time to avoid marking stack bloat. if (!_objarray_stack.is_empty()) { ObjArrayTask task = _objarray_stack.pop(); - ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass(); + ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass(); k->oop_follow_contents(task.obj(), task.index()); } } while (!_marking_stack.is_empty() || !_objarray_stack.is_empty()); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/allocation.cpp --- a/src/share/vm/memory/allocation.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/allocation.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -49,10 +49,15 @@ # include "os_bsd.inline.hpp" #endif -void* StackObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }; -void StackObj::operator delete(void* p) { ShouldNotCallThis(); }; -void* _ValueObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }; -void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); }; +void* StackObj::operator new(size_t size) { ShouldNotCallThis(); return 0; } +void StackObj::operator delete(void* p) { ShouldNotCallThis(); } +void* StackObj::operator new [](size_t size) { ShouldNotCallThis(); return 0; } +void StackObj::operator delete [](void* p) { ShouldNotCallThis(); } + +void* _ValueObj::operator new(size_t size) { ShouldNotCallThis(); return 0; } +void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); } +void* _ValueObj::operator new [](size_t size) { ShouldNotCallThis(); return 0; } +void _ValueObj::operator delete [](void* p) { ShouldNotCallThis(); } void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, bool read_only, TRAPS) { @@ -81,7 +86,6 @@ st->print(" {"INTPTR_FORMAT"}", this); } - void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) { address res; switch (type) { @@ -99,6 +103,10 @@ return res; } +void* ResourceObj::operator new [](size_t size, allocation_type type, MEMFLAGS flags) { + return (address) operator new(size, type, flags); +} + void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_constant, allocation_type type, MEMFLAGS flags) { //should only call this with std::nothrow, use other operator new() otherwise @@ -118,6 +126,10 @@ return res; } +void* ResourceObj::operator new [](size_t size, const std::nothrow_t& nothrow_constant, + allocation_type type, MEMFLAGS flags) { + return (address)operator new(size, nothrow_constant, type, flags); +} void ResourceObj::operator delete(void* p) { assert(((ResourceObj *)p)->allocated_on_C_heap(), @@ -126,6 +138,10 @@ FreeHeap(p); } +void ResourceObj::operator delete [](void* p) { + operator delete(p); +} + #ifdef ASSERT void ResourceObj::set_allocation_type(address res, allocation_type type) { // Set allocation type in the resource object @@ -215,8 +231,6 @@ tty->print_cr("Heap free " INTPTR_FORMAT, p); } -bool warn_new_operator = false; // see vm_main - //-------------------------------------------------------------------------------------- // ChunkPool implementation @@ -360,7 +374,7 @@ void* Chunk::operator new(size_t requested_size, size_t length) { // requested_size is equal to sizeof(Chunk) but in order for the arena // allocations to come out aligned as expected the size must be aligned - // to expected arean alignment. + // to expected arena alignment. // expect requested_size but if sizeof(Chunk) doesn't match isn't proper size we must align it. assert(ARENA_ALIGN(requested_size) == aligned_overhead_size(), "Bad alignment"); size_t bytes = ARENA_ALIGN(requested_size) + length; @@ -669,19 +683,40 @@ // a memory leak. Use CHeapObj as the base class of such objects to make it explicit // that they're allocated on the C heap. // Commented out in product version to avoid conflicts with third-party C++ native code. -// %% note this is causing a problem on solaris debug build. the global -// new is being called from jdk source and causing data corruption. -// src/share/native/sun/awt/font/fontmanager/textcache/hsMemory.cpp::hsSoftNew -// define CATCH_OPERATOR_NEW_USAGE if you want to use this. -#ifdef CATCH_OPERATOR_NEW_USAGE +// On certain platforms, such as Mac OS X (Darwin), in debug version, new is being called +// from jdk source and causing data corruption. Such as +// Java_sun_security_ec_ECKeyPairGenerator_generateECKeyPair +// define ALLOW_OPERATOR_NEW_USAGE for platform on which global operator new allowed. +// +#ifndef ALLOW_OPERATOR_NEW_USAGE void* operator new(size_t size){ - static bool warned = false; - if (!warned && warn_new_operator) - warning("should not call global (default) operator new"); - warned = true; - return (void *) AllocateHeap(size, "global operator new"); + assert(false, "Should not call global operator new"); + return 0; +} + +void* operator new [](size_t size){ + assert(false, "Should not call global operator new[]"); + return 0; +} + +void* operator new(size_t size, const std::nothrow_t& nothrow_constant){ + assert(false, "Should not call global operator new"); + return 0; } -#endif + +void* operator new [](size_t size, std::nothrow_t& nothrow_constant){ + assert(false, "Should not call global operator new[]"); + return 0; +} + +void operator delete(void* p) { + assert(false, "Should not call global delete"); +} + +void operator delete [](void* p) { + assert(false, "Should not call global delete []"); +} +#endif // ALLOW_OPERATOR_NEW_USAGE void AllocatedObj::print() const { print_on(tty); } void AllocatedObj::print_value() const { print_value_on(tty); } diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/allocation.hpp --- a/src/share/vm/memory/allocation.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/allocation.hpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -86,12 +86,23 @@ // subclasses. // // The following macros and function should be used to allocate memory -// directly in the resource area or in the C-heap: +// directly in the resource area or in the C-heap, The _OBJ variants +// of the NEW/FREE_C_HEAP macros are used for alloc/dealloc simple +// objects which are not inherited from CHeapObj, note constructor and +// destructor are not called. The preferable way to allocate objects +// is using the new operator. // -// NEW_RESOURCE_ARRAY(type,size) +// WARNING: The array variant must only be used for a homogenous array +// where all objects are of the exact type specified. If subtypes are +// stored in the array then must pay attention to calling destructors +// at needed. +// +// NEW_RESOURCE_ARRAY(type, size) // NEW_RESOURCE_OBJ(type) -// NEW_C_HEAP_ARRAY(type,size) -// NEW_C_HEAP_OBJ(type) +// NEW_C_HEAP_ARRAY(type, size) +// NEW_C_HEAP_OBJ(type, memflags) +// FREE_C_HEAP_ARRAY(type, old, memflags) +// FREE_C_HEAP_OBJ(objname, type, memflags) // char* AllocateHeap(size_t size, const char* name); // void FreeHeap(void* p); // @@ -195,8 +206,11 @@ _NOINLINE_ void* operator new(size_t size, address caller_pc = 0); _NOINLINE_ void* operator new (size_t size, const std::nothrow_t& nothrow_constant, address caller_pc = 0); - + _NOINLINE_ void* operator new [](size_t size, address caller_pc = 0); + _NOINLINE_ void* operator new [](size_t size, const std::nothrow_t& nothrow_constant, + address caller_pc = 0); void operator delete(void* p); + void operator delete [] (void* p); }; // Base class for objects allocated on the stack only. @@ -206,6 +220,8 @@ private: void* operator new(size_t size); void operator delete(void* p); + void* operator new [](size_t size); + void operator delete [](void* p); }; // Base class for objects used as value objects. @@ -229,7 +245,9 @@ class _ValueObj { private: void* operator new(size_t size); - void operator delete(void* p); + void operator delete(void* p); + void* operator new [](size_t size); + void operator delete [](void* p); }; @@ -510,13 +528,24 @@ public: void* operator new(size_t size, allocation_type type, MEMFLAGS flags); + void* operator new [](size_t size, allocation_type type, MEMFLAGS flags); void* operator new(size_t size, const std::nothrow_t& nothrow_constant, allocation_type type, MEMFLAGS flags); + void* operator new [](size_t size, const std::nothrow_t& nothrow_constant, + allocation_type type, MEMFLAGS flags); + void* operator new(size_t size, Arena *arena) { address res = (address)arena->Amalloc(size); DEBUG_ONLY(set_allocation_type(res, ARENA);) return res; } + + void* operator new [](size_t size, Arena *arena) { + address res = (address)arena->Amalloc(size); + DEBUG_ONLY(set_allocation_type(res, ARENA);) + return res; + } + void* operator new(size_t size) { address res = (address)resource_allocate_bytes(size); DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);) @@ -529,7 +558,20 @@ return res; } + void* operator new [](size_t size) { + address res = (address)resource_allocate_bytes(size); + DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);) + return res; + } + + void* operator new [](size_t size, const std::nothrow_t& nothrow_constant) { + address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL); + DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);) + return res; + } + void operator delete(void* p); + void operator delete [](void* p); }; // One of the following macros must be used when allocating an array @@ -563,24 +605,25 @@ #define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\ (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags)) -#define FREE_C_HEAP_ARRAY(type,old,memflags) \ +#define FREE_C_HEAP_ARRAY(type, old, memflags) \ FreeHeap((char*)(old), memflags) -#define NEW_C_HEAP_OBJ(type, memflags)\ - NEW_C_HEAP_ARRAY(type, 1, memflags) - - #define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\ (type*) (AllocateHeap((size) * sizeof(type), memflags, pc)) #define REALLOC_C_HEAP_ARRAY2(type, old, size, memflags, pc)\ (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags, pc)) -#define NEW_C_HEAP_OBJ2(type, memflags, pc)\ - NEW_C_HEAP_ARRAY2(type, 1, memflags, pc) +#define NEW_C_HEAP_ARRAY3(type, size, memflags, pc, allocfail) \ + (type*) AllocateHeap(size * sizeof(type), memflags, pc, allocfail) +// allocate type in heap without calling ctor +#define NEW_C_HEAP_OBJ(type, memflags)\ + NEW_C_HEAP_ARRAY(type, 1, memflags) -extern bool warn_new_operator; +// deallocate obj of type in heap without calling dtor +#define FREE_C_HEAP_OBJ(objname, memflags)\ + FreeHeap((char*)objname, memflags); // for statistics #ifndef PRODUCT diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/allocation.inline.hpp --- a/src/share/vm/memory/allocation.inline.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/allocation.inline.hpp Fri May 17 06:01:10 2013 +0200 @@ -86,30 +86,39 @@ template void* CHeapObj::operator new(size_t size, address caller_pc){ + void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); #ifdef ASSERT - void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); +#endif return p; -#else - return (void *) AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); -#endif } template void* CHeapObj::operator new (size_t size, const std::nothrow_t& nothrow_constant, address caller_pc) { -#ifdef ASSERT void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC), AllocFailStrategy::RETURN_NULL); +#ifdef ASSERT if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); +#endif return p; -#else - return (void *) AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC), - AllocFailStrategy::RETURN_NULL); -#endif +} + +template void* CHeapObj::operator new [](size_t size, + address caller_pc){ + return CHeapObj::operator new(size, caller_pc); +} + +template void* CHeapObj::operator new [](size_t size, + const std::nothrow_t& nothrow_constant, address caller_pc) { + return CHeapObj::operator new(size, nothrow_constant, caller_pc); } template void CHeapObj::operator delete(void* p){ - FreeHeap(p, F); + FreeHeap(p, F); +} + +template void CHeapObj::operator delete [](void* p){ + FreeHeap(p, F); } template diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/cardTableModRefBS.cpp --- a/src/share/vm/memory/cardTableModRefBS.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/cardTableModRefBS.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -80,15 +80,11 @@ _covered = new MemRegion[max_covered_regions]; _committed = new MemRegion[max_covered_regions]; - if (_covered == NULL || _committed == NULL) + if (_covered == NULL || _committed == NULL) { vm_exit_during_initialization("couldn't alloc card table covered region set."); - int i; - for (i = 0; i < max_covered_regions; i++) { - _covered[i].set_word_size(0); - _committed[i].set_word_size(0); } + _cur_covered_regions = 0; - const size_t rs_align = _page_size == (size_t) os::vm_page_size() ? 0 : MAX2(_page_size, (size_t) os::vm_allocation_granularity()); ReservedSpace heap_rs(_byte_map_size, rs_align, false); @@ -134,7 +130,7 @@ || _lowest_non_clean_base_chunk_index == NULL || _last_LNC_resizing_collection == NULL) vm_exit_during_initialization("couldn't allocate an LNC array."); - for (i = 0; i < max_covered_regions; i++) { + for (int i = 0; i < max_covered_regions; i++) { _lowest_non_clean[i] = NULL; _lowest_non_clean_chunk_size[i] = 0; _last_LNC_resizing_collection[i] = -1; @@ -153,6 +149,33 @@ } } +CardTableModRefBS::~CardTableModRefBS() { + if (_covered) { + delete[] _covered; + _covered = NULL; + } + if (_committed) { + delete[] _committed; + _committed = NULL; + } + if (_lowest_non_clean) { + FREE_C_HEAP_ARRAY(CardArr, _lowest_non_clean, mtGC); + _lowest_non_clean = NULL; + } + if (_lowest_non_clean_chunk_size) { + FREE_C_HEAP_ARRAY(size_t, _lowest_non_clean_chunk_size, mtGC); + _lowest_non_clean_chunk_size = NULL; + } + if (_lowest_non_clean_base_chunk_index) { + FREE_C_HEAP_ARRAY(uintptr_t, _lowest_non_clean_base_chunk_index, mtGC); + _lowest_non_clean_base_chunk_index = NULL; + } + if (_last_LNC_resizing_collection) { + FREE_C_HEAP_ARRAY(int, _last_LNC_resizing_collection, mtGC); + _last_LNC_resizing_collection = NULL; + } +} + int CardTableModRefBS::find_covering_region_by_base(HeapWord* base) { int i; for (i = 0; i < _cur_covered_regions; i++) { diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/cardTableModRefBS.hpp --- a/src/share/vm/memory/cardTableModRefBS.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/cardTableModRefBS.hpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -280,6 +280,7 @@ } CardTableModRefBS(MemRegion whole_heap, int max_covered_regions); + ~CardTableModRefBS(); // *** Barrier set functions. diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/cardTableRS.cpp --- a/src/share/vm/memory/cardTableRS.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/cardTableRS.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -54,9 +54,10 @@ _ct_bs = new CardTableModRefBSForCTRS(whole_heap, max_covered_regions); #endif set_bs(_ct_bs); - _last_cur_val_in_gen = new jbyte[GenCollectedHeap::max_gens + 1]; + _last_cur_val_in_gen = NEW_C_HEAP_ARRAY3(jbyte, GenCollectedHeap::max_gens + 1, + mtGC, 0, AllocFailStrategy::RETURN_NULL); if (_last_cur_val_in_gen == NULL) { - vm_exit_during_initialization("Could not last_cur_val_in_gen array."); + vm_exit_during_initialization("Could not create last_cur_val_in_gen array."); } for (int i = 0; i < GenCollectedHeap::max_gens + 1; i++) { _last_cur_val_in_gen[i] = clean_card_val(); @@ -64,6 +65,16 @@ _ct_bs->set_CTRS(this); } +CardTableRS::~CardTableRS() { + if (_ct_bs) { + delete _ct_bs; + _ct_bs = NULL; + } + if (_last_cur_val_in_gen) { + FREE_C_HEAP_ARRAY(jbyte, _last_cur_val_in_gen, mtInternal); + } +} + void CardTableRS::resize_covered_region(MemRegion new_region) { _ct_bs->resize_covered_region(new_region); } diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/cardTableRS.hpp --- a/src/share/vm/memory/cardTableRS.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/cardTableRS.hpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -102,6 +102,7 @@ public: CardTableRS(MemRegion whole_heap, int max_covered_regions); + ~CardTableRS(); // *** GenRemSet functions. GenRemSet::Name rs_kind() { return GenRemSet::CardTable; } diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/collectorPolicy.cpp --- a/src/share/vm/memory/collectorPolicy.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/collectorPolicy.cpp Fri May 17 06:01:10 2013 +0200 @@ -877,7 +877,7 @@ } void MarkSweepPolicy::initialize_generations() { - _generations = new GenerationSpecPtr[number_of_generations()]; + _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, 0, AllocFailStrategy::RETURN_NULL); if (_generations == NULL) vm_exit_during_initialization("Unable to allocate gen spec"); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/heapInspection.cpp --- a/src/share/vm/memory/heapInspection.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/heapInspection.cpp Fri May 17 06:01:10 2013 +0200 @@ -154,12 +154,12 @@ } } -uint KlassInfoTable::hash(Klass* p) { +uint KlassInfoTable::hash(const Klass* p) { assert(p->is_metadata(), "all klasses are metadata"); return (uint)(((uintptr_t)p - (uintptr_t)_ref) >> 2); } -KlassInfoEntry* KlassInfoTable::lookup(Klass* const k) { +KlassInfoEntry* KlassInfoTable::lookup(Klass* k) { uint idx = hash(k) % _size; assert(_buckets != NULL, "Allocation failure should have been caught"); KlassInfoEntry* e = _buckets[idx].lookup(k); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/heapInspection.hpp --- a/src/share/vm/memory/heapInspection.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/heapInspection.hpp Fri May 17 06:01:10 2013 +0200 @@ -189,15 +189,15 @@ KlassInfoEntry(Klass* k, KlassInfoEntry* next) : _klass(k), _instance_count(0), _instance_words(0), _next(next), _index(-1) {} - KlassInfoEntry* next() { return _next; } - bool is_equal(Klass* k) { return k == _klass; } - Klass* klass() { return _klass; } - long count() { return _instance_count; } + KlassInfoEntry* next() const { return _next; } + bool is_equal(const Klass* k) { return k == _klass; } + Klass* klass() const { return _klass; } + long count() const { return _instance_count; } void set_count(long ct) { _instance_count = ct; } - size_t words() { return _instance_words; } + size_t words() const { return _instance_words; } void set_words(size_t wds) { _instance_words = wds; } void set_index(long index) { _index = index; } - long index() { return _index; } + long index() const { return _index; } int compare(KlassInfoEntry* e1, KlassInfoEntry* e2); void print_on(outputStream* st) const; const char* name() const; @@ -215,7 +215,7 @@ KlassInfoEntry* list() { return _list; } void set_list(KlassInfoEntry* l) { _list = l; } public: - KlassInfoEntry* lookup(Klass* const k); + KlassInfoEntry* lookup(Klass* k); void initialize() { _list = NULL; } void empty(); void iterate(KlassInfoClosure* cic); @@ -231,8 +231,8 @@ HeapWord* _ref; KlassInfoBucket* _buckets; - uint hash(Klass* p); - KlassInfoEntry* lookup(Klass* const k); // allocates if not found! + uint hash(const Klass* p); + KlassInfoEntry* lookup(Klass* k); // allocates if not found! class AllClassesFinder : public KlassClosure { KlassInfoTable *_table; diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/memRegion.cpp --- a/src/share/vm/memory/memRegion.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/memRegion.cpp Fri May 17 06:01:10 2013 +0200 @@ -23,6 +23,8 @@ */ #include "precompiled.hpp" +#include "memory/allocation.hpp" +#include "memory/allocation.inline.hpp" #include "memory/memRegion.hpp" #include "runtime/globals.hpp" @@ -99,3 +101,19 @@ ShouldNotReachHere(); return MemRegion(); } + +void* MemRegion::operator new(size_t size) { + return (address)AllocateHeap(size, mtGC, 0, AllocFailStrategy::RETURN_NULL); +} + +void* MemRegion::operator new [](size_t size) { + return (address)AllocateHeap(size, mtGC, 0, AllocFailStrategy::RETURN_NULL); +} +void MemRegion::operator delete(void* p) { + FreeHeap(p, mtGC); +} + +void MemRegion::operator delete [](void* p) { + FreeHeap(p, mtGC); +} + diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/memRegion.hpp --- a/src/share/vm/memory/memRegion.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/memRegion.hpp Fri May 17 06:01:10 2013 +0200 @@ -34,7 +34,9 @@ // Note that MemRegions are passed by value, not by reference. // The intent is that they remain very small and contain no -// objects. +// objects. _ValueObj should never be allocated in heap but we do +// create MemRegions (in CardTableModRefBS) in heap so operator +// new and operator new [] added for this special case. class MetaWord; @@ -92,6 +94,10 @@ size_t word_size() const { return _word_size; } bool is_empty() const { return word_size() == 0; } + void* operator new(size_t size); + void* operator new [](size_t size); + void operator delete(void* p); + void operator delete [](void* p); }; // For iteration over MemRegion's. diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/universe.cpp --- a/src/share/vm/memory/universe.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/universe.cpp Fri May 17 06:01:10 2013 +0200 @@ -1425,25 +1425,25 @@ } -void ActiveMethodOopsCache::add_previous_version(Method* const method) { +void ActiveMethodOopsCache::add_previous_version(Method* method) { assert(Thread::current()->is_VM_thread(), "only VMThread can add previous versions"); // Only append the previous method if it is executing on the stack. if (method->on_stack()) { - if (_prev_methods == NULL) { - // This is the first previous version so make some space. - // Start with 2 elements under the assumption that the class - // won't be redefined much. + if (_prev_methods == NULL) { + // This is the first previous version so make some space. + // Start with 2 elements under the assumption that the class + // won't be redefined much. _prev_methods = new (ResourceObj::C_HEAP, mtClass) GrowableArray(2, true); - } + } - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE(0x00000100, - ("add: %s(%s): adding prev version ref for cached method @%d", - method->name()->as_C_string(), method->signature()->as_C_string(), - _prev_methods->length())); + // RC_TRACE macro has an embedded ResourceMark + RC_TRACE(0x00000100, + ("add: %s(%s): adding prev version ref for cached method @%d", + method->name()->as_C_string(), method->signature()->as_C_string(), + _prev_methods->length())); _prev_methods->append(method); } @@ -1464,16 +1464,17 @@ MetadataFactory::free_metadata(method->method_holder()->class_loader_data(), method); } else { // RC_TRACE macro has an embedded ResourceMark - RC_TRACE(0x00000400, ("add: %s(%s): previous cached method @%d is alive", - method->name()->as_C_string(), method->signature()->as_C_string(), i)); + RC_TRACE(0x00000400, + ("add: %s(%s): previous cached method @%d is alive", + method->name()->as_C_string(), method->signature()->as_C_string(), i)); } } } // end add_previous_version() -bool ActiveMethodOopsCache::is_same_method(Method* const method) const { +bool ActiveMethodOopsCache::is_same_method(const Method* method) const { InstanceKlass* ik = InstanceKlass::cast(klass()); - Method* check_method = ik->method_with_idnum(method_idnum()); + const Method* check_method = ik->method_with_idnum(method_idnum()); assert(check_method != NULL, "sanity check"); if (check_method == method) { // done with the easy case diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/memory/universe.hpp --- a/src/share/vm/memory/universe.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/memory/universe.hpp Fri May 17 06:01:10 2013 +0200 @@ -90,8 +90,8 @@ ActiveMethodOopsCache() { _prev_methods = NULL; } ~ActiveMethodOopsCache(); - void add_previous_version(Method* const method); - bool is_same_method(Method* const method) const; + void add_previous_version(Method* method); + bool is_same_method(const Method* method) const; }; diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/oops/constantPool.hpp --- a/src/share/vm/oops/constantPool.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/oops/constantPool.hpp Fri May 17 06:01:10 2013 +0200 @@ -354,7 +354,7 @@ Symbol* klass_name_at(int which); // Returns the name, w/o resolving. - Klass* resolved_klass_at(int which) { // Used by Compiler + Klass* resolved_klass_at(int which) const { // Used by Compiler guarantee(tag_at(which).is_klass(), "Corrupted constant pool"); // Must do an acquire here in case another thread resolved the klass // behind our back, lest we later load stale values thru the oop. diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/oops/instanceKlass.cpp --- a/src/share/vm/oops/instanceKlass.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/oops/instanceKlass.cpp Fri May 17 06:01:10 2013 +0200 @@ -2724,7 +2724,7 @@ OsrList_lock->unlock(); } -nmethod* InstanceKlass::lookup_osr_nmethod(Method* const m, int bci, int comp_level, bool match_level) const { +nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_level, bool match_level) const { // This is a short non-blocking critical region, so the no safepoint check is ok. OsrList_lock->lock_without_safepoint_check(); nmethod* osr = osr_nmethods_head(); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/oops/instanceKlass.hpp --- a/src/share/vm/oops/instanceKlass.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/oops/instanceKlass.hpp Fri May 17 06:01:10 2013 +0200 @@ -739,7 +739,7 @@ void set_osr_nmethods_head(nmethod* h) { _osr_nmethods_head = h; }; void add_osr_nmethod(nmethod* n); void remove_osr_nmethod(nmethod* n); - nmethod* lookup_osr_nmethod(Method* const m, int bci, int level, bool match_level) const; + nmethod* lookup_osr_nmethod(const Method* m, int bci, int level, bool match_level) const; // Breakpoint support (see methods on Method* for details) BreakpointInfo* breakpoints() const { return _breakpoints; }; diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/oops/klass.cpp --- a/src/share/vm/oops/klass.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/oops/klass.cpp Fri May 17 06:01:10 2013 +0200 @@ -50,7 +50,7 @@ if (_name != NULL) _name->increment_refcount(); } -bool Klass::is_subclass_of(Klass* k) const { +bool Klass::is_subclass_of(const Klass* k) const { // Run up the super chain and check if (this == k) return true; diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/oops/klass.hpp --- a/src/share/vm/oops/klass.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/oops/klass.hpp Fri May 17 06:01:10 2013 +0200 @@ -393,9 +393,10 @@ // vtables virtual klassVtable* vtable() const { return NULL; } + virtual int vtable_length() const { return 0; } // subclass check - bool is_subclass_of(Klass* k) const; + bool is_subclass_of(const Klass* k) const; // subtype check: true if is_subclass_of, or if k is interface and receiver implements it bool is_subtype_of(Klass* k) const { juint off = k->super_check_offset(); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/oops/method.cpp --- a/src/share/vm/oops/method.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/oops/method.cpp Fri May 17 06:01:10 2013 +0200 @@ -1581,7 +1581,7 @@ } int Method::highest_comp_level() const { - MethodData* mdo = method_data(); + const MethodData* mdo = method_data(); if (mdo != NULL) { return mdo->highest_comp_level(); } else { @@ -1590,7 +1590,7 @@ } int Method::highest_osr_comp_level() const { - MethodData* mdo = method_data(); + const MethodData* mdo = method_data(); if (mdo != NULL) { return mdo->highest_osr_comp_level(); } else { diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/oops/method.hpp --- a/src/share/vm/oops/method.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/oops/method.hpp Fri May 17 06:01:10 2013 +0200 @@ -986,7 +986,7 @@ u2 _length; public: - ExceptionTable(Method* m) { + ExceptionTable(const Method* m) { if (m->has_exception_handler()) { _table = m->exception_table_start(); _length = m->exception_table_length(); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/oops/methodData.hpp --- a/src/share/vm/oops/methodData.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/oops/methodData.hpp Fri May 17 06:01:10 2013 +0200 @@ -1338,9 +1338,9 @@ void set_would_profile(bool p) { _would_profile = p; } bool would_profile() const { return _would_profile; } - int highest_comp_level() { return _highest_comp_level; } + int highest_comp_level() const { return _highest_comp_level; } void set_highest_comp_level(int level) { _highest_comp_level = level; } - int highest_osr_comp_level() { return _highest_osr_comp_level; } + int highest_osr_comp_level() const { return _highest_osr_comp_level; } void set_highest_osr_comp_level(int level) { _highest_osr_comp_level = level; } int num_loops() const { return _num_loops; } diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/opto/idealGraphPrinter.hpp --- a/src/share/vm/opto/idealGraphPrinter.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/opto/idealGraphPrinter.hpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -41,9 +41,8 @@ class InlineTree; class ciMethod; -class IdealGraphPrinter -{ -private: +class IdealGraphPrinter : public CHeapObj { + private: static const char *INDENT; static const char *TOP_ELEMENT; @@ -121,7 +120,7 @@ IdealGraphPrinter(); ~IdealGraphPrinter(); -public: + public: static void clean_up(); static IdealGraphPrinter *printer(); @@ -135,8 +134,6 @@ void print_method(Compile* compile, const char *name, int level=1, bool clear_nodes = false); void print(Compile* compile, const char *name, Node *root, int level=1, bool clear_nodes = false); void print_xml(const char *name); - - }; #endif diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/prims/jvm.cpp --- a/src/share/vm/prims/jvm.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/prims/jvm.cpp Fri May 17 06:01:10 2013 +0200 @@ -1710,7 +1710,7 @@ for (int i = 0; i < num_params; i++) { MethodParametersElement* params = mh->method_parameters_start(); // For a 0 index, give a NULL symbol - Symbol* const sym = 0 != params[i].name_cp_index ? + Symbol* sym = 0 != params[i].name_cp_index ? mh->constants()->symbol_at(params[i].name_cp_index) : NULL; int flags = params[i].flags; oop param = Reflection::new_parameter(reflected_method, i, sym, diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/prims/jvmtiExport.cpp --- a/src/share/vm/prims/jvmtiExport.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/prims/jvmtiExport.cpp Fri May 17 06:01:10 2013 +0200 @@ -619,6 +619,9 @@ // 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; } diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/prims/jvmtiRedefineClasses.cpp --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp Fri May 17 06:01:10 2013 +0200 @@ -160,7 +160,8 @@ if (RC_TRACE_ENABLED(0x00004000)) { #endif RC_TRACE_WITH_THREAD(0x00004000, thread, ("calling check_class")); - SystemDictionary::classes_do(check_class, thread); + CheckClass check_class(thread); + ClassLoaderDataGraph::classes_do(&check_class); #ifdef PRODUCT } #endif @@ -2653,29 +2654,35 @@ } // end set_new_constant_pool() -void VM_RedefineClasses::adjust_array_vtable(Klass* k_oop) { - ArrayKlass* ak = ArrayKlass::cast(k_oop); - bool trace_name_printed = false; - ak->vtable()->adjust_method_entries(_matching_old_methods, - _matching_new_methods, - _matching_methods_length, - &trace_name_printed); -} - // Unevolving classes may point to methods of the_class directly // from their constant pool caches, itables, and/or vtables. We -// use the SystemDictionary::classes_do() facility and this helper +// use the ClassLoaderDataGraph::classes_do() facility and this helper // to fix up these pointers. -// -// Note: We currently don't support updating the vtable in -// arrayKlassOops. See Open Issues in jvmtiRedefineClasses.hpp. -void VM_RedefineClasses::adjust_cpool_cache_and_vtable(Klass* k_oop, - ClassLoaderData* initiating_loader, - TRAPS) { - Klass *k = k_oop; - if (k->oop_is_instance()) { - HandleMark hm(THREAD); - InstanceKlass *ik = (InstanceKlass *) k; + +// Adjust cpools and vtables closure +void VM_RedefineClasses::AdjustCpoolCacheAndVtable::do_klass(Klass* k) { + + // This is a very busy routine. We don't want too much tracing + // printed out. + bool trace_name_printed = false; + + // Very noisy: only enable this call if you are trying to determine + // that a specific class gets found by this routine. + // RC_TRACE macro has an embedded ResourceMark + // RC_TRACE_WITH_THREAD(0x00100000, THREAD, + // ("adjust check: name=%s", k->external_name())); + // trace_name_printed = true; + + // If the class being redefined is java.lang.Object, we need to fix all + // array class vtables also + if (k->oop_is_array() && _the_class_oop == SystemDictionary::Object_klass()) { + k->vtable()->adjust_method_entries(_matching_old_methods, + _matching_new_methods, + _matching_methods_length, + &trace_name_printed); + } else if (k->oop_is_instance()) { + HandleMark hm(_thread); + InstanceKlass *ik = InstanceKlass::cast(k); // HotSpot specific optimization! HotSpot does not currently // support delegation from the bootstrap class loader to a @@ -2695,23 +2702,6 @@ return; } - // If the class being redefined is java.lang.Object, we need to fix all - // array class vtables also - if (_the_class_oop == SystemDictionary::Object_klass()) { - ik->array_klasses_do(adjust_array_vtable); - } - - // This is a very busy routine. We don't want too much tracing - // printed out. - bool trace_name_printed = false; - - // Very noisy: only enable this call if you are trying to determine - // that a specific class gets found by this routine. - // RC_TRACE macro has an embedded ResourceMark - // RC_TRACE_WITH_THREAD(0x00100000, THREAD, - // ("adjust check: name=%s", ik->external_name())); - // trace_name_printed = true; - // Fix the vtable embedded in the_class and subclasses of the_class, // if one exists. We discard scratch_class and we don't keep an // InstanceKlass around to hold obsolete methods so we don't have @@ -2719,7 +2709,7 @@ // holds the Method*s for virtual (but not final) methods. if (ik->vtable_length() > 0 && ik->is_subtype_of(_the_class_oop)) { // ik->vtable() creates a wrapper object; rm cleans it up - ResourceMark rm(THREAD); + ResourceMark rm(_thread); ik->vtable()->adjust_method_entries(_matching_old_methods, _matching_new_methods, _matching_methods_length, @@ -2735,7 +2725,7 @@ if (ik->itable_length() > 0 && (_the_class_oop->is_interface() || ik->is_subclass_of(_the_class_oop))) { // ik->itable() creates a wrapper object; rm cleans it up - ResourceMark rm(THREAD); + ResourceMark rm(_thread); ik->itable()->adjust_method_entries(_matching_old_methods, _matching_new_methods, _matching_methods_length, @@ -2758,7 +2748,7 @@ constantPoolHandle other_cp; ConstantPoolCache* cp_cache; - if (k_oop != _the_class_oop) { + if (ik != _the_class_oop) { // this klass' constant pool cache may need adjustment other_cp = constantPoolHandle(ik->constants()); cp_cache = other_cp->cache(); @@ -2770,7 +2760,7 @@ } } { - ResourceMark rm(THREAD); + ResourceMark rm(_thread); // PreviousVersionInfo objects returned via PreviousVersionWalker // contain a GrowableArray of handles. We have to clean up the // GrowableArray _after_ the PreviousVersionWalker destructor @@ -3208,7 +3198,7 @@ // parts of the_class // - adjusting constant pool caches and vtables in other classes // that refer to methods in the_class. These adjustments use the -// SystemDictionary::classes_do() facility which only allows +// ClassLoaderDataGraph::classes_do() facility which only allows // a helper method to be specified. The interesting parameters // that we would like to pass to the helper method are saved in // static global fields in the VM operation. @@ -3366,6 +3356,10 @@ } #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()); @@ -3438,7 +3432,8 @@ // Adjust constantpool caches and vtables for all classes // that reference methods of the evolved class. - SystemDictionary::classes_do(adjust_cpool_cache_and_vtable, THREAD); + AdjustCpoolCacheAndVtable adjust_cpool_cache_and_vtable(THREAD); + ClassLoaderDataGraph::classes_do(&adjust_cpool_cache_and_vtable); // JSR-292 support MemberNameTable* mnt = the_class->member_names(); @@ -3499,34 +3494,33 @@ } } -void VM_RedefineClasses::check_class(Klass* k_oop, - ClassLoaderData* initiating_loader, - TRAPS) { - Klass *k = k_oop; +void VM_RedefineClasses::CheckClass::do_klass(Klass* k) { + bool no_old_methods = true; // be optimistic + + // Both array and instance classes have vtables. + // a vtable should never contain old or obsolete methods + ResourceMark rm(_thread); + if (k->vtable_length() > 0 && + !k->vtable()->check_no_old_or_obsolete_entries()) { + if (RC_TRACE_ENABLED(0x00004000)) { + RC_TRACE_WITH_THREAD(0x00004000, _thread, + ("klassVtable::check_no_old_or_obsolete_entries failure" + " -- OLD or OBSOLETE method found -- class: %s", + k->signature_name())); + k->vtable()->dump_vtable(); + } + no_old_methods = false; + } + if (k->oop_is_instance()) { - HandleMark hm(THREAD); - InstanceKlass *ik = (InstanceKlass *) k; - bool no_old_methods = true; // be optimistic - ResourceMark rm(THREAD); - - // a vtable should never contain old or obsolete methods - if (ik->vtable_length() > 0 && - !ik->vtable()->check_no_old_or_obsolete_entries()) { - if (RC_TRACE_ENABLED(0x00004000)) { - RC_TRACE_WITH_THREAD(0x00004000, THREAD, - ("klassVtable::check_no_old_or_obsolete_entries failure" - " -- OLD or OBSOLETE method found -- class: %s", - ik->signature_name())); - ik->vtable()->dump_vtable(); - } - no_old_methods = false; - } + HandleMark hm(_thread); + InstanceKlass *ik = InstanceKlass::cast(k); // an itable should never contain old or obsolete methods if (ik->itable_length() > 0 && !ik->itable()->check_no_old_or_obsolete_entries()) { if (RC_TRACE_ENABLED(0x00004000)) { - RC_TRACE_WITH_THREAD(0x00004000, THREAD, + RC_TRACE_WITH_THREAD(0x00004000, _thread, ("klassItable::check_no_old_or_obsolete_entries failure" " -- OLD or OBSOLETE method found -- class: %s", ik->signature_name())); @@ -3540,7 +3534,7 @@ ik->constants()->cache() != NULL && !ik->constants()->cache()->check_no_old_or_obsolete_entries()) { if (RC_TRACE_ENABLED(0x00004000)) { - RC_TRACE_WITH_THREAD(0x00004000, THREAD, + RC_TRACE_WITH_THREAD(0x00004000, _thread, ("cp-cache::check_no_old_or_obsolete_entries failure" " -- OLD or OBSOLETE method found -- class: %s", ik->signature_name())); @@ -3548,19 +3542,21 @@ } no_old_methods = false; } - - if (!no_old_methods) { - if (RC_TRACE_ENABLED(0x00004000)) { - dump_methods(); - } else { - tty->print_cr("INFO: use the '-XX:TraceRedefineClasses=16384' option " - "to see more info about the following guarantee() failure."); - } - guarantee(false, "OLD and/or OBSOLETE method(s) found"); + } + + // print and fail guarantee if old methods are found. + if (!no_old_methods) { + if (RC_TRACE_ENABLED(0x00004000)) { + dump_methods(); + } else { + tty->print_cr("INFO: use the '-XX:TraceRedefineClasses=16384' option " + "to see more info about the following guarantee() failure."); } + guarantee(false, "OLD and/or OBSOLETE method(s) found"); } } + void VM_RedefineClasses::dump_methods() { int j; RC_TRACE(0x00004000, ("_old_methods --")); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/prims/jvmtiRedefineClasses.hpp --- a/src/share/vm/prims/jvmtiRedefineClasses.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/prims/jvmtiRedefineClasses.hpp Fri May 17 06:01:10 2013 +0200 @@ -87,7 +87,7 @@ // parts of the_class // - adjusting constant pool caches and vtables in other classes // that refer to methods in the_class. These adjustments use the -// SystemDictionary::classes_do() facility which only allows +// ClassLoaderDataGraph::classes_do() facility which only allows // a helper method to be specified. The interesting parameters // that we would like to pass to the helper method are saved in // static global fields in the VM operation. @@ -333,8 +333,8 @@ class VM_RedefineClasses: public VM_Operation { private: - // These static fields are needed by SystemDictionary::classes_do() - // facility and the adjust_cpool_cache_and_vtable() helper: + // These static fields are needed by ClassLoaderDataGraph::classes_do() + // facility and the AdjustCpoolCacheAndVtable helper: static Array* _old_methods; static Array* _new_methods; static Method** _matching_old_methods; @@ -408,13 +408,6 @@ int * emcp_method_count_p); void transfer_old_native_function_registrations(instanceKlassHandle the_class); - // Unevolving classes may point to methods of the_class directly - // from their constant pool caches, itables, and/or vtables. We - // use the SystemDictionary::classes_do() facility and this helper - // to fix up these pointers. - static void adjust_cpool_cache_and_vtable(Klass* k_oop, ClassLoaderData* initiating_loader, TRAPS); - static void adjust_array_vtable(Klass* k_oop); - // Install the redefinition of a class void redefine_single_class(jclass the_jclass, Klass* scratch_class_oop, TRAPS); @@ -480,10 +473,27 @@ void flush_dependent_code(instanceKlassHandle k_h, TRAPS); - static void check_class(Klass* k_oop, ClassLoaderData* initiating_loader, - TRAPS); static void dump_methods(); + // Check that there are no old or obsolete methods + class CheckClass : public KlassClosure { + Thread* _thread; + public: + CheckClass(Thread* t) : _thread(t) {} + void do_klass(Klass* k); + }; + + // Unevolving classes may point to methods of the_class directly + // from their constant pool caches, itables, and/or vtables. We + // use the ClassLoaderDataGraph::classes_do() facility and this helper + // to fix up these pointers. + class AdjustCpoolCacheAndVtable : public KlassClosure { + Thread* _thread; + public: + AdjustCpoolCacheAndVtable(Thread* t) : _thread(t) {} + void do_klass(Klass* k); + }; + public: VM_RedefineClasses(jint class_count, const jvmtiClassDefinition *class_defs, diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/prims/jvmtiTagMap.cpp --- a/src/share/vm/prims/jvmtiTagMap.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/prims/jvmtiTagMap.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -2857,7 +2857,7 @@ // references from the constant pool { - ConstantPool* const pool = ik->constants(); + ConstantPool* pool = ik->constants(); for (int i = 1; i < pool->length(); i++) { constantTag tag = pool->tag_at(i).value(); if (tag.is_string() || tag.is_klass()) { diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/prims/methodHandles.cpp --- a/src/share/vm/prims/methodHandles.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/prims/methodHandles.cpp Fri May 17 06:01:10 2013 +0200 @@ -193,19 +193,15 @@ 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 @@ } 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 @@ 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 @@ 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) { diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/runtime/arguments.cpp --- a/src/share/vm/runtime/arguments.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/runtime/arguments.cpp Fri May 17 06:01:10 2013 +0200 @@ -2179,6 +2179,26 @@ #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; } @@ -3181,36 +3201,27 @@ } void Arguments::set_shared_spaces_flags() { - const bool must_share = DumpSharedSpaces || RequireSharedSpaces; - const bool might_share = must_share || UseSharedSpaces; - - // 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")); +#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. + 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) { @@ -3255,25 +3266,37 @@ } #endif // INCLUDE_ALL_GCS +// Sharing support +// Construct the path to the archive +static char* get_shared_archive_path() { + char *shared_archive_path; + if (SharedArchiveFile == NULL) { + char jvm_path[JVM_MAXPATHLEN]; + os::jvm_path(jvm_path, sizeof(jvm_path)); + char *end = strrchr(jvm_path, *os::file_separator()); + if (end != NULL) *end = '\0'; + size_t jvm_path_len = strlen(jvm_path); + size_t file_sep_len = strlen(os::file_separator()); + shared_archive_path = NEW_C_HEAP_ARRAY(char, jvm_path_len + + file_sep_len + 20, mtInternal); + if (shared_archive_path != NULL) { + strncpy(shared_archive_path, jvm_path, jvm_path_len + 1); + strncat(shared_archive_path, os::file_separator(), file_sep_len); + strncat(shared_archive_path, "classes.jsa", 11); + } + } else { + shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(SharedArchiveFile) + 1, mtInternal); + if (shared_archive_path != NULL) { + strncpy(shared_archive_path, SharedArchiveFile, strlen(SharedArchiveFile) + 1); + } + } + return shared_archive_path; +} + // Parse entry point called from JNI_CreateJavaVM jint Arguments::parse(const JavaVMInitArgs* args) { - // Sharing support - // Construct the path to the archive - char jvm_path[JVM_MAXPATHLEN]; - os::jvm_path(jvm_path, sizeof(jvm_path)); - char *end = strrchr(jvm_path, *os::file_separator()); - if (end != NULL) *end = '\0'; - char *shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(jvm_path) + - strlen(os::file_separator()) + 20, mtInternal); - if (shared_archive_path == NULL) return JNI_ENOMEM; - strcpy(shared_archive_path, jvm_path); - strcat(shared_archive_path, os::file_separator()); - strcat(shared_archive_path, "classes"); - strcat(shared_archive_path, ".jsa"); - SharedArchivePath = shared_archive_path; - // Remaining part of option string const char* tail; @@ -3364,6 +3387,12 @@ return result; } + // Call get_shared_archive_path() here, after possible SharedArchiveFile option got parsed. + SharedArchivePath = get_shared_archive_path(); + if (SharedArchivePath == NULL) { + return JNI_ENOMEM; + } + // Delay warning until here so that we've had a chance to process // the -XX:-PrintWarnings flag if (needs_hotspotrc_warning) { diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/runtime/globals.hpp Fri May 17 06:01:10 2013 +0200 @@ -1159,9 +1159,6 @@ product(bool, CompactFields, true, \ "Allocate nonstatic fields in gaps between previous fields") \ \ - notproduct(bool, PrintCompactFieldsSavings, false, \ - "Print how many words were saved with CompactFields") \ - \ notproduct(bool, PrintFieldLayout, false, \ "Print field layout for each class") \ \ @@ -3681,6 +3678,9 @@ product(bool , AllowNonVirtualCalls, false, \ "Obey the ACC_SUPER flag and allow invokenonvirtual calls") \ \ + diagnostic(ccstr, SharedArchiveFile, NULL, \ + "Override the default location of the CDS archive file") \ + \ experimental(uintx, ArrayAllocatorMallocLimit, \ SOLARIS_ONLY(64*K) NOT_SOLARIS(max_uintx), \ "Allocation less than this value will be allocated " \ diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/runtime/handles.cpp --- a/src/share/vm/runtime/handles.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/runtime/handles.cpp Fri May 17 06:01:10 2013 +0200 @@ -179,6 +179,22 @@ _thread->set_last_handle_mark(previous_handle_mark()); } +void* HandleMark::operator new(size_t size) { + return AllocateHeap(size, mtThread); +} + +void* HandleMark::operator new [] (size_t size) { + return AllocateHeap(size, mtThread); +} + +void HandleMark::operator delete(void* p) { + FreeHeap(p, mtThread); +} + +void HandleMark::operator delete[](void* p) { + FreeHeap(p, mtThread); +} + #ifdef ASSERT NoHandleMark::NoHandleMark() { diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/runtime/handles.hpp --- a/src/share/vm/runtime/handles.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/runtime/handles.hpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -281,7 +281,7 @@ // across the HandleMark boundary. // The base class of HandleMark should have been StackObj but we also heap allocate -// a HandleMark when a thread is created. +// a HandleMark when a thread is created. The operator new is for this special case. class HandleMark { private: @@ -308,6 +308,11 @@ void push(); // called in the destructor of HandleMarkCleaner void pop_and_restore(); + // overloaded operators + void* operator new(size_t size); + void* operator new [](size_t size); + void operator delete(void* p); + void operator delete[](void* p); }; //------------------------------------------------------------------------------------------------------------------------ diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/runtime/objectMonitor.hpp --- a/src/share/vm/runtime/objectMonitor.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/runtime/objectMonitor.hpp Fri May 17 06:01:10 2013 +0200 @@ -303,6 +303,18 @@ public: static int Knob_Verbose; static int Knob_SpinLimit; + void* operator new (size_t size) { + return AllocateHeap(size, mtInternal); + } + void* operator new[] (size_t size) { + return operator new (size); + } + void operator delete(void* p) { + FreeHeap(p, mtInternal); + } + void operator delete[] (void *p) { + operator delete(p); + } }; #undef TEVENT diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/runtime/reflectionUtils.hpp --- a/src/share/vm/runtime/reflectionUtils.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/runtime/reflectionUtils.hpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -136,10 +136,10 @@ } }; -class FilteredField { +class FilteredField : public CHeapObj { private: Klass* _klass; - int _field_offset; + int _field_offset; public: FilteredField(Klass* klass, int field_offset) { diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/runtime/unhandledOops.hpp --- a/src/share/vm/runtime/unhandledOops.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/runtime/unhandledOops.hpp Fri May 17 06:01:10 2013 +0200 @@ -48,7 +48,7 @@ class oop; class Thread; -class UnhandledOopEntry { +class UnhandledOopEntry : public CHeapObj { friend class UnhandledOops; private: oop* _oop_ptr; @@ -62,7 +62,7 @@ }; -class UnhandledOops { +class UnhandledOops : public CHeapObj { friend class Thread; private: Thread* _thread; diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/runtime/vmStructs.cpp --- a/src/share/vm/runtime/vmStructs.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/runtime/vmStructs.cpp Fri May 17 06:01:10 2013 +0200 @@ -3119,15 +3119,15 @@ // Search for the base type by peeling off const and * size_t len = strlen(typeName); if (typeName[len-1] == '*') { - char * s = new char[len]; + char * s = NEW_C_HEAP_ARRAY(char, len, mtInternal); strncpy(s, typeName, len - 1); s[len-1] = '\0'; // tty->print_cr("checking \"%s\" for \"%s\"", s, typeName); if (recursiveFindType(origtypes, s, true) == 1) { - delete [] s; + FREE_C_HEAP_ARRAY(char, s, mtInternal); return 1; } - delete [] s; + FREE_C_HEAP_ARRAY(char, s, mtInternal); } const char* start = NULL; if (strstr(typeName, "GrowableArray<") == typeName) { @@ -3138,15 +3138,15 @@ if (start != NULL) { const char * end = strrchr(typeName, '>'); int len = end - start + 1; - char * s = new char[len]; + char * s = NEW_C_HEAP_ARRAY(char, len, mtInternal); strncpy(s, start, len - 1); s[len-1] = '\0'; // tty->print_cr("checking \"%s\" for \"%s\"", s, typeName); if (recursiveFindType(origtypes, s, true) == 1) { - delete [] s; + FREE_C_HEAP_ARRAY(char, s, mtInternal); return 1; } - delete [] s; + FREE_C_HEAP_ARRAY(char, s, mtInternal); } if (strstr(typeName, "const ") == typeName) { const char * s = typeName + strlen("const "); diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/utilities/events.hpp --- a/src/share/vm/utilities/events.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/utilities/events.hpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -69,7 +69,7 @@ // semantics aren't appropriate. The name is used as the label of the // log when it is dumped during a crash. template class EventLogBase : public EventLog { - template class EventRecord { + template class EventRecord : public CHeapObj { public: double timestamp; Thread* thread; diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/utilities/quickSort.cpp --- a/src/share/vm/utilities/quickSort.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/utilities/quickSort.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -30,6 +30,8 @@ #include "runtime/os.hpp" #include "utilities/quickSort.hpp" +#include "memory/allocation.hpp" +#include "memory/allocation.inline.hpp" #include static int test_comparator(int a, int b) { @@ -187,8 +189,8 @@ // test sorting random arrays for (int i = 0; i < 1000; i++) { int length = os::random() % 100; - int* test_array = new int[length]; - int* expected_array = new int[length]; + int* test_array = NEW_C_HEAP_ARRAY(int, length, mtInternal); + int* expected_array = NEW_C_HEAP_ARRAY(int, length, mtInternal); for (int j = 0; j < length; j++) { // Choose random values, but get a chance of getting duplicates test_array[j] = os::random() % (length * 2); @@ -210,8 +212,8 @@ sort(test_array, length, test_even_odd_comparator, true); assert(compare_arrays(test_array, expected_array, length), "Sorting already sorted array changed order of elements - not idempotent"); - delete[] test_array; - delete[] expected_array; + FREE_C_HEAP_ARRAY(int, test_array, mtInternal); + FREE_C_HEAP_ARRAY(int, expected_array, mtInternal); } } diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/utilities/workgroup.cpp --- a/src/share/vm/utilities/workgroup.cpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/utilities/workgroup.cpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -529,7 +529,7 @@ FreeIdSet::FreeIdSet(int sz, Monitor* mon) : _sz(sz), _mon(mon), _hd(0), _waiters(0), _index(-1), _claimed(0) { - _ids = new int[sz]; + _ids = NEW_C_HEAP_ARRAY(int, sz, mtInternal); for (int i = 0; i < sz; i++) _ids[i] = i+1; _ids[sz-1] = end_of_list; // end of list. if (_stat_init) { @@ -549,6 +549,7 @@ FreeIdSet::~FreeIdSet() { _sets[_index] = NULL; + FREE_C_HEAP_ARRAY(int, _ids, mtInternal); } void FreeIdSet::set_safepoint(bool b) { diff -r acac2b03a07f -r 2958af1d8c5a src/share/vm/utilities/workgroup.hpp --- a/src/share/vm/utilities/workgroup.hpp Thu May 16 23:51:51 2013 +0200 +++ b/src/share/vm/utilities/workgroup.hpp Fri May 17 06:01:10 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -494,7 +494,7 @@ }; // Represents a set of free small integer ids. -class FreeIdSet { +class FreeIdSet : public CHeapObj { enum { end_of_list = -1, claimed = -2 diff -r acac2b03a07f -r 2958af1d8c5a test/runtime/RedefineObject/Agent.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/runtime/RedefineObject/Agent.java Fri May 17 06:01:10 2013 +0200 @@ -0,0 +1,61 @@ +/* + * 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. + */ +import java.security.*; +import java.lang.instrument.*; + +public class Agent implements ClassFileTransformer { + public synchronized byte[] transform(final ClassLoader classLoader, + final String className, + Class classBeingRedefined, + ProtectionDomain protectionDomain, + byte[] classfileBuffer) { + //System.out.println("Transforming class " + className); + return classfileBuffer; + } + + public static void premain(String agentArgs, Instrumentation instrumentation) { + + Agent transformer = new Agent(); + + instrumentation.addTransformer(transformer, true); + + Class c = Object.class; + try { + instrumentation.retransformClasses(c); + } catch (Exception e) { + e.printStackTrace(); + } + + instrumentation.removeTransformer(transformer); + } + + public static void main(String[] args) { + byte[] ba = new byte[0]; + + // If it survives 1000 GC's, it's good. + for (int i = 0; i < 1000 ; i++) { + System.gc(); + ba.clone(); + } + } +} diff -r acac2b03a07f -r 2958af1d8c5a test/runtime/RedefineObject/TestRedefineObject.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/runtime/RedefineObject/TestRedefineObject.java Fri May 17 06:01:10 2013 +0200 @@ -0,0 +1,50 @@ +/* + * 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. + */ +import java.io.PrintWriter; +import com.oracle.java.testlibrary.*; + +/* + * Test to redefine java/lang/Object and verify that it doesn't crash on vtable + * call on basic array type. + * + * @test + * @bug 8005056 + * @library /testlibrary + * @build Agent + * @run main ClassFileInstaller Agent + * @run main Test + * @run main/othervm -javaagent:agent.jar Agent + */ +public class Test { + public static void main(String[] args) throws Exception { + + PrintWriter pw = new PrintWriter("MANIFEST.MF"); + pw.println("Premain-Class: Agent"); + pw.println("Can-Retransform-Classes: true"); + pw.close(); + + ProcessBuilder pb = new ProcessBuilder(); + pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "Agent.class"}); + pb.start().waitFor(); + } +} diff -r acac2b03a07f -r 2958af1d8c5a test/runtime/SharedArchiveFile/SharedArchiveFile.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/runtime/SharedArchiveFile/SharedArchiveFile.java Fri May 17 06:01:10 2013 +0200 @@ -0,0 +1,53 @@ +/* + * 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 + * @bug 8014138 + * @summary Testing new -XX:SharedArchiveFile= option + * @library /testlibrary + */ + +import com.oracle.java.testlibrary.*; + +public class SharedArchiveFile { + public static void main(String[] args) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + try { + output.shouldContain("Loading classes to share"); + output.shouldHaveExitValue(0); + + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:on", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("sharing"); + output.shouldHaveExitValue(0); + + } catch (RuntimeException e) { + output.shouldContain("Unable to use shared archive"); + output.shouldHaveExitValue(1); + } + } +} diff -r acac2b03a07f -r 2958af1d8c5a test/testlibrary/ClassFileInstaller.java --- a/test/testlibrary/ClassFileInstaller.java Thu May 16 23:51:51 2013 +0200 +++ b/test/testlibrary/ClassFileInstaller.java Fri May 17 06:01:10 2013 +0200 @@ -45,7 +45,9 @@ // Create the class file's package directory Path p = Paths.get(pathName); - Files.createDirectories(p.getParent()); + if (pathName.contains("/")) { + Files.createDirectories(p.getParent()); + } // Create the class file Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING); }