5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_PROMOTIONFAILEDINFO_HPP 26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_PROMOTIONFAILEDINFO_HPP 27 28 #include "runtime/thread.hpp" 29 #include "utilities/globalDefinitions.hpp" 30 31 class PromotionFailedInfo VALUE_OBJ_CLASS_SPEC { 32 size_t _first_size; 33 size_t _smallest_size; 34 size_t _total_size; 35 uint _count; 36 OSThread* _thread; 37 38 public: 39 PromotionFailedInfo() : _first_size(0), _smallest_size(0), _total_size(0), _count(0), _thread(NULL) {} 40 41 void register_promotion_failed(size_t size) { 42 if (_first_size == 0) { 43 _first_size = size; 44 _smallest_size = size; 45 _thread = Thread::current()->osthread(); 46 } else if (size < _smallest_size) { 47 _smallest_size = size; 48 } 49 _total_size += size; 50 _count++; 51 assert(_thread == Thread::current()->osthread(), "The PromotionFailedInfo should be thread local."); 52 } 53 54 void reset() { 55 _first_size = 0; 56 _smallest_size = 0; 57 _total_size = 0; 58 _count = 0; 59 _thread = NULL; 60 } 61 62 bool promotion_failed() const { return _count != 0; } 63 size_t first_size() const { return _first_size; } 64 size_t smallest_size() const { return _smallest_size; } 65 size_t total_size() const { return _total_size; } 66 uint promotion_failed_count() const { return _count; } 67 OSThread* thread() const { return _thread; } 68 }; 69 70 #endif /* SHARE_VM_GC_IMPLEMENTATION_SHARED_PROMOTIONFAILEDINFO_HPP */ | 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_COPYFAILEDINFO_HPP 26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_COPYFAILEDINFO_HPP 27 28 #include "runtime/thread.hpp" 29 #include "utilities/globalDefinitions.hpp" 30 31 class CopyFailedInfo VALUE_OBJ_CLASS_SPEC { 32 size_t _first_size; 33 size_t _smallest_size; 34 size_t _total_size; 35 uint _count; 36 OSThread* _thread; 37 38 public: 39 CopyFailedInfo() : _first_size(0), _smallest_size(0), _total_size(0), _count(0), _thread(NULL) {} 40 41 void register_copy_failure(size_t size) { 42 if (_first_size == 0) { 43 _first_size = size; 44 _smallest_size = size; 45 _thread = Thread::current()->osthread(); 46 } else if (size < _smallest_size) { 47 _smallest_size = size; 48 } 49 _total_size += size; 50 _count++; 51 assert(_thread == Thread::current()->osthread(), "The PromotionFailedInfo should be thread local."); 52 } 53 54 void reset() { 55 _first_size = 0; 56 _smallest_size = 0; 57 _total_size = 0; 58 _count = 0; 59 _thread = NULL; 60 } 61 62 bool has_failed() const { return _count != 0; } 63 size_t first_size() const { return _first_size; } 64 size_t smallest_size() const { return _smallest_size; } 65 size_t total_size() const { return _total_size; } 66 uint failed_count() const { return _count; } 67 OSThread* thread() const { return _thread; } 68 }; 69 70 class PromotionFailedInfo : public CopyFailedInfo {}; 71 72 #endif /* SHARE_VM_GC_IMPLEMENTATION_SHARED_COPYFAILEDINFO_HPP */ |