Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit06c4313

Browse files
eregonwoess
authored andcommitted
[GR-36894] Migrate GraalPy to DynamicObject nodes
Co-authored-by: Andreas Woess <andreas.woess@oracle.com>
1 parentfa8b95e commit06c4313

File tree

15 files changed

+143
-165
lines changed

15 files changed

+143
-165
lines changed

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextNamespaceBuiltins.java‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@
6363
importcom.oracle.truffle.api.dsl.Cached;
6464
importcom.oracle.truffle.api.dsl.Cached.Shared;
6565
importcom.oracle.truffle.api.dsl.Specialization;
66-
importcom.oracle.truffle.api.library.CachedLibrary;
6766
importcom.oracle.truffle.api.nodes.Node;
68-
importcom.oracle.truffle.api.object.DynamicObjectLibrary;
67+
importcom.oracle.truffle.api.object.DynamicObject;
6968

7069
publicfinalclassPythonCextNamespaceBuiltins {
7170

@@ -78,20 +77,20 @@ static Object impDict(PDict dict,
7877
@Shared("itNext")@CachedHashingStorageIteratorNextitNext,
7978
@Shared("itKey")@CachedHashingStorageIteratorKeyitKey,
8079
@Shared("itVal")@CachedHashingStorageIteratorValueitValue,
81-
@Shared("dylib")@CachedLibrary(limit ="1")DynamicObjectLibrarydyLib) {
80+
@Shared@CachedDynamicObject.PutNodeputNode) {
8281
HashingStoragestorage =dict.getDictStorage();
83-
returnimpl(inliningTarget,storage,getIterator,itNext,itKey,itValue,dyLib);
82+
returnimpl(inliningTarget,storage,getIterator,itNext,itKey,itValue,putNode);
8483
}
8584

8685
privatestaticObjectimpl(NodeinliningTarget,HashingStoragestorage,HashingStorageGetIteratorgetIterator,HashingStorageIteratorNextitNext,
8786
HashingStorageIteratorKeyitKey,HashingStorageIteratorValueitValue,
88-
DynamicObjectLibrarydyLib) {
87+
DynamicObject.PutNodeputNode) {
8988
PSimpleNamespacens =PFactory.createSimpleNamespace(PythonLanguage.get(inliningTarget));
9089
HashingStorageNodes.HashingStorageIteratorit =getIterator.execute(inliningTarget,storage);
9190
while (itNext.execute(inliningTarget,storage,it)) {
9291
Objectkey =itKey.execute(inliningTarget,storage,it);
9392
Objectvalue =itValue.execute(inliningTarget,storage,it);
94-
dyLib.put(ns,assertNoJavaString(key),value);
93+
putNode.execute(ns,assertNoJavaString(key),value);
9594
}
9695
returnns;
9796
}
@@ -104,9 +103,9 @@ static Object impGeneric(Object dict,
104103
@Shared("itNext")@CachedHashingStorageIteratorNextitNext,
105104
@Shared("itKey")@CachedHashingStorageIteratorKeyitKey,
106105
@Shared("itVal")@CachedHashingStorageIteratorValueitValue,
107-
@Shared("dylib")@CachedLibrary(limit ="1")DynamicObjectLibrarydyLib) {
106+
@Shared@CachedDynamicObject.PutNodeputNode) {
108107
HashingStoragehs =initNode.execute(null,dict,PKeyword.EMPTY_KEYWORDS);
109-
returnimpl(inliningTarget,hs,getIterator,itNext,itKey,itValue,dyLib);
108+
returnimpl(inliningTarget,hs,getIterator,itNext,itKey,itValue,putNode);
110109
}
111110
}
112111

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextStructSeqBuiltins.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
importcom.oracle.truffle.api.interop.InteropLibrary;
9191
importcom.oracle.truffle.api.library.CachedLibrary;
9292
importcom.oracle.truffle.api.nodes.Node;
93-
importcom.oracle.truffle.api.object.DynamicObjectLibrary;
93+
importcom.oracle.truffle.api.object.DynamicObject;
9494
importcom.oracle.truffle.api.strings.TruffleString;
9595

9696
publicfinalclassPythonCextStructSeqBuiltins {
@@ -139,16 +139,17 @@ abstract static class GraalPyPrivate_StructSequence_NewType extends CApiQuaterna
139139
ObjectdoGeneric(TruffleStringtypeName,TruffleStringtypeDoc,Objectfields,intnInSequence,
140140
@CachedGraalPyPrivate_StructSequence_InitType2initNode,
141141
@CachedReadAttributeFromModuleNodereadTypeBuiltinNode,
142-
@CachedLibrary(limit ="1")DynamicObjectLibrarydylib,
142+
@CachedDynamicObject.GetShapeFlagsNodegetShapeFlagsNode,
143+
@CachedDynamicObject.SetShapeFlagsNodesetShapeFlagsNode,
143144
@CachedCallNodecallTypeNewNode,
144145
@BindPythonLanguagelanguage) {
145146
ObjecttypeBuiltin =readTypeBuiltinNode.execute(getCore().getBuiltins(),BuiltinNames.T_TYPE);
146147
PTuplebases =PFactory.createTuple(language,newObject[]{PythonBuiltinClassType.PTuple});
147148
PDictnamespace =PFactory.createDict(language,newPKeyword[]{newPKeyword(SpecialAttributeNames.T___DOC__,typeDoc)});
148149
Objectcls =callTypeNewNode.executeWithoutFrame(typeBuiltin,typeName,bases,namespace);
149150
initNode.execute(cls,fields,nInSequence);
150-
if (clsinstanceofPythonClass) {
151-
((PythonClass)cls).makeStaticBase(dylib);
151+
if (clsinstanceofPythonClasspythonClass) {
152+
pythonClass.makeStaticBase(getShapeFlagsNode,setShapeFlagsNode);
152153
}
153154
returncls;
154155
}

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextTypeBuiltins.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@
126126
importcom.oracle.truffle.api.nodes.Node;
127127
importcom.oracle.truffle.api.nodes.RootNode;
128128
importcom.oracle.truffle.api.object.DynamicObject;
129-
importcom.oracle.truffle.api.object.DynamicObjectLibrary;
130129
importcom.oracle.truffle.api.object.Shape;
131130
importcom.oracle.truffle.api.strings.TruffleString;
132131
importcom.oracle.truffle.api.utilities.CyclicAssumption;
@@ -143,7 +142,8 @@ Object doGeneric(Object type, Object name,
143142
@CachedPythonCextBuiltins.PromoteBorrowedValuepromoteBorrowedValue,
144143
@CachedCStructAccess.ReadObjectNodegetNativeDict,
145144
@CachedGetDictIfExistsNodegetDictIfExistsNode,
146-
@CachedLibrary(limit ="3")DynamicObjectLibrarydylib,
145+
@CachedDynamicObject.GetNodegetNode,
146+
@CachedDynamicObject.PutNodeputNode,
147147
@CachedPyDictGetItemgetItem,
148148
@CachedPyDictSetItemsetItem) {
149149
TruffleStringkey =castToTruffleStringNode.castKnownString(inliningTarget,name);
@@ -165,15 +165,15 @@ Object doGeneric(Object type, Object name,
165165
}
166166
Objectvalue;
167167
if (dict ==null) {
168-
value =dylib.getOrDefault((DynamicObject)cls,key,null);
168+
value =getNode.execute((PythonManagedClass)cls,key,null);
169169
}else {
170170
value =getItem.execute(null,inliningTarget,dict,key);
171171
}
172172
if (value !=null &&value !=PNone.NO_VALUE) {
173173
Objectpromoted =promoteBorrowedValue.execute(inliningTarget,value);
174174
if (promoted !=null) {
175175
if (dict ==null) {
176-
dylib.put((DynamicObject)cls,key,promoted);
176+
putNode.execute((PythonManagedClass)cls,key,promoted);
177177
}else {
178178
setItem.execute(null,inliningTarget,dict,key,promoted);
179179
}

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/DynamicObjectStorage.java‎

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,14 @@
6868
importcom.oracle.truffle.api.dsl.GenerateInline;
6969
importcom.oracle.truffle.api.dsl.GenerateUncached;
7070
importcom.oracle.truffle.api.dsl.ImportStatic;
71-
importcom.oracle.truffle.api.dsl.NeverDefault;
7271
importcom.oracle.truffle.api.dsl.Specialization;
7372
importcom.oracle.truffle.api.frame.Frame;
74-
importcom.oracle.truffle.api.library.CachedLibrary;
7573
importcom.oracle.truffle.api.nodes.ExplodeLoop;
7674
importcom.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind;
7775
importcom.oracle.truffle.api.nodes.Node;
7876
importcom.oracle.truffle.api.object.DynamicObject;
79-
importcom.oracle.truffle.api.object.DynamicObjectLibrary;
8077
importcom.oracle.truffle.api.object.Shape;
78+
importcom.oracle.truffle.api.profiles.InlinedBranchProfile;
8179
importcom.oracle.truffle.api.profiles.InlinedConditionProfile;
8280
importcom.oracle.truffle.api.strings.TruffleString;
8381

@@ -277,8 +275,8 @@ private static boolean hasNext(Iterator<Object> keys) {
277275
}
278276
}
279277

280-
voidsetStringKey(TruffleStringkey,Objectvalue,DynamicObjectLibrarydylib) {
281-
dylib.put(store,key,assertNoJavaString(value));
278+
voidsetStringKey(TruffleStringkey,Objectvalue,DynamicObject.PutNodeputNode) {
279+
putNode.execute(store,key,assertNoJavaString(value));
282280
}
283281

284282
booleanshouldTransitionOnPut() {
@@ -298,8 +296,8 @@ abstract static class ClearNode extends Node {
298296

299297
@Specialization(guards ="!isPythonObject(receiver.getStore())")
300298
staticHashingStorageclearPlain(DynamicObjectStoragereceiver,
301-
@CachedLibrary(limit ="3")DynamicObjectLibrarydylib) {
302-
dylib.resetShape(receiver.getStore(),PythonLanguage.get(dylib).getEmptyShape());
299+
@CachedDynamicObject.ResetShapeNoderesetShapeNode) {
300+
resetShapeNode.execute(receiver.getStore(),PythonLanguage.get(resetShapeNode).getEmptyShape());
303301
returnreceiver;
304302
}
305303

@@ -327,39 +325,12 @@ static HashingStorage clearObjectBacked(Node inliningTarget, DynamicObjectStorag
327325
abstractstaticclassCopyextendsNode {
328326
abstractDynamicObjectStorageexecute(Nodenode,DynamicObjectStoragereceiver);
329327

330-
@NeverDefault
331-
staticDynamicObjectLibrary[]createAccess(intlength) {
332-
DynamicObjectLibrary[]result =newDynamicObjectLibrary[length];
333-
for (inti =0;i <length;i++) {
334-
result[i] =DynamicObjectLibrary.getFactory().createDispatched(1);
335-
}
336-
returnresult;
337-
}
338-
339-
@ExplodeLoop
340-
@Specialization(limit ="1",guards = {"cachedLength < EXPLODE_LOOP_SIZE_LIMIT","keys.length == cachedLength"})
328+
@Specialization
341329
publicstaticDynamicObjectStoragecopy(DynamicObjectStoragereceiver,
342-
@SuppressWarnings("unused")@Bind("receiver.store")DynamicObjectstore,
343-
@SuppressWarnings("unused")@CachedLibrary("store")DynamicObjectLibrarydylib,
344-
@Bind("dylib.getKeyArray(store)")Object[]keys,
345-
@Cached(value ="keys.length")intcachedLength,
346-
@Cached("createAccess(cachedLength)")DynamicObjectLibrary[]readLib,
347-
@Cached("createAccess(cachedLength)")DynamicObjectLibrary[]writeLib) {
348-
DynamicObjectcopy =newStore(PythonLanguage.get(dylib).getEmptyShape());
349-
for (inti =0;i <cachedLength;i++) {
350-
writeLib[i].put(copy,keys[i],readLib[i].getOrDefault(receiver.store,keys[i],PNone.NO_VALUE));
351-
}
352-
returnnewDynamicObjectStorage(copy);
353-
}
354-
355-
@Specialization(replaces ="copy")
356-
publicstaticDynamicObjectStoragecopyGeneric(DynamicObjectStoragereceiver,
357-
@CachedLibrary(limit ="3")DynamicObjectLibrarydylib) {
358-
DynamicObjectcopy =newStore(PythonLanguage.get(dylib).getEmptyShape());
359-
Object[]keys =dylib.getKeyArray(receiver.store);
360-
for (Objectkey :keys) {
361-
dylib.put(copy,key,dylib.getOrDefault(receiver.store,key,PNone.NO_VALUE));
362-
}
330+
@BindNodeinliningTarget,
331+
@CachedDynamicObject.CopyPropertiesNodecopyPropertiesNode) {
332+
DynamicObjectcopy =newStore(PythonLanguage.get(inliningTarget).getEmptyShape());
333+
copyPropertiesNode.execute(receiver.store,copy);
363334
returnnewDynamicObjectStorage(copy);
364335
}
365336
}
@@ -369,9 +340,10 @@ public static DynamicObjectStorage copyGeneric(DynamicObjectStorage receiver,
369340
@GenerateCached(false)
370341
publicabstractstaticclassDynamicObjectStorageSetStringKeyextendsSpecializedSetStringKey {
371342
@Specialization
372-
staticvoiddoIt(HashingStorageself,TruffleStringkey,Objectvalue,
373-
@CachedLibrary(limit ="3")DynamicObjectLibrarydylib) {
374-
((DynamicObjectStorage)self).setStringKey(key,value,dylib);
343+
staticvoiddoIt(NodeinliningTarget,HashingStorageself,TruffleStringkey,Objectvalue,
344+
@CachedDynamicObject.PutNodeputNode,
345+
@CachedInlinedBranchProfileinvalidateMro) {
346+
((DynamicObjectStorage)self).setStringKey(key,value,putNode);
375347
}
376348
}
377349
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp