@Override
 public void lower(LoweringTool tool) {
   if (graph().getGuardsStage().areFrameStatesAtDeopts()) {
     ForeignCallDescriptor desc =
         HotSpotHostForeignCallsProvider.lookupCheckcastArraycopyDescriptor(isUninit());
     StructuredGraph graph = graph();
     ValueNode srcAddr = computeBase(getSource(), getSourcePosition());
     ValueNode destAddr = computeBase(getDestination(), getDestinationPosition());
     ValueNode len = getLength();
     if (len.stamp().getStackKind() != runtime.getTarget().wordJavaKind) {
       len =
           IntegerConvertNode.convert(
               len, StampFactory.forKind(runtime.getTarget().wordJavaKind), graph());
     }
     ForeignCallNode call =
         graph.add(
             new ForeignCallNode(
                 runtime.getHostBackend().getForeignCalls(),
                 desc,
                 srcAddr,
                 destAddr,
                 len,
                 superCheckOffset,
                 destElemKlass));
     call.setStateAfter(stateAfter());
     graph.replaceFixedWithFixed(this, call);
   }
 }
Пример #2
0
    /**
     * Instantiate the snippet template and fix up the FrameState of any Invokes of System.arraycopy
     * and propagate the captured bci in the ArrayCopySlowPathNode.
     *
     * @param args
     * @param arraycopy
     */
    private void instantiate(Arguments args, BasicArrayCopyNode arraycopy) {
      StructuredGraph graph = arraycopy.graph();
      SnippetTemplate template = template(args);
      Map<Node, Node> replacements =
          template.instantiate(
              providers.getMetaAccess(), arraycopy, SnippetTemplate.DEFAULT_REPLACER, args);
      for (Node originalNode : replacements.keySet()) {
        if (originalNode instanceof Invoke) {
          Invoke invoke = (Invoke) replacements.get(originalNode);
          assert invoke.asNode().graph() == graph;
          CallTargetNode call = invoke.callTarget();

          if (!call.targetMethod().equals(originalArraycopy)) {
            throw new GraalError("unexpected invoke %s in snippet", call.targetMethod());
          }
          // Here we need to fix the bci of the invoke
          InvokeNode newInvoke = graph.add(new InvokeNode(invoke.callTarget(), arraycopy.getBci()));
          if (arraycopy.stateDuring() != null) {
            newInvoke.setStateDuring(arraycopy.stateDuring());
          } else {
            assert arraycopy.stateAfter() != null;
            newInvoke.setStateAfter(arraycopy.stateAfter());
          }
          graph.replaceFixedWithFixed((InvokeNode) invoke.asNode(), newInvoke);
        } else if (originalNode instanceof ArrayCopySlowPathNode) {
          ArrayCopySlowPathNode slowPath = (ArrayCopySlowPathNode) replacements.get(originalNode);
          assert arraycopy.stateAfter() != null;
          slowPath.setStateAfter(arraycopy.stateAfter());
          slowPath.setBci(arraycopy.getBci());
        }
      }
    }
Пример #3
0
 @Override
 protected void replaceProfile(StructuredGraph graph, JavaTypeProfile profile) {
   CheckCastNode ccn = graph.getNodes(CheckCastNode.class).first();
   if (ccn != null) {
     CheckCastNode ccnNew = graph.add(new CheckCastNode(ccn.type(), ccn.object(), profile, false));
     graph.replaceFixedWithFixed(ccn, ccnNew);
   }
 }
Пример #4
0
 public void replaceFixed(FixedWithNextNode node, Node replacement) {
   if (replacement instanceof FixedWithNextNode) {
     replaceFixedWithFixed(node, (FixedWithNextNode) replacement);
   } else {
     assert replacement != null : "cannot replace " + node + " with null";
     assert replacement instanceof FloatingNode
         : "cannot replace " + node + " with " + replacement;
     replaceFixedWithFloating(node, (FloatingNode) replacement);
   }
 }