# HG changeset patch # User dlong # Date 1332019919 14400 # Node ID 6522ad563f99dce88a2e323ae1ffb26af04f2786 # Parent f96bddf3d3f321ab917f33a3c48887bf56f30350# Parent 21b94feb697c1c79de1f4b1fee04c82e2593d4dd Merge diff -r 21b94feb697c -r 6522ad563f99 agent/src/share/classes/sun/jvm/hotspot/jdi/ConnectorImpl.java --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/ConnectorImpl.java Tue Mar 13 15:37:50 2012 -0700 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/ConnectorImpl.java Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2012, 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 @@ -217,8 +217,8 @@ } protected void checkNativeLink(SecurityManager sm, String os) { - if (os.equals("SunOS") || os.equals("Linux")) { - // link "saproc" - SA native library on SunOS and Linux? + if (os.equals("SunOS") || os.equals("Linux") || os.contains("OS X")) { + // link "saproc" - SA native library on SunOS, Linux, and Mac OS X sm.checkLink("saproc"); } else if (os.startsWith("Windows")) { // link "sawindbg" - SA native library on Windows. diff -r 21b94feb697c -r 6522ad563f99 agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java Tue Mar 13 15:37:50 2012 -0700 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, 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 @@ -43,7 +43,7 @@ return "bsd"; } else if (os.equals("OpenBSD")) { return "bsd"; - } else if (os.equals("Darwin") || os.startsWith("Mac OS X")) { + } else if (os.equals("Darwin") || os.contains("OS X")) { return "bsd"; } else if (os.startsWith("Windows")) { return "win32"; @@ -52,17 +52,17 @@ } } - /* Returns "sparc" if on SPARC, "x86" if on x86. */ + /* Returns "sparc" for SPARC based platforms and "x86" for x86 based + platforms. Otherwise returns the value of os.arch. If the value + is not recognized as supported, an exception is thrown instead. */ public static String getCPU() throws UnsupportedPlatformException { String cpu = System.getProperty("os.arch"); - if (cpu.equals("i386")) { + if (cpu.equals("i386") || cpu.equals("x86")) { return "x86"; - } else if (cpu.equals("sparc") || cpu.equals("x86") || cpu.equals("ia64")) { + } else if (cpu.equals("sparc") || cpu.equals("sparcv9")) { + return "sparc"; + } else if (cpu.equals("ia64") || cpu.equals("amd64") || cpu.equals("x86_64")) { return cpu; - } else if (cpu.equals("sparcv9")) { - return "sparc"; - } else if (cpu.equals("x86_64") || cpu.equals("amd64")) { - return "amd64"; } else { throw new UnsupportedPlatformException("CPU type " + cpu + " not yet supported"); } diff -r 21b94feb697c -r 6522ad563f99 src/os/linux/vm/os_linux.cpp --- a/src/os/linux/vm/os_linux.cpp Tue Mar 13 15:37:50 2012 -0700 +++ b/src/os/linux/vm/os_linux.cpp Sat Mar 17 17:31:59 2012 -0400 @@ -2547,7 +2547,14 @@ } void os::free_memory(char *addr, size_t bytes, size_t alignment_hint) { - commit_memory(addr, bytes, alignment_hint, false); + // This method works by doing an mmap over an existing mmaping and effectively discarding + // the existing pages. However it won't work for SHM-based large pages that cannot be + // uncommitted at all. We don't do anything in this case to avoid creating a segment with + // small pages on top of the SHM segment. This method always works for small pages, so we + // allow that in any case. + if (alignment_hint <= (size_t)os::vm_page_size() || !UseSHM) { + commit_memory(addr, bytes, alignment_hint, false); + } } void os::numa_make_global(char *addr, size_t bytes) { diff -r 21b94feb697c -r 6522ad563f99 src/share/vm/gc_implementation/g1/survRateGroup.cpp --- a/src/share/vm/gc_implementation/g1/survRateGroup.cpp Tue Mar 13 15:37:50 2012 -0700 +++ b/src/share/vm/gc_implementation/g1/survRateGroup.cpp Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2012, 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 @@ -38,33 +38,36 @@ _summary_surv_rates(NULL), _surv_rate(NULL), _accum_surv_rate_pred(NULL), - _surv_rate_pred(NULL) -{ + _surv_rate_pred(NULL), + _stats_arrays_length(0) { reset(); if (summary_surv_rates_len > 0) { size_t length = summary_surv_rates_len; - _summary_surv_rates = NEW_C_HEAP_ARRAY(NumberSeq*, length); - if (_summary_surv_rates == NULL) { - vm_exit_out_of_memory(sizeof(NumberSeq*) * length, - "Not enough space for surv rate summary"); + _summary_surv_rates = NEW_C_HEAP_ARRAY(NumberSeq*, length); + for (size_t i = 0; i < length; ++i) { + _summary_surv_rates[i] = new NumberSeq(); } - for (size_t i = 0; i < length; ++i) - _summary_surv_rates[i] = new NumberSeq(); } start_adding_regions(); } - -void SurvRateGroup::reset() -{ +void SurvRateGroup::reset() { _all_regions_allocated = 0; _setup_seq_num = 0; - _stats_arrays_length = 0; _accum_surv_rate = 0.0; _last_pred = 0.0; // the following will set up the arrays with length 1 _region_num = 1; + + // The call to stop_adding_regions() will use "new" to refill + // the _surv_rate_pred array, so we need to make sure to call + // "delete". + for (size_t i = 0; i < _stats_arrays_length; ++i) { + delete _surv_rate_pred[i]; + } + _stats_arrays_length = 0; + stop_adding_regions(); guarantee( _stats_arrays_length == 1, "invariant" ); guarantee( _surv_rate_pred[0] != NULL, "invariant" ); @@ -73,72 +76,47 @@ _region_num = 0; } - void SurvRateGroup::start_adding_regions() { _setup_seq_num = _stats_arrays_length; _region_num = 0; _accum_surv_rate = 0.0; - -#if 0 - gclog_or_tty->print_cr("[%s] start adding regions, seq num %d, length %d", - _name, _setup_seq_num, _region_num); -#endif // 0 } void SurvRateGroup::stop_adding_regions() { - -#if 0 - gclog_or_tty->print_cr("[%s] stop adding regions, length %d", _name, _region_num); -#endif // 0 - if (_region_num > _stats_arrays_length) { double* old_surv_rate = _surv_rate; double* old_accum_surv_rate_pred = _accum_surv_rate_pred; TruncatedSeq** old_surv_rate_pred = _surv_rate_pred; _surv_rate = NEW_C_HEAP_ARRAY(double, _region_num); - if (_surv_rate == NULL) { - vm_exit_out_of_memory(sizeof(double) * _region_num, - "Not enough space for surv rate array."); - } _accum_surv_rate_pred = NEW_C_HEAP_ARRAY(double, _region_num); - if (_accum_surv_rate_pred == NULL) { - vm_exit_out_of_memory(sizeof(double) * _region_num, - "Not enough space for accum surv rate pred array."); - } _surv_rate_pred = NEW_C_HEAP_ARRAY(TruncatedSeq*, _region_num); - if (_surv_rate == NULL) { - vm_exit_out_of_memory(sizeof(TruncatedSeq*) * _region_num, - "Not enough space for surv rate pred array."); - } - for (size_t i = 0; i < _stats_arrays_length; ++i) + for (size_t i = 0; i < _stats_arrays_length; ++i) { _surv_rate_pred[i] = old_surv_rate_pred[i]; - -#if 0 - gclog_or_tty->print_cr("[%s] stop adding regions, new seqs %d to %d", - _name, _array_length, _region_num - 1); -#endif // 0 - + } for (size_t i = _stats_arrays_length; i < _region_num; ++i) { _surv_rate_pred[i] = new TruncatedSeq(10); - // _surv_rate_pred[i]->add(last_pred); } _stats_arrays_length = _region_num; - if (old_surv_rate != NULL) + if (old_surv_rate != NULL) { FREE_C_HEAP_ARRAY(double, old_surv_rate); - if (old_accum_surv_rate_pred != NULL) + } + if (old_accum_surv_rate_pred != NULL) { FREE_C_HEAP_ARRAY(double, old_accum_surv_rate_pred); - if (old_surv_rate_pred != NULL) - FREE_C_HEAP_ARRAY(NumberSeq*, old_surv_rate_pred); + } + if (old_surv_rate_pred != NULL) { + FREE_C_HEAP_ARRAY(TruncatedSeq*, old_surv_rate_pred); + } } - for (size_t i = 0; i < _stats_arrays_length; ++i) + for (size_t i = 0; i < _stats_arrays_length; ++i) { _surv_rate[i] = 0.0; + } } double @@ -187,12 +165,6 @@ SurvRateGroup::all_surviving_words_recorded(bool propagate) { if (propagate && _region_num > 0) { // conservative double surv_rate = _surv_rate_pred[_region_num-1]->last(); - -#if 0 - gclog_or_tty->print_cr("propagating %1.2lf from %d to %d", - surv_rate, _curr_length, _array_length - 1); -#endif // 0 - for (size_t i = _region_num; i < _stats_arrays_length; ++i) { guarantee( _surv_rate[i] <= 0.00001, "the slot should not have been updated" ); diff -r 21b94feb697c -r 6522ad563f99 src/share/vm/memory/cardTableModRefBS.hpp --- a/src/share/vm/memory/cardTableModRefBS.hpp Tue Mar 13 15:37:50 2012 -0700 +++ b/src/share/vm/memory/cardTableModRefBS.hpp Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, 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 @@ -72,6 +72,9 @@ CT_MR_BS_last_reserved = 16 }; + // a word's worth (row) of clean card values + static const intptr_t clean_card_row = (intptr_t)(-1); + // dirty and precleaned are equivalent wrt younger_refs_iter. static bool card_is_dirty_wrt_gen_iter(jbyte cv) { return cv == dirty_card || cv == precleaned_card; diff -r 21b94feb697c -r 6522ad563f99 src/share/vm/memory/cardTableRS.cpp --- a/src/share/vm/memory/cardTableRS.cpp Tue Mar 13 15:37:50 2012 -0700 +++ b/src/share/vm/memory/cardTableRS.cpp Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2012, 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 @@ -173,6 +173,10 @@ SharedHeap::heap()->workers()->active_workers()), "Mismatch"); } +bool ClearNoncleanCardWrapper::is_word_aligned(jbyte* entry) { + return (((intptr_t)entry) & (BytesPerWord-1)) == 0; +} + void ClearNoncleanCardWrapper::do_MemRegion(MemRegion mr) { assert(mr.word_size() > 0, "Error"); assert(_ct->is_aligned(mr.start()), "mr.start() should be card aligned"); @@ -194,6 +198,17 @@ const MemRegion mrd(start_of_non_clean, end_of_non_clean); _dirty_card_closure->do_MemRegion(mrd); } + + // fast forward through potential continuous whole-word range of clean cards beginning at a word-boundary + if (is_word_aligned(cur_entry)) { + jbyte* cur_row = cur_entry - BytesPerWord; + while (cur_row >= limit && *((intptr_t*)cur_row) == CardTableRS::clean_card_row()) { + cur_row -= BytesPerWord; + } + cur_entry = cur_row + BytesPerWord; + cur_hw = _ct->addr_for(cur_entry); + } + // Reset the dirty window, while continuing to look // for the next dirty card that will start a // new dirty window. diff -r 21b94feb697c -r 6522ad563f99 src/share/vm/memory/cardTableRS.hpp --- a/src/share/vm/memory/cardTableRS.hpp Tue Mar 13 15:37:50 2012 -0700 +++ b/src/share/vm/memory/cardTableRS.hpp Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2012, 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 @@ -45,6 +45,10 @@ return CardTableModRefBS::clean_card; } + static intptr_t clean_card_row() { + return CardTableModRefBS::clean_card_row; + } + static bool card_is_dirty_wrt_gen_iter(jbyte cv) { return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv); @@ -176,6 +180,8 @@ // Work methods called by the clear_card() inline bool clear_card_serial(jbyte* entry); inline bool clear_card_parallel(jbyte* entry); + // check alignment of pointer + bool is_word_aligned(jbyte* entry); public: ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct); diff -r 21b94feb697c -r 6522ad563f99 src/share/vm/oops/arrayKlass.cpp --- a/src/share/vm/oops/arrayKlass.cpp Tue Mar 13 15:37:50 2012 -0700 +++ b/src/share/vm/oops/arrayKlass.cpp Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, 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 @@ -153,6 +153,7 @@ } if (length > arrayOopDesc::max_array_length(T_ARRAY)) { report_java_out_of_memory("Requested array size exceeds VM limit"); + JvmtiExport::post_array_size_exhausted(); THROW_OOP_0(Universe::out_of_memory_error_array_size()); } int size = objArrayOopDesc::object_size(length); diff -r 21b94feb697c -r 6522ad563f99 src/share/vm/oops/instanceKlass.cpp --- a/src/share/vm/oops/instanceKlass.cpp Tue Mar 13 15:37:50 2012 -0700 +++ b/src/share/vm/oops/instanceKlass.cpp Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, 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 @@ -669,6 +669,7 @@ if (length < 0) THROW_0(vmSymbols::java_lang_NegativeArraySizeException()); if (length > arrayOopDesc::max_array_length(T_OBJECT)) { report_java_out_of_memory("Requested array size exceeds VM limit"); + JvmtiExport::post_array_size_exhausted(); THROW_OOP_0(Universe::out_of_memory_error_array_size()); } int size = objArrayOopDesc::object_size(length); diff -r 21b94feb697c -r 6522ad563f99 src/share/vm/oops/objArrayKlass.cpp --- a/src/share/vm/oops/objArrayKlass.cpp Tue Mar 13 15:37:50 2012 -0700 +++ b/src/share/vm/oops/objArrayKlass.cpp Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, 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 @@ -68,6 +68,7 @@ return a; } else { report_java_out_of_memory("Requested array size exceeds VM limit"); + JvmtiExport::post_array_size_exhausted(); THROW_OOP_0(Universe::out_of_memory_error_array_size()); } } else { diff -r 21b94feb697c -r 6522ad563f99 src/share/vm/oops/typeArrayKlass.cpp --- a/src/share/vm/oops/typeArrayKlass.cpp Tue Mar 13 15:37:50 2012 -0700 +++ b/src/share/vm/oops/typeArrayKlass.cpp Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, 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 @@ -93,6 +93,7 @@ return t; } else { report_java_out_of_memory("Requested array size exceeds VM limit"); + JvmtiExport::post_array_size_exhausted(); THROW_OOP_0(Universe::out_of_memory_error_array_size()); } } else { diff -r 21b94feb697c -r 6522ad563f99 src/share/vm/prims/jvmtiExport.hpp --- a/src/share/vm/prims/jvmtiExport.hpp Tue Mar 13 15:37:50 2012 -0700 +++ b/src/share/vm/prims/jvmtiExport.hpp Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2012, 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 @@ -324,6 +324,12 @@ record_vm_internal_object_allocation(object); } } + inline static void post_array_size_exhausted() { + if (should_post_resource_exhausted()) { + post_resource_exhausted(JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR, + "Requested array size exceeds VM limit"); + } + } static void cleanup_thread (JavaThread* thread) KERNEL_RETURN; diff -r 21b94feb697c -r 6522ad563f99 src/share/vm/utilities/numberSeq.cpp --- a/src/share/vm/utilities/numberSeq.cpp Tue Mar 13 15:37:50 2012 -0700 +++ b/src/share/vm/utilities/numberSeq.cpp Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2012, 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 @@ -156,6 +156,10 @@ _sequence[i] = 0.0; } +TruncatedSeq::~TruncatedSeq() { + FREE_C_HEAP_ARRAY(double, _sequence); +} + void TruncatedSeq::add(double val) { AbsSeq::add(val); diff -r 21b94feb697c -r 6522ad563f99 src/share/vm/utilities/numberSeq.hpp --- a/src/share/vm/utilities/numberSeq.hpp Tue Mar 13 15:37:50 2012 -0700 +++ b/src/share/vm/utilities/numberSeq.hpp Sat Mar 17 17:31:59 2012 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2012, 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 @@ -118,6 +118,7 @@ // accepts a value for L TruncatedSeq(int length = DefaultSeqLength, double alpha = DEFAULT_ALPHA_VALUE); + ~TruncatedSeq(); virtual void add(double val); virtual double maximum() const; virtual double last() const; // the last value added to the sequence