Skip to content

Commit 53adfc9

Browse files
author
Adam Hrbac
committed
Move @TruffleBoundary deeper into the call tree
1 parent 9c3dfc7 commit 53adfc9

File tree

3 files changed

+25
-27
lines changed

3 files changed

+25
-27
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ContextvarsModuleBuiltins.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import com.oracle.graal.python.builtins.PythonBuiltins;
5151
import com.oracle.graal.python.builtins.objects.PNone;
5252
import com.oracle.graal.python.builtins.objects.contextvars.PContextVar;
53-
import com.oracle.graal.python.builtins.objects.contextvars.PContextVarsContext;
5453
import com.oracle.graal.python.nodes.ErrorMessages;
5554
import com.oracle.graal.python.nodes.PRaiseNode;
5655
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/Hamt.java

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656

5757
public final class Hamt {
5858

59-
@CompilerDirectives.TruffleBoundary
6059
public String dump() {
6160
return dumpPart(this.root, 0);
6261
}
@@ -65,28 +64,6 @@ private static String dumpPart(TreePart i, int indent) {
6564
return i == null ? " ".repeat(indent) + "null\n" : i.dump(indent);
6665
}
6766

68-
private interface TreePart {
69-
String dump(int indent);
70-
}
71-
72-
@CompilerDirectives.ValueType
73-
public static final class Entry implements TreePart {
74-
final Object key;
75-
final int hash;
76-
final Object value;
77-
78-
public Entry(Object key, int hash, Object value) {
79-
this.key = key;
80-
this.hash = hash & 0x3FFFFFFF; // 30 bits
81-
this.value = value;
82-
}
83-
84-
@Override
85-
public String dump(int indent) {
86-
return " ".repeat(indent) + String.format("%s : %s (%d)\n", key, value, hash);
87-
}
88-
}
89-
9067
// TODO: track size on the Hamt.
9168
private final TreePart root;
9269

@@ -135,6 +112,7 @@ private static BitmapPart bitmapPartsForPair(TreePart one, int hashOne, TreePart
135112
return new BitmapPart(oneIdx > twoIdx ? new TreePart[]{one, two} : new TreePart[]{two, one}, idxToBit(twoIdx) | idxToBit(oneIdx));
136113
}
137114

115+
@CompilerDirectives.TruffleBoundary
138116
private static TreePart partWithEntry(TreePart original, Entry newEntry, int hashShift) {
139117
assert hashShift <= 25;
140118
if (original == null) {
@@ -219,6 +197,7 @@ public Hamt withEntry(Entry newEntry) {
219197
return new Hamt(root);
220198
}
221199

200+
@CompilerDirectives.TruffleBoundary
222201
private static Object lookupKeyInPart(TreePart part, Object key, int hash, int hashShift) {
223202
assert hashShift <= 25;
224203
if (part == null) {
@@ -314,6 +293,7 @@ private static TreePart bitmapWithoutKey(BitmapPart existing, Object key, int ha
314293
return new BitmapPart(newElems, existing.bitmap);
315294
}
316295

296+
@CompilerDirectives.TruffleBoundary
317297
private static TreePart partWithoutKey(TreePart root, Object key, int hash, int hashShift) {
318298
if (root == null) {
319299
return null;
@@ -391,6 +371,10 @@ public Hamt without(Object key, int hash) {
391371
return new Hamt(partWithoutKey(root, key, hash, 0));
392372
}
393373

374+
private interface TreePart {
375+
String dump(int indent);
376+
}
377+
394378
private static final class BitmapPart implements TreePart {
395379
final int bitmap;
396380
final TreePart[] elems;
@@ -459,4 +443,22 @@ public String dump(int indent) {
459443
return result.toString();
460444
}
461445
}
446+
447+
@CompilerDirectives.ValueType
448+
public static final class Entry implements TreePart {
449+
final Object key;
450+
final int hash;
451+
final Object value;
452+
453+
public Entry(Object key, int hash, Object value) {
454+
this.key = key;
455+
this.hash = hash & 0x3FFFFFFF; // 30 bits
456+
this.value = value;
457+
}
458+
459+
@Override
460+
public String dump(int indent) {
461+
return " ".repeat(indent) + String.format("%s : %s (%d)\n", key, value, hash);
462+
}
463+
}
462464
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/PContextVar.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242

4343
import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject;
4444
import com.oracle.graal.python.runtime.PythonContext;
45-
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
4645
import com.oracle.truffle.api.object.Shape;
4746
import com.oracle.truffle.api.strings.TruffleString;
4847

@@ -72,12 +71,10 @@ public Object getDefault() {
7271
return def;
7372
}
7473

75-
@TruffleBoundary
7674
public Object getValue(PythonContext.PythonThreadState state) {
7775
return state.getContextVarsContext().contextVarValues.lookup(this, getHash());
7876
}
7977

80-
@TruffleBoundary
8178
public void setValue(PythonContext.PythonThreadState state, Object value) {
8279
PContextVarsContext current = state.getContextVarsContext();
8380
current.contextVarValues = current.contextVarValues.withEntry(new Hamt.Entry(this, getHash(), value));

0 commit comments

Comments
 (0)