@@ -116,30 +116,32 @@ private static boolean getFlagBoolValue(String flag, String where) {
116116 }
117117
118118 public static void main (String args []) throws Exception {
119- // Tests
120-
121- long M = 1L * 1024L * 1024L ;
122-
123119 // Hotspot startup logic reduces MaxHeapForCompressedOops by HeapBaseMinAddress
124120 // in order to get zero based compressed oops offsets.
125121 long heapbaseminaddr = getHeapBaseMinAddress ();
126122 long maxcoopheap = TestUseCompressedOopsErgoTools .getMaxHeapForCompressedOops (new String [0 ]) - heapbaseminaddr ;
127123
128- double headroom = (double )64 * M ;
124+ // The headroom is used to get/not get compressed oops from the maxcoopheap size
125+ long M = 1L * 1024L * 1024L ;
126+ long headroom = 64 * M ;
127+
128+ long requiredHostMemory = maxcoopheap + headroom ;
129129
130130 // Get host memory
131131 long hostMemory = getHostMaxMemory ();
132132
133- if (hostMemory > (maxcoopheap + headroom )) {
134- double MaxRAMPercentage = ((double )maxcoopheap / hostMemory ) * 100.0 ;
135- double headroomPercentage = ((double )headroom / hostMemory ) * 100.0 ;
133+ System .out .println ("hostMemory: " + hostMemory + ", requiredHostMemory: " + requiredHostMemory );
136134
137- // Args: MaxRAMPercentage, forcecoop, expect heap, expect coop
138- checkMaxRAMSize (MaxRAMPercentage - headroomPercentage , false , maxcoopheap - (long )headroom , true );
139- checkMaxRAMSize (MaxRAMPercentage + headroomPercentage , false , maxcoopheap + (long )headroom , false );
140- checkMaxRAMSize (MaxRAMPercentage , true , maxcoopheap , true );
141- } else {
135+ if (hostMemory < requiredHostMemory ) {
142136 throw new SkippedException ("Not enough RAM on machine to run. Test skipped!" );
143137 }
138+
139+ double MaxRAMPercentage = ((double )maxcoopheap / hostMemory ) * 100.0 ;
140+ double headroomPercentage = ((double )headroom / hostMemory ) * 100.0 ;
141+
142+ // Args: MaxRAMPercentage, forcecoop, expectheap, expectcoop
143+ checkMaxRAMSize (MaxRAMPercentage - headroomPercentage , false , maxcoopheap - (long )headroom , true );
144+ checkMaxRAMSize (MaxRAMPercentage + headroomPercentage , false , maxcoopheap + (long )headroom , false );
145+ checkMaxRAMSize (MaxRAMPercentage , true , maxcoopheap , true );
144146 }
145147}
0 commit comments