< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.word/src/org/graalvm/compiler/word/WordOperationPlugin.java

Print this page




 430         } else if (canonical.getCanonicalCondition() == CanonicalCondition.BT) {
 431             comparison = new IntegerBelowNode(a, b);
 432         } else {
 433             assert canonical.getCanonicalCondition() == CanonicalCondition.LT;
 434             comparison = new IntegerLessThanNode(a, b);
 435         }
 436 
 437         ConstantNode trueValue = graph.add(forInt(1));
 438         ConstantNode falseValue = graph.add(forInt(0));
 439 
 440         if (canonical.mustNegate()) {
 441             ConstantNode temp = trueValue;
 442             trueValue = falseValue;
 443             falseValue = temp;
 444         }
 445         return graph.add(new ConditionalNode(graph.add(comparison), trueValue, falseValue));
 446     }
 447 
 448     protected ValueNode readOp(GraphBuilderContext b, JavaKind readKind, AddressNode address, LocationIdentity location, Opcode op) {
 449         assert op == Opcode.READ_POINTER || op == Opcode.READ_OBJECT || op == Opcode.READ_BARRIERED;
 450         final BarrierType barrier = (op == Opcode.READ_BARRIERED ? BarrierType.PRECISE : BarrierType.NONE);
 451         final boolean compressible = (op == Opcode.READ_OBJECT || op == Opcode.READ_BARRIERED);
 452 
 453         return readOp(b, readKind, address, location, barrier, compressible);
 454     }
 455 
 456     public static ValueNode readOp(GraphBuilderContext b, JavaKind readKind, AddressNode address, LocationIdentity location, BarrierType barrierType, boolean compressible) {
 457         /*
 458          * A JavaReadNode lowered to a ReadNode that will not float. This means it cannot float
 459          * above an explicit zero check on its base address or any other test that ensures the read
 460          * is safe.
 461          */
 462         JavaReadNode read = b.add(new JavaReadNode(readKind, address, location, barrierType, compressible));
 463         return read;
 464     }
 465 
 466     protected void writeOp(GraphBuilderContext b, JavaKind writeKind, AddressNode address, LocationIdentity location, ValueNode value, Opcode op) {
 467         assert op == Opcode.WRITE_POINTER || op == Opcode.WRITE_OBJECT || op == Opcode.WRITE_BARRIERED || op == Opcode.INITIALIZE;
 468         final BarrierType barrier = (op == Opcode.WRITE_BARRIERED ? BarrierType.PRECISE : BarrierType.NONE);
 469         final boolean compressible = (op == Opcode.WRITE_OBJECT || op == Opcode.WRITE_BARRIERED);
 470         assert op != Opcode.INITIALIZE || location.isInit() : "must use init location for initializing";
 471         b.add(new JavaWriteNode(writeKind, address, location, value, barrier, compressible));
 472     }
 473 
 474     protected AbstractCompareAndSwapNode casOp(JavaKind writeKind, JavaKind returnKind, AddressNode address, LocationIdentity location, ValueNode expectedValue, ValueNode newValue) {
 475         boolean isLogic = returnKind == JavaKind.Boolean;
 476         assert isLogic || writeKind == returnKind : writeKind + " != " + returnKind;
 477         AbstractCompareAndSwapNode cas;
 478         if (isLogic) {
 479             cas = new LogicCompareAndSwapNode(address, expectedValue, newValue, location);
 480         } else {
 481             cas = new ValueCompareAndSwapNode(address, expectedValue, newValue, location);
 482         }
 483         return cas;
 484     }
 485 
 486     public AddressNode makeAddress(GraphBuilderContext b, ValueNode base, ValueNode offset) {
 487         return b.add(new OffsetAddressNode(base, fromSigned(b, offset)));
 488     }




 430         } else if (canonical.getCanonicalCondition() == CanonicalCondition.BT) {
 431             comparison = new IntegerBelowNode(a, b);
 432         } else {
 433             assert canonical.getCanonicalCondition() == CanonicalCondition.LT;
 434             comparison = new IntegerLessThanNode(a, b);
 435         }
 436 
 437         ConstantNode trueValue = graph.add(forInt(1));
 438         ConstantNode falseValue = graph.add(forInt(0));
 439 
 440         if (canonical.mustNegate()) {
 441             ConstantNode temp = trueValue;
 442             trueValue = falseValue;
 443             falseValue = temp;
 444         }
 445         return graph.add(new ConditionalNode(graph.add(comparison), trueValue, falseValue));
 446     }
 447 
 448     protected ValueNode readOp(GraphBuilderContext b, JavaKind readKind, AddressNode address, LocationIdentity location, Opcode op) {
 449         assert op == Opcode.READ_POINTER || op == Opcode.READ_OBJECT || op == Opcode.READ_BARRIERED;
 450         final BarrierType barrier = (op == Opcode.READ_BARRIERED ? BarrierType.UNKNOWN : BarrierType.NONE);
 451         final boolean compressible = (op == Opcode.READ_OBJECT || op == Opcode.READ_BARRIERED);
 452 
 453         return readOp(b, readKind, address, location, barrier, compressible);
 454     }
 455 
 456     public static ValueNode readOp(GraphBuilderContext b, JavaKind readKind, AddressNode address, LocationIdentity location, BarrierType barrierType, boolean compressible) {
 457         /*
 458          * A JavaReadNode lowered to a ReadNode that will not float. This means it cannot float
 459          * above an explicit zero check on its base address or any other test that ensures the read
 460          * is safe.
 461          */
 462         JavaReadNode read = b.add(new JavaReadNode(readKind, address, location, barrierType, compressible));
 463         return read;
 464     }
 465 
 466     protected void writeOp(GraphBuilderContext b, JavaKind writeKind, AddressNode address, LocationIdentity location, ValueNode value, Opcode op) {
 467         assert op == Opcode.WRITE_POINTER || op == Opcode.WRITE_OBJECT || op == Opcode.WRITE_BARRIERED || op == Opcode.INITIALIZE;
 468         final BarrierType barrier = (op == Opcode.WRITE_BARRIERED ? BarrierType.UNKNOWN : BarrierType.NONE);
 469         final boolean compressible = (op == Opcode.WRITE_OBJECT || op == Opcode.WRITE_BARRIERED);
 470         assert op != Opcode.INITIALIZE || location.isInit() : "must use init location for initializing";
 471         b.add(new JavaWriteNode(writeKind, address, location, value, barrier, compressible));
 472     }
 473 
 474     protected AbstractCompareAndSwapNode casOp(JavaKind writeKind, JavaKind returnKind, AddressNode address, LocationIdentity location, ValueNode expectedValue, ValueNode newValue) {
 475         boolean isLogic = returnKind == JavaKind.Boolean;
 476         assert isLogic || writeKind == returnKind : writeKind + " != " + returnKind;
 477         AbstractCompareAndSwapNode cas;
 478         if (isLogic) {
 479             cas = new LogicCompareAndSwapNode(address, expectedValue, newValue, location);
 480         } else {
 481             cas = new ValueCompareAndSwapNode(address, expectedValue, newValue, location);
 482         }
 483         return cas;
 484     }
 485 
 486     public AddressNode makeAddress(GraphBuilderContext b, ValueNode base, ValueNode offset) {
 487         return b.add(new OffsetAddressNode(base, fromSigned(b, offset)));
 488     }


< prev index next >