reverse class order for instvar indexing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

reverse class order for instvar indexing

S11001001
I was getting instvar indexing conflicts (different classes would choose
instvar 0 for different instvars) in Compiler until the attached tiny
patch to STSymbolTable>>#declareEnvironment:.  Iterating from the other
end of the inheritance tree seems to be what is intended by the readOnly
calculation semantics, anyway.

--
Stephen Compall
http://scompall.nocandysw.com/blog

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

gst-reverse-instVar-indexing.diff (518 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: reverse class order for instvar indexing

Paolo Bonzini
Stephen Compall wrote:
> I was getting instvar indexing conflicts (different classes would choose
> instvar 0 for different instvars) in Compiler until the attached tiny
> patch to STSymbolTable>>#declareEnvironment:.  Iterating from the other
> end of the inheritance tree seems to be what is intended by the readOnly
> calculation semantics, anyway.

Applied the patch, and reworked the readOnly stuff to be correct.  See
the equivalent snippet of libgst/sym.c, where if the method is trusted
all variables are read-write (in is_instance_variable_read_only).

@@ -157,18 +157,19 @@ addPool: poolDictionary

  declareEnvironment: aBehavior

-    | i readOnly |
+    | i canAlwaysStore inSandbox |
      environment := aBehavior.
+    inSandbox := thisContext isUntrusted.

      i := -1.
-    readOnly := aBehavior isUntrusted not and: [ thisContext isUntrusted ].
-    aBehavior withAllSuperclassesDo: [ :class |
-       readOnly := readOnly and: [ class isUntrusted not ].
+    canAlwaysStore := aBehavior isUntrusted.
+    aBehavior withAllSuperclasses reverseDo: [ :class |
+       canAlwaysStore := canAlwaysStore and: [ class isUntrusted ].
         class instVarNames do: [ :iv |
             instVars at: iv asSymbol put: (STVariable
                 id: (i := i + 1)
                 scope: 0
-               canStore: readOnly not).
+               canStore: (canAlwaysStore or: [ inSandbox not ])).
         ].
      ].
      self declareGlobals

Paolo



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk