Ejemplo n.º 1
0
 @ExplodeLoop
 public int getSelectedPositionsCount(PositionProfile[] profiles) {
   if (positionsCheck.length == 1) {
     return selectedPositionsCountProfile.profile(profiles[0].selectedPositionsCount);
   } else {
     int newSize = 1;
     for (int i = 0; i < positionsCheck.length; i++) {
       newSize *= profiles[i].selectedPositionsCount;
     }
     return selectedPositionsCountProfile.profile(newSize);
   }
 }
Ejemplo n.º 2
0
 @ExplodeLoop
 public int getMaxOutOfBounds(PositionProfile[] replacementStatistics) {
   if (positionsCheck.length == 1) {
     return maxOutOfBoundsProfile.profile(replacementStatistics[0].maxOutOfBoundsIndex);
   } else {
     // impossible to be relevant as position check will throw an error in this case.
     return 0;
   }
 }
Ejemplo n.º 3
0
  public final Object execute(
      PositionProfile profile,
      RAbstractContainer vector,
      int[] vectorDimensions,
      int vectorLength,
      Object position) {
    Object castPosition = castNode.execute(positionClass.cast(position));

    int dimensionLength;
    if (numDimensions == 1) {
      dimensionLength = vectorLength;
    } else {
      assert vectorDimensions != null;
      assert vectorDimensions.length == numDimensions;
      dimensionLength = vectorDimensions[dimensionIndex];
    }

    if (characterLookup != null) {
      castPosition =
          characterLookup.execute(vector, (RAbstractStringVector) castPosition, dimensionLength);
    }

    RTypedValue positionVector = (RTypedValue) profilePosition(castPosition);

    int positionLength;
    if (positionVector instanceof RMissing) {
      positionLength = -1;
    } else {
      positionLength =
          positionLengthProfile.profile(((RAbstractVector) positionVector).getLength());
    }

    assert isValidCastedType(positionVector)
        : "result type of a position cast node must be integer or logical";

    return execute(profile, dimensionLength, positionVector, positionLength);
  }