コード例 #1
0
ファイル: MonitorGraphTest.java プロジェクト: headius/graal
 private StructuredGraph parseAndProcess(String snippet) {
   StructuredGraph graph = parse(snippet);
   LocalNode local = graph.getNodes(LocalNode.class).first();
   ConstantNode constant = ConstantNode.forInt(0, graph);
   for (Node n : local.usages().filter(isNotA(FrameState.class)).snapshot()) {
     n.replaceFirstInput(local, constant);
   }
   Map<Invoke, Double> hints = new HashMap<>();
   for (Invoke invoke : graph.getInvokes()) {
     hints.put(invoke, 1000d);
   }
   Assumptions assumptions = new Assumptions(false);
   new InliningPhase(
           runtime(),
           hints,
           replacements,
           assumptions,
           null,
           getDefaultPhasePlan(),
           OptimisticOptimizations.ALL)
       .apply(graph);
   new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(graph);
   new DeadCodeEliminationPhase().apply(graph);
   return graph;
 }
コード例 #2
0
ファイル: GraphUtil.java プロジェクト: rjsingh/graal
 private static void killEnd(AbstractEndNode end) {
   MergeNode merge = end.merge();
   if (merge != null) {
     merge.removeEnd(end);
     StructuredGraph graph = end.graph();
     if (merge instanceof LoopBeginNode && merge.forwardEndCount() == 0) { // dead loop
       for (PhiNode phi : merge.phis().snapshot()) {
         propagateKill(phi);
       }
       LoopBeginNode begin = (LoopBeginNode) merge;
       // disconnect and delete loop ends & loop exits
       for (LoopEndNode loopend : begin.loopEnds().snapshot()) {
         loopend.predecessor().replaceFirstSuccessor(loopend, null);
         loopend.safeDelete();
       }
       begin.removeExits();
       FixedNode loopBody = begin.next();
       if (loopBody != null) { // for small infinite loops, the body may be killed while
         // killing the loop ends
         killCFG(loopBody);
       }
       begin.safeDelete();
     } else if (merge instanceof LoopBeginNode
         && ((LoopBeginNode) merge).loopEnds().isEmpty()) { // not
       // a
       // loop
       // anymore
       graph.reduceDegenerateLoopBegin((LoopBeginNode) merge);
     } else if (merge.phiPredecessorCount() == 1) { // not a merge anymore
       graph.reduceTrivialMerge(merge);
     }
   }
 }
コード例 #3
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());
        }
      }
    }
コード例 #4
0
  @Test
  public void testBlockSchedule() {
    ScheduleResult schedule =
        getFinalSchedule("testBlockScheduleSnippet", TestMode.WITHOUT_FRAMESTATES);
    StructuredGraph graph = schedule.getCFG().graph;
    NodeIterable<WriteNode> writeNodes = graph.getNodes().filter(WriteNode.class);

    assertDeepEquals(1, schedule.getCFG().getBlocks().size());
    assertDeepEquals(8, writeNodes.count());
    assertDeepEquals(1, graph.getNodes().filter(FloatingReadNode.class).count());

    FloatingReadNode read = graph.getNodes().filter(FloatingReadNode.class).first();

    WriteNode[] writes = new WriteNode[8];
    int i = 0;
    for (WriteNode n : writeNodes) {
      writes[i] = n;
      i++;
    }
    assertOrderedAfterSchedule(schedule, writes[4], read);
    assertOrderedAfterSchedule(schedule, read, writes[5]);
    for (int j = 0; j < 7; j++) {
      assertOrderedAfterSchedule(schedule, writes[j], writes[j + 1]);
    }
  }
コード例 #5
0
 @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);
   }
 }
コード例 #6
0
ファイル: MonitorGraphTest.java プロジェクト: headius/graal
 @Test
 public void test2() {
   StructuredGraph graph = parseAndProcess("test2Snippet");
   NodeIterable<MonitorExitNode> monitors = graph.getNodes(MonitorExitNode.class);
   Assert.assertEquals(1, monitors.count());
   Assert.assertEquals(monitors.first().stateAfter().bci, 3);
 }
コード例 #7
0
 public void lower(ArrayCopySlowPathNode arraycopy, LoweringTool tool) {
   StructuredGraph graph = arraycopy.graph();
   if (!graph.getGuardsStage().areFrameStatesAtDeopts()) {
     // Can't be lowered yet
     return;
   }
   SnippetInfo snippetInfo = arraycopy.getSnippet();
   Arguments args = new Arguments(snippetInfo, graph.getGuardsStage(), tool.getLoweringStage());
   args.add("nonNullSrc", arraycopy.getSource());
   args.add("srcPos", arraycopy.getSourcePosition());
   args.add("nonNullDest", arraycopy.getDestination());
   args.add("destPos", arraycopy.getDestinationPosition());
   if (snippetInfo == arraycopyUnrolledWorkSnippet) {
     args.addConst("length", ((Integer) arraycopy.getArgument()).intValue());
     args.addConst("elementKind", arraycopy.getElementKind());
   } else {
     args.add("length", arraycopy.getLength());
   }
   if (snippetInfo == arraycopyPredictedObjectWorkSnippet) {
     HotSpotResolvedObjectType arrayKlass =
         (HotSpotResolvedObjectType) tool.getMetaAccess().lookupJavaType(Object[].class);
     ValueNode objectArrayKlass =
         ConstantNode.forConstant(
             KlassPointerStamp.klassNonNull(),
             arrayKlass.klass(),
             tool.getMetaAccess(),
             arraycopy.graph());
     args.add("objectArrayKlass", objectArrayKlass);
     args.addConst("counter", arraycopyCallCounters.get(JavaKind.Object));
     args.addConst("copiedCounter", arraycopyCallCopiedCounters.get(JavaKind.Object));
   }
   instantiate(args, arraycopy);
 }
コード例 #8
0
ファイル: CheckCastTest.java プロジェクト: rjsingh/graal
 @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);
   }
 }
コード例 #9
0
 @Test
 public void testLoop9() {
   ScheduleResult schedule = getFinalSchedule("testLoop9Snippet", TestMode.WITHOUT_FRAMESTATES);
   StructuredGraph graph = schedule.getCFG().getStartBlock().getBeginNode().graph();
   assertThat(graph.getNodes(ReturnNode.TYPE), hasCount(1));
   ReturnNode ret = graph.getNodes(ReturnNode.TYPE).first();
   assertThat(ret.result(), instanceOf(FloatingReadNode.class));
   Block readBlock = schedule.getNodeToBlockMap().get(ret.result());
   Assert.assertEquals(0, readBlock.getLoopDepth());
 }
コード例 #10
0
 /**
  * Checks that second lowering of a given graph did not introduce any new nodes.
  *
  * @param graph a graph that was just {@linkplain #lower lowered}
  * @throws AssertionError if the check fails
  */
 private boolean checkPostLowering(StructuredGraph graph, PhaseContext context) {
   Mark expectedMark = graph.getMark();
   lower(graph, context, LoweringMode.VERIFY_LOWERING);
   Mark mark = graph.getMark();
   assert mark.equals(expectedMark)
       : graph
           + ": a second round in the current lowering phase introduced these new nodes: "
           + graph.getNewNodes(expectedMark).snapshot();
   return true;
 }
コード例 #11
0
 @Override
 public void run(StructuredGraph graph) {
   schedulePhase.apply(graph, false);
   schedule = graph.getLastSchedule();
   schedule.getCFG().computePostdominators();
   Block startBlock = schedule.getCFG().getStartBlock();
   ProcessFrame rootFrame =
       new ProcessFrame(startBlock, graph.createNodeBitMap(), startBlock.getBeginNode(), null);
   LoweringPhase.processBlock(rootFrame);
 }
コード例 #12
0
 @Test
 public void testSimple() {
   for (TestMode mode : TestMode.values()) {
     ScheduleResult schedule = getFinalSchedule("testSimpleSnippet", mode);
     StructuredGraph graph = schedule.getCFG().graph;
     assertReadAndWriteInSameBlock(schedule, true);
     assertOrderedAfterSchedule(
         schedule,
         graph.getNodes().filter(FloatingReadNode.class).first(),
         graph.getNodes().filter(WriteNode.class).first());
   }
 }
コード例 #13
0
 @Test
 public void testArrayCopy() {
   ScheduleResult schedule =
       getFinalSchedule("testArrayCopySnippet", TestMode.INLINED_WITHOUT_FRAMESTATES);
   StructuredGraph graph = schedule.getCFG().getStartBlock().getBeginNode().graph();
   assertDeepEquals(1, graph.getNodes(ReturnNode.TYPE).count());
   ReturnNode ret = graph.getNodes(ReturnNode.TYPE).first();
   assertTrue(
       ret.result() + " should be a FloatingReadNode", ret.result() instanceof FloatingReadNode);
   assertDeepEquals(schedule.getCFG().blockFor(ret), schedule.getCFG().blockFor(ret.result()));
   assertReadWithinAllReturnBlocks(schedule, true);
 }
コード例 #14
0
 private void test(String snippet) {
   StructuredGraph graph = parseProfiled(snippet, AllowAssumptions.NO);
   Map<Invoke, Double> hints = new HashMap<>();
   for (Invoke invoke : graph.getInvokes()) {
     hints.put(invoke, 1000d);
   }
   HighTierContext context =
       new HighTierContext(
           getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
   new InliningPhase(hints, new CanonicalizerPhase(true)).apply(graph, context);
   new CanonicalizerPhase(true).apply(graph, context);
   new DeadCodeEliminationPhase().apply(graph);
 }
コード例 #15
0
    @SuppressWarnings("try")
    public void run(
        StructuredGraph graph, SchedulingStrategy selectedStrategy, boolean immutableGraph) {
      // assert GraphOrder.assertNonCyclicGraph(graph);
      cfg = ControlFlowGraph.compute(graph, true, true, true, false);

      NodeMap<Block> currentNodeMap = graph.createNodeMap();
      NodeBitMap visited = graph.createNodeBitMap();
      BlockMap<List<Node>> earliestBlockToNodesMap = new BlockMap<>(cfg);
      this.nodeToBlockMap = currentNodeMap;
      this.blockToNodesMap = earliestBlockToNodesMap;

      scheduleEarliestIterative(
          earliestBlockToNodesMap, currentNodeMap, visited, graph, immutableGraph);

      if (selectedStrategy != SchedulingStrategy.EARLIEST) {
        // For non-earliest schedules, we need to do a second pass.
        BlockMap<List<Node>> latestBlockToNodesMap = new BlockMap<>(cfg);
        for (Block b : cfg.getBlocks()) {
          latestBlockToNodesMap.put(b, new ArrayList<Node>());
        }

        BlockMap<ArrayList<FloatingReadNode>> watchListMap =
            calcLatestBlocks(
                selectedStrategy,
                currentNodeMap,
                earliestBlockToNodesMap,
                visited,
                latestBlockToNodesMap,
                immutableGraph);
        sortNodesLatestWithinBlock(
            cfg,
            earliestBlockToNodesMap,
            latestBlockToNodesMap,
            currentNodeMap,
            watchListMap,
            visited);

        assert verifySchedule(cfg, latestBlockToNodesMap, currentNodeMap);
        assert MemoryScheduleVerification.check(cfg.getStartBlock(), latestBlockToNodesMap);

        this.blockToNodesMap = latestBlockToNodesMap;

        cfg.setNodeToBlock(currentNodeMap);
      }

      graph.setLastSchedule(
          new ScheduleResult(this.cfg, this.nodeToBlockMap, this.blockToNodesMap));
    }
コード例 #16
0
  @SuppressWarnings("try")
  private ScheduleResult getFinalSchedule(
      final String snippet, final TestMode mode, final SchedulingStrategy schedulingStrategy) {
    final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    try (Scope d = Debug.scope("FloatingReadTest", graph)) {
      try (OverrideScope s =
          OptionValue.override(
              OptScheduleOutOfLoops,
              schedulingStrategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS,
              OptImplicitNullChecks,
              false)) {
        HighTierContext context = getDefaultHighTierContext();
        CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
        canonicalizer.apply(graph, context);
        if (mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
          new InliningPhase(canonicalizer).apply(graph, context);
        }
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER)
            .apply(graph, context);
        if (mode == TestMode.WITHOUT_FRAMESTATES || mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
          graph.clearAllStateAfter();
        }
        Debug.dump(graph, "after removal of framestates");

        new FloatingReadPhase().apply(graph);
        new RemoveValueProxyPhase().apply(graph);

        MidTierContext midContext =
            new MidTierContext(
                getProviders(),
                getTargetProvider(),
                OptimisticOptimizations.ALL,
                graph.getProfilingInfo());
        new GuardLoweringPhase().apply(graph, midContext);
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER)
            .apply(graph, midContext);
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.LOW_TIER)
            .apply(graph, midContext);

        SchedulePhase schedule = new SchedulePhase(schedulingStrategy);
        schedule.apply(graph);
        assertDeepEquals(1, graph.getNodes().filter(StartNode.class).count());
        return graph.getLastSchedule();
      }
    } catch (Throwable e) {
      throw Debug.handle(e);
    }
  }
