Skip to content

Commit fe73df9

Browse files
committed
[GR-31342] Implemented node object inlining, lock free specialization and other features for Truffle DSL.
PullRequest: graal/12538
2 parents 5be01a6 + 85dfa56 commit fe73df9

File tree

490 files changed

+32058
-7565
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

490 files changed

+32058
-7565
lines changed

compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/SimplifyingGraphDecoder.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.graalvm.compiler.nodes.extended.AnchoringNode;
4545
import org.graalvm.compiler.nodes.extended.GuardingNode;
4646
import org.graalvm.compiler.nodes.extended.IntegerSwitchNode;
47+
import org.graalvm.compiler.nodes.extended.UnsafeAccessNode;
4748
import org.graalvm.compiler.nodes.java.ArrayLengthNode;
4849
import org.graalvm.compiler.nodes.java.LoadFieldNode;
4950
import org.graalvm.compiler.nodes.java.LoadIndexedNode;
@@ -202,9 +203,18 @@ protected void handleFixedNode(MethodScope methodScope, LoopScope loopScope, int
202203
* canonicalized (and therefore be a non-fixed node).
203204
*
204205
* @param methodScope The current method.
205-
* @param node The node to be canonicalized.
206+
* @param originalNode The node to be canonicalized.
206207
*/
207-
protected Node canonicalizeFixedNode(MethodScope methodScope, Node node) {
208+
protected Node canonicalizeFixedNode(MethodScope methodScope, Node originalNode) {
209+
Node node = originalNode;
210+
if (originalNode instanceof UnsafeAccessNode) {
211+
/*
212+
* Ensure that raw stores and loads are eventually transformed to fields to make node
213+
* plugins trigger for them reliably during PE.
214+
*/
215+
node = ((UnsafeAccessNode) node).canonical(canonicalizerTool);
216+
}
217+
208218
/*
209219
* Duplicate cases for frequent classes (LoadFieldNode, LoadIndexedNode and ArrayLengthNode)
210220
* to improve performance (Haeubl, 2017).

compiler/src/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/PEGraphDecoder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,9 +1466,10 @@ private static void deleteInvoke(Invoke invoke) {
14661466

14671467
@SuppressWarnings("try")
14681468
@Override
1469-
protected Node canonicalizeFixedNode(MethodScope s, Node node) {
1469+
protected Node canonicalizeFixedNode(MethodScope s, Node originalNode) {
14701470
PEMethodScope methodScope = (PEMethodScope) s;
14711471

1472+
Node node = originalNode;
14721473
Node replacedNode = node;
14731474
if (nodePlugins != null && nodePlugins.length > 0) {
14741475
if (node instanceof LoadFieldNode) {

compiler/src/org.graalvm.compiler.truffle.compiler.hotspot/src/org/graalvm/compiler/truffle/compiler/hotspot/HotSpotTruffleGraphBuilderPlugins.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343

4444
final class HotSpotTruffleGraphBuilderPlugins {
4545

46+
/**
47+
* Installed for runtime compilation using partial evaluation.
48+
*/
4649
static void registerCompilationFinalReferencePlugins(InvocationPlugins plugins, boolean canDelayIntrinsification, HotSpotKnownTruffleTypes types) {
4750
InvocationPlugins.Registration r = new InvocationPlugins.Registration(plugins, Reference.class);
4851
r.register(new RequiredInvocationPlugin("get", InvocationPlugin.Receiver.class) {
@@ -85,6 +88,7 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
8588
return true;
8689
}
8790
});
91+
8892
}
8993

9094
}

compiler/src/org.graalvm.compiler.truffle.runtime/src/org/graalvm/compiler/truffle/runtime/GraalTruffleRuntime.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
import com.oracle.truffle.api.TruffleOptions;
9595
import com.oracle.truffle.api.TruffleRuntime;
9696
import com.oracle.truffle.api.TruffleSafepoint;
97+
import com.oracle.truffle.api.dsl.InlineSupport;
9798
import com.oracle.truffle.api.dsl.Specialization;
9899
import com.oracle.truffle.api.frame.FrameDescriptor;
99100
import com.oracle.truffle.api.frame.FrameInstance;
@@ -402,6 +403,17 @@ private static UnmodifiableEconomicMap<String, Class<?>> initLookupTypes(Iterabl
402403
TruffleString.class,
403404
AbstractTruffleString.class,
404405
Buffer.class,
406+
InlineSupport.InlinableField.class,
407+
InlineSupport.StateField.class,
408+
InlineSupport.BooleanField.class,
409+
InlineSupport.ByteField.class,
410+
InlineSupport.ShortField.class,
411+
InlineSupport.IntField.class,
412+
InlineSupport.CharField.class,
413+
InlineSupport.FloatField.class,
414+
InlineSupport.LongField.class,
415+
InlineSupport.DoubleField.class,
416+
InlineSupport.ReferenceField.class,
405417
}) {
406418
m.put(c.getName(), c);
407419
}

compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/CachedLibraryCompilationTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.oracle.truffle.api.nodes.Node;
4646
import com.oracle.truffle.api.nodes.RootNode;
4747

48+
@SuppressWarnings("truffle-inlining")
4849
public class CachedLibraryCompilationTest extends PartialEvaluationTest {
4950

5051
private Context context;

compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/ContextLookupCompilationTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.graalvm.word.LocationIdentity;
4646
import org.junit.Assert;
4747
import org.junit.Assume;
48+
import org.junit.Ignore;
4849
import org.junit.Test;
4950

5051
import com.oracle.truffle.api.CompilerAsserts;
@@ -153,6 +154,7 @@ public String getName() {
153154
}
154155

155156
@Test
157+
@Ignore("GR-43475") // fails transiently
156158
public void testContextThreadLocalRead() throws Throwable {
157159
Engine engine = Engine.create();
158160
Context c = createContext(engine, SHARED1);

compiler/src/org.graalvm.compiler.truffle.test/src/org/graalvm/compiler/truffle/test/GR35581Test.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ protected Object runUnderASTLock() {
102102
}
103103

104104
@Specialization
105+
@SuppressWarnings("truffle-neverdefault")
105106
Object doIt(@Cached("runUnderASTLock()") Object cacheValue) {
106107
return cacheValue;
107108
}

0 commit comments

Comments
 (0)