# HG changeset patch # User Gilles Duboscq # Date 1328092610 -3600 # Node ID e952b6c6949b67600f5d4c2a684314e5bf82e450 # Parent 168dd8970b964fb1c65dec0b9b209ba24edc6052# Parent 2302b1514e7e13561493eb0e6e8bc4fa7a4dfdbf Merge diff -r 2302b1514e7e -r e952b6c6949b graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java Tue Jan 31 10:47:55 2012 +0100 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java Wed Feb 01 11:36:50 2012 +0100 @@ -181,7 +181,6 @@ new ReadEliminationPhase().apply(graph); } } - new RemovePlaceholderPhase().apply(graph); new DeadCodeEliminationPhase().apply(graph); plan.runPhases(PhasePosition.MID_LEVEL, graph); diff -r 2302b1514e7e -r e952b6c6949b graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InsertStateAfterPlaceholderPhase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InsertStateAfterPlaceholderPhase.java Wed Feb 01 11:36:50 2012 +0100 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2012, 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.max.graal.compiler.phases; + +import com.oracle.max.graal.nodes.*; + +public class InsertStateAfterPlaceholderPhase extends Phase { + + @Override + protected void run(StructuredGraph graph) { + for (ReturnNode ret : graph.getNodes(ReturnNode.class)) { + PlaceholderNode p = graph.add(new PlaceholderNode()); + p.setStateAfter(graph.add(new FrameState(null, FrameState.AFTER_BCI, 0, 0, false))); + graph.addBeforeFixed(ret, p); + } + } + +} diff -r 2302b1514e7e -r e952b6c6949b graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/RemovePlaceholderPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/RemovePlaceholderPhase.java Tue Jan 31 10:47:55 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011, 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.max.graal.compiler.phases; - -import com.oracle.max.graal.nodes.*; - -public class RemovePlaceholderPhase extends Phase { - @Override - protected void run(StructuredGraph graph) { - for (PlaceholderNode n : graph.getNodes(PlaceholderNode.class)) { - graph.removeFixed(n); - } - } -} diff -r 2302b1514e7e -r e952b6c6949b graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java Tue Jan 31 10:47:55 2012 +0100 +++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java Wed Feb 01 11:36:50 2012 +0100 @@ -49,6 +49,7 @@ private final Compiler compiler; private int compiledMethodCount; + private IntrinsifyArrayCopyPhase intrinsifyArrayCopy; public final HotSpotTypePrimitive typeBoolean; public final HotSpotTypePrimitive typeChar; @@ -110,6 +111,7 @@ // Install intrinsics. HotSpotRuntime runtime = (HotSpotRuntime) compiler.getCompiler().runtime; if (GraalOptions.Intrinsify) { + this.intrinsifyArrayCopy = new IntrinsifyArrayCopyPhase(runtime); GraalIntrinsics.installIntrinsics(runtime, runtime.getCompiler().getTarget(), PhasePlan.DEFAULT); Snippets.install(runtime, runtime.getCompiler().getTarget(), new SystemSnippets(), PhasePlan.DEFAULT); Snippets.install(runtime, runtime.getCompiler().getTarget(), new UnsafeSnippets(), PhasePlan.DEFAULT); @@ -239,7 +241,7 @@ public void run() { try { - PhasePlan plan = new PhasePlan(); + PhasePlan plan = getDefaultPhasePlan(); GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(compiler.getRuntime()); plan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); long startTime = 0; @@ -376,4 +378,10 @@ public CiConstant createCiConstantObject(Object object) { return CiConstant.forObject(object); } + + private PhasePlan getDefaultPhasePlan() { + PhasePlan phasePlan = new PhasePlan(); + phasePlan.addPhase(PhasePosition.HIGH_LEVEL, intrinsifyArrayCopy); + return phasePlan; + } } diff -r 2302b1514e7e -r e952b6c6949b graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java --- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java Tue Jan 31 10:47:55 2012 +0100 +++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java Wed Feb 01 11:36:50 2012 +0100 @@ -75,27 +75,6 @@ @Input private final NodeInputList virtualObjectMappings; - public FrameState outerFrameState() { - return outerFrameState; - } - - public void setOuterFrameState(FrameState x) { - updateUsages(this.outerFrameState, x); - this.outerFrameState = x; - } - - public FrameState outermostFrameState() { - FrameState fs = this; - while (fs.outerFrameState() != null) { - fs = fs.outerFrameState(); - } - return fs; - } - - public void setValueAt(int i, ValueNode x) { - values.set(i, x); - } - /** * The bytecode index to which this frame state applies. This will be {@code -1} * iff this state is mutable. @@ -143,6 +122,27 @@ assert !rethrowException || stackSize == 1 : "must have exception on top of the stack"; } + public FrameState outerFrameState() { + return outerFrameState; + } + + public void setOuterFrameState(FrameState x) { + updateUsages(this.outerFrameState, x); + this.outerFrameState = x; + } + + public FrameState outermostFrameState() { + FrameState fs = this; + while (fs.outerFrameState() != null) { + fs = fs.outerFrameState(); + } + return fs; + } + + public void setValueAt(int i, ValueNode x) { + values.set(i, x); + } + public boolean rethrowException() { return rethrowException; } diff -r 2302b1514e7e -r e952b6c6949b graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/GraalIntrinsics.java --- a/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/GraalIntrinsics.java Tue Jan 31 10:47:55 2012 +0100 +++ b/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/GraalIntrinsics.java Wed Feb 01 11:36:50 2012 +0100 @@ -25,7 +25,6 @@ import com.oracle.max.cri.ci.*; import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.phases.*; -import com.oracle.max.graal.compiler.phases.PhasePlan.PhasePosition; import com.oracle.max.graal.cri.*; /** @@ -39,7 +38,6 @@ Snippets.install(runtime, target, new FloatSnippets(), plan); Snippets.install(runtime, target, new NodeClassSnippets(), plan); Snippets.install(runtime, target, new ArrayCopySnippets(), plan); - plan.addPhase(PhasePosition.HIGH_LEVEL, new IntrinsifyArrayCopyPhase(runtime)); } } } diff -r 2302b1514e7e -r e952b6c6949b graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/IntrinsifyArrayCopyPhase.java --- a/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/IntrinsifyArrayCopyPhase.java Tue Jan 31 10:47:55 2012 +0100 +++ b/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/IntrinsifyArrayCopyPhase.java Wed Feb 01 11:36:50 2012 +0100 @@ -29,6 +29,7 @@ import com.oracle.max.graal.compiler.phases.*; import com.oracle.max.graal.compiler.util.*; import com.oracle.max.graal.cri.*; +import com.oracle.max.graal.debug.*; import com.oracle.max.graal.graph.*; import com.oracle.max.graal.nodes.*; import com.oracle.max.graal.nodes.java.*; @@ -71,6 +72,7 @@ @Override protected void run(StructuredGraph graph) { + boolean hits = false; for (MethodCallTargetNode methodCallTarget : graph.getNodes(MethodCallTargetNode.class)) { RiResolvedMethod targetMethod = methodCallTarget.targetMethod(); RiResolvedMethod snippetMethod = null; @@ -115,10 +117,13 @@ if (snippetMethod != null) { StructuredGraph snippetGraph = (StructuredGraph) snippetMethod.compilerStorage().get(Graph.class); assert snippetGraph != null : "ArrayCopySnippets should be installed"; - //TTY.println(" > Intinsify"); + hits = true; + Debug.log(" > Intinsify (%s)", snippetMethod.signature().argumentTypeAt(0, snippetMethod.holder()).componentType()); InliningUtil.inline(methodCallTarget.invoke(), snippetGraph, false); } } - new CanonicalizerPhase(null, runtime, null).apply(graph); + if (hits) { + new CanonicalizerPhase(null, runtime, null).apply(graph); + } } } diff -r 2302b1514e7e -r e952b6c6949b graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java --- a/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java Tue Jan 31 10:47:55 2012 +0100 +++ b/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java Wed Feb 01 11:36:50 2012 +0100 @@ -121,6 +121,7 @@ for (LoopEndNode end : graph.getNodes(LoopEndNode.class)) { end.setSafepointPolling(false); } + new InsertStateAfterPlaceholderPhase().apply(graph); Debug.dump(graph, "%s: Final", snippetRiMethod.name()); @@ -128,5 +129,4 @@ return graph; } - }