# HG changeset patch # User Christian Humer # Date 1414427865 -3600 # Node ID 35639ec046d7eea7e438d905d79a36f2071e14ba # Parent 7f63e7683ee7ba5e888b0cc3b0b25539cd73cd8c Truffle: extract methods from OptimizedCallUtils and remove it. diff -r 7f63e7683ee7 -r 35639ec046d7 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/DefaultTruffleSplittingStrategy.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/DefaultTruffleSplittingStrategy.java Mon Oct 27 17:34:08 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/DefaultTruffleSplittingStrategy.java Mon Oct 27 17:37:45 2014 +0100 @@ -62,7 +62,7 @@ return false; } OptimizedCallTarget splitTarget = call.getCallTarget(); - int nodeCount = OptimizedCallUtils.countNonTrivialNodes(splitTarget, false); + int nodeCount = splitTarget.countNonTrivialNodes(false); if (nodeCount > TruffleCompilerOptions.TruffleSplittingMaxCalleeSize.getValue()) { return false; } diff -r 7f63e7683ee7 -r 35639ec046d7 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/DefaultTruffleSplittingStrategyNew.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/DefaultTruffleSplittingStrategyNew.java Mon Oct 27 17:34:08 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/DefaultTruffleSplittingStrategyNew.java Mon Oct 27 17:37:45 2014 +0100 @@ -57,7 +57,7 @@ if (TruffleCompilerOptions.TruffleSplittingAggressive.getValue()) { return true; } - int size = OptimizedCallUtils.countNonTrivialNodes(call.getCallTarget(), false); + int size = call.getCallTarget().countNonTrivialNodes(false); if (size > TruffleCompilerOptions.TruffleSplittingMaxCalleeSize.getValue()) { return false; } diff -r 7f63e7683ee7 -r 35639ec046d7 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Mon Oct 27 17:34:08 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Mon Oct 27 17:37:45 2014 +0100 @@ -449,6 +449,10 @@ return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), false); } + public int countNonTrivialNodes(final boolean inlined) { + return (int) nodeStream(inlined).filter(e -> e != null && !e.getCost().isTrivial()).count(); + } + public Map getDebugProperties() { Map properties = new LinkedHashMap<>(); AbstractDebugCompilationListener.addASTSizeProperty(this, properties); diff -r 7f63e7683ee7 -r 35639ec046d7 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java Mon Oct 27 17:34:08 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java Mon Oct 27 17:37:45 2014 +0100 @@ -49,7 +49,7 @@ } public static void addASTSizeProperty(OptimizedCallTarget target, Map properties) { - int nodeCount = OptimizedCallUtils.countNonTrivialNodes(target, false); + int nodeCount = target.countNonTrivialNodes(false); int deepNodeCount = nodeCount; TruffleInlining inlining = target.getInlining(); if (inlining != null) { diff -r 7f63e7683ee7 -r 35639ec046d7 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallUtils.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallUtils.java Mon Oct 27 17:34:08 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.truffle; - -import java.io.*; -import java.util.*; - -import com.oracle.graal.truffle.TruffleInlining.CallTreeNodeVisitor; -import com.oracle.truffle.api.nodes.*; -import com.oracle.truffle.api.nodes.NodeUtil.NodeClass; -import com.oracle.truffle.api.nodes.NodeUtil.NodeField; - -public class OptimizedCallUtils { - - public static int countNonTrivialNodes(final OptimizedCallTarget target, final boolean inlined) { - return (int) target.nodeStream(inlined).filter(e -> e != null && !e.getCost().isTrivial()).count(); - } - -} diff -r 7f63e7683ee7 -r 35639ec046d7 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInlining.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInlining.java Mon Oct 27 17:34:08 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInlining.java Mon Oct 27 17:37:45 2014 +0100 @@ -42,7 +42,7 @@ } private static List createDecisions(OptimizedCallTarget sourceTarget, TruffleInliningPolicy policy) { - int nodeCount = OptimizedCallUtils.countNonTrivialNodes(sourceTarget, false); + int nodeCount = sourceTarget.countNonTrivialNodes(false); List exploredCallSites = exploreCallSites(new ArrayList<>(Arrays.asList(sourceTarget)), nodeCount, policy); return decideInlining(exploredCallSites, policy, nodeCount); } @@ -65,7 +65,7 @@ List childCallSites = Collections.emptyList(); double frequency = calculateFrequency(parentTarget, callNode); - int nodeCount = OptimizedCallUtils.countNonTrivialNodes(callNode.getCurrentCallTarget(), false); + int nodeCount = callNode.getCurrentCallTarget().countNonTrivialNodes(false); boolean recursive = isRecursiveStack(callStack); int deepNodeCount = nodeCount; diff -r 7f63e7683ee7 -r 35639ec046d7 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/debug/AbstractDebugCompilationListener.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/debug/AbstractDebugCompilationListener.java Mon Oct 27 17:34:08 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/debug/AbstractDebugCompilationListener.java Mon Oct 27 17:37:45 2014 +0100 @@ -70,7 +70,7 @@ } public static void addASTSizeProperty(OptimizedCallTarget target, Map properties) { - int nodeCount = OptimizedCallUtils.countNonTrivialNodes(target, false); + int nodeCount = target.countNonTrivialNodes(false); int deepNodeCount = nodeCount; TruffleInlining inlining = target.getInlining(); if (inlining != null) {