@@ -78,12 +78,12 @@ public void postInitialize(Python3Core core) {
7878 structModule .setModuleState (cache );
7979 }
8080
81- protected static PStruct getStruct (PythonModule structModule , Object format , StructBuiltins .ConstructStructNode constructStructNode ) {
81+ protected static PStruct getStruct (Node location , PythonModule structModule , Object format , StructBuiltins .ConstructStructNode constructStructNode ) {
8282 LRUStructCache cache = structModule .getModuleState (LRUStructCache .class );
83- PStruct pStruct = cache .get (format );
83+ PStruct pStruct = cache .get (location , format );
8484 if (pStruct == null ) {
8585 pStruct = constructStructNode .execute (format );
86- cache .put (format , pStruct );
86+ cache .put (location , format , pStruct );
8787 }
8888 return pStruct ;
8989 }
@@ -94,8 +94,8 @@ protected static PStruct getStruct(PythonModule structModule, Object format, Str
9494 abstract static class GetStructNode extends PNodeWithContext {
9595 abstract PStruct execute (Node inliningTarget , PythonModule module , Object format , StructBuiltins .ConstructStructNode constructStructNode );
9696
97- protected PStruct getStructInternal (PythonModule module , Object format , StructBuiltins .ConstructStructNode constructStructNode ) {
98- return getStruct (module , format , constructStructNode );
97+ protected PStruct getStructInternal (Node location , PythonModule module , Object format , StructBuiltins .ConstructStructNode constructStructNode ) {
98+ return getStruct (location , module , format , constructStructNode );
9999 }
100100
101101 protected boolean eq (TruffleString s1 , TruffleString s2 , TruffleString .EqualNode eqNode ) {
@@ -107,7 +107,7 @@ protected boolean eq(TruffleString s1, TruffleString s2, TruffleString.EqualNode
107107 static PStruct doCachedString (PythonModule module , TruffleString format , StructBuiltins .ConstructStructNode constructStructNode ,
108108 @ Cached ("format" ) TruffleString cachedFormat ,
109109 @ Cached TruffleString .EqualNode eqNode ,
110- @ Cached (value = "getStructInternal(module, format, constructStructNode)" , weak = true ) PStruct cachedStruct ) {
110+ @ Cached (value = "getStructInternal($node, module, format, constructStructNode)" , weak = true ) PStruct cachedStruct ) {
111111 return cachedStruct ;
112112 }
113113
@@ -116,13 +116,14 @@ static PStruct doCachedString(PythonModule module, TruffleString format, StructB
116116 static PStruct doCachedBytes (PythonModule module , PBytes format , StructBuiltins .ConstructStructNode constructStructNode ,
117117 @ CachedLibrary ("format" ) PythonBufferAccessLibrary bufferLib ,
118118 @ Cached (value = "bufferLib.getCopiedByteArray(format)" , dimensions = 1 ) byte [] cachedFormat ,
119- @ Cached (value = "getStructInternal(module, format, constructStructNode)" , weak = true ) PStruct cachedStruct ) {
119+ @ Cached (value = "getStructInternal($node, module, format, constructStructNode)" , weak = true ) PStruct cachedStruct ) {
120120 return cachedStruct ;
121121 }
122122
123123 @ Specialization (replaces = {"doCachedString" , "doCachedBytes" })
124- static PStruct doGeneric (PythonModule module , Object format , StructBuiltins .ConstructStructNode constructStructNode ) {
125- return getStruct (module , format , constructStructNode );
124+ static PStruct doGeneric (PythonModule module , Object format , StructBuiltins .ConstructStructNode constructStructNode ,
125+ @ Bind Node location ) {
126+ return getStruct (location , module , format , constructStructNode );
126127 }
127128 }
128129
@@ -241,7 +242,7 @@ abstract static class ClearCacheNode extends PythonUnaryBuiltinNode {
241242 @ Specialization
242243 Object clearCache (PythonModule self ) {
243244 LRUStructCache cache = self .getModuleState (LRUStructCache .class );
244- cache .clear ();
245+ cache .clear (this );
245246 return PNone .NONE ;
246247 }
247248 }
0 commit comments