Author: Lars Wassermann <[email protected]>
Branch: 
Changeset: r160:9d99442f994d
Date: 2013-03-10 20:48 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/9d99442f994d/

Log:    refactored ClassShadow to hold onto s_methoddict instead of
        w_methoddict

diff --git a/spyvm/objspace.py b/spyvm/objspace.py
--- a/spyvm/objspace.py
+++ b/spyvm/objspace.py
@@ -299,7 +299,7 @@
     s.version = shadow.Version()
     s.instance_size = instsize
     s.instance_kind = format
-    s.w_methoddict = None
+    s._s_methoddict = None
     s.instance_varsized = varsized or format != shadow.POINTERS
     w_class.store_shadow(s)
     return w_class
diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -74,10 +74,10 @@
     (i.e. used as the class of another Smalltalk object).
     """
 
-    _attr_ = ["name", "instance_size", "instance_varsized", "instance_kind", 
"w_methoddict", "s_methoddict", "_s_superclass"]
+    _attr_ = ["name", "instance_size", "instance_varsized", "instance_kind", 
"_s_methoddict", "_s_superclass"]
 
     def __init__(self, space, w_self):
-        # fields added here should also be in objspace.py:60ff, 300ff
+        # fields added here should also be in objspace.py:56ff, 300ff
         self.name = ''
         AbstractCachingShadow.__init__(self, space, w_self)
 
@@ -137,7 +137,8 @@
         # read the methoddict
         w_methoddict = w_self._fetch(constants.CLASS_METHODDICT_INDEX)
         assert isinstance(w_methoddict, model.W_PointersObject)
-        self.w_methoddict = w_methoddict
+        if not w_methoddict.is_same_object(self.space.w_nil):
+            self._s_methoddict = 
w_methoddict.as_methoddict_get_shadow(self.space)
 
         w_superclass = w_self._fetch(constants.CLASS_SUPERCLASS_INDEX)
         if w_superclass.is_same_object(self.space.w_nil):
@@ -191,7 +192,8 @@
         return w_new
 
     def s_methoddict(self):
-        return 
jit.promote(self.w_methoddict.as_methoddict_get_shadow(self.space))
+        jit.promote(self._s_methoddict.version)
+        return self._s_methoddict
 
     def s_superclass(self):
         if self._s_superclass is None:
@@ -271,9 +273,10 @@
 
     def initialize_methoddict(self):
         "NOT_RPYTHON"     # this is only for testing.
-        if self.w_methoddict is None:
-            self.w_methoddict = model.W_PointersObject(None, 2)
-            self.w_methoddict._store(1, model.W_PointersObject(None, 0))
+        if self._s_methoddict is None:
+            w_methoddict = model.W_PointersObject(None, 2)
+            w_methoddict._store(1, model.W_PointersObject(None, 0))
+            self._s_methoddict = 
w_methoddict.as_methoddict_get_shadow(self.space)
             self.s_methoddict().sync_cache()
         self.s_methoddict().invalid = False
 
@@ -316,10 +319,9 @@
         AbstractShadow.store(self, n0, w_value)
         self.invalid = True
 
-    def update(self):
-        self.sync_cache()
-
     def sync_cache(self):
+        if self.w_self().size() == 0:
+            return
         w_values = self.w_self()._fetch(constants.METHODDICT_VALUES_INDEX)
         assert isinstance(w_values, model.W_PointersObject)
         s_values = w_values.as_observed_get_shadow(self.space)
@@ -991,4 +993,7 @@
     def notify(self, dependent):
         if self.dependent is not None and dependent is not self.dependent:
             raise RuntimeError('Meant to be observed by only one value, so 
far')
-        self.dependent = dependent
\ No newline at end of file
+        self.dependent = dependent
+
+    def update(self): pass
+    
\ No newline at end of file
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to