src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/stubs/Stub.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/stubs/Stub.java	Mon Mar 20 17:39:09 2017
--- new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/stubs/Stub.java	Mon Mar 20 17:39:09 2017

*** 24,40 **** --- 24,36 ---- import static org.graalvm.compiler.core.GraalCompiler.emitBackEnd; import static org.graalvm.compiler.core.GraalCompiler.emitFrontEnd; import static org.graalvm.compiler.core.common.GraalOptions.GeneratePIC; import static org.graalvm.compiler.hotspot.HotSpotHostBackend.UNCOMMON_TRAP_HANDLER; + import static org.graalvm.util.CollectionsUtil.allMatch; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.ListIterator; import java.util.Set; import org.graalvm.compiler.code.CompilationResult; import org.graalvm.compiler.core.common.CompilationIdentifier; import org.graalvm.compiler.core.target.Backend; import org.graalvm.compiler.debug.Debug;
*** 48,60 **** --- 44,58 ---- import org.graalvm.compiler.lir.phases.LIRPhase; import org.graalvm.compiler.lir.phases.LIRSuites; import org.graalvm.compiler.lir.phases.PostAllocationOptimizationPhase.PostAllocationOptimizationContext; import org.graalvm.compiler.lir.profiling.MoveProfilingPhase; import org.graalvm.compiler.nodes.StructuredGraph; + import org.graalvm.compiler.options.OptionValues; import org.graalvm.compiler.phases.OptimisticOptimizations; import org.graalvm.compiler.phases.PhaseSuite; import org.graalvm.compiler.phases.tiers.Suites; + import org.graalvm.util.EconomicSet; import jdk.vm.ci.code.CodeCacheProvider; import jdk.vm.ci.code.InstalledCode; import jdk.vm.ci.code.Register; import jdk.vm.ci.code.RegisterConfig;
*** 75,86 **** --- 73,82 ---- * and/or a callee saved call to a HotSpot C/C++ runtime function or even a another compiled Java * method. */ public abstract class Stub { private static final List<Stub> stubs = new ArrayList<>(); /** * The linkage information for a call to this stub from compiled code. */ protected final HotSpotForeignCallLinkage linkage;
*** 90,112 **** --- 86,118 ---- protected InstalledCode code; /** * The registers destroyed by this stub (from the caller's perspective). */ ! private EconomicSet<Register> destroyedCallerRegisters; + + private static boolean checkRegisterSetEquivalency(EconomicSet<Register> a, EconomicSet<Register> b) { + if (a == b) { + return true; + } + if (a.size() != b.size()) { + return false; + } + return allMatch(a, e -> b.contains(e)); + } ! public void initDestroyedCallerRegisters(EconomicSet<Register> registers) { assert registers != null; ! assert destroyedCallerRegisters == null || registers.equals(destroyedCallerRegisters) : "cannot redefine"; ! assert destroyedCallerRegisters == null || checkRegisterSetEquivalency(registers, destroyedCallerRegisters) : "cannot redefine"; destroyedCallerRegisters = registers; } /** * Gets the registers destroyed by this stub from a caller's perspective. These are the * temporaries of this stub and must thus be caller saved by a callers of this stub. */ ! public EconomicSet<Register> getDestroyedCallerRegisters() { assert destroyedCallerRegisters != null : "not yet initialized"; return destroyedCallerRegisters; } /**
*** 115,142 **** --- 121,142 ---- */ public boolean preservesRegisters() { return true; } + protected final OptionValues options; protected final HotSpotProviders providers; /** * Creates a new stub. * * @param linkage linkage details for a call to the stub */ ! public Stub(OptionValues options, HotSpotProviders providers, HotSpotForeignCallLinkage linkage) { this.linkage = linkage; + this.options = options; this.providers = providers; stubs.add(this); } /** * Gets an immutable view of all stubs that have been created. */ public static Collection<Stub> getStubs() { return Collections.unmodifiableList(stubs); } /** * Gets the linkage for a call to this stub from compiled code. */
*** 176,185 **** --- 176,186 ---- @SuppressWarnings("try") public synchronized InstalledCode getCode(final Backend backend) { if (code == null) { try (Scope d = Debug.sandbox("CompilingStub", DebugScope.getConfig(), providers.getCodeCache(), debugScopeContext())) { CodeCacheProvider codeCache = providers.getCodeCache(); + CompilationResult compResult = buildCompilationResult(backend); try (Scope s = Debug.scope("CodeInstall", compResult)) { assert destroyedCallerRegisters != null; // Add a GeneratePIC check here later, we don't want to install // code if we don't have a corresponding VM global symbol.
*** 197,207 **** --- 198,208 ---- return code; } @SuppressWarnings("try") private CompilationResult buildCompilationResult(final Backend backend) { ! CompilationResult compResult = new CompilationResult(toString(), GeneratePIC.getValue(options)); final StructuredGraph graph = getGraph(getStubCompilationId()); // Stubs cannot be recompiled so they cannot be compiled with assumptions assert graph.getAssumptions() == null;
*** 273,288 **** --- 274,289 ---- } return true; } protected Suites createSuites() { ! Suites defaultSuites = providers.getSuites().getDefaultSuites(options); return new Suites(new PhaseSuite<>(), defaultSuites.getMidTier(), defaultSuites.getLowTier()); } protected LIRSuites createLIRSuites() { ! LIRSuites lirSuites = new LIRSuites(providers.getSuites().getDefaultLIRSuites(options)); ListIterator<LIRPhase<PostAllocationOptimizationContext>> moveProfiling = lirSuites.getPostAllocationOptimizationStage().findPhase(MoveProfilingPhase.class); if (moveProfiling != null) { moveProfiling.remove(); } return lirSuites;

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/stubs/Stub.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File