コード例 #17
0
 private void lower(StructuredGraph graph, PhaseContext context, LoweringMode mode) {
   IncrementalCanonicalizerPhase<PhaseContext> incrementalCanonicalizer =
       new IncrementalCanonicalizerPhase<>(canonicalizer);
   incrementalCanonicalizer.appendPhase(new Round(context, mode));
   incrementalCanonicalizer.apply(graph, context);
   assert graph.verify();
 }
コード例 #18
0
  @Override
  public void notifyCompilationTruffleTierFinished(
      OptimizedCallTarget target, TruffleInlining inliningDecision, StructuredGraph graph) {
    compilationLocal.get().truffleTierFinished = System.nanoTime();

    nodeStatistics.accept(
        target.nodeStream(inliningDecision).filter(n -> n != null).map(node -> node.getClass()));

    CallTargetNodeStatistics callTargetStat =
        new CallTargetNodeStatistics(target, inliningDecision);
    nodeCount.accept(callTargetStat.getNodeCount());
    nodeCountTrivial.accept(callTargetStat.getNodeCountTrivial());
    nodeCountNonTrivial.accept(callTargetStat.getNodeCountNonTrivial());
    nodeCountMonomorphic.accept(callTargetStat.getNodeCountMonomorphic());
    nodeCountPolymorphic.accept(callTargetStat.getNodeCountPolymorphic());
    nodeCountMegamorphic.accept(callTargetStat.getNodeCountMegamorphic());

    callCount.accept(callTargetStat.getCallCount());
    callCountIndirect.accept(callTargetStat.getCallCountIndirect());
    callCountDirect.accept(callTargetStat.getCallCountDirect());
    callCountDirectDispatched.accept(callTargetStat.getCallCountDirectDispatched());
    callCountDirectInlined.accept(callTargetStat.getCallCountDirectInlined());
    callCountDirectCloned.accept(callTargetStat.getCallCountDirectCloned());
    callCountDirectNotCloned.accept(callTargetStat.getCallCountDirectNotCloned());
    loopCount.accept(callTargetStat.getLoopCount());

    truffleTierNodeCount.accept(graph.getNodeCount());
    if (TruffleCompilerOptions.TruffleCompilationStatisticDetails.getValue()) {
      truffleTierNodeStatistics.accept(nodeClassStream(graph));
    }
  }
コード例 #19
0
 private static boolean verifySchedule(
     ControlFlowGraph cfg, BlockMap<List<Node>> blockToNodesMap, NodeMap<Block> nodeMap) {
   for (Block b : cfg.getBlocks()) {
     List<Node> nodes = blockToNodesMap.get(b);
     for (Node n : nodes) {
       assert n.isAlive();
       assert nodeMap.get(n) == b;
       StructuredGraph g = (StructuredGraph) n.graph();
       if (g.hasLoops()
           && g.getGuardsStage() == GuardsStage.AFTER_FSA
           && n instanceof DeoptimizeNode) {
         assert b.getLoopDepth() == 0 : n;
       }
     }
   }
   return true;
 }
コード例 #20
0
 public boolean continueInlining(StructuredGraph currentGraph) {
   if (currentGraph.getNodeCount() >= MaximumDesiredSize.getValue()) {
     InliningUtil.logInliningDecision("inlining is cut off by MaximumDesiredSize");
     metricInliningStoppedByMaxDesiredSize.increment();
     return false;
   }
   return true;
 }
