Skip to content

Commit 0a13043

Browse files
committed
Introduce IsolatedTruffleCodeInstallBridge to avoid truffle dependency
Implements `OptimizedAssumptionDependency` on top of `IsolatedCodeInstallBridge` in `com.oracle.svm.truffle` to avoid pulling truffle dependencies in `com.oracle.svm.graal`.
1 parent f7d522f commit 0a13043

File tree

3 files changed

+59
-16
lines changed

3 files changed

+59
-16
lines changed

substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolatedCodeInstallBridge.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@
3333

3434
/**
3535
* A helper to pass information for installing code in the compilation client through a Truffle
36-
* compilation. It does not implement {@link InstalledCode} or {@link OptimizedAssumptionDependency}
37-
* in any meaningful way.
36+
* compilation. It does not implement {@link InstalledCode} in any meaningful way.
3837
*/
39-
public final class IsolatedCodeInstallBridge extends InstalledCode implements OptimizedAssumptionDependency {
38+
public class IsolatedCodeInstallBridge extends InstalledCode {
4039
private final ClientHandle<? extends SubstrateInstalledCode.Factory> factoryHandle;
4140
private ClientHandle<? extends SubstrateInstalledCode> installedCodeHandle;
4241

@@ -58,7 +57,7 @@ public ClientHandle<? extends SubstrateInstalledCode> getSubstrateInstalledCodeH
5857
return installedCodeHandle;
5958
}
6059

61-
private static final String DO_NOT_CALL_REASON = IsolatedCodeInstallBridge.class.getSimpleName() +
60+
protected static final String DO_NOT_CALL_REASON = IsolatedCodeInstallBridge.class.getSimpleName() +
6261
" only acts as an accessor for cross-isolate data. None of the implemented methods may be called.";
6362

6463
@Override
@@ -86,19 +85,9 @@ public byte[] getCode() {
8685
throw VMError.shouldNotReachHere(DO_NOT_CALL_REASON);
8786
}
8887

89-
@Override
90-
public void onAssumptionInvalidated(Object source, CharSequence reason) {
91-
throw VMError.shouldNotReachHere(DO_NOT_CALL_REASON);
92-
}
93-
9488
@Override
9589
public Object executeVarargs(Object... args) {
9690
throw VMError.shouldNotReachHere(DO_NOT_CALL_REASON);
9791
}
9892

99-
@Override
100-
public TruffleCompilable getCompilable() {
101-
throw VMError.shouldNotReachHere(DO_NOT_CALL_REASON);
102-
}
103-
10493
}

substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/isolated/IsolatedCompilableTruffleAST.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import com.oracle.svm.graal.isolated.ClientIsolateThread;
4040
import com.oracle.svm.graal.isolated.CompilerHandle;
4141
import com.oracle.svm.graal.isolated.CompilerIsolateThread;
42-
import com.oracle.svm.graal.isolated.IsolatedCodeInstallBridge;
4342
import com.oracle.svm.graal.isolated.IsolatedCompileClient;
4443
import com.oracle.svm.graal.isolated.IsolatedCompileContext;
4544
import com.oracle.svm.graal.isolated.IsolatedObjectConstant;
@@ -138,7 +137,7 @@ public SubstrateInstalledCode createSubstrateInstalledCode() {
138137

139138
@Override
140139
public InstalledCode createPreliminaryInstalledCode() {
141-
return new IsolatedCodeInstallBridge(handle);
140+
return new IsolatedTruffleCodeInstallBridge(handle);
142141
}
143142

144143
@Override
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2022, 2022, Red Hat Inc. All rights reserved.
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
*
6+
* This code is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License version 2 only, as
8+
* published by the Free Software Foundation. Oracle designates this
9+
* particular file as subject to the "Classpath" exception as provided
10+
* by Oracle in the LICENSE file that accompanied this code.
11+
*
12+
* This code is distributed in the hope that it will be useful, but WITHOUT
13+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+
* version 2 for more details (a copy is included in the LICENSE file that
16+
* accompanied this code).
17+
*
18+
* You should have received a copy of the GNU General Public License version
19+
* 2 along with this work; if not, write to the Free Software Foundation,
20+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21+
*
22+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23+
* or visit www.oracle.com if you need additional information or have any
24+
* questions.
25+
*/
26+
package com.oracle.svm.truffle.isolated;
27+
28+
import com.oracle.svm.core.deopt.SubstrateInstalledCode;
29+
import com.oracle.svm.core.util.VMError;
30+
import com.oracle.svm.graal.isolated.ClientHandle;
31+
import com.oracle.svm.graal.isolated.IsolatedCodeInstallBridge;
32+
import jdk.vm.ci.code.InstalledCode;
33+
import org.graalvm.compiler.truffle.common.OptimizedAssumptionDependency;
34+
import org.graalvm.compiler.truffle.common.TruffleCompilable;
35+
36+
/**
37+
* A helper to pass information for installing code in the compilation client through a Truffle
38+
* compilation. It does not implement {@link InstalledCode} or {@link OptimizedAssumptionDependency}
39+
* in any meaningful way.
40+
*/
41+
public final class IsolatedTruffleCodeInstallBridge extends IsolatedCodeInstallBridge implements OptimizedAssumptionDependency {
42+
public IsolatedTruffleCodeInstallBridge(ClientHandle<? extends SubstrateInstalledCode.Factory> factoryHandle) {
43+
super(factoryHandle);
44+
}
45+
46+
@Override
47+
public void onAssumptionInvalidated(Object source, CharSequence reason) {
48+
throw VMError.shouldNotReachHere(DO_NOT_CALL_REASON);
49+
}
50+
51+
@Override
52+
public TruffleCompilable getCompilable() {
53+
throw VMError.shouldNotReachHere(DO_NOT_CALL_REASON);
54+
}
55+
}

0 commit comments

Comments
 (0)