1130 1131 @ForceInline 1132 static $type$ getAndBitwiseXorRelease(Array handle, Object oarray, int index, $type$ value) { 1133 $type$[] array = ($type$[]) oarray; 1134 return UNSAFE.getAndBitwiseXor$Type$Release(array, 1135 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1136 value); 1137 } 1138 1139 @ForceInline 1140 static $type$ getAndBitwiseXorAcquire(Array handle, Object oarray, int index, $type$ value) { 1141 $type$[] array = ($type$[]) oarray; 1142 return UNSAFE.getAndBitwiseXor$Type$Acquire(array, 1143 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1144 value); 1145 } 1146 #end[Bitwise] 1147 1148 static final VarForm FORM = new VarForm(Array.class, {#if[Object]?Object[].class:$type$[].class}, {#if[Object]?Object.class:$type$.class}, int.class); 1149 } 1150 } | 1130 1131 @ForceInline 1132 static $type$ getAndBitwiseXorRelease(Array handle, Object oarray, int index, $type$ value) { 1133 $type$[] array = ($type$[]) oarray; 1134 return UNSAFE.getAndBitwiseXor$Type$Release(array, 1135 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1136 value); 1137 } 1138 1139 @ForceInline 1140 static $type$ getAndBitwiseXorAcquire(Array handle, Object oarray, int index, $type$ value) { 1141 $type$[] array = ($type$[]) oarray; 1142 return UNSAFE.getAndBitwiseXor$Type$Acquire(array, 1143 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1144 value); 1145 } 1146 #end[Bitwise] 1147 1148 static final VarForm FORM = new VarForm(Array.class, {#if[Object]?Object[].class:$type$[].class}, {#if[Object]?Object.class:$type$.class}, int.class); 1149 } 1150 1151 #if[Object] 1152 static final class ValueArray extends VarHandle { 1153 final int abase; 1154 final int ashift; 1155 final Class<?> arrayType; 1156 final Class<?> componentType; 1157 1158 ValueArray(int abase, int ashift, Class<?> arrayType) { 1159 super(ValueArray.FORM); 1160 this.abase = abase; 1161 this.ashift = ashift; 1162 this.arrayType = arrayType; 1163 this.componentType = arrayType.getComponentType(); 1164 } 1165 1166 @Override 1167 final MethodType accessModeTypeUncached(AccessMode accessMode) { 1168 return accessMode.at.accessModeType(arrayType, arrayType.getComponentType(), int.class); 1169 } 1170 1171 @ForceInline 1172 static Object runtimeTypeCheck(ValueArray handle, Object[] oarray, Object value) { 1173 if (handle.arrayType == oarray.getClass()) { 1174 // Fast path: static array type same as argument array type 1175 return handle.componentType.cast(Objects.requireNonNull(value)); 1176 } else { 1177 // Slow path: check value against argument array component type 1178 return reflectiveTypeCheck(oarray, value); 1179 } 1180 } 1181 1182 @ForceInline 1183 static Object reflectiveTypeCheck(Object[] oarray, Object value) { 1184 try { 1185 return oarray.getClass().getComponentType().cast(Objects.requireNonNull(value)); 1186 } catch (ClassCastException e) { 1187 throw new ArrayStoreException(); 1188 } 1189 } 1190 1191 @ForceInline 1192 static $type$ get(ValueArray handle, Object oarray, int index) { 1193 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1194 return array[index]; 1195 } 1196 1197 @ForceInline 1198 static void set(ValueArray handle, Object oarray, int index, $type$ value) { 1199 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1200 array[index] = handle.componentType.cast(Objects.requireNonNull(value)); 1201 } 1202 1203 @ForceInline 1204 static $type$ getVolatile(ValueArray handle, Object oarray, int index) { 1205 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1206 return UNSAFE.getValueVolatile(array, 1207 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1208 handle.componentType); 1209 } 1210 1211 @ForceInline 1212 static void setVolatile(ValueArray handle, Object oarray, int index, $type$ value) { 1213 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1214 UNSAFE.putValueVolatile(array, 1215 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1216 handle.componentType, 1217 runtimeTypeCheck(handle, array, value)); 1218 } 1219 1220 @ForceInline 1221 static $type$ getOpaque(ValueArray handle, Object oarray, int index) { 1222 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1223 return UNSAFE.getValueOpaque(array, 1224 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1225 handle.componentType); 1226 } 1227 1228 @ForceInline 1229 static void setOpaque(ValueArray handle, Object oarray, int index, $type$ value) { 1230 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1231 UNSAFE.putValueOpaque(array, 1232 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1233 handle.componentType, 1234 runtimeTypeCheck(handle, array, value)); 1235 } 1236 1237 @ForceInline 1238 static $type$ getAcquire(ValueArray handle, Object oarray, int index) { 1239 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1240 return UNSAFE.getValueAcquire(array, 1241 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1242 handle.componentType); 1243 } 1244 1245 @ForceInline 1246 static void setRelease(ValueArray handle, Object oarray, int index, $type$ value) { 1247 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1248 UNSAFE.putValueRelease(array, 1249 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1250 handle.componentType, 1251 runtimeTypeCheck(handle, array, value)); 1252 } 1253 #if[CAS] 1254 1255 @ForceInline 1256 static boolean compareAndSet(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { 1257 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1258 return UNSAFE.compareAndSetValue(array, 1259 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1260 handle.componentType, 1261 handle.componentType.cast(Objects.requireNonNull(expected)), 1262 runtimeTypeCheck(handle, array, value)); 1263 } 1264 1265 @ForceInline 1266 static $type$ compareAndExchange(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { 1267 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1268 return UNSAFE.compareAndExchangeValue(array, 1269 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1270 handle.componentType, 1271 handle.componentType.cast(Objects.requireNonNull(expected)), 1272 runtimeTypeCheck(handle, array, value)); 1273 } 1274 1275 @ForceInline 1276 static $type$ compareAndExchangeAcquire(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { 1277 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1278 return UNSAFE.compareAndExchangeValueAcquire(array, 1279 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1280 handle.componentType, 1281 handle.componentType.cast(Objects.requireNonNull(expected)), 1282 runtimeTypeCheck(handle, array, value)); 1283 } 1284 1285 @ForceInline 1286 static $type$ compareAndExchangeRelease(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { 1287 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1288 return UNSAFE.compareAndExchangeValueRelease(array, 1289 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1290 handle.componentType, 1291 handle.componentType.cast(Objects.requireNonNull(expected)), 1292 runtimeTypeCheck(handle, array, value)); 1293 } 1294 1295 @ForceInline 1296 static boolean weakCompareAndSetPlain(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { 1297 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1298 return UNSAFE.weakCompareAndSetValuePlain(array, 1299 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1300 handle.componentType, 1301 handle.componentType.cast(Objects.requireNonNull(expected)), 1302 runtimeTypeCheck(handle, array, value)); 1303 } 1304 1305 @ForceInline 1306 static boolean weakCompareAndSet(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { 1307 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1308 return UNSAFE.weakCompareAndSetValue(array, 1309 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1310 handle.componentType, 1311 handle.componentType.cast(Objects.requireNonNull(expected)), 1312 runtimeTypeCheck(handle, array, value)); 1313 } 1314 1315 @ForceInline 1316 static boolean weakCompareAndSetAcquire(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { 1317 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1318 return UNSAFE.weakCompareAndSetValueAcquire(array, 1319 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1320 handle.componentType, 1321 handle.componentType.cast(Objects.requireNonNull(expected)), 1322 runtimeTypeCheck(handle, array, value)); 1323 } 1324 1325 @ForceInline 1326 static boolean weakCompareAndSetRelease(ValueArray handle, Object oarray, int index, $type$ expected, $type$ value) { 1327 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1328 return UNSAFE.weakCompareAndSetValueRelease(array, 1329 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1330 handle.componentType, 1331 handle.componentType.cast(Objects.requireNonNull(expected)), 1332 runtimeTypeCheck(handle, array, value)); 1333 } 1334 1335 @ForceInline 1336 static $type$ getAndSet(ValueArray handle, Object oarray, int index, $type$ value) { 1337 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1338 return UNSAFE.getAndSetValue(array, 1339 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1340 handle.componentType, 1341 runtimeTypeCheck(handle, array, value)); 1342 } 1343 1344 @ForceInline 1345 static $type$ getAndSetAcquire(ValueArray handle, Object oarray, int index, $type$ value) { 1346 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1347 return UNSAFE.getAndSetValueAcquire(array, 1348 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1349 handle.componentType, 1350 runtimeTypeCheck(handle, array, value)); 1351 } 1352 1353 @ForceInline 1354 static $type$ getAndSetRelease(ValueArray handle, Object oarray, int index, $type$ value) { 1355 Object[] array = (Object[]) handle.arrayType.cast(oarray); 1356 return UNSAFE.getAndSetValueRelease(array, 1357 (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, 1358 handle.componentType, 1359 runtimeTypeCheck(handle, array, value)); 1360 } 1361 #end[CAS] 1362 1363 static final VarForm FORM = new VarForm(ValueArray.class, {#if[Object]?Object[].class:$type$[].class}, {#if[Object]?Object.class:$type$.class}, int.class); 1364 } 1365 #end[Object] 1366 } |