Mercurial > hg > truffle
changeset 18479:16e61bb57e90
Introduce StampProvider to support different stamps for metadata on different VMs.
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Thu Nov 20 14:02:35 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Thu Nov 20 14:13:38 2014 +0100 @@ -144,7 +144,7 @@ // Replacements cannot have speculative optimizations since they have // to be valid for the entire run of the VM. Assumptions assumptions = new Assumptions(false); - Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null); + Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null, new HotSpotStampProvider()); try (InitTimer rt = timer("create SnippetReflection provider")) { snippetReflection = createSnippetReflection(); } @@ -240,15 +240,15 @@ } else { /* * System V Application Binary Interface, AMD64 Architecture Processor Supplement - * + * * Draft Version 0.96 - * + * * http://www.uclibc.org/docs/psABI-x86_64.pdf - * + * * 3.2.1 - * + * * ... - * + * * This subsection discusses usage of each register. Registers %rbp, %rbx and %r12 * through %r15 "belong" to the calling function and the called function is required to * preserve their values. In other words, a called function must preserve these
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackendFactory.java Thu Nov 20 14:02:35 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackendFactory.java Thu Nov 20 14:13:38 2014 +0100 @@ -55,7 +55,7 @@ // Replacements cannot have speculative optimizations since they have // to be valid for the entire run of the VM. Assumptions assumptions = new Assumptions(false); - Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null); + Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null, new HotSpotStampProvider()); Replacements replacements = new HSAILHotSpotReplacementsImpl(p, host.getSnippetReflection(), assumptions, codeCache.getTarget(), host.getReplacements()); HotSpotDisassemblerProvider disassembler = host.getDisassembler(); SuitesProvider suites = new HotSpotSuitesProvider(runtime);
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Thu Nov 20 14:02:35 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Thu Nov 20 14:13:38 2014 +0100 @@ -63,7 +63,7 @@ // Replacements cannot have speculative optimizations since they have // to be valid for the entire run of the VM. Assumptions assumptions = new Assumptions(false); - Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null); + Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null, new HotSpotStampProvider()); HotSpotSnippetReflectionProvider snippetReflection = new HotSpotSnippetReflectionProvider(); HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(p, snippetReflection, runtime.getConfig(), assumptions, target); HotSpotDisassemblerProvider disassembler = new HotSpotDisassemblerProvider(runtime);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProviders.java Thu Nov 20 14:02:35 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProviders.java Thu Nov 20 14:13:38 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -42,7 +42,7 @@ public HotSpotProviders(MetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, HotSpotForeignCallsProvider foreignCalls, LoweringProvider lowerer, Replacements replacements, HotSpotDisassemblerProvider disassembler, SuitesProvider suites, HotSpotRegistersProvider registers, SnippetReflectionProvider snippetReflection) { - super(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements); + super(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, new HotSpotStampProvider()); this.disassembler = disassembler; this.suites = suites; this.registers = registers;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotStampProvider.java Thu Nov 20 14:13:38 2014 +0100 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014, 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.hotspot.meta; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.type.*; +import com.oracle.graal.nodes.spi.*; + +public class HotSpotStampProvider implements StampProvider { + + public Stamp createHubStamp(ObjectStamp object) { + return StampFactory.forPointer(PointerType.Type); + } + + public Stamp createMethodStamp() { + return StampFactory.forPointer(PointerType.Method); + } +}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java Thu Nov 20 14:02:35 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java Thu Nov 20 14:13:38 2014 +0100 @@ -77,7 +77,7 @@ } // the canonicalization before loop unrolling is needed to propagate the length into // additions, etc. - PhaseContext context = new PhaseContext(tool.getMetaAccess(), tool.getConstantReflection(), tool.getLowerer(), tool.getReplacements(), tool.assumptions()); + PhaseContext context = new PhaseContext(tool.getMetaAccess(), tool.getConstantReflection(), tool.getLowerer(), tool.getReplacements(), tool.assumptions(), tool.getStampProvider()); new CanonicalizerPhase(true).apply(snippetGraph, context); new LoopFullUnrollPhase(new CanonicalizerPhase(true)).apply(snippetGraph, context); new CanonicalizerPhase(true).apply(snippetGraph, context);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java Thu Nov 20 14:02:35 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java Thu Nov 20 14:13:38 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -39,6 +39,8 @@ Replacements getReplacements(); + StampProvider getStampProvider(); + GuardingNode createGuard(FixedNode before, LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action); GuardingNode createGuard(FixedNode before, LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/StampProvider.java Thu Nov 20 14:13:38 2014 +0100 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014, 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.nodes.spi; + +import com.oracle.graal.compiler.common.type.*; +import com.oracle.graal.nodes.extended.*; + +/** + * Provides a capability for creating platform dependent stamps. + */ +public interface StampProvider { + + /** + * Create the stamp of the {@link LoadHubNode hub} of an object. + */ + Stamp createHubStamp(ObjectStamp object); + + /** + * Create the stamp of a pointer to a method. + */ + Stamp createMethodStamp(); +}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Thu Nov 20 14:02:35 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Thu Nov 20 14:13:38 2014 +0100 @@ -131,6 +131,10 @@ return context.getAssumptions(); } + public StampProvider getStampProvider() { + return context.getStampProvider(); + } + @Override public GuardingNode createGuard(FixedNode before, LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) { if (OptEliminateGuards.getValue()) {
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java Thu Nov 20 14:02:35 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java Thu Nov 20 14:13:38 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -27,7 +27,6 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.spi.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.util.*; @@ -38,19 +37,14 @@ private final Map<ResolvedJavaMethod, StructuredGraph> cache; private final OptimisticOptimizations optimisticOpts; - public HighTierContext(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, LoweringProvider lowerer, Replacements replacements, Assumptions assumptions, - Map<ResolvedJavaMethod, StructuredGraph> cache, PhaseSuite<HighTierContext> graphBuilderSuite, OptimisticOptimizations optimisticOpts) { - super(metaAccess, constantReflection, lowerer, replacements, assumptions); + public HighTierContext(Providers providers, Assumptions assumptions, Map<ResolvedJavaMethod, StructuredGraph> cache, PhaseSuite<HighTierContext> graphBuilderSuite, + OptimisticOptimizations optimisticOpts) { + super(providers, assumptions); this.cache = cache; this.graphBuilderSuite = graphBuilderSuite; this.optimisticOpts = optimisticOpts; } - public HighTierContext(Providers providers, Assumptions assumptions, Map<ResolvedJavaMethod, StructuredGraph> cache, PhaseSuite<HighTierContext> graphBuilderSuite, - OptimisticOptimizations optimisticOpts) { - this(providers.getMetaAccess(), providers.getConstantReflection(), providers.getLowerer(), providers.getReplacements(), assumptions, cache, graphBuilderSuite, optimisticOpts); - } - public PhaseSuite<HighTierContext> getGraphBuilderSuite() { return graphBuilderSuite; } @@ -64,6 +58,6 @@ } public HighTierContext replaceAssumptions(Assumptions newAssumptions) { - return new HighTierContext(getMetaAccess(), getConstantReflection(), getLowerer(), getReplacements(), newAssumptions, getGraphCache(), getGraphBuilderSuite(), getOptimisticOptimizations()); + return new HighTierContext(new Providers(this), newAssumptions, cache, graphBuilderSuite, optimisticOpts); } }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java Thu Nov 20 14:02:35 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java Thu Nov 20 14:13:38 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -34,17 +34,20 @@ private final LoweringProvider lowerer; private final Replacements replacements; private final Assumptions assumptions; + private final StampProvider stampProvider; - public PhaseContext(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, LoweringProvider lowerer, Replacements replacements, Assumptions assumptions) { + public PhaseContext(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, LoweringProvider lowerer, Replacements replacements, Assumptions assumptions, + StampProvider stampProvider) { this.metaAccess = metaAccess; this.constantReflection = constantReflection; this.lowerer = lowerer; this.replacements = replacements; this.assumptions = assumptions; + this.stampProvider = stampProvider; } public PhaseContext(Providers providers, Assumptions assumptions) { - this(providers.getMetaAccess(), providers.getConstantReflection(), providers.getLowerer(), providers.getReplacements(), assumptions); + this(providers.getMetaAccess(), providers.getConstantReflection(), providers.getLowerer(), providers.getReplacements(), assumptions, providers.getStampProvider()); } public MetaAccessProvider getMetaAccess() { @@ -66,4 +69,8 @@ public Assumptions getAssumptions() { return assumptions; } + + public StampProvider getStampProvider() { + return stampProvider; + } }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/Providers.java Thu Nov 20 14:02:35 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/Providers.java Thu Nov 20 14:13:38 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -39,23 +39,26 @@ private final ConstantReflectionProvider constantReflection; private final ForeignCallsProvider foreignCalls; private final Replacements replacements; + private final StampProvider stampProvider; public Providers(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, ForeignCallsProvider foreignCalls, LoweringProvider lowerer, - Replacements replacements) { + Replacements replacements, StampProvider stampProvider) { this.metaAccess = metaAccess; this.codeCache = codeCache; this.constantReflection = constantReflection; this.foreignCalls = foreignCalls; this.lowerer = lowerer; this.replacements = replacements; + this.stampProvider = stampProvider; } public Providers(Providers copyFrom) { - this(copyFrom.getMetaAccess(), copyFrom.getCodeCache(), copyFrom.getConstantReflection(), copyFrom.getForeignCalls(), copyFrom.getLowerer(), copyFrom.getReplacements()); + this(copyFrom.getMetaAccess(), copyFrom.getCodeCache(), copyFrom.getConstantReflection(), copyFrom.getForeignCalls(), copyFrom.getLowerer(), copyFrom.getReplacements(), + copyFrom.getStampProvider()); } public Providers(PhaseContext copyFrom) { - this(copyFrom.getMetaAccess(), null, copyFrom.getConstantReflection(), null, copyFrom.getLowerer(), copyFrom.getReplacements()); + this(copyFrom.getMetaAccess(), null, copyFrom.getConstantReflection(), null, copyFrom.getLowerer(), copyFrom.getReplacements(), copyFrom.getStampProvider()); } public MetaAccessProvider getMetaAccess() { @@ -82,27 +85,35 @@ return replacements; } + public StampProvider getStampProvider() { + return stampProvider; + } + public Providers copyWith(MetaAccessProvider substitution) { - return new Providers(substitution, codeCache, constantReflection, foreignCalls, lowerer, replacements); + return new Providers(substitution, codeCache, constantReflection, foreignCalls, lowerer, replacements, stampProvider); } public Providers copyWith(CodeCacheProvider substitution) { - return new Providers(metaAccess, substitution, constantReflection, foreignCalls, lowerer, replacements); + return new Providers(metaAccess, substitution, constantReflection, foreignCalls, lowerer, replacements, stampProvider); } public Providers copyWith(ConstantReflectionProvider substitution) { - return new Providers(metaAccess, codeCache, substitution, foreignCalls, lowerer, replacements); + return new Providers(metaAccess, codeCache, substitution, foreignCalls, lowerer, replacements, stampProvider); } public Providers copyWith(ForeignCallsProvider substitution) { - return new Providers(metaAccess, codeCache, constantReflection, substitution, lowerer, replacements); + return new Providers(metaAccess, codeCache, constantReflection, substitution, lowerer, replacements, stampProvider); } public Providers copyWith(LoweringProvider substitution) { - return new Providers(metaAccess, codeCache, constantReflection, foreignCalls, substitution, replacements); + return new Providers(metaAccess, codeCache, constantReflection, foreignCalls, substitution, replacements, stampProvider); } public Providers copyWith(Replacements substitution) { - return new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, substitution); + return new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, substitution, stampProvider); + } + + public Providers copyWith(StampProvider substitution) { + return new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, substitution); } }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Thu Nov 20 14:02:35 2014 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Thu Nov 20 14:13:38 2014 +0100 @@ -133,7 +133,7 @@ * @param replacementGraph a replacement (i.e., snippet or method substitution) graph */ protected StructuredGraph lowerReplacement(final StructuredGraph replacementGraph, LoweringTool tool) { - final PhaseContext c = new PhaseContext(tool.getMetaAccess(), tool.getConstantReflection(), tool.getLowerer(), tool.getReplacements(), tool.assumptions()); + final PhaseContext c = new PhaseContext(tool.getMetaAccess(), tool.getConstantReflection(), tool.getLowerer(), tool.getReplacements(), tool.assumptions(), tool.getStampProvider()); if (!graph().hasValueProxies()) { new RemoveValueProxyPhase().apply(replacementGraph); }