# HG changeset patch # User Thomas Wuerthinger # Date 1381885879 -7200 # Node ID 97fe8342a90f211eae328d9817973f331be9eb25 # Parent 4811a78ced14515e6da818821500363c0f7bf185 Remove files of Truffle printer. diff -r 4811a78ced14 -r 97fe8342a90f graal/com.oracle.graal.truffle.printer/src/com/oracle/graal/truffle/printer/InlinePrinterProcessor.java --- a/graal/com.oracle.graal.truffle.printer/src/com/oracle/graal/truffle/printer/InlinePrinterProcessor.java Wed Oct 16 03:03:34 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2013, 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.printer; - -import java.util.*; - -import com.oracle.graal.debug.*; -import com.oracle.graal.truffle.printer.method.*; - -public final class InlinePrinterProcessor { - - private static final String IDENT = " "; - private static InlinePrinterProcessor instance; - - private final List inlineTree = new ArrayList<>(); - - public static void initialize() { - if (instance == null) { - instance = new InlinePrinterProcessor(); - } else { - throw new IllegalStateException(); - } - } - - public static void addInlining(MethodHolder methodHolder) { - instance.addExecuteInline(methodHolder); - } - - public static void printTree() { - instance.print(); - } - - public static void reset() { - instance = null; - } - - private void addExecuteInline(MethodHolder executeMethod) { - if (inlineTree.isEmpty()) { - inlineTree.add(new TruffleMethodNode(null, executeMethod)); - } else { - TruffleMethodNode newNode = null; - for (TruffleMethodNode node : inlineTree) { - newNode = node.addTruffleExecuteMethodNode(executeMethod); - if (newNode != null) { - break; - } - } - if (newNode == null) { - throw new AssertionError("Not able to add " + executeMethod.getMethod().toString() + " to the inlineing tree"); - } - inlineTree.add(newNode); - } - } - - private TruffleMethodNode getInlineTree() { - TruffleMethodNode root = inlineTree.get(0); - while (root.getParent() != null) { - root = root.getParent(); - } - - // asserting: - for (TruffleMethodNode node : inlineTree) { - TruffleMethodNode nodeRoot = node; - while (nodeRoot.getParent() != null) { - nodeRoot = nodeRoot.getParent(); - } - if (root != nodeRoot) { - throw new AssertionError("Different roots found"); - } - } - - return root; - } - - private void print() { - String curIndent = ""; - TruffleMethodNode root = getInlineTree(); - String name = root.getJavaMethod().getDeclaringClass().getName(); - TTY.print(name.substring(name.lastIndexOf('/') + 1, name.lastIndexOf(';')) + "::" + root.getJavaMethod().getName()); - TTY.println(); - recursivePrint(curIndent, root); - } - - private void recursivePrint(String curIdent, TruffleMethodNode node) { - Map> inlinings = node.getInlinings(); - for (int l : inlinings.keySet()) { - for (TruffleMethodNode n : inlinings.get(l)) { - TTY.print(curIdent); - TTY.print("L" + l + " "); - String name = n.getJavaMethod().getDeclaringClass().getName(); - TTY.print(name.substring(name.lastIndexOf('/') + 1, name.lastIndexOf(';')) + "::" + n.getJavaMethod().getName()); - TTY.println(); - recursivePrint(curIdent + IDENT, n); - } - } - } -} diff -r 4811a78ced14 -r 97fe8342a90f graal/com.oracle.graal.truffle.printer/src/com/oracle/graal/truffle/printer/method/CallStackElement.java --- a/graal/com.oracle.graal.truffle.printer/src/com/oracle/graal/truffle/printer/method/CallStackElement.java Wed Oct 16 03:03:34 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2013, 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.printer.method; - -import com.oracle.graal.api.meta.*; - -public class CallStackElement { - - private final int lineOfInvoke; - private final ResolvedJavaMethod callerMethod; - - public CallStackElement(ResolvedJavaMethod callerMethod, int lineOfInvoke) { - this.lineOfInvoke = lineOfInvoke; - this.callerMethod = callerMethod; - } - - public int getLineOfInvoke() { - return lineOfInvoke; - } - - @Override - public boolean equals(Object o) { - if (o instanceof CallStackElement) { - CallStackElement i = (CallStackElement) o; - if (i.getCallerMethod() == this.getCallerMethod()/* - * && i.lineOfInvoke == - * this.lineOfInvoke - */) { - return true; - } else { - return false; - } - } else { - return false; - } - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - public ResolvedJavaMethod getCallerMethod() { - return callerMethod; - } -} diff -r 4811a78ced14 -r 97fe8342a90f graal/com.oracle.graal.truffle.printer/src/com/oracle/graal/truffle/printer/method/MethodHolder.java --- a/graal/com.oracle.graal.truffle.printer/src/com/oracle/graal/truffle/printer/method/MethodHolder.java Wed Oct 16 03:03:34 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2013, 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.printer.method; - -import java.util.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.java.*; - -public final class MethodHolder { - - private final List callStack; - private final ResolvedJavaMethod method; - - public static MethodHolder getNewTruffleExecuteMethod(MethodCallTargetNode targetNode) { - return new MethodHolder(getCallStack(targetNode), targetNode.targetMethod()); - } - - private MethodHolder(List callStack, ResolvedJavaMethod callee) { - this.callStack = callStack; - this.method = callee; - } - - public List getCallStack() { - return callStack; - } - - public ResolvedJavaMethod getMethod() { - return method; - } - - private static List getCallStack(MethodCallTargetNode targetNode) { - List callStack = new ArrayList<>(); - FrameState state = targetNode.invoke().stateAfter(); - while (state != null) { - ResolvedJavaMethod method = state.method(); - LineNumberTable table = method.getLineNumberTable(); - int lineNr = table.getLineNumber(state.bci - 1); - callStack.add(new CallStackElement(method, lineNr)); - state = state.outerFrameState(); - } - return callStack; - } -} diff -r 4811a78ced14 -r 97fe8342a90f graal/com.oracle.graal.truffle.printer/src/com/oracle/graal/truffle/printer/method/TruffleMethodNode.java --- a/graal/com.oracle.graal.truffle.printer/src/com/oracle/graal/truffle/printer/method/TruffleMethodNode.java Wed Oct 16 03:03:34 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2013, 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.printer.method; - -import java.util.*; - -import com.oracle.graal.api.meta.*; - -public final class TruffleMethodNode { - - private final TruffleMethodNode parent; - private final MethodHolder truffleExecuteMethod; - private final Map> inlinings; - - public TruffleMethodNode(TruffleMethodNode parent, MethodHolder truffleExecuteMethod) { - this.parent = parent; - this.truffleExecuteMethod = truffleExecuteMethod; - this.inlinings = new HashMap<>(); - } - - public TruffleMethodNode getParent() { - return parent; - } - - public ResolvedJavaMethod getJavaMethod() { - return truffleExecuteMethod.getMethod(); - } - - public Map> getInlinings() { - return inlinings; - } - - public void putInlineList(int lineOfInvoke, List list) { - inlinings.put(lineOfInvoke, list); - } - - public List getInliningsAtLine(int line) { - return inlinings.get(line); - } - - public MethodHolder getTruffleExecuteMethod() { - return truffleExecuteMethod; - } - - public TruffleMethodNode addTruffleExecuteMethodNode(MethodHolder newMethod) { - int lineOfInvoke = newMethod.getCallStack().get(0).getLineOfInvoke(); - - if (!callStackMatch(newMethod.getCallStack())) { - return null; - } else { - TruffleMethodNode node = new TruffleMethodNode(this, newMethod); - if (getInliningsAtLine(lineOfInvoke) == null) { - List list = new ArrayList<>(); - list.add(node); - putInlineList(lineOfInvoke, list); - } else { - getInliningsAtLine(lineOfInvoke).add(node); - } - return node; - } - } - - private boolean callStackMatch(List callStack) { - List curCallStack = truffleExecuteMethod.getCallStack(); - if (curCallStack.size() == callStack.size() - 1) { - if (curCallStack.size() >= 1) { - if (curCallStack.get(0).getCallerMethod() != callStack.get(1).getCallerMethod()) { - return false; - } - } - for (int i = 1; i < curCallStack.size(); i++) { - if (!curCallStack.get(i).equals(callStack.get(i + 1))) { - return false; - } - } - } else { - return false; - } - return true; - } - -}