Skip to content

Commit 1632b5d

Browse files
committed
make PythonObject.storage field final
1 parent 0149964 commit 1632b5d

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/PythonBuiltinObject.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public abstract class PythonBuiltinObject extends PythonObject {
4343

4444
public PythonBuiltinObject(PythonClass cls) {
4545
super(cls);
46-
assert cls != null : getClass().getSimpleName();
4746
}
4847

4948
private boolean isBuiltin() {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/PythonObject.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import com.oracle.graal.python.builtins.objects.type.PythonClass;
4141
import com.oracle.truffle.api.CompilerAsserts;
4242
import com.oracle.truffle.api.CompilerDirectives;
43-
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
4443
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
4544
import com.oracle.truffle.api.object.DynamicObject;
4645
import com.oracle.truffle.api.object.Location;
@@ -49,23 +48,24 @@
4948

5049
public class PythonObject extends PythonAbstractObject {
5150
protected final PythonClass pythonClass;
52-
@CompilationFinal protected DynamicObject storage;
51+
protected final DynamicObject storage;
5352
private PDict dict;
5453

5554
public PythonObject(PythonClass pythonClass) {
55+
assert pythonClass != null : getClass().getSimpleName();
56+
this.pythonClass = pythonClass;
57+
storage = pythonClass.getInstanceShape().newInstance();
58+
}
59+
60+
public PythonObject(PythonClass pythonClass, Shape instanceShape) {
5661
if (pythonClass == null) {
5762
CompilerDirectives.transferToInterpreter();
5863
// special case for base type class
5964
assert this instanceof PythonBuiltinClass;
6065
this.pythonClass = (PythonClass) this;
6166
} else {
6267
this.pythonClass = pythonClass;
63-
storage = pythonClass.getInstanceShape().newInstance();
6468
}
65-
}
66-
67-
public PythonObject(PythonClass pythonClass, Shape instanceShape) {
68-
this.pythonClass = pythonClass;
6969
storage = instanceShape.newInstance();
7070
}
7171

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/PythonClass.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public final boolean isBuiltin() {
7373

7474
@TruffleBoundary
7575
public PythonClass(PythonClass typeClass, String name, PythonClass... baseClasses) {
76-
super(typeClass);
76+
super(typeClass, freshShape() /* do not inherit layout from the TypeClass */);
7777
this.className = name;
7878
this.lookupStableAssumption = new CyclicAssumption(className);
7979

@@ -89,8 +89,6 @@ public PythonClass(PythonClass typeClass, String name, PythonClass... baseClasse
8989
// Compute MRO
9090
computeMethodResolutionOrder();
9191

92-
// do not inherit layout from the TypeClass.
93-
storage = freshShape().newInstance();
9492
setAttribute(__NAME__, getBaseName(name));
9593
setAttribute(__QUALNAME__, className);
9694
setAttribute(__DOC__, PNone.NONE);

0 commit comments

Comments
 (0)