コード例 #1
0
 @Override
 public LocationIdentity getLocationIdentity() {
   /*
    * Because of restrictions that the memory graph of snippets matches the original node,
    * pretend that we kill any.
    */
   return LocationIdentity.any();
 }
コード例 #2
0
    public void lower(ArrayCopyNode arraycopy, LoweringTool tool) {
      JavaKind componentKind = selectComponentKind(arraycopy);
      SnippetInfo snippetInfo = null;
      SnippetInfo slowPathSnippetInfo = null;
      Object slowPathArgument = null;

      if (arraycopy.getLength().isConstant()
          && arraycopy.getLength().asJavaConstant().asLong() == 0) {
        snippetInfo = arraycopyZeroLengthIntrinsicSnippet;
      } else if (arraycopy.isExact()) {
        snippetInfo = arraycopyExactIntrinsicSnippet;
        if (shouldUnroll(arraycopy.getLength())) {
          snippetInfo = arraycopyUnrolledIntrinsicSnippet;
        }
      } else {
        if (componentKind == JavaKind.Object) {
          ResolvedJavaType srcType = StampTool.typeOrNull(arraycopy.getSource().stamp());
          ResolvedJavaType destType = StampTool.typeOrNull(arraycopy.getDestination().stamp());
          ResolvedJavaType srcComponentType = srcType == null ? null : srcType.getComponentType();
          ResolvedJavaType destComponentType =
              destType == null ? null : destType.getComponentType();
          if (srcComponentType != null
              && destComponentType != null
              && !srcComponentType.isPrimitive()
              && !destComponentType.isPrimitive()) {
            snippetInfo = arraycopySlowPathIntrinsicSnippet;
            slowPathSnippetInfo = checkcastArraycopyWorkSnippet;
            slowPathArgument = LocationIdentity.any();
            /*
             * Because this snippet has to use Sysytem.arraycopy as a slow path, we must
             * pretend to kill any() so clear the componentKind.
             */
            componentKind = null;
          }
        }
        if (componentKind == null && snippetInfo == null) {
          JavaKind predictedKind = selectComponentKind(arraycopy, false);
          if (predictedKind != null) {
            /*
             * At least one array is of a known type requiring no store checks, so
             * assume the other is of the same type. Generally this is working around
             * deficiencies in our propagation of type information.
             */
            componentKind = predictedKind;
            if (predictedKind == JavaKind.Object) {
              snippetInfo = arraycopySlowPathIntrinsicSnippet;
              slowPathSnippetInfo = arraycopyPredictedObjectWorkSnippet;
              slowPathArgument = predictedKind;
              componentKind = null;
            } else {
              snippetInfo = arraycopyPredictedExactIntrinsicSnippet;
            }
          }
        }
        if (snippetInfo == null) {
          snippetInfo = arraycopyGenericSnippet;
        }
      }
      Arguments args =
          new Arguments(snippetInfo, arraycopy.graph().getGuardsStage(), tool.getLoweringStage());
      args.add("src", arraycopy.getSource());
      args.add("srcPos", arraycopy.getSourcePosition());
      args.add("dest", arraycopy.getDestination());
      args.add("destPos", arraycopy.getDestinationPosition());
      args.add("length", arraycopy.getLength());
      if (snippetInfo == arraycopyUnrolledIntrinsicSnippet) {
        args.addConst("unrolledLength", arraycopy.getLength().asJavaConstant().asInt());
        args.addConst("elementKind", componentKind != null ? componentKind : JavaKind.Illegal);
      } else if (snippetInfo == arraycopySlowPathIntrinsicSnippet) {
        args.addConst("elementKind", componentKind != null ? componentKind : JavaKind.Illegal);
        args.addConst("slowPath", slowPathSnippetInfo);
        assert slowPathArgument != null;
        args.addConst("slowPathArgument", slowPathArgument);
      } else if (snippetInfo == arraycopyExactIntrinsicSnippet
          || snippetInfo == arraycopyPredictedExactIntrinsicSnippet) {
        assert componentKind != null;
        args.addConst("elementKind", componentKind);
        args.addConst("counter", arraycopyCallCounters.get(componentKind));
        args.addConst("copiedCounter", arraycopyCallCopiedCounters.get(componentKind));
      }
      instantiate(args, arraycopy);
    }
コード例 #3
0
 protected SnippetInfo snippet(String methodName) {
   SnippetInfo info = snippet(ArrayCopySnippets.class, methodName, LocationIdentity.any());
   info.setOriginalMethod(originalArraycopy());
   return info;
 }