diff --git a/gc/base/MemoryPoolSplitAddressOrderedListBase.cpp b/gc/base/MemoryPoolSplitAddressOrderedListBase.cpp index 71b088f18b2..b6af1769dfd 100644 --- a/gc/base/MemoryPoolSplitAddressOrderedListBase.cpp +++ b/gc/base/MemoryPoolSplitAddressOrderedListBase.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 1991, 2017 IBM Corp. and others + * Copyright (c) 1991, 2019 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -186,7 +186,7 @@ MM_MemoryPoolSplitAddressOrderedListBase::initialize(MM_EnvironmentBase* env) return false; } else { for (uintptr_t i = 0; i < _heapFreeListCountExtended; ++i) { - new (&_largeObjectAllocateStatsForFreeList[i]) MM_LargeObjectAllocateStats(); + new (&_largeObjectAllocateStatsForFreeList[i]) MM_LargeObjectAllocateStats(env); /* set multiple factor = 2 for doubling _maxVeryLargeEntrySizes to avoid run out of _veryLargeEntryPool (minus count during decrement) */ if (!_largeObjectAllocateStatsForFreeList[i].initialize(env, (uint16_t)extensions->largeObjectAllocationProfilingTopK, extensions->largeObjectAllocationProfilingThreshold, extensions->largeObjectAllocationProfilingVeryLargeObjectThreshold, (float)extensions->largeObjectAllocationProfilingSizeClassRatio / (float)100.0, diff --git a/gc/stats/LargeObjectAllocateStats.cpp b/gc/stats/LargeObjectAllocateStats.cpp index 6e067c3595b..8174477cd3e 100644 --- a/gc/stats/LargeObjectAllocateStats.cpp +++ b/gc/stats/LargeObjectAllocateStats.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2016 IBM Corp. and others + * Copyright (c) 2012, 2019 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -489,7 +489,7 @@ MM_LargeObjectAllocateStats::newInstance(MM_EnvironmentBase *env, uint16_t maxAl largeObjectAllocateStats = (MM_LargeObjectAllocateStats *)env->getForge()->allocate(sizeof(MM_LargeObjectAllocateStats), OMR::GC::AllocationCategory::FIXED, OMR_GET_CALLSITE()); if(NULL != largeObjectAllocateStats) { - new(largeObjectAllocateStats) MM_LargeObjectAllocateStats(); + new(largeObjectAllocateStats) MM_LargeObjectAllocateStats(env); if(!largeObjectAllocateStats->initialize(env, maxAllocateSizes, largeObjectThreshold, veryLargeObjectThreshold, sizeClassRatio, maxHeapSize, tlhMaximumSize, tlhMinimumSize, factorVeryLargeEntryPool)) { largeObjectAllocateStats->kill(env); @@ -503,7 +503,7 @@ MM_LargeObjectAllocateStats::newInstance(MM_EnvironmentBase *env, uint16_t maxAl bool MM_LargeObjectAllocateStats::initialize(MM_EnvironmentBase *env, uint16_t maxAllocateSizes, uintptr_t largeObjectThreshold, uintptr_t veryLargeObjectThreshold, float sizeClassRatio, uintptr_t maxHeapSize, uintptr_t tlhMaximumSize, uintptr_t tlhMinimumSize, uintptr_t factorVeryLargeEntryPool) { - _portLibrary = env->getPortLibrary(); + OMRPortLibrary *portLibrary = env->getPortLibrary(); #if defined(OMR_GC_THREAD_LOCAL_HEAP) _tlhMaximumSize = tlhMaximumSize; _tlhMinimumSize = tlhMinimumSize; @@ -516,23 +516,23 @@ MM_LargeObjectAllocateStats::initialize(MM_EnvironmentBase *env, uint16_t maxAll /* To accurately maintain for stats for top _maxAllocateSizes different sizes, * we'll actually maintain stats for 2x more, and discard info for lower 1/2 */ - if (NULL == (_spaceSavingSizes = spaceSavingNew(_portLibrary, _maxAllocateSizes * 2))) { + if (NULL == (_spaceSavingSizes = spaceSavingNew(portLibrary, _maxAllocateSizes * 2))) { return false; } - if (NULL == (_spaceSavingSizeClasses = spaceSavingNew(_portLibrary, _maxAllocateSizes * 2))) { + if (NULL == (_spaceSavingSizeClasses = spaceSavingNew(portLibrary, _maxAllocateSizes * 2))) { return false; } - if (NULL == (_spaceSavingSizesAveragePercent = spaceSavingNew(_portLibrary, _maxAllocateSizes * 2))) { + if (NULL == (_spaceSavingSizesAveragePercent = spaceSavingNew(portLibrary, _maxAllocateSizes * 2))) { return false; } - if (NULL == (_spaceSavingSizeClassesAveragePercent = spaceSavingNew(_portLibrary, _maxAllocateSizes * 2))) { + if (NULL == (_spaceSavingSizeClassesAveragePercent = spaceSavingNew(portLibrary, _maxAllocateSizes * 2))) { return false; } - if (NULL == (_spaceSavingTemp = spaceSavingNew(_portLibrary, _maxAllocateSizes * 2))) { + if (NULL == (_spaceSavingTemp = spaceSavingNew(portLibrary, _maxAllocateSizes * 2))) { return false; } @@ -1553,16 +1553,15 @@ MM_LargeObjectAllocateStats::getSizeClassIndex(uintptr_t size) * a Linux kernel on problematic machine */ - /* the logarithm for integer can not be negative! */ - Assert_MM_true(logValue >= 0.0); - - /* CMVC 194170 (remove when resolved) */ - Assert_MM_true(0.0 != _sizeClassRatioLog); + /* the logarithm can not be negative! */ + Assert_GC_true_with_message2(_env, (logValue >= 0.0), "Error calculation log(), passed %zu, returned %f\n", size, logValue); + Assert_GC_true_with_message(_env, (_sizeClassRatioLog > 0.0), "_sizeClassRatioLog is %f but must be larger then zero\n", _sizeClassRatioLog); uintptr_t result = (uintptr_t)(logValue / _sizeClassRatioLog); /* the logarithm value is larger then we can accept - probably larger then log(UDATA_MAX) */ - Assert_MM_true((_freeEntrySizeClassStats._maxSizeClasses == 0) || (result < _freeEntrySizeClassStats._maxSizeClasses)); + Assert_GC_true_with_message2(_env, ((_freeEntrySizeClassStats._maxSizeClasses == 0) || (result < _freeEntrySizeClassStats._maxSizeClasses)), + "Calculated value of getSizeClassIndex() %zu can not be larger then maximum %zu\n", result, _freeEntrySizeClassStats._maxSizeClasses); return result; } diff --git a/gc/stats/LargeObjectAllocateStats.hpp b/gc/stats/LargeObjectAllocateStats.hpp index 8d8b0a58128..0136c9fc131 100644 --- a/gc/stats/LargeObjectAllocateStats.hpp +++ b/gc/stats/LargeObjectAllocateStats.hpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2016 IBM Corp. and others + * Copyright (c) 2012, 2019 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -148,7 +148,7 @@ class MM_FreeEntrySizeClassStats { class MM_LargeObjectAllocateStats : public MM_Base { public: private: - OMRPortLibrary *_portLibrary; + MM_EnvironmentBase *_env; /**< cached thread environment */ #if defined(OMR_GC_THREAD_LOCAL_HEAP) uintptr_t _tlhMaximumSize; /**< cached value of _tlhMaximumSize */ uintptr_t _tlhMinimumSize; /**< cached value of _tlhMinimumSize */ @@ -325,8 +325,8 @@ class MM_LargeObjectAllocateStats : public MM_Base { uintptr_t getFreeMemoryBeforeEstimate() { return _freeMemoryBeforeEstimate; } uintptr_t getMaxHeapSize() {return _maxHeapSize; } - MM_LargeObjectAllocateStats() : - _portLibrary(NULL), + MM_LargeObjectAllocateStats(MM_EnvironmentBase* env) : + _env(env), #if defined(OMR_GC_THREAD_LOCAL_HEAP) _tlhMaximumSize(0), _tlhMinimumSize(0),