示例#1
0
 public static long saturate(long v, Kind kind) {
   long max = kind.getMaxValue();
   if (v > max) {
     return max;
   }
   long min = kind.getMinValue();
   if (v < min) {
     return min;
   }
   return v;
 }
示例#2
0
 private static Stamp narrowingKindConvertion(IntegerStamp fromStamp, Kind toKind) {
   long mask = fromStamp.mask() & IntegerStamp.defaultMask(toKind);
   long lowerBound = saturate(fromStamp.lowerBound(), toKind);
   long upperBound = saturate(fromStamp.upperBound(), toKind);
   if (fromStamp.lowerBound() < toKind.getMinValue()) {
     upperBound = toKind.getMaxValue();
   }
   if (fromStamp.upperBound() > toKind.getMaxValue()) {
     lowerBound = toKind.getMinValue();
   }
   return StampFactory.forInteger(toKind.getStackKind(), lowerBound, upperBound, mask);
 }
 /**
  * Ensure that the frame state is formatted as expected by the JVM, with null or Illegal in the
  * slot following a double word item. This should really be checked in FrameState itself but
  * because of Word type rewriting and alternative backends that can't be done.
  */
 public boolean validateFormat() {
   if (caller() != null) {
     caller().validateFormat();
   }
   for (int i = 0; i < numLocals + numStack; i++) {
     if (values[i] != null) {
       Kind kind = values[i].getKind();
       if (kind.needsTwoSlots()) {
         assert values.length > i + 1 : String.format("missing second word %s", this);
         assert values[i + 1] == null || values[i + 1].getKind() == Kind.Illegal : this;
       }
     }
   }
   return true;
 }
示例#4
0
 public static Stamp negate(Stamp stamp) {
   Kind kind = stamp.kind();
   if (stamp instanceof IntegerStamp) {
     IntegerStamp integerStamp = (IntegerStamp) stamp;
     if (integerStamp.lowerBound() != kind.getMinValue()) {
       // TODO(ls) check if the mask calculation is correct...
       return new IntegerStamp(
           kind,
           -integerStamp.upperBound(),
           -integerStamp.lowerBound(),
           IntegerStamp.defaultMask(kind) & (integerStamp.mask() | -integerStamp.mask()));
     }
   }
   return StampFactory.forKind(kind);
 }
示例#5
0
 protected DirectReadNode(ValueNode address, Kind readKind) {
   super(StampFactory.forKind(readKind.getStackKind()));
   this.address = address;
   this.readKind = readKind;
 }