@@ -247,9 +247,9 @@ private AllocatableValue asAllocatable(Value value, ValueKind<?> kind) {
247
247
}
248
248
}
249
249
250
- private Value emitCompareAndSwap (boolean isLogic , LIRKind accessKind , Value address , Value expectedValue , Value newValue , Value trueValue , Value falseValue , BarrierType barrierType ) {
250
+ private Value emitCompareAndSwapHelper (boolean isLogic , LIRKind accessKind , Value address , Value expectedValue , Value newValue , BarrierType barrierType ) {
251
251
ValueKind <?> kind = newValue .getValueKind ();
252
- assert kind .equals (expectedValue .getValueKind ());
252
+ GraalError . guarantee ( kind .equals (expectedValue . getValueKind ()), "%s != %s" , kind , expectedValue .getValueKind ());
253
253
254
254
AMD64AddressValue addressValue = asAddressValue (address );
255
255
LIRKind integerAccessKind = accessKind ;
@@ -270,15 +270,20 @@ private Value emitCompareAndSwap(boolean isLogic, LIRKind accessKind, Value addr
270
270
AllocatableValue allocatableNewValue = asAllocatable (reinterpretedNewValue , integerAccessKind );
271
271
emitMove (aRes , reinterpretedExpectedValue );
272
272
emitCompareAndSwapOp (isLogic , integerAccessKind , memKind , aRes , addressValue , allocatableNewValue , barrierType );
273
+ return aRes ;
274
+ }
275
+
276
+ private Value emitCompareAndSwap (boolean isLogic , LIRKind accessKind , Value address , Value expectedValue , Value newValue , Value trueValue , Value falseValue , BarrierType barrierType ) {
277
+ Value aRes = emitCompareAndSwapHelper (isLogic , accessKind , address , expectedValue , newValue , barrierType );
273
278
274
279
if (isLogic ) {
275
280
assert trueValue .getValueKind ().equals (falseValue .getValueKind ());
276
281
return emitCondMoveOp (Condition .EQ , trueValue , falseValue , false , false );
277
282
} else {
278
- if (isXmm ) {
283
+ if ((( AMD64Kind ) accessKind . getPlatformKind ()). isXMM () ) {
279
284
return arithmeticLIRGen .emitReinterpret (accessKind , aRes );
280
285
} else {
281
- Variable result = newVariable (kind );
286
+ Variable result = newVariable (newValue . getValueKind () );
282
287
emitMove (result , aRes );
283
288
return result ;
284
289
}
@@ -298,13 +303,11 @@ public Value emitValueCompareAndSwap(LIRKind accessKind, Value address, Value ex
298
303
299
304
public void emitCompareAndSwapBranch (boolean isLogic , LIRKind kind , AMD64AddressValue address , Value expectedValue , Value newValue , Condition condition , LabelRef trueLabel , LabelRef falseLabel ,
300
305
double trueLabelProbability , BarrierType barrierType ) {
301
- assert kind .getPlatformKind ().getSizeInBytes () <= expectedValue .getValueKind ().getPlatformKind ().getSizeInBytes () : kind + " " + expectedValue ;
302
- assert kind .getPlatformKind ().getSizeInBytes () <= newValue .getValueKind ().getPlatformKind ().getSizeInBytes () : kind + " " + newValue ;
303
- assert condition == Condition .EQ || condition == Condition .NE : Assertions .errorMessage (condition , address , expectedValue , newValue );
304
- AMD64Kind memKind = (AMD64Kind ) kind .getPlatformKind ();
305
- RegisterValue raxValue = AMD64 .rax .asValue (kind );
306
- emitMove (raxValue , expectedValue );
307
- emitCompareAndSwapOp (isLogic , kind , memKind , raxValue , address , asAllocatable (newValue ), barrierType );
306
+ GraalError .guarantee (kind .getPlatformKind ().getSizeInBytes () <= expectedValue .getValueKind ().getPlatformKind ().getSizeInBytes (), "kind=%s, expectedValue=%s" , kind , expectedValue );
307
+ GraalError .guarantee (kind .getPlatformKind ().getSizeInBytes () <= newValue .getValueKind ().getPlatformKind ().getSizeInBytes (), "kind=%s, newValue=%s" , kind , newValue );
308
+ GraalError .guarantee (condition == Condition .EQ || condition == Condition .NE , Assertions .errorMessage (condition , address , expectedValue , newValue ));
309
+
310
+ emitCompareAndSwapHelper (isLogic , kind , address , expectedValue , newValue , barrierType );
308
311
append (new BranchOp (condition , trueLabel , falseLabel , trueLabelProbability ));
309
312
}
310
313
0 commit comments