Mercurial > hg > release > icedtea7-forest-2.5 > hotspot
changeset 5773:ad68fdd7d0ac
Merge
author | asaha |
---|---|
date | Mon, 14 Jul 2014 13:31:47 -0700 |
parents | a16eaa7e9c95 (current diff) 7835108a451f (diff) |
children | c97866b6d4b0 |
files | .hgtags make/hotspot_version |
diffstat | 16 files changed, 368 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Wed Jul 09 12:01:32 2014 -0700 +++ b/.hgtags Mon Jul 14 13:31:47 2014 -0700 @@ -688,7 +688,11 @@ 4c6df9a369cb9d54fe2d898452883a22b8ec6640 jdk7u65-b17 aca05127f95b5704ee3a34104a8f86e36326f0c0 jdk7u65-b30 d006213be74730453cf5c3ce31f1d1d505334419 jdk7u65-b18 +1d8226b3e9896656451801393eb3ae394faeb638 jdk7u65-b19 +c43b0b843f897a4d8cf0a3566b017b87230dd3b4 jdk7u65-b32 +d3c9265e12fa115052f18d1e3d379143b56bbf63 jdk7u65-b20 cf8b3a090e597e59177c5f67d44cdec12309777f jdk7u65-b31 +df855c3f4d31dd7db081d68e3054518380127893 jdk7u65-b33 6b37a189944aaa09e81d97d394496464d16bee42 jdk7u66-b00 121dc94194d9234e2b13c867d875e23e1bdd6abd jdk7u66-b01 f28ea516eb0b9e99f1e342954ab4642456af4da1 jdk7u66-b09 @@ -704,4 +708,9 @@ f95d6d32e08006209f1798f82b60d7d05767a3e8 jdk7u71-b01 1c760efe2d0795f4ce8260ec655b8870bfd77ca1 jdk7u71-b02 0cb0b5abd0b5aa25fc8bd5920c8d61c5b85a10c6 jdk7u71-b03 +a491e5e52998c23502ebb1340955e3e726d44ad6 jdk7u71-b04 +1bd3adac3aac3c29c81303812b35f484ff90cb2b jdk7u72-b01 +0caed46767e35c00eff69b22acf984d98eb66b3d jdk7u72-b02 +3a2934191de4bb8ca9d2faca93f3381e521e8cac jdk7u72-b03 +e4708cde2898df4c936595aacb57bc5b4e15869a jdk7u72-b04 e6b6d91b3934c281086f8efacb0926e7451cc18b jdk7u75-b00
--- a/agent/src/share/classes/sun/jvm/hotspot/utilities/Hashtable.java Wed Jul 09 12:01:32 2014 -0700 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/Hashtable.java Mon Jul 14 13:31:47 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,8 +61,9 @@ long h = 0; int s = 0; int len = buf.length; + // Emulate the unsigned int in java_lang_String::hash_code while (len-- > 0) { - h = 31*h + (0xFFL & buf[s]); + h = 31*h + (0xFFFFFFFFL & buf[s]); s++; } return h & 0xFFFFFFFFL;
--- a/src/cpu/sparc/vm/vm_version_sparc.hpp Wed Jul 09 12:01:32 2014 -0700 +++ b/src/cpu/sparc/vm/vm_version_sparc.hpp Mon Jul 14 13:31:47 2014 -0700 @@ -48,7 +48,8 @@ sparc64_family = 14, M_family = 15, T_family = 16, - T1_model = 17 + T1_model = 17, + sparc5_instructions = 18 }; enum Feature_Flag_Set { @@ -73,6 +74,7 @@ M_family_m = 1 << M_family, T_family_m = 1 << T_family, T1_model_m = 1 << T1_model, + sparc5_instructions_m = 1 << sparc5_instructions, generic_v8_m = v8_instructions_m | hardware_mul32_m | hardware_div32_m | hardware_fsmuld_m, generic_v9_m = generic_v8_m | v9_instructions_m, @@ -117,6 +119,7 @@ static bool has_vis3() { return (_features & vis3_instructions_m) != 0; } static bool has_blk_init() { return (_features & blk_init_instructions_m) != 0; } static bool has_cbcond() { return (_features & cbcond_instructions_m) != 0; } + static bool has_sparc5_instr() { return (_features & sparc5_instructions_m) != 0; } static bool supports_compare_and_exchange() { return has_v9(); } @@ -127,6 +130,7 @@ static bool is_M_series() { return is_M_family(_features); } static bool is_T4() { return is_T_family(_features) && has_cbcond(); } + static bool is_T7() { return is_T_family(_features) && has_sparc5_instr(); } // Fujitsu SPARC64 static bool is_sparc64() { return (_features & sparc64_family_m) != 0; } @@ -146,7 +150,7 @@ static const char* cpu_features() { return _features_str; } static intx prefetch_data_size() { - return is_T4() ? 32 : 64; // default prefetch block size on sparc + return is_T4() && !is_T7() ? 32 : 64; // default prefetch block size on sparc } // Prefetch
--- a/src/os/bsd/vm/os_bsd.cpp Wed Jul 09 12:01:32 2014 -0700 +++ b/src/os/bsd/vm/os_bsd.cpp Mon Jul 14 13:31:47 2014 -0700 @@ -1297,9 +1297,20 @@ ////////////////////////////////////////////////////////////////////////////// // thread local storage +// Restore the thread pointer if the destructor is called. This is in case +// someone from JNI code sets up a destructor with pthread_key_create to run +// detachCurrentThread on thread death. Unless we restore the thread pointer we +// will hang or crash. When detachCurrentThread is called the key will be set +// to null and we will not be called again. If detachCurrentThread is never +// called we could loop forever depending on the pthread implementation. +static void restore_thread_pointer(void* p) { + Thread* thread = (Thread*) p; + os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread); +} + int os::allocate_thread_local_storage() { pthread_key_t key; - int rslt = pthread_key_create(&key, NULL); + int rslt = pthread_key_create(&key, restore_thread_pointer); assert(rslt == 0, "cannot allocate thread local storage"); return (int)key; }
--- a/src/os/linux/vm/os_linux.cpp Wed Jul 09 12:01:32 2014 -0700 +++ b/src/os/linux/vm/os_linux.cpp Mon Jul 14 13:31:47 2014 -0700 @@ -1103,9 +1103,20 @@ ////////////////////////////////////////////////////////////////////////////// // thread local storage +// Restore the thread pointer if the destructor is called. This is in case +// someone from JNI code sets up a destructor with pthread_key_create to run +// detachCurrentThread on thread death. Unless we restore the thread pointer we +// will hang or crash. When detachCurrentThread is called the key will be set +// to null and we will not be called again. If detachCurrentThread is never +// called we could loop forever depending on the pthread implementation. +static void restore_thread_pointer(void* p) { + Thread* thread = (Thread*) p; + os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread); +} + int os::allocate_thread_local_storage() { pthread_key_t key; - int rslt = pthread_key_create(&key, NULL); + int rslt = pthread_key_create(&key, restore_thread_pointer); assert(rslt == 0, "cannot allocate thread local storage"); return (int)key; }
--- a/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp Wed Jul 09 12:01:32 2014 -0700 +++ b/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp Mon Jul 14 13:31:47 2014 -0700 @@ -75,13 +75,19 @@ do_sysinfo(SI_ARCHITECTURE_64, "sparcv9", &features, generic_v9_m); // Extract valid instruction set extensions. - uint_t av; - uint_t avn = os::Solaris::getisax(&av, 1); - assert(avn == 1, "should only return one av"); + uint_t avs[2]; + uint_t avn = os::Solaris::getisax(avs, 2); + assert(avn <= 2, "should return two or less av's"); + uint_t av = avs[0]; #ifndef PRODUCT - if (PrintMiscellaneous && Verbose) - tty->print_cr("getisax(2) returned: " PTR32_FORMAT, av); + if (PrintMiscellaneous && Verbose) { + tty->print("getisax(2) returned: " PTR32_FORMAT, av); + if (avn > 1) { + tty->print(", " PTR32_FORMAT, avs[1]); + } + tty->cr(); + } #endif if (av & AV_SPARC_MUL32) features |= hardware_mul32_m; @@ -91,6 +97,13 @@ if (av & AV_SPARC_POPC) features |= hardware_popc_m; if (av & AV_SPARC_VIS) features |= vis1_instructions_m; if (av & AV_SPARC_VIS2) features |= vis2_instructions_m; + if (avn > 1) { + uint_t av2 = avs[1]; +#ifndef AV2_SPARC_SPARC5 +#define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */ +#endif + if (av2 & AV2_SPARC_SPARC5) features |= sparc5_instructions_m; + } // Next values are not defined before Solaris 10 // but Solaris 8 is used for jdk6 update builds.
--- a/src/share/vm/oops/cpCacheOop.hpp Wed Jul 09 12:01:32 2014 -0700 +++ b/src/share/vm/oops/cpCacheOop.hpp Mon Jul 14 13:31:47 2014 -0700 @@ -140,8 +140,15 @@ oop_store(&_f1, f1); } void release_set_f1(oop f1); - void set_f2(intx f2) { assert(_f2 == 0 || _f2 == f2, "illegal field change"); _f2 = f2; } - void set_f2_as_vfinal_method(methodOop f2) { assert(_f2 == 0 || _f2 == (intptr_t) f2, "illegal field change"); assert(is_vfinal(), "flags must be set"); _f2 = (intptr_t) f2; } + void set_f2(intx f2) { + intx existing_f2 = _f2; // read once + assert(existing_f2 == 0 || existing_f2 == f2, "illegal field change"); + _f2 = f2; + } + void set_f2_as_vfinal_method(methodOop f2) { + assert(is_vfinal(), "flags must be set"); + set_f2((intx)f2); + } int make_flags(TosState state, int option_bits, int field_index_or_method_params); void set_flags(intx flags) { _flags = flags; } bool init_flags_atomic(intx flags);
--- a/src/share/vm/opto/library_call.cpp Wed Jul 09 12:01:32 2014 -0700 +++ b/src/share/vm/opto/library_call.cpp Mon Jul 14 13:31:47 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3699,8 +3699,11 @@ } -//------------------------------inline_native_hashcode-------------------- -// Build special case code for calls to hashCode on an object. +/** + * Build special case code for calls to hashCode on an object. This call may + * be virtual (invokevirtual) or bound (invokespecial). For each case we generate + * slightly different code. + */ bool LibraryCallKit::inline_native_hashcode(bool is_virtual, bool is_static) { assert(is_static == callee()->is_static(), "correct intrinsic selection"); assert(!(is_virtual && is_static), "either virtual, special, or static"); @@ -3708,11 +3711,9 @@ enum { _slow_path = 1, _fast_path, _null_path, PATH_LIMIT }; RegionNode* result_reg = new(C) RegionNode(PATH_LIMIT); - PhiNode* result_val = new(C) PhiNode(result_reg, - TypeInt::INT); + PhiNode* result_val = new(C) PhiNode(result_reg, TypeInt::INT); PhiNode* result_io = new(C) PhiNode(result_reg, Type::ABIO); - PhiNode* result_mem = new(C) PhiNode(result_reg, Type::MEMORY, - TypePtr::BOTTOM); + PhiNode* result_mem = new(C) PhiNode(result_reg, Type::MEMORY, TypePtr::BOTTOM); Node* obj = NULL; if (!is_static) { // Check for hashing null object @@ -3738,12 +3739,6 @@ return true; } - // After null check, get the object's klass. - Node* obj_klass = load_object_klass(obj); - - // This call may be virtual (invokevirtual) or bound (invokespecial). - // For each case we generate slightly different code. - // We only go to the fast case code if we pass a number of guards. The // paths which do not pass are accumulated in the slow_region. RegionNode* slow_region = new (C) RegionNode(1); @@ -3756,19 +3751,24 @@ // guard for non-virtual calls -- the caller is known to be the native // Object hashCode(). if (is_virtual) { + // After null check, get the object's klass. + Node* obj_klass = load_object_klass(obj); generate_virtual_guard(obj_klass, slow_region); } // Get the header out of the object, use LoadMarkNode when available Node* header_addr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes()); - Node* header = make_load(control(), header_addr, TypeX_X, TypeX_X->basic_type()); + // The control of the load must be NULL. Otherwise, the load can move before + // the null check after castPP removal. + Node* no_ctrl = NULL; + Node* header = make_load(no_ctrl, header_addr, TypeX_X, TypeX_X->basic_type()); // Test the header to see if it is unlocked. - Node *lock_mask = _gvn.MakeConX(markOopDesc::biased_lock_mask_in_place); - Node *lmasked_header = _gvn.transform( new (C) AndXNode(header, lock_mask) ); - Node *unlocked_val = _gvn.MakeConX(markOopDesc::unlocked_value); - Node *chk_unlocked = _gvn.transform( new (C) CmpXNode( lmasked_header, unlocked_val)); - Node *test_unlocked = _gvn.transform( new (C) BoolNode( chk_unlocked, BoolTest::ne) ); + Node* lock_mask = _gvn.MakeConX(markOopDesc::biased_lock_mask_in_place); + Node* lmasked_header = _gvn.transform(new (C) AndXNode(header, lock_mask)); + Node* unlocked_val = _gvn.MakeConX(markOopDesc::unlocked_value); + Node* chk_unlocked = _gvn.transform(new (C) CmpXNode( lmasked_header, unlocked_val)); + Node* test_unlocked = _gvn.transform(new (C) BoolNode( chk_unlocked, BoolTest::ne)); generate_slow_guard(test_unlocked, slow_region); @@ -3776,19 +3776,19 @@ // We depend on hash_mask being at most 32 bits and avoid the use of // hash_mask_in_place because it could be larger than 32 bits in a 64-bit // vm: see markOop.hpp. - Node *hash_mask = _gvn.intcon(markOopDesc::hash_mask); - Node *hash_shift = _gvn.intcon(markOopDesc::hash_shift); - Node *hshifted_header= _gvn.transform( new (C) URShiftXNode(header, hash_shift) ); + Node* hash_mask = _gvn.intcon(markOopDesc::hash_mask); + Node* hash_shift = _gvn.intcon(markOopDesc::hash_shift); + Node* hshifted_header= _gvn.transform(new (C) URShiftXNode(header, hash_shift)); // This hack lets the hash bits live anywhere in the mark object now, as long // as the shift drops the relevant bits into the low 32 bits. Note that // Java spec says that HashCode is an int so there's no point in capturing // an 'X'-sized hashcode (32 in 32-bit build or 64 in 64-bit build). hshifted_header = ConvX2I(hshifted_header); - Node *hash_val = _gvn.transform( new (C) AndINode(hshifted_header, hash_mask) ); - - Node *no_hash_val = _gvn.intcon(markOopDesc::no_hash); - Node *chk_assigned = _gvn.transform( new (C) CmpINode( hash_val, no_hash_val)); - Node *test_assigned = _gvn.transform( new (C) BoolNode( chk_assigned, BoolTest::eq) ); + Node* hash_val = _gvn.transform(new (C) AndINode(hshifted_header, hash_mask)); + + Node* no_hash_val = _gvn.intcon(markOopDesc::no_hash); + Node* chk_assigned = _gvn.transform(new (C) CmpINode( hash_val, no_hash_val)); + Node* test_assigned = _gvn.transform(new (C) BoolNode( chk_assigned, BoolTest::eq)); generate_slow_guard(test_assigned, slow_region);
--- a/src/share/vm/opto/loopTransform.cpp Wed Jul 09 12:01:32 2014 -0700 +++ b/src/share/vm/opto/loopTransform.cpp Mon Jul 14 13:31:47 2014 -0700 @@ -1127,6 +1127,7 @@ // Now force out all loop-invariant dominating tests. The optimizer // finds some, but we _know_ they are all useless. peeled_dom_test_elim(loop,old_new); + loop->record_for_igvn(); } //------------------------------is_invariant-----------------------------
--- a/src/share/vm/opto/loopnode.cpp Wed Jul 09 12:01:32 2014 -0700 +++ b/src/share/vm/opto/loopnode.cpp Mon Jul 14 13:31:47 2014 -0700 @@ -3171,17 +3171,16 @@ bool had_error = false; #ifdef ASSERT if (early != C->root()) { - // Make sure that there's a dominance path from use to LCA - Node* d = use; - while (d != LCA) { - d = idom(d); + // Make sure that there's a dominance path from LCA to early + Node* d = LCA; + while (d != early) { if (d == C->root()) { - tty->print_cr("*** Use %d isn't dominated by def %s", use->_idx, n->_idx); - n->dump(); - use->dump(); + dump_bad_graph("Bad graph detected in compute_lca_of_uses", n, early, LCA); + tty->print_cr("*** Use %d isn't dominated by def %d ***", use->_idx, n->_idx); had_error = true; break; } + d = idom(d); } } #endif @@ -3434,6 +3433,13 @@ _igvn._worklist.push(n); // Maybe we'll normalize it, if no more loops. } +#ifdef ASSERT + if (_verify_only && !n->is_CFG()) { + // Check def-use domination. + compute_lca_of_uses(n, get_ctrl(n), true /* verify */); + } +#endif + // CFG and pinned nodes already handled if( n->in(0) ) { if( n->in(0)->is_top() ) return; // Dead?
--- a/src/share/vm/opto/loopopts.cpp Wed Jul 09 12:01:32 2014 -0700 +++ b/src/share/vm/opto/loopopts.cpp Mon Jul 14 13:31:47 2014 -0700 @@ -2684,6 +2684,7 @@ // Inhibit more partial peeling on this loop new_head_clone->set_partial_peel_loop(); C->set_major_progress(); + loop->record_for_igvn(); #if !defined(PRODUCT) if (TracePartialPeeling) {
--- a/src/share/vm/runtime/vmThread.cpp Wed Jul 09 12:01:32 2014 -0700 +++ b/src/share/vm/runtime/vmThread.cpp Mon Jul 14 13:31:47 2014 -0700 @@ -327,6 +327,9 @@ _terminate_lock->notify(); } + // Thread destructor usually does this. + ThreadLocalStorage::set_thread(NULL); + // Deletion must be done synchronously by the JNI DestroyJavaVM thread // so that the VMThread deletion completes before the main thread frees // up the CodeHeap.
--- a/src/share/vm/services/heapDumper.cpp Wed Jul 09 12:01:32 2014 -0700 +++ b/src/share/vm/services/heapDumper.cpp Mon Jul 14 13:31:47 2014 -0700 @@ -720,7 +720,7 @@ // reflection and sun.misc.Unsafe classes may have a reference to a // klassOop so filter it out. - if (o != NULL && o->is_klass()) { + if (o != NULL && o->is_perm() && o->is_klass()) { o = NULL; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/hashcode/TestHashCode.java Mon Jul 14 13:31:47 2014 -0700 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8011646 + * @summary SEGV in compiled code with loop predication + * @run main/othervm -XX:-TieredCompilation -XX:CompileOnly=TestHashCode.m1,Object.hashCode TestHashCode + * + */ + +public class TestHashCode { + static class A { + int i; + } + + static class B extends A { + } + + static boolean crash = false; + + static A m2() { + if (crash) { + return null; + } + return new A(); + } + + static int m1(A aa) { + int res = 0; + for (int i = 0; i < 10; i++) { + A a = m2(); + int j = a.i; + if (aa instanceof B) { + } + res += a.hashCode(); + } + return res; + } + + public static void main(String[] args) { + A a = new A(); + for (int i = 0; i < 20000; i++) { + m1(a); + } + crash = true; + try { + m1(a); + } catch (NullPointerException e) { + System.out.println("Test passed"); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/gc/heap_inspection/TestG1ConcurrentGCHeapDump.java Mon Jul 14 13:31:47 2014 -0700 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test TestG1ConcurrentGCHeapDump + * @bug 8038925 + * @summary Checks that a heap dump can be made with G1 when no fullgc + * has been made + * @run main/othervm -Xms512m -Xmx1024m -XX:+ExplicitGCInvokesConcurrent TestG1ConcurrentGCHeapDump + */ +import java.util.List; +import java.util.ArrayList; +import java.util.LinkedList; + +import javax.management.MBeanServer; +import java.lang.management.ManagementFactory; +import java.lang.management.GarbageCollectorMXBean; + +import sun.management.ManagementFactoryHelper; +import com.sun.management.HotSpotDiagnosticMXBean; +import com.sun.management.VMOption; + +import java.io.IOException; + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.Files; + +public class TestG1ConcurrentGCHeapDump { + + private static final String HOTSPOT_BEAN_NAME = + "com.sun.management:type=HotSpotDiagnostic"; + + private static final String G1_OLD_BEAN_NAME = + "java.lang:type=GarbageCollector,name=G1 Old Generation"; + + private static MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + + private static void dumpHeap() throws IOException { + HotSpotDiagnosticMXBean hotspot_bean = + ManagementFactory.newPlatformMXBeanProxy(server, + HOTSPOT_BEAN_NAME, HotSpotDiagnosticMXBean.class); + + Path dir = Files.createTempDirectory("JDK-8038925_"); + String file = dir + File.separator + "heapdump"; + hotspot_bean.dumpHeap(file, false); + Files.delete(Paths.get(file)); + Files.delete(dir); + } + + private static void verifyNoFullGC() throws IOException { + GarbageCollectorMXBean g1_old_bean = + ManagementFactory.newPlatformMXBeanProxy(server, + G1_OLD_BEAN_NAME, GarbageCollectorMXBean.class); + + if (g1_old_bean.getCollectionCount() != 0) { + throw new RuntimeException("A full GC has occured, this test will not work."); + } + } + + public static void main(String[] args) throws IOException { + HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean(); + VMOption option = diagnostic.getVMOption("UseG1GC"); + if (option.getValue().equals("false")) { + System.out.println("Skipping this test. It is only a G1 test."); + return; + } + + // Create some dead objects + ArrayList<List<Integer>> arraylist = new ArrayList<List<Integer>>(); + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 100; j++) { + LinkedList<Integer> li = new LinkedList<Integer>(); + arraylist.add(li); + for (int k = 0; k < 10000; k++) { + li.add(k); + } + } + arraylist = new ArrayList<List<Integer>>(); + System.gc(); + } + // Try to dump heap + dumpHeap(); + // Make sure no full GC has happened, since test won't work if that is the case + verifyNoFullGC(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/serviceability/sa/jmap-hashcode/Test8028623.java Mon Jul 14 13:31:47 2014 -0700 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8028623 + * @summary Test hashing of extended characters in Serviceability Agent. + * @library /testlibrary + */ + +import com.oracle.java.testlibrary.JDKToolLauncher; +import com.oracle.java.testlibrary.OutputBuffer; +import com.oracle.java.testlibrary.ProcessTools; + +import java.io.File; + +public class Test8028623 { + + public static int à = 1; + public static String dumpFile = "heap.out"; + + public static void main (String[] args) { + + System.out.println(Ã); + + try { + int pid = ProcessTools.getProcessId(); + JDKToolLauncher jmap = JDKToolLauncher.create("jmap") + .addToolArg("-F") + .addToolArg("-dump:live,format=b,file=" + dumpFile) + .addToolArg(Integer.toString(pid)); + ProcessBuilder pb = new ProcessBuilder(jmap.getCommand()); + OutputBuffer output = ProcessTools.getOutput(pb); + Process p = pb.start(); + int e = p.waitFor(); + System.out.println("stdout:"); + System.out.println(output.getStdout()); + System.out.println("stderr:"); + System.out.println(output.getStderr()); + + if (e != 0) { + throw new RuntimeException("jmap returns: " + e); + } + if (! new File(dumpFile).exists()) { + throw new RuntimeException("dump file NOT created: '" + dumpFile + "'"); + } + } catch (Throwable t) { + t.printStackTrace(); + throw new RuntimeException("Test failed with: " + t); + } + } +}