コード例 #21
0
  /**
   * Creates a graph for this stub.
   *
   * <p>If the stub returns an object, the graph created corresponds to this pseudo code:
   *
   * <pre>
   *     Object foreignFunctionStub(args...) {
   *         foreignFunction(currentThread,  args);
   *         if (clearPendingException(thread())) {
   *             getAndClearObjectResult(thread());
   *             DeoptimizeCallerNode.deopt(InvalidateReprofile, RuntimeConstraint);
   *         }
   *         return verifyObject(getAndClearObjectResult(thread()));
   *     }
   * </pre>
   *
   * If the stub returns a primitive or word, the graph created corresponds to this pseudo code
   * (using {@code int} as the primitive return type):
   *
   * <pre>
   *     int foreignFunctionStub(args...) {
   *         int result = foreignFunction(currentThread,  args);
   *         if (clearPendingException(thread())) {
   *             DeoptimizeCallerNode.deopt(InvalidateReprofile, RuntimeConstraint);
   *         }
   *         return result;
   *     }
   * </pre>
   *
   * If the stub is void, the graph created corresponds to this pseudo code:
   *
   * <pre>
   *     void foreignFunctionStub(args...) {
   *         foreignFunction(currentThread,  args);
   *         if (clearPendingException(thread())) {
   *             DeoptimizeCallerNode.deopt(InvalidateReprofile, RuntimeConstraint);
   *         }
   *     }
   * </pre>
   *
   * In each example above, the {@code currentThread} argument is the C++ JavaThread value (i.e.,
   * %r15 on AMD64) and is only prepended if {@link #prependThread} is true.
   */
  @Override
  protected StructuredGraph getGraph() {
    WordTypes wordTypes = providers.getWordTypes();
    Class<?>[] args = linkage.getDescriptor().getArgumentTypes();
    boolean isObjectResult =
        !linkage.getOutgoingCallingConvention().getReturn().getLIRKind().isValue();

    StructuredGraph graph = new StructuredGraph(toString(), null, AllowAssumptions.NO);
    graph.disableUnsafeAccessTracking();

    GraphKit kit = new GraphKit(graph, providers, wordTypes, providers.getGraphBuilderPlugins());
    ParameterNode[] params = createParameters(kit, args);

    ReadRegisterNode thread =
        kit.append(
            new ReadRegisterNode(
                providers.getRegisters().getThreadRegister(),
                wordTypes.getWordKind(),
                true,
                false));
    ValueNode result = createTargetCall(kit, params, thread);
    kit.createInvoke(
        StubUtil.class,
        "handlePendingException",
        thread,
        ConstantNode.forBoolean(isObjectResult, graph));
    if (isObjectResult) {
      InvokeNode object =
          kit.createInvoke(HotSpotReplacementsUtil.class, "getAndClearObjectResult", thread);
      result = kit.createInvoke(StubUtil.class, "verifyObject", object);
    }
    kit.append(
        new ReturnNode(linkage.getDescriptor().getResultType() == void.class ? null : result));

    if (Debug.isDumpEnabled()) {
      Debug.dump(graph, "Initial stub graph");
    }

    kit.inlineInvokes();

    if (Debug.isDumpEnabled()) {
      Debug.dump(graph, "Stub graph before compilation");
    }

    return graph;
  }
コード例 #22
0
ファイル: EdgesTest.java プロジェクト: sanzinger/graal-core
  private void testMethod(Method method, Object receiver, Object... args) {
    try {
      // Invoke the method to ensure it has a type profile
      for (int i = 0; i < 5000; i++) {
        method.invoke(receiver, args);
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }

    ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method);
    StructuredGraph g = parseProfiled(javaMethod, AllowAssumptions.NO);
    HighTierContext context = getDefaultHighTierContext();
    new InliningPhase(new InlineMethodSubstitutionsPolicy(), new CanonicalizerPhase())
        .apply(g, context);
    new CanonicalizerPhase().apply(g, context);
    Assert.assertTrue(g.getNodes().filter(CheckCastNode.class).isEmpty());
  }
コード例 #23
0
 public void lower(ArrayCopyUnrollNode arraycopy, LoweringTool tool) {
   StructuredGraph graph = arraycopy.graph();
   if (!graph.getGuardsStage().areFrameStatesAtDeopts()) {
     // Can't be lowered yet
     return;
   }
   SnippetInfo snippetInfo = arraycopyUnrolledWorkSnippet;
   Arguments args = new Arguments(snippetInfo, graph.getGuardsStage(), tool.getLoweringStage());
   args.add("nonNullSrc", arraycopy.getSource());
   args.add("srcPos", arraycopy.getSourcePosition());
   args.add("nonNullDest", arraycopy.getDestination());
   args.add("destPos", arraycopy.getDestinationPosition());
   args.addConst("length", arraycopy.getUnrollLength());
   args.addConst("elementKind", arraycopy.getElementKind());
   template(args)
       .instantiate(
           providers.getMetaAccess(), arraycopy, SnippetTemplate.DEFAULT_REPLACER, args);
 }
コード例 #24
0
  private void assertReadWithinAllReturnBlocks(ScheduleResult schedule, boolean withinReturnBlock) {
    StructuredGraph graph = schedule.getCFG().graph;
    assertTrue(graph.getNodes(ReturnNode.TYPE).isNotEmpty());

    int withRead = 0;
    int returnBlocks = 0;
    for (ReturnNode returnNode : graph.getNodes(ReturnNode.TYPE)) {
      Block block = schedule.getCFG().getNodeToBlock().get(returnNode);
      for (Node node : schedule.getBlockToNodesMap().get(block)) {
        if (node instanceof FloatingReadNode) {
          withRead++;
          break;
        }
      }
      returnBlocks++;
    }
    assertDeepEquals(withRead == returnBlocks, withinReturnBlock);
  }
コード例 #25
0
  @Override
  public void notifyCompilationGraalTierFinished(
      OptimizedCallTarget target, StructuredGraph graph) {
    compilationLocal.get().graalTierFinished = System.nanoTime();
    graalTierNodeCount.accept(graph.getNodeCount());

    if (TruffleCompilerOptions.TruffleCompilationStatisticDetails.getValue()) {
      graalTierNodeStatistics.accept(nodeClassStream(graph));
    }
  }
コード例 #26
0
  @Override
  protected void run(final StructuredGraph graph, PhaseContext context) {
    assert graph.hasValueProxies() : "ConvertDeoptimizeToGuardPhase always creates proxies";
    if (graph.getNodes(DeoptimizeNode.TYPE).isEmpty()) {
      return;
    }
    for (DeoptimizeNode d : graph.getNodes(DeoptimizeNode.TYPE)) {
      assert d.isAlive();
      visitDeoptBegin(
          AbstractBeginNode.prevBegin(d), d.action(), d.reason(), d.getSpeculation(), graph);
    }

    if (context != null) {
      for (FixedGuardNode fixedGuard : graph.getNodes(FixedGuardNode.TYPE)) {
        trySplitFixedGuard(fixedGuard, context);
      }
    }

    new DeadCodeEliminationPhase(Optional).apply(graph);
  }
コード例 #27
0
 @Override
 protected boolean checkLowTierGraph(StructuredGraph graph) {
   for (ConstantNode constantNode : graph.getNodes().filter(ConstantNode.class)) {
     assert constantNode.asJavaConstant() == null
             || constantNode.asJavaConstant().getJavaKind() != JavaKind.Object
             || constantNode.asJavaConstant().isDefaultForKind()
         : "Found unexpected object constant "
             + constantNode
             + ", this should have been removed by the LoadJavaMirrorWithKlassPhase.";
   }
   return true;
 }
コード例 #28
0
ファイル: EdgesTest.java プロジェクト: sanzinger/graal-core
 public EdgesTest() {
   node = new TestNode();
   i1 = ConstantNode.forInt(1, graph);
   i2 = ConstantNode.forDouble(1.0d, graph);
   i3 = ConstantNode.forInt(4, graph);
   i4 = ConstantNode.forInt(14, graph);
   node.itail = new NodeInputList<>(node, new ValueNode[] {i3, i4});
   node.i1 = i1;
   node.i2 = i2;
   graph.add(node);
   inputs = node.getNodeClass().getInputEdges();
 }
コード例 #29
0
  @Override
  public void run(StructuredGraph graph) {
    if (optional && Options.ReduceDCE.getValue()) {
      return;
    }

    NodeFlood flood = graph.createNodeFlood();
    int totalNodeCount = graph.getNodeCount();
    flood.add(graph.start());
    iterateSuccessorsAndInputs(flood);
    int totalMarkedCount = flood.getTotalMarkedCount();
    if (totalNodeCount == totalMarkedCount) {
      // All nodes are live => nothing more to do.
      return;
    } else {
      // Some nodes are not marked alive and therefore dead => proceed.
      assert totalNodeCount > totalMarkedCount;
    }

    deleteNodes(flood, graph);
  }
コード例 #30
0
 @Override
 protected boolean checkMidTierGraph(StructuredGraph graph) {
   int count = 0;
   for (IsNullNode isNull : graph.getNodes().filter(IsNullNode.class).snapshot()) {
     ValueNode value = isNull.getValue();
     if (value instanceof CompressionNode) {
       count++;
       isNull.replaceFirstInput(value, ((CompressionNode) value).getValue());
     }
   }
   Assert.assertEquals("graph should contain exactly one IsNullNode", 1, count);
   return super.checkMidTierGraph(graph);
 }