Skip to content

Commit

Permalink
[GR-26851] Enable MultiTier option.
Browse files Browse the repository at this point in the history
PullRequest: graal/7926
  • Loading branch information
peter-hofer committed Dec 23, 2020
2 parents 63b9e64 + 247f2f1 commit d7cc62a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private String indent(int nameLength) {
// MultiTier

@Option(help = "Whether to use multiple Truffle compilation tiers by default.", category = OptionCategory.EXPERT)
public static final OptionKey<Boolean> MultiTier = new OptionKey<>(false);
public static final OptionKey<Boolean> MultiTier = new OptionKey<>(true);

@Option(help = "Explicitly pick a first tier inlining policy by name (None, TrivialOnly). If empty (default) the lowest priority policy (TrivialOnly) is chosen.", category = OptionCategory.INTERNAL)
public static final OptionKey<String> FirstTierInliningPolicy = new OptionKey<>("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ public long getCodeAddress() {
return installedCode.getAddress();
}

/**
* Prevents reads from floating across a safepoint when the caller is inlined in another method.
* Intrinsified in {@link SubstrateTruffleGraphBuilderPlugins}.
*/
public static void safepointBarrier() {
// Intrinsified, but empty so it can be called during hosted Truffle calls
}

@Override
public Object doInvoke(Object[] args) {
return SubstrateOptimizedCallTargetInstalledCode.doInvoke(this, args);
Expand Down Expand Up @@ -119,7 +127,11 @@ public SubstrateOptimizedCallTargetInstalledCode createSubstrateInstalledCode()
return createInstalledCode();
}

void setInstalledCode(SubstrateOptimizedCallTargetInstalledCode code) {
/**
* Called from {@link SubstrateOptimizedCallTargetInstalledCode#setAddress} for code
* representing this call target.
*/
protected void onCodeInstalled(SubstrateOptimizedCallTargetInstalledCode code) {
VMOperation.guaranteeInProgressAtSafepoint("Must be at a safepoint");
assert code != null : "Must never become null";
if (code == installedCode) {
Expand All @@ -129,6 +141,15 @@ void setInstalledCode(SubstrateOptimizedCallTargetInstalledCode code) {
installedCode = code;
}

/**
* Called from {@link SubstrateOptimizedCallTargetInstalledCode#clearAddress} for code
* representing this call target. The caller can, however, be older code and not the current
* entry point, so that {@code code != installedCode}.
*/
protected void onCodeCleared(@SuppressWarnings("unused") SubstrateOptimizedCallTargetInstalledCode code) {
VMOperation.guaranteeInProgressAtSafepoint("Must be at a safepoint");
}

/** Creates the instance for initializing {@link #installedCode} so it is never {@code null}. */
protected SubstrateOptimizedCallTargetInstalledCode createInitializationInstalledCode() {
return createInstalledCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,15 @@ public void setAddress(long address, ResolvedJavaMethod method) {
assert VMOperation.isInProgressAtSafepoint();
this.entryPoint = address;
this.address = address;
callTarget.setInstalledCode(this);
callTarget.onCodeInstalled(this);
}

@Override
public void clearAddress() {
assert VMOperation.isInProgressAtSafepoint();
this.entryPoint = 0;
this.address = 0;
callTarget.onCodeCleared(this);
}

@Override
Expand All @@ -147,16 +148,8 @@ private void invalidateWithoutDeoptimization0() {
}
}

/**
* Prevents reads from floating across a safepoint when the caller is inlined in another method.
* Intrinsified in {@link SubstrateTruffleGraphBuilderPlugins}.
*/
protected static void safepointBarrier() {
// Intrinsified, but empty so it can be called during hosted Truffle calls
}

static Object doInvoke(SubstrateOptimizedCallTarget callTarget, Object[] args) {
safepointBarrier();
SubstrateOptimizedCallTarget.safepointBarrier();
/*
* We have to be very careful that the calling code is uninterruptible, i.e., has no
* safepoint between the read of the entry point address and the indirect call to this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
}

private static void registerOptimizedCallTargetPlugins(InvocationPlugins plugins) {
InvocationPlugins.Registration r0 = new InvocationPlugins.Registration(plugins, SubstrateOptimizedCallTargetInstalledCode.class);
InvocationPlugins.Registration r0 = new InvocationPlugins.Registration(plugins, SubstrateOptimizedCallTarget.class);
r0.register0("safepointBarrier", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
Expand Down

0 comments on commit d7cc62a

Please sign in to comment.