Skip to content

Commit a739edc

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 b386c93 commit a739edc

File tree

3 files changed

+59
-19
lines changed

3 files changed

+59
-19
lines changed

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,16 @@
2424
*/
2525
package com.oracle.svm.graal.isolated;
2626

27-
import org.graalvm.compiler.truffle.common.TruffleCompilable;
28-
import org.graalvm.compiler.truffle.common.OptimizedAssumptionDependency;
29-
3027
import com.oracle.svm.core.deopt.SubstrateInstalledCode;
3128
import com.oracle.svm.core.util.VMError;
3229

3330
import jdk.vm.ci.code.InstalledCode;
3431

3532
/**
3633
* A helper to pass information for installing code in the compilation client through a Truffle
37-
* compilation. It does not implement {@link InstalledCode} or {@link OptimizedAssumptionDependency}
38-
* in any meaningful way.
34+
* compilation. It does not implement {@link InstalledCode} in any meaningful way.
3935
*/
40-
public final class IsolatedCodeInstallBridge extends InstalledCode implements OptimizedAssumptionDependency {
36+
public class IsolatedCodeInstallBridge extends InstalledCode {
4137
private final ClientHandle<? extends SubstrateInstalledCode.Factory> factoryHandle;
4238
private ClientHandle<? extends SubstrateInstalledCode> installedCodeHandle;
4339

@@ -59,7 +55,7 @@ public ClientHandle<? extends SubstrateInstalledCode> getSubstrateInstalledCodeH
5955
return installedCodeHandle;
6056
}
6157

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

6561
@Override
@@ -87,19 +83,9 @@ public byte[] getCode() {
8783
throw VMError.shouldNotReachHere(DO_NOT_CALL_REASON);
8884
}
8985

90-
@Override
91-
public void onAssumptionInvalidated(Object source, CharSequence reason) {
92-
throw VMError.shouldNotReachHere(DO_NOT_CALL_REASON);
93-
}
94-
9586
@Override
9687
public Object executeVarargs(Object... args) {
9788
throw VMError.shouldNotReachHere(DO_NOT_CALL_REASON);
9889
}
9990

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

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
@@ -43,7 +43,6 @@
4343
import com.oracle.svm.graal.isolated.ClientIsolateThread;
4444
import com.oracle.svm.graal.isolated.CompilerHandle;
4545
import com.oracle.svm.graal.isolated.CompilerIsolateThread;
46-
import com.oracle.svm.graal.isolated.IsolatedCodeInstallBridge;
4746
import com.oracle.svm.graal.isolated.IsolatedCompileClient;
4847
import com.oracle.svm.graal.isolated.IsolatedCompileContext;
4948
import com.oracle.svm.graal.isolated.IsolatedObjectConstant;
@@ -140,7 +139,7 @@ public SubstrateInstalledCode createSubstrateInstalledCode() {
140139

141140
@Override
142141
public InstalledCode createPreliminaryInstalledCode() {
143-
return new IsolatedCodeInstallBridge(handle);
142+
return new IsolatedTruffleCodeInstallBridge(handle);
144143
}
145144

146145
@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)