Skip to content

Commit c3d8a6d

Browse files
committed
IsBuiltinClassProfile as node
1 parent ea88383 commit c3d8a6d

36 files changed

+113
-123
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2020, Oracle and/or its affiliates.
33
* Copyright (c) 2013, Regents of the University of California
44
*
55
* All rights reserved.
@@ -75,7 +75,7 @@ public void loopWithOnlyStop() throws UnexpectedResultException {
7575
Object iter = getIter.executeWith(null, range);
7676
GetNextNode next = GetNextNode.create();
7777
testRoot.doInsert(next);
78-
IsBuiltinClassProfile errorProfile = IsBuiltinClassProfile.create();
78+
IsBuiltinClassProfile errorProfile = IsBuiltinClassProfile.getUncached();
7979

8080
while (true) {
8181
try {
@@ -99,7 +99,7 @@ public void loopWithStep() throws UnexpectedResultException {
9999
Object iter = getIter.executeWith(null, range);
100100
GetNextNode next = GetNextNode.create();
101101
testRoot.doInsert(next);
102-
IsBuiltinClassProfile errorProfile = IsBuiltinClassProfile.create();
102+
IsBuiltinClassProfile errorProfile = IsBuiltinClassProfile.getUncached();
103103

104104
while (true) {
105105
try {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public void initialize(PythonCore core) {
236236

237237
@TypeSystemReference(PythonArithmeticTypes.class)
238238
protected abstract static class CreateByteOrByteArrayNode extends PythonBuiltinNode {
239-
private final IsBuiltinClassProfile isClassProfile = IsBuiltinClassProfile.create();
239+
@Child private IsBuiltinClassProfile isClassProfile = IsBuiltinClassProfile.create();
240240

241241
@SuppressWarnings("unused")
242242
protected Object create(LazyPythonClass cls, byte[] barr) {
@@ -347,8 +347,8 @@ public abstract static class ComplexNode extends PythonBuiltinNode {
347347

348348
@Child private LookupAndCallUnaryNode callComplexFunc;
349349

350-
private final IsBuiltinClassProfile isPrimitiveProfile = IsBuiltinClassProfile.create();
351-
@CompilationFinal private IsBuiltinClassProfile isComplexTypeProfile;
350+
@Child private IsBuiltinClassProfile isPrimitiveProfile = IsBuiltinClassProfile.create();
351+
@Child private IsBuiltinClassProfile isComplexTypeProfile;
352352

353353
private PComplex createComplex(LazyPythonClass cls, double real, double imaginary) {
354354
if (isPrimitiveProfile.profileClass(cls, PythonBuiltinClassType.PComplex)) {
@@ -525,7 +525,7 @@ PComplex complexFromString(LazyPythonClass cls, String real, Object imaginary) {
525525
private IsBuiltinClassProfile getIsComplexTypeProfile() {
526526
if (isComplexTypeProfile == null) {
527527
CompilerDirectives.transferToInterpreterAndInvalidate();
528-
isComplexTypeProfile = IsBuiltinClassProfile.create();
528+
isComplexTypeProfile = insert(IsBuiltinClassProfile.create());
529529
}
530530
return isComplexTypeProfile;
531531
}
@@ -889,8 +889,8 @@ public Object reversed(VirtualFrame frame, LazyPythonClass cls, Object sequence,
889889
public abstract static class FloatNode extends PythonBuiltinNode {
890890
@Child private BytesNodes.ToBytesNode toByteArrayNode;
891891

892-
private final IsBuiltinClassProfile isPrimitiveProfile = IsBuiltinClassProfile.create();
893-
@CompilationFinal private ConditionProfile isNanProfile;
892+
@Child private IsBuiltinClassProfile isPrimitiveProfile = IsBuiltinClassProfile.create();
893+
private ConditionProfile isNanProfile;
894894

895895
public abstract Object executeWith(VirtualFrame frame, Object cls, Object arg);
896896

@@ -1346,7 +1346,7 @@ private static long parseLong(String arg, int base) {
13461346
return negative ? -value : value;
13471347
}
13481348

1349-
private final IsBuiltinClassProfile isPrimitiveProfile = IsBuiltinClassProfile.create();
1349+
@Child private IsBuiltinClassProfile isPrimitiveProfile = IsBuiltinClassProfile.create();
13501350

13511351
protected boolean isPrimitiveInt(LazyPythonClass cls) {
13521352
return isPrimitiveProfile.profileClass(cls, PythonBuiltinClassType.PInt);
@@ -1861,7 +1861,7 @@ public PSet listObject(@SuppressWarnings("unused") Object cls, Object arg) {
18611861
public abstract static class StrNode extends PythonBuiltinNode {
18621862
@Child private LookupAndCallTernaryNode callDecodeNode;
18631863

1864-
private final IsBuiltinClassProfile isPrimitiveProfile = IsBuiltinClassProfile.create();
1864+
@Child private IsBuiltinClassProfile isPrimitiveProfile = IsBuiltinClassProfile.create();
18651865

18661866
@CompilationFinal private ConditionProfile isStringProfile;
18671867
@CompilationFinal private ConditionProfile isPStringProfile;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,9 +1713,9 @@ public abstract static class SumFunctionNode extends PythonBuiltinNode {
17131713
@Child private LookupAndCallUnaryNode next = LookupAndCallUnaryNode.create(__NEXT__);
17141714
@Child private LookupAndCallBinaryNode add = BinaryArithmetic.Add.create();
17151715

1716-
private final IsBuiltinClassProfile errorProfile1 = IsBuiltinClassProfile.create();
1717-
private final IsBuiltinClassProfile errorProfile2 = IsBuiltinClassProfile.create();
1718-
private final IsBuiltinClassProfile errorProfile3 = IsBuiltinClassProfile.create();
1716+
@Child private IsBuiltinClassProfile errorProfile1 = IsBuiltinClassProfile.create();
1717+
@Child private IsBuiltinClassProfile errorProfile2 = IsBuiltinClassProfile.create();
1718+
@Child private IsBuiltinClassProfile errorProfile3 = IsBuiltinClassProfile.create();
17191719

17201720
@Specialization(rewriteOn = UnexpectedResultException.class)
17211721
public int sumInt(VirtualFrame frame, Object arg1, @SuppressWarnings("unused") PNone start) throws UnexpectedResultException {

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

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@
4949
import java.io.IOException;
5050
import java.util.List;
5151

52+
import org.tukaani.xz.ARMOptions;
53+
import org.tukaani.xz.ARMThumbOptions;
54+
import org.tukaani.xz.DeltaOptions;
55+
import org.tukaani.xz.FilterOptions;
56+
import org.tukaani.xz.IA64Options;
57+
import org.tukaani.xz.LZMA2Options;
58+
import org.tukaani.xz.LZMAOutputStream;
59+
import org.tukaani.xz.PowerPCOptions;
60+
import org.tukaani.xz.SPARCOptions;
61+
import org.tukaani.xz.UnsupportedOptionsException;
62+
import org.tukaani.xz.X86Options;
63+
import org.tukaani.xz.XZ;
64+
import org.tukaani.xz.XZOutputStream;
65+
import org.tukaani.xz.check.Check;
66+
5267
import com.oracle.graal.python.builtins.Builtin;
5368
import com.oracle.graal.python.builtins.CoreFunctions;
5469
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
@@ -74,7 +89,6 @@
7489
import com.oracle.graal.python.runtime.exception.PException;
7590
import com.oracle.graal.python.util.OverflowException;
7691
import com.oracle.truffle.api.CompilerDirectives;
77-
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
7892
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
7993
import com.oracle.truffle.api.TruffleLanguage.ContextReference;
8094
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
@@ -84,21 +98,6 @@
8498
import com.oracle.truffle.api.frame.VirtualFrame;
8599
import com.oracle.truffle.api.library.CachedLibrary;
86100

87-
import org.tukaani.xz.ARMOptions;
88-
import org.tukaani.xz.ARMThumbOptions;
89-
import org.tukaani.xz.DeltaOptions;
90-
import org.tukaani.xz.FilterOptions;
91-
import org.tukaani.xz.IA64Options;
92-
import org.tukaani.xz.LZMA2Options;
93-
import org.tukaani.xz.LZMAOutputStream;
94-
import org.tukaani.xz.PowerPCOptions;
95-
import org.tukaani.xz.SPARCOptions;
96-
import org.tukaani.xz.UnsupportedOptionsException;
97-
import org.tukaani.xz.X86Options;
98-
import org.tukaani.xz.XZ;
99-
import org.tukaani.xz.XZOutputStream;
100-
import org.tukaani.xz.check.Check;
101-
102101
@CoreFunctions(defineModule = "_lzma")
103102
public class LZMAModuleBuiltins extends PythonBuiltins {
104103

@@ -175,7 +174,7 @@ abstract static class LZMANode extends PythonBuiltinNode {
175174

176175
@Child private GetItemNode getItemNode;
177176
@Child private PythonObjectLibrary castToLongNode;
178-
@CompilationFinal private IsBuiltinClassProfile keyErrorProfile;
177+
@Child private IsBuiltinClassProfile keyErrorProfile;
179178

180179
@TruffleBoundary
181180
protected static LZMA2Options parseLZMAOptions(int preset) {
@@ -273,7 +272,7 @@ private Object getItem(VirtualFrame frame, Object receiver, Object key) {
273272
private IsBuiltinClassProfile ensureKeyErrorProfile() {
274273
if (keyErrorProfile == null) {
275274
CompilerDirectives.transferToInterpreterAndInvalidate();
276-
keyErrorProfile = IsBuiltinClassProfile.create();
275+
keyErrorProfile = insert(IsBuiltinClassProfile.create());
277276
}
278277
return keyErrorProfile;
279278
}
@@ -413,7 +412,7 @@ abstract static class LZMADecompressorNode extends LZMANode {
413412

414413
@Child private GetItemNode getItemNode;
415414

416-
@CompilationFinal private IsBuiltinClassProfile keyErrorProfile;
415+
@Child private IsBuiltinClassProfile keyErrorProfile;
417416

418417
@Specialization
419418
PLZMADecompressor doCreate(VirtualFrame frame, LazyPythonClass cls, Object formatObj, Object memlimitObj, Object filters,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ abstract static class MarshallerNode extends PNodeWithState {
231231
@Child private CastToJavaStringNode castStrNode;
232232
@Child private MarshallerNode recursiveNode;
233233
private int depth = 0;
234-
private IsBuiltinClassProfile isBuiltinProfile;
234+
@Child private IsBuiltinClassProfile isBuiltinProfile;
235235

236236
protected MarshallerNode getRecursiveNode() {
237237
if (recursiveNode == null) {
@@ -521,7 +521,8 @@ void writeObject(Object v, int version, DataOutputStream buffer) {
521521
writeByte(TYPE_NONE, version, buffer);
522522
} else if (v instanceof LazyPythonClass) {
523523
if (isBuiltinProfile == null) {
524-
isBuiltinProfile = IsBuiltinClassProfile.create();
524+
CompilerDirectives.transferToInterpreterAndInvalidate();
525+
isBuiltinProfile = insert(IsBuiltinClassProfile.create());
525526
}
526527
if (isBuiltinProfile.profileClass(v, PythonBuiltinClassType.StopIteration)) {
527528
writeByte(TYPE_STOPITER, version, buffer);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PEllipsis.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ public int compareTo(Object o) {
6565
return this.hashCode() - o.hashCode();
6666
}
6767

68-
@Override
69-
public Object getInternalLazyPythonClass() {
70-
return getLazyPythonClass();
71-
}
72-
7368
@Override
7469
@ExportMessage
7570
@SuppressWarnings("static-method")

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PNone.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ static boolean isNull(@SuppressWarnings("unused") PNone self) {
5959
return true;
6060
}
6161

62-
@Override
63-
public Object getInternalLazyPythonClass() {
64-
return getLazyPythonClass();
65-
}
66-
6762
@Override
6863
@ExportMessage
6964
@SuppressWarnings("static-method")

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PNotImplemented.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ public int compareTo(Object o) {
4949
return this.hashCode() - o.hashCode();
5050
}
5151

52-
@Override
53-
public Object getInternalLazyPythonClass() {
54-
return getLazyPythonClass();
55-
}
56-
5752
@Override
5853
@ExportMessage
5954
@SuppressWarnings("static-method")

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cell/PCell.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@ public int compareTo(Object o) {
115115
throw new UnsupportedOperationException();
116116
}
117117

118-
@Override
119-
public Object getInternalLazyPythonClass() {
120-
return getLazyPythonClass();
121-
}
122-
123118
@Override
124119
@ExportMessage
125120
@SuppressWarnings("static-method")

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/DynamicObjectNativeWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ static Object doTpDict(PythonManagedClass object, @SuppressWarnings("unused") Py
11201120
@Cached WriteAttributeToObjectNode writeAttrNode,
11211121
@Cached IsBuiltinClassProfile isPrimitiveDictProfile) throws UnsupportedMessageException {
11221122
Object value = asPythonObjectNode.execute(nativeValue);
1123-
if (value instanceof PDict && isPrimitiveDictProfile.profileObject((PDict) value, PythonBuiltinClassType.PDict)) {
1123+
if (value instanceof PDict && isPrimitiveDictProfile.profileObject(value, PythonBuiltinClassType.PDict)) {
11241124
// special and fast case: commit items and change store
11251125
PDict d = (PDict) value;
11261126
for (HashingStorage.DictEntry entry : d.entries()) {

0 commit comments

Comments
 (0)