1 /* |
1 /* |
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
117 // Usage is not predictable, check weaker >= condition |
117 // Usage is not predictable, check weaker >= condition |
118 Asserts.assertGTE(newValue, oldValue, msg); |
118 Asserts.assertGTE(newValue, oldValue, msg); |
119 } |
119 } |
120 } |
120 } |
121 |
121 |
|
122 /** |
|
123 * Verifies that 'newValue' is equal to 'oldValue' if usage of the |
|
124 * corresponding code heap is predictable. Checks the weaker condition |
|
125 * 'newValue <= oldValue' if usage is not predictable because intermediate |
|
126 * allocations may happen. |
|
127 * |
|
128 * @param btype BlobType of the code heap to be checked |
|
129 * @param newValue New value to be verified |
|
130 * @param oldValue Old value to be verified |
|
131 * @param msg Error message if verification fails |
|
132 */ |
|
133 public static void assertEQorLTE(BlobType btype, long newValue, long oldValue, String msg) { |
|
134 if (CodeCacheUtils.isCodeHeapPredictable(btype)) { |
|
135 // Usage is predictable, check strong == condition |
|
136 Asserts.assertEQ(newValue, oldValue, msg); |
|
137 } else { |
|
138 // Usage is not predictable, check weaker <= condition |
|
139 Asserts.assertLTE(newValue, oldValue, msg); |
|
140 } |
|
141 } |
|
142 |
|
143 |
122 public static void disableCollectionUsageThresholds() { |
144 public static void disableCollectionUsageThresholds() { |
123 BlobType.getAvailable().stream() |
145 BlobType.getAvailable().stream() |
124 .map(BlobType::getMemoryPool) |
146 .map(BlobType::getMemoryPool) |
125 .filter(MemoryPoolMXBean::isCollectionUsageThresholdSupported) |
147 .filter(MemoryPoolMXBean::isCollectionUsageThresholdSupported) |
126 .forEach(b -> b.setCollectionUsageThreshold(0L)); |
148 .forEach(b -> b.setCollectionUsageThreshold(0L)); |