@@ -73,7 +73,8 @@ private static void verifyMinHeapSize() {
73
73
74
74
UnsignedWord maxHeapSize = Word .unsigned (SubstrateGCOptions .MaxHeapSize .getValue ());
75
75
if (maxHeapSize .notEqual (0 ) && minHeapSize .aboveThan (maxHeapSize )) {
76
- throwError (minHeapSize , MIN_HEAP_SIZE_NAME , maxHeapSize , MAX_HEAP_SIZE_NAME );
76
+ String message = formatError (minHeapSize , MIN_HEAP_SIZE_NAME , maxHeapSize , MAX_HEAP_SIZE_NAME );
77
+ throw reportError (message );
77
78
}
78
79
}
79
80
@@ -84,7 +85,8 @@ private static void verifyMaxNewSize() {
84
85
85
86
UnsignedWord maxHeapSize = Word .unsigned (SubstrateGCOptions .MaxHeapSize .getValue ());
86
87
if (maxHeapSize .notEqual (0 ) && maxNewSize .aboveThan (maxHeapSize )) {
87
- throwError (maxNewSize , MAX_NEW_SIZE_NAME , maxHeapSize , MAX_HEAP_SIZE_NAME );
88
+ String message = formatError (maxNewSize , MAX_NEW_SIZE_NAME , maxHeapSize , MAX_HEAP_SIZE_NAME );
89
+ throw reportError (message );
88
90
}
89
91
}
90
92
@@ -103,24 +105,31 @@ public static void verifyMaxNewSizeAgainstMaxAddressSpaceSize(UnsignedWord maxNe
103
105
private static void verifyAgainstMaxAddressSpaceSize (UnsignedWord actualValue , String actualValueName ) {
104
106
UnsignedWord maxAddressSpaceSize = ReferenceAccess .singleton ().getMaxAddressSpaceSize ();
105
107
if (actualValue .aboveThan (maxAddressSpaceSize )) {
106
- throwError (actualValue , actualValueName , maxAddressSpaceSize , "largest possible heap address space" );
108
+ String message = formatError (actualValue , actualValueName , maxAddressSpaceSize , "largest possible heap address space" );
109
+ if (ReferenceAccess .singleton ().getCompressionShift () > 0 ) {
110
+ message += " To allow larger values, please disable compressed references when building the image by adding the option '-H:-UseCompressedReferences'" ;
111
+ }
112
+ throw reportError (message );
107
113
}
108
114
}
109
115
110
116
private static void verifyAgainstReservedAddressSpaceSize (UnsignedWord actualValue , String actualValueName ) {
111
117
UnsignedWord reservedAddressSpaceSize = Word .unsigned (SubstrateGCOptions .ReservedAddressSpaceSize .getValue ());
112
118
if (reservedAddressSpaceSize .notEqual (0 ) && actualValue .aboveThan (reservedAddressSpaceSize )) {
113
- throwError (actualValue , actualValueName , reservedAddressSpaceSize , "value of the option '" + SubstrateGCOptions .ReservedAddressSpaceSize .getName () + "'" );
119
+ String message = formatError (actualValue , actualValueName , reservedAddressSpaceSize , SubstrateGCOptions .ReservedAddressSpaceSize .getName ());
120
+ throw reportError (message );
114
121
}
115
122
}
116
123
117
- private static void throwError ( UnsignedWord actualValue , String actualValueName , UnsignedWord maxValue , String maxValueName ) throws UserException {
124
+ private static RuntimeException reportError ( String message ) throws UserException {
118
125
if (SubstrateUtil .HOSTED ) {
119
- throw UserError .abort ("The specified %s (%s) must not be larger than the %s (%s)." , actualValueName , format (actualValue ), maxValueName , format (maxValue ));
120
- } else {
121
- throw new IllegalArgumentException (
122
- "The specified " + actualValueName + " (" + format (actualValue ) + ") must not be larger than the " + maxValueName + " (" + format (maxValue ) + ")." );
126
+ throw UserError .abort (message );
123
127
}
128
+ throw new IllegalArgumentException (message );
129
+ }
130
+
131
+ private static String formatError (UnsignedWord actualValue , String actualValueName , UnsignedWord maxValue , String maxValueName ) {
132
+ return "The specified " + actualValueName + " (" + format (actualValue ) + ") must not be larger than the " + maxValueName + " (" + format (maxValue ) + ")." ;
124
133
}
125
134
126
135
private static String format (UnsignedWord bytes ) {
0 commit comments