# HG changeset patch # User Doug Simon # Date 1386962411 -3600 # Node ID 5d47d69d523a2b17d0d2d3cc4f0fb86ae7eace85 # Parent 5e94b8c9e9d0ce03af013437c1f17f028c946f73# Parent 63724649e19ee936112e85557152e549c4222edc Merge. diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java Fri Dec 13 20:16:44 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java Fri Dec 13 20:20:11 2013 +0100 @@ -110,6 +110,10 @@ return isEnabled(logFilter); } + public boolean isLogEnabledForMethod() { + return isEnabledForMethod(logFilter); + } + public boolean isMeterEnabled() { return isEnabled(meterFilter); } @@ -118,6 +122,10 @@ return isEnabled(dumpFilter); } + public boolean isDumpEnabledForMethod() { + return isEnabledForMethod(dumpFilter); + } + public boolean isTimeEnabled() { return isEnabled(timerFilter); } @@ -130,6 +138,10 @@ return checkDebugFilter(Debug.currentScope(), filter) && checkMethodFilter(); } + private boolean isEnabledForMethod(DebugFilter filter) { + return filter != null && checkMethodFilter(); + } + private static boolean checkDebugFilter(String currentScope, DebugFilter filter) { return filter != null && filter.matches(currentScope); } diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Fri Dec 13 20:16:44 2013 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Fri Dec 13 20:20:11 2013 +0100 @@ -69,6 +69,17 @@ return ENABLED; } + public static boolean isDumpEnabledForMethod() { + if (!ENABLED) { + return false; + } + DebugConfig config = DebugScope.getConfig(); + if (config == null) { + return false; + } + return config.isDumpEnabledForMethod(); + } + public static boolean isDumpEnabled() { return ENABLED && DebugScope.getInstance().isDumpEnabled(); } @@ -81,6 +92,17 @@ return ENABLED && DebugScope.getInstance().isTimeEnabled(); } + public static boolean isLogEnabledForMethod() { + if (!ENABLED) { + return false; + } + DebugConfig config = DebugScope.getConfig(); + if (config == null) { + return false; + } + return config.isLogEnabledForMethod(); + } + public static boolean isLogEnabled() { return ENABLED && DebugScope.getInstance().isLogEnabled(); } @@ -431,6 +453,10 @@ return isLogEnabled; } + public boolean isLogEnabledForMethod() { + return isLogEnabled; + } + @Override public boolean isMeterEnabled() { return isMeterEnabled; @@ -441,6 +467,10 @@ return isDumpEnabled; } + public boolean isDumpEnabledForMethod() { + return isDumpEnabled; + } + @Override public boolean isTimeEnabled() { return isTimerEnabled; diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugConfig.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugConfig.java Fri Dec 13 20:16:44 2013 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugConfig.java Fri Dec 13 20:20:11 2013 +0100 @@ -36,6 +36,12 @@ boolean isLogEnabled(); /** + * Determines if logging can be enabled in the current method, regardless of the + * {@linkplain Debug#currentScope() current debug scope}. + */ + boolean isLogEnabledForMethod(); + + /** * Determines if metering is enabled in the {@linkplain Debug#currentScope() current debug * scope}. * @@ -52,6 +58,12 @@ boolean isDumpEnabled(); /** + * Determines if dumping can be enabled in the current method, regardless of the + * {@linkplain Debug#currentScope() current debug scope}. + */ + boolean isDumpEnabledForMethod(); + + /** * Adds an object the context used by this configuration to do filtering. */ void addToContext(Object o); diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DelegatingDebugConfig.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DelegatingDebugConfig.java Fri Dec 13 20:16:44 2013 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DelegatingDebugConfig.java Fri Dec 13 20:20:11 2013 +0100 @@ -38,6 +38,10 @@ return delegate.isLogEnabled(); } + public boolean isLogEnabledForMethod() { + return delegate.isLogEnabledForMethod(); + } + @Override public boolean isMeterEnabled() { return delegate.isMeterEnabled(); @@ -48,6 +52,10 @@ return delegate.isDumpEnabled(); } + public boolean isDumpEnabledForMethod() { + return delegate.isDumpEnabledForMethod(); + } + @Override public boolean isTimeEnabled() { return delegate.isTimeEnabled(); diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Fri Dec 13 20:16:44 2013 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Fri Dec 13 20:20:11 2013 +0100 @@ -565,7 +565,7 @@ * ordering between the nodes within the list. */ public boolean maybeCompress() { - if (Debug.isEnabled()) { + if (Debug.isDumpEnabledForMethod() || Debug.isLogEnabledForMethod()) { return false; } int liveNodeCount = getNodeCount(); diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java Fri Dec 13 20:16:44 2013 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java Fri Dec 13 20:20:11 2013 +0100 @@ -27,6 +27,7 @@ import java.util.*; import java.util.Map.Entry; +import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.StructuredGraph.GuardsStage; @@ -34,7 +35,6 @@ import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.util.*; -import com.oracle.graal.options.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.graph.*; import com.oracle.graal.phases.schedule.*; @@ -54,13 +54,6 @@ * does the actual control-flow expansion of the remaining {@link GuardNode GuardNodes}. */ public class GuardLoweringPhase extends BasePhase { - static class Options { - //@formatter:off - @Option(help = "") - public static final OptionValue UseGuardIdAsSpeculationId = new OptionValue<>(false); - //@formatter:on - } - private static class UseImplicitNullChecks extends ScheduledNodeIterator { private final IdentityHashMap nullGuarded = new IdentityHashMap<>(); @@ -134,9 +127,9 @@ private final Block block; private boolean useGuardIdAsSpeculationId; - public LowerGuards(Block block) { + public LowerGuards(Block block, boolean useGuardIdAsSpeculationId) { this.block = block; - this.useGuardIdAsSpeculationId = Options.UseGuardIdAsSpeculationId.getValue(); + this.useGuardIdAsSpeculationId = useGuardIdAsSpeculationId; } @Override @@ -203,6 +196,6 @@ if (OptImplicitNullChecks.getValue() && implicitNullCheckLimit > 0) { new UseImplicitNullChecks(implicitNullCheckLimit).processNodes(block, schedule); } - new LowerGuards(block).processNodes(block, schedule); + new LowerGuards(block, Debug.isDumpEnabledForMethod() || Debug.isLogEnabledForMethod()).processNodes(block, schedule); } } diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Fri Dec 13 20:16:44 2013 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Fri Dec 13 20:20:11 2013 +0100 @@ -324,7 +324,7 @@ assert (unscheduledUsages = getUnscheduledUsages(node)) != null; Mark preLoweringMark = node.graph().getMark(); ((Lowerable) node).lower(loweringTool); - if (node == startAnchor && node.isDeleted()) { + if (loweringTool.guardAnchor.asNode().isDeleted()) { loweringTool.guardAnchor = BeginNode.prevBegin(nextNode); } assert checkPostNodeLowering(node, loweringTool, preLoweringMark, unscheduledUsages); diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/AlwaysValidAssumptionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/AlwaysValidAssumptionTest.java Fri Dec 13 20:20:11 2013 +0100 @@ -0,0 +1,51 @@ +/* + * 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.truffle.api.test.utilities; + +import static org.junit.Assert.*; +import org.junit.*; + +import com.oracle.truffle.api.nodes.*; +import com.oracle.truffle.api.utilities.*; + +public class AlwaysValidAssumptionTest { + + @Test + public void testCheck() throws InvalidAssumptionException { + final AlwaysValidAssumption assumption = new AlwaysValidAssumption(); + assumption.check(); + } + + @Test + public void testIsValid() { + final AlwaysValidAssumption assumption = new AlwaysValidAssumption(); + assertTrue(assumption.isValid()); + } + + @Test(expected = UnsupportedOperationException.class) + public void testCannotInvalidate() { + final AlwaysValidAssumption assumption = new AlwaysValidAssumption(); + assumption.invalidate(); + } + +} diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/AssumedValueTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/AssumedValueTest.java Fri Dec 13 20:20:11 2013 +0100 @@ -0,0 +1,46 @@ +/* + * 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.truffle.api.test.utilities; + +import static org.junit.Assert.*; +import org.junit.*; + +import com.oracle.truffle.api.utilities.*; + +public class AssumedValueTest { + + @Test + public void testGet() { + final AssumedValue assumedValue = new AssumedValue<>("assumed-value", "1"); + assertEquals("1", assumedValue.get()); + } + + @Test + public void testSet() { + final AssumedValue assumedValue = new AssumedValue<>("assumed-value", "1"); + assertEquals("1", assumedValue.get()); + assumedValue.set("2"); + assertEquals("2", assumedValue.get()); + } + +} diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/CyclicAssumptionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/CyclicAssumptionTest.java Fri Dec 13 20:20:11 2013 +0100 @@ -0,0 +1,62 @@ +/* + * 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.truffle.api.test.utilities; + +import static org.junit.Assert.*; + +import org.junit.*; + +import com.oracle.truffle.api.*; +import com.oracle.truffle.api.utilities.*; + +public class CyclicAssumptionTest { + + @Test + public void testIsValid() { + final CyclicAssumption assumption = new CyclicAssumption("cyclic-assumption"); + assertTrue(assumption.getAssumption().isValid()); + } + + @Test + public void testInvalidate() { + final CyclicAssumption cyclicAssumption = new CyclicAssumption("cyclic-assumption"); + + final Assumption firstAssumption = cyclicAssumption.getAssumption(); + assertEquals("cyclic-assumption", firstAssumption.getName()); + assertTrue(firstAssumption.isValid()); + + cyclicAssumption.invalidate(); + + assertFalse(firstAssumption.isValid()); + + final Assumption secondAssumption = cyclicAssumption.getAssumption(); + assertEquals("cyclic-assumption", secondAssumption.getName()); + assertTrue(secondAssumption.isValid()); + + cyclicAssumption.invalidate(); + + assertFalse(firstAssumption.isValid()); + assertFalse(secondAssumption.isValid()); + } + +} diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/UnionAssumptionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/UnionAssumptionTest.java Fri Dec 13 20:20:11 2013 +0100 @@ -0,0 +1,119 @@ +/* + * 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.truffle.api.test.utilities; + +import static org.junit.Assert.*; + +import org.junit.*; + +import com.oracle.truffle.api.*; +import com.oracle.truffle.api.nodes.*; +import com.oracle.truffle.api.utilities.*; + +public class UnionAssumptionTest { + + @Test + public void testIsValid() { + final Assumption first = Truffle.getRuntime().createAssumption("first"); + final Assumption second = Truffle.getRuntime().createAssumption("second"); + final UnionAssumption union = new UnionAssumption(first, second); + assertTrue(union.isValid()); + } + + @Test + public void testCheck() throws InvalidAssumptionException { + final Assumption first = Truffle.getRuntime().createAssumption("first"); + final Assumption second = Truffle.getRuntime().createAssumption("second"); + final UnionAssumption union = new UnionAssumption(first, second); + union.check(); + } + + @Test + public void testFirstInvalidateIsValid() { + final Assumption first = Truffle.getRuntime().createAssumption("first"); + final Assumption second = Truffle.getRuntime().createAssumption("second"); + final UnionAssumption union = new UnionAssumption(first, second); + + first.invalidate(); + + assertFalse(union.isValid()); + } + + @Test(expected = InvalidAssumptionException.class) + public void testFirstInvalidateCheck() throws InvalidAssumptionException { + final Assumption first = Truffle.getRuntime().createAssumption("first"); + final Assumption second = Truffle.getRuntime().createAssumption("second"); + final UnionAssumption union = new UnionAssumption(first, second); + + first.invalidate(); + + union.check(); + } + + @Test + public void testSecondInvalidateIsValid() { + final Assumption first = Truffle.getRuntime().createAssumption("first"); + final Assumption second = Truffle.getRuntime().createAssumption("second"); + final UnionAssumption union = new UnionAssumption(first, second); + + second.invalidate(); + + assertFalse(union.isValid()); + } + + @Test(expected = InvalidAssumptionException.class) + public void testSecondInvalidateCheck() throws InvalidAssumptionException { + final Assumption first = Truffle.getRuntime().createAssumption("first"); + final Assumption second = Truffle.getRuntime().createAssumption("second"); + final UnionAssumption union = new UnionAssumption(first, second); + + second.invalidate(); + + union.check(); + } + + @Test + public void testBothInvalidateIsValid() { + final Assumption first = Truffle.getRuntime().createAssumption("first"); + final Assumption second = Truffle.getRuntime().createAssumption("second"); + final UnionAssumption union = new UnionAssumption(first, second); + + first.invalidate(); + second.invalidate(); + + assertFalse(union.isValid()); + } + + @Test(expected = InvalidAssumptionException.class) + public void testBothInvalidateCheck() throws InvalidAssumptionException { + final Assumption first = Truffle.getRuntime().createAssumption("first"); + final Assumption second = Truffle.getRuntime().createAssumption("second"); + final UnionAssumption union = new UnionAssumption(first, second); + + first.invalidate(); + second.invalidate(); + + union.check(); + } + +} diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/AlwaysValidAssumption.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/AlwaysValidAssumption.java Fri Dec 13 20:20:11 2013 +0100 @@ -0,0 +1,57 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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.truffle.api.utilities; + +import com.oracle.truffle.api.*; +import com.oracle.truffle.api.nodes.*; + +/** + * An assumption that is always valid. Used as a placeholder where an assumption is needed but never + * invalidated. + */ +public class AlwaysValidAssumption implements Assumption { + + public static final AlwaysValidAssumption INSTANCE = new AlwaysValidAssumption(); + + @Override + public void check() throws InvalidAssumptionException { + } + + @Override + public void invalidate() { + throw new UnsupportedOperationException("Cannot invalidation this assumption - it is always valid"); + } + + @Override + public String getName() { + return getClass().getName(); + } + + @Override + public boolean isValid() { + return true; + } + +} diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/AssumedValue.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/AssumedValue.java Fri Dec 13 20:20:11 2013 +0100 @@ -0,0 +1,68 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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.truffle.api.utilities; + +import com.oracle.truffle.api.*; +import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; +import com.oracle.truffle.api.nodes.*; + +/** + * A {@link CompilationFinal} value combined with an {@link Assumption} to notify when it changes. + * Note that you should be careful that modifications to this value do not cause deoptimization + * loops. This could be by using a value that is monotonic. + */ +public class AssumedValue { + + @CompilationFinal private T value; + private final CyclicAssumption assumption; + + public AssumedValue(String name, T initialValue) { + assumption = new CyclicAssumption(name); + value = initialValue; + } + + /** + * Get the current value, updating it if it has been {@link #set}. The compiler may be able to + * make this method return a constant value, but still accommodate mutation. + */ + public T get() { + try { + assumption.getAssumption().check(); + } catch (InvalidAssumptionException e) { + // No need to rewrite anything - just pick up the new value + } + + return value; + } + + /** + * Set a new value, which will be picked up the next time {@link #get} is called. + */ + public void set(T newValue) { + value = newValue; + assumption.invalidate(); + } + +} diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/CyclicAssumption.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/CyclicAssumption.java Fri Dec 13 20:20:11 2013 +0100 @@ -0,0 +1,58 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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.truffle.api.utilities; + +import com.oracle.truffle.api.*; + +/** + * Holds an {@link Assumption}, and knows how to recreate it with the same properties on + * invalidation. Used so that mutability is isolated in this class, and all other classes that need + * an assumption that may be recreated can have a final reference to an object of this class. Note + * that you should be careful that repeated invalidations do not cause a deoptimization loop in that + * same way that you would with any other assumption. + */ +public class CyclicAssumption { + + private final String name; + private Assumption assumption; + + public CyclicAssumption(String name) { + this.name = name; + invalidate(); + } + + public void invalidate() { + if (assumption != null) { + assumption.invalidate(); + } + + assumption = Truffle.getRuntime().createAssumption(name); + } + + public Assumption getAssumption() { + return assumption; + } + +} diff -r 5e94b8c9e9d0 -r 5d47d69d523a graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/UnionAssumption.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/UnionAssumption.java Fri Dec 13 20:20:11 2013 +0100 @@ -0,0 +1,72 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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.truffle.api.utilities; + +import com.oracle.truffle.api.*; +import com.oracle.truffle.api.nodes.*; + +/** + * An assumption that combines two other assumptions. A check on this assumption checks both of the + * child assumptions. + */ +public class UnionAssumption implements Assumption { + + private final String name; + private final Assumption first; + private final Assumption second; + + public UnionAssumption(String name, Assumption first, Assumption second) { + this.name = name; + this.first = first; + this.second = second; + } + + public UnionAssumption(Assumption first, Assumption second) { + this(null, first, second); + } + + @Override + public void check() throws InvalidAssumptionException { + first.check(); + second.check(); + } + + @Override + public void invalidate() { + first.invalidate(); + second.invalidate(); + } + + @Override + public String getName() { + return name; + } + + @Override + public boolean isValid() { + return first.isValid() && second.isValid(); + } + +} diff -r 5e94b8c9e9d0 -r 5d47d69d523a mx/mx_graal.py --- a/mx/mx_graal.py Fri Dec 13 20:16:44 2013 +0100 +++ b/mx/mx_graal.py Fri Dec 13 20:20:11 2013 +0100 @@ -808,7 +808,7 @@ f_testfile.close() harness(projectscp, vmArgs) -def _unittest(args, annotations): +def _unittest(args, annotations, prefixcp=""): mxdir = dirname(__file__) name = 'JUnitWrapper' javaSource = join(mxdir, name + '.java') @@ -830,9 +830,9 @@ if len(testclasses) == 1: # Execute Junit directly when one test is being run. This simplifies # replaying the VM execution in a native debugger (e.g., gdb). - vm(prefixArgs + vmArgs + ['-cp', projectscp, 'org.junit.runner.JUnitCore'] + testclasses) + vm(prefixArgs + vmArgs + ['-cp', prefixcp + projectscp, 'org.junit.runner.JUnitCore'] + testclasses) else: - vm(prefixArgs + vmArgs + ['-cp', projectscp + os.pathsep + mxdir, name] + [testfile]) + vm(prefixArgs + vmArgs + ['-cp', prefixcp + projectscp + os.pathsep + mxdir, name] + [testfile]) try: _run_tests(args, harness, annotations, testfile) @@ -1348,9 +1348,17 @@ def trufflejar(args=None): """make truffle.jar""" + + # Test with the built classes + _unittest(["com.oracle.truffle.api.test", "com.oracle.truffle.api.dsl.test"], ['@Test', '@LongTest', '@Parameters']) + # We use the DSL processor as the starting point for the classpath - this # therefore includes the DSL processor, the DSL and the API. - packagejar(mx.classpath("com.oracle.truffle.dsl.processor").split(os.pathsep), "truffle.jar", None) + packagejar(mx.classpath("com.oracle.truffle.dsl.processor").split(os.pathsep), "truffle.jar", None, "com.oracle.truffle.dsl.processor.TruffleProcessor") + + # Test with the JAR + _unittest(["com.oracle.truffle.api.test", "com.oracle.truffle.api.dsl.test"], ['@Test', '@LongTest', '@Parameters'], "truffle.jar:") + def isGraalEnabled(vm): return vm != 'original' and not vm.endswith('nograal') @@ -1444,7 +1452,7 @@ mx.distribution('GRAAL').add_update_listener(_installGraalJarInJdks) -def packagejar(classpath, outputFile, mainClass): +def packagejar(classpath, outputFile, mainClass, annotationProcessor=None): prefix = '' if mx.get_os() != 'windows' else '\\??\\' # long file name hack print "creating", outputFile filecount, totalsize = 0, 0 @@ -1453,6 +1461,8 @@ if mainClass != None: manifest += "Main-Class: %s\n\n" % (mainClass) zf.writestr("META-INF/MANIFEST.MF", manifest) + if annotationProcessor != None: + zf.writestr("META-INF/services/javax.annotation.processing.Processor", annotationProcessor) for cp in classpath: print "+", cp if cp.endswith(".jar"): diff -r 5e94b8c9e9d0 -r 5d47d69d523a src/share/vm/runtime/vframe.cpp --- a/src/share/vm/runtime/vframe.cpp Fri Dec 13 20:16:44 2013 +0100 +++ b/src/share/vm/runtime/vframe.cpp Fri Dec 13 20:20:11 2013 +0100 @@ -266,7 +266,7 @@ // Get oopmap describing oops and int for current bci InterpreterOopMap oop_mask; - if (TraceDeoptimization && Verbose) { + if ((TraceDeoptimization && Verbose) GRAAL_ONLY( || PrintDeoptimizationDetails)) { methodHandle m_h(thread(), method()); OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask); } else { @@ -333,7 +333,7 @@ InterpreterOopMap oop_mask; // Get oopmap describing oops and int for current bci - if (TraceDeoptimization && Verbose) { + if ((TraceDeoptimization && Verbose) GRAAL_ONLY( || PrintDeoptimizationDetails)) { methodHandle m_h(method()); OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask); } else {