# HG changeset patch # User Thomas Wuerthinger # Date 1427909425 -7200 # Node ID 374b48caeb9ca88a9b793286fee1840aee56086d # Parent a9c8df485789a09f16242c8376825cecda3c470f# Parent b9f65c441427881d066d816e15791dc7926a9b2f Merge. diff -r a9c8df485789 -r 374b48caeb9c graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Wed Apr 01 19:30:14 2015 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Wed Apr 01 19:30:25 2015 +0200 @@ -23,7 +23,6 @@ package com.oracle.graal.compiler; import static com.oracle.graal.compiler.GraalCompiler.Options.*; -import static com.oracle.graal.compiler.MethodFilter.*; import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.*; import java.util.*; @@ -66,71 +65,15 @@ private static final DebugTimer EmitLIR = Debug.timer("EmitLIR"); private static final DebugTimer EmitCode = Debug.timer("EmitCode"); - /** - * The set of positive filters specified by the {@code -G:IntrinsificationsEnabled} option. To - * enable a fast path in {@link #shouldIntrinsify(JavaMethod)}, this field is {@code null} when - * no enabling/disabling filters are specified. - */ - private static final MethodFilter[] positiveIntrinsificationFilter; - - /** - * The set of negative filters specified by the {@code -G:IntrinsificationsDisabled} option. - */ - private static final MethodFilter[] negativeIntrinsificationFilter; - static class Options { // @formatter:off - /** - * @see MethodFilter - */ - @Option(help = "Pattern for method(s) to which intrinsification (if available) will be applied. " + - "By default, all available intrinsifications are applied except for methods matched " + - "by IntrinsificationsDisabled. See MethodFilter class for pattern syntax.", type = OptionType.Debug) - public static final OptionValue IntrinsificationsEnabled = new OptionValue<>(null); - /** - * @see MethodFilter - */ - @Option(help = "Pattern for method(s) to which intrinsification will not be applied. " + - "See MethodFilter class for pattern syntax.", type = OptionType.Debug) - public static final OptionValue IntrinsificationsDisabled = new OptionValue<>(null); - @Option(help = "Repeatedly run the LIR code generation pass to improve statistical profiling results.", type = OptionType.Debug) public static final OptionValue EmitLIRRepeatCount = new OptionValue<>(0); // @formatter:on } - static { - if (IntrinsificationsDisabled.getValue() != null) { - negativeIntrinsificationFilter = parse(IntrinsificationsDisabled.getValue()); - } else { - negativeIntrinsificationFilter = null; - } - - if (Options.IntrinsificationsEnabled.getValue() != null) { - positiveIntrinsificationFilter = parse(IntrinsificationsEnabled.getValue()); - } else if (negativeIntrinsificationFilter != null) { - positiveIntrinsificationFilter = new MethodFilter[0]; - } else { - positiveIntrinsificationFilter = null; - } - } - - /** - * Determines if a given method should be intrinsified based on the values of - * {@link Options#IntrinsificationsEnabled} and {@link Options#IntrinsificationsDisabled}. - */ - public static boolean shouldIntrinsify(JavaMethod method) { - if (positiveIntrinsificationFilter == null) { - return true; - } - if (positiveIntrinsificationFilter.length == 0 || matches(positiveIntrinsificationFilter, method)) { - return negativeIntrinsificationFilter == null || !matches(negativeIntrinsificationFilter, method); - } - return false; - } - /** * Encapsulates all the inputs to a {@linkplain GraalCompiler#compile(Request) compilation}. */ diff -r a9c8df485789 -r 374b48caeb9c graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/GraphBuilderContext.java --- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/GraphBuilderContext.java Wed Apr 01 19:30:14 2015 +0200 +++ b/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/GraphBuilderContext.java Wed Apr 01 19:30:25 2015 +0200 @@ -58,6 +58,12 @@ * intrinsic will restart the interpreter at the intrinsified call. */ boolean isIntrinsic(); + + /** + * Determines if a call within the compilation scope of this replacement represents a call + * to the {@linkplain #getOriginalMethod() original} method. + */ + boolean isCallToOriginal(ResolvedJavaMethod method); } /** diff -r a9c8df485789 -r 374b48caeb9c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java Wed Apr 01 19:30:14 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java Wed Apr 01 19:30:25 2015 +0200 @@ -22,8 +22,6 @@ */ package com.oracle.graal.hotspot.replacements; -import static com.oracle.graal.compiler.GraalCompiler.*; - import java.lang.reflect.*; import com.oracle.graal.api.meta.*; @@ -50,10 +48,6 @@ @Override protected StructuredGraph getLoweredSnippetGraph(LoweringTool tool) { - if (!shouldIntrinsify(getTargetMethod())) { - return null; - } - ResolvedJavaType type = StampTool.typeOrNull(getObject()); if (type != null) { if (type.isArray()) { diff -r a9c8df485789 -r 374b48caeb9c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java Wed Apr 01 19:30:14 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java Wed Apr 01 19:30:25 2015 +0200 @@ -22,16 +22,14 @@ */ package com.oracle.graal.hotspot.replacements; -import static com.oracle.graal.compiler.GraalCompiler.*; - import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.nodeinfo.*; +import com.oracle.graal.nodes.CallTargetNode.InvokeKind; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.CallTargetNode.InvokeKind; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.replacements.nodes.*; @@ -74,10 +72,6 @@ * @return ConstantNode of the caller class, or null */ private ConstantNode getCallerClassNode(MetaAccessProvider metaAccess) { - if (!shouldIntrinsify(getTargetMethod())) { - return null; - } - // Walk back up the frame states to find the caller at the required depth. FrameState state = stateAfter(); diff -r a9c8df485789 -r 374b48caeb9c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopyNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopyNode.java Wed Apr 01 19:30:14 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopyNode.java Wed Apr 01 19:30:25 2015 +0200 @@ -22,8 +22,6 @@ */ package com.oracle.graal.hotspot.replacements.arraycopy; -import static com.oracle.graal.compiler.GraalCompiler.*; - import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.debug.*; @@ -31,8 +29,8 @@ import com.oracle.graal.graph.*; import com.oracle.graal.loop.phases.*; import com.oracle.graal.nodeinfo.*; +import com.oracle.graal.nodes.CallTargetNode.InvokeKind; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.CallTargetNode.InvokeKind; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.common.*; @@ -85,10 +83,6 @@ @Override protected StructuredGraph getLoweredSnippetGraph(final LoweringTool tool) { - if (!shouldIntrinsify(getTargetMethod())) { - return null; - } - final Replacements replacements = tool.getReplacements(); StructuredGraph snippetGraph = selectSnippet(tool, replacements); if (snippetGraph == null) { diff -r a9c8df485789 -r 374b48caeb9c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Wed Apr 01 19:30:14 2015 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Wed Apr 01 19:30:25 2015 +0200 @@ -327,9 +327,9 @@ private static void processFloatable(FloatableAccessNode accessNode, MemoryMapImpl state) { StructuredGraph graph = accessNode.graph(); - assert accessNode.getNullCheck() == false; LocationIdentity locationIdentity = accessNode.location().getLocationIdentity(); if (accessNode.canFloat()) { + assert accessNode.getNullCheck() == false; MemoryNode lastLocationAccess = state.getLastLocationAccess(locationIdentity); FloatingAccessNode floatingNode = accessNode.asFloatingNode(lastLocationAccess); ValueAnchorNode anchor = null; diff -r a9c8df485789 -r 374b48caeb9c graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java Wed Apr 01 19:30:14 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java Wed Apr 01 19:30:25 2015 +0200 @@ -271,12 +271,12 @@ ReadNode memoryRead = createUnsafeRead(graph, load, valueAnchorNode); graph.replaceFixedWithFixed(load, valueAnchorNode); graph.addAfterFixed(valueAnchorNode, memoryRead); - } else if (!graph.getGuardsStage().allowsFloatingGuards()) { + } else { assert load.getKind() != Kind.Illegal; - ReadNode memoryRead = createUnsafeRead(graph, load, null); // An unsafe read must not float outside its block otherwise // it may float above an explicit null check on its object. - memoryRead.setGuard(AbstractBeginNode.prevBegin(load)); + AbstractBeginNode guard = AbstractBeginNode.prevBegin(load); + ReadNode memoryRead = createUnsafeRead(graph, load, guard); graph.replaceFixedWithFixed(load, memoryRead); } } diff -r a9c8df485789 -r 374b48caeb9c graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Wed Apr 01 19:30:14 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Wed Apr 01 19:30:25 2015 +0200 @@ -23,7 +23,6 @@ package com.oracle.graal.replacements; import static com.oracle.graal.api.meta.MetaUtil.*; -import static com.oracle.graal.compiler.GraalCompiler.*; import static com.oracle.graal.compiler.common.GraalOptions.*; import static com.oracle.graal.java.AbstractBytecodeParser.Options.*; import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.*; @@ -124,10 +123,9 @@ public void notifyOfNoninlinedInvoke(GraphBuilderContext b, ResolvedJavaMethod method, Invoke invoke) { if (b.parsingReplacement()) { - boolean compilingSnippet = b.getRootMethod().getAnnotation(Snippet.class) != null; Replacement replacement = b.getReplacement(); - assert compilingSnippet : format("All calls in the replacement %s must be inlined or intrinsified: found call to %s", replacement.getReplacementMethod().format("%H.%n(%p)"), - method.format("%h.%n(%p)")); + assert replacement.isCallToOriginal(method) : format("All non-recursive calls in the replacement %s must be inlined or intrinsified: found call to %s", + replacement.getReplacementMethod().format("%H.%n(%p)"), method.format("%h.%n(%p)")); } } @@ -174,7 +172,7 @@ for (Executable originalMethod : originalMethods) { if (originalMethod != null && (guard == null || guard.execute())) { ResolvedJavaMethod original = registerMethodSubstitution(this, originalMethod, substituteMethod); - if (original != null && methodSubstitution.forced() && shouldIntrinsify(original)) { + if (original != null && methodSubstitution.forced()) { forcedSubstitutions.add(original); } } diff -r a9c8df485789 -r 374b48caeb9c graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Wed Apr 01 19:30:14 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Wed Apr 01 19:30:25 2015 +0200 @@ -66,16 +66,6 @@ protected final JavaType returnType; protected final InvokeKind invokeKind; - protected MacroNode(NodeClass c, Invoke invoke) { - super(c, StampFactory.forKind(((MethodCallTargetNode) invoke.callTarget()).targetMethod().getSignature().getReturnKind())); - MethodCallTargetNode methodCallTarget = (MethodCallTargetNode) invoke.callTarget(); - this.arguments = new NodeInputList<>(this, methodCallTarget.arguments()); - this.bci = invoke.bci(); - this.targetMethod = methodCallTarget.targetMethod(); - this.returnType = methodCallTarget.returnType(); - this.invokeKind = methodCallTarget.invokeKind(); - } - protected MacroNode(NodeClass c, InvokeKind invokeKind, ResolvedJavaMethod targetMethod, int bci, JavaType returnType, ValueNode... arguments) { super(c, StampFactory.forKind(returnType.getKind())); assert targetMethod.getSignature().getParameterCount(!targetMethod.isStatic()) == arguments.length; @@ -181,7 +171,16 @@ Debug.dump(graph(), "After inlining replacement %s", replacementGraph); } else { if (invoke.stateAfter() == null) { - throw new GraalInternalError("cannot lower to invoke without state: %s", this); + ResolvedJavaMethod method = graph().method(); + if (method.getAnnotation(MethodSubstitution.class) != null || method.getAnnotation(Snippet.class) != null) { + // One cause for this is that a MacroNode is created for a method that + // no longer needs a MacroNode. For example, Class.getComponentType() + // only needs a MacroNode prior to JDK9 as it was given a non-native + // implementation in JDK9. + throw new GraalInternalError("%s macro created for call to %s in %s must be lowerable to a snippet or intrinsic graph. " + + "Maybe a macro node is not needed for this method in the current JDK?", getClass().getSimpleName(), targetMethod.format("%h.%n(%p)"), graph()); + } + throw new GraalInternalError("%s: cannot lower to invoke without state: %s", graph(), this); } invoke.lower(tool); } diff -r a9c8df485789 -r 374b48caeb9c graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/BailoutNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/BailoutNode.java Wed Apr 01 19:30:14 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2013, 2015, 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.nodes; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.graph.spi.*; -import com.oracle.graal.nodeinfo.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.replacements.nodes.*; - -@NodeInfo -public final class BailoutNode extends MacroNode implements Canonicalizable { - - public static final NodeClass TYPE = NodeClass.create(BailoutNode.class); - - public BailoutNode(Invoke invoke) { - super(TYPE, invoke); - assert arguments.size() == 1; - } - - public ValueNode getMessage() { - return arguments.get(0); - } - - @Override - public void lower(LoweringTool tool) { - throw new BailoutException("bailout (message is not compile-time constant, so no additional information is available)"); - } - - @Override - public Node canonical(CanonicalizerTool tool) { - if (getMessage().isConstant()) { - throw new BailoutException(getMessage().asConstant().toValueString()); - } - return this; - } -} diff -r a9c8df485789 -r 374b48caeb9c mx/suite.py --- a/mx/suite.py Wed Apr 01 19:30:14 2015 +0200 +++ b/mx/suite.py Wed Apr 01 19:30:25 2015 +0200 @@ -1048,7 +1048,6 @@ "sourceDirs" : ["src"], "dependencies" : [ "com.oracle.truffle.api", - "com.oracle.graal.replacements", "com.oracle.graal.runtime", "com.oracle.graal.printer", ], diff -r a9c8df485789 -r 374b48caeb9c mxtool/mx.py --- a/mxtool/mx.py Wed Apr 01 19:30:14 2015 +0200 +++ b/mxtool/mx.py Wed Apr 01 19:30:25 2015 +0200 @@ -837,6 +837,24 @@ else: return None + def locate(self, sDir, patterns=None, abortOnError=True): + try: + if patterns is None: + patterns = [] + elif not isinstance(patterns, list): + patterns = [patterns] + return subprocess.check_output(['hg', 'locate', '-R', sDir] + patterns).split('\n') + except OSError: + warn(self.missing) + except subprocess.CalledProcessError as e: + if e.returncode == 1: + # hg locate returns 1 if no matches were found + return [] + if abortOnError: + abort('failed to locate') + else: + return None + def _load_suite_dict(mxDir): suffix = 1 @@ -4664,8 +4682,13 @@ def fsckprojects(args): """find directories corresponding to deleted Java projects and delete them""" + if not sys.stdout.isatty(): + log('fsckprojects command must be run in an interactive shell') + return + hg = HgConfig() for suite in suites(True): projectDirs = [p.dir for p in suite.projects] + distIdeDirs = [d.get_ide_project_dir() for d in suite.dists if d.get_ide_project_dir() is not None] for dirpath, dirnames, files in os.walk(suite.dir): if dirpath == suite.dir: # no point in traversing .hg or lib/ @@ -4673,13 +4696,20 @@ elif dirpath in projectDirs: # don't traverse subdirs of an existing project in this suite dirnames[:] = [] + elif dirpath in distIdeDirs: + # don't traverse subdirs of an existing distributions in this suite + dirnames[:] = [] else: - projectConfigFiles = frozenset(['.classpath', 'nbproject']) + projectConfigFiles = frozenset(['.classpath', '.project', 'nbproject']) indicators = projectConfigFiles.intersection(files) if len(indicators) != 0: - if not sys.stdout.isatty() or ask_yes_no(dirpath + ' looks like a removed project -- delete it', 'n'): - shutil.rmtree(dirpath) - log('Deleted ' + dirpath) + indicators = [os.path.relpath(join(dirpath, i), suite.dir) for i in indicators] + indicatorsInHg = hg.locate(suite.dir, indicators) + # Only proceed if there are indicator files that are not under HG + if len(indicators) > len(indicatorsInHg): + if not sys.stdout.isatty() or ask_yes_no(dirpath + ' looks like a removed project -- delete it', 'n'): + shutil.rmtree(dirpath) + log('Deleted ' + dirpath) def javadoc(args, parser=None, docDir='javadoc', includeDeps=True, stdDoclet=True): """generate javadoc for some/all Java projects"""