Author: Lars Wassermann <[email protected]>
Branch: 
Changeset: r162:52374f03b7ac
Date: 2013-03-11 00:23 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/52374f03b7ac/

Log:    removed version from methoddict added back link from methoddict to
        s_class to change s_class version when s_methoddict changes removed
        synchronize methods in favor of update methods removed the elidable
        annotations, resulting in horrible traces for this version the
        idea is that promoting the class version is sufficient for elidable
        lookups for that, only subclass links are missing

diff --git a/spyvm/model.py b/spyvm/model.py
--- a/spyvm/model.py
+++ b/spyvm/model.py
@@ -335,7 +335,7 @@
             if shadow is not None:
                 raise DetachingShadowError(shadow, TheClass)
             shadow = self.attach_shadow_of_class(space, TheClass)
-            shadow.synchronize()
+            shadow.update()
         return shadow
 
     def get_shadow(self, space):
diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -23,7 +23,7 @@
     def getname(self):
         return repr(self)
     def attach_shadow(self): pass
-    def synchronize(self): pass
+    def update(self): pass
 
 class AbstractCachingShadow(AbstractShadow):
     _immutable_fields_ = ['version?']
@@ -42,9 +42,6 @@
         object changes."""
         self.sync_cache()
 
-    def synchronize(self):
-        self.update()
-
     def sync_cache(self):
         raise NotImplementedError()
 
@@ -139,6 +136,7 @@
         assert isinstance(w_methoddict, model.W_PointersObject)
         if not w_methoddict.is_same_object(self.space.w_nil):
             self._s_methoddict = 
w_methoddict.as_methoddict_get_shadow(self.space)
+            self._s_methoddict.s_class = self
 
         w_superclass = w_self._fetch(constants.CLASS_SUPERCLASS_INDEX)
         if w_superclass.is_same_object(self.space.w_nil):
@@ -195,7 +193,6 @@
         return self.w_self()._fetch(constants.CLASS_METHODDICT_INDEX)
 
     def s_methoddict(self):
-        jit.promote(self._s_methoddict.version)
         return self._s_methoddict
 
     def s_superclass(self):
@@ -292,27 +289,22 @@
             method = w_method.as_compiledmethod_get_shadow(self.space)
             method.w_compiledin = self.w_self()
 
-class MethodDictionaryShadow(AbstractCachingShadow):
+class MethodDictionaryShadow(AbstractShadow):
 
-    _immutable_fields_ = ['invalid?']
+    _immutable_fields_ = ['invalid?', 's_class']
     _attr_ = ['methoddict']
 
     def __init__(self, space, w_self):
         self.invalid = True
+        self.s_class = None
         self.methoddict = {}
-        AbstractCachingShadow.__init__(self, space, w_self)
+        AbstractShadow.__init__(self, space, w_self)
 
     def find_selector(self, w_selector):
         assert not self.invalid
-        jit.promote(self)
-        version = self.version
-        jit.promote(version)
-        return self._safe_find_selector(w_selector, version)
+        return self.methoddict.get(w_selector, None)
 
-    @jit.elidable
-    def _safe_find_selector(self, w_selector, version):
-        assert version is self.version
-        return self.methoddict.get(w_selector, None)
+    def update(self): return self.sync_cache()
 
     # Remove update call for changes to ourselves:
     # Whenever a method is added, it's keyword is added to w_self, then the
@@ -347,7 +339,8 @@
                 self.methoddict[w_selector] = w_compiledmethod
                 selector = w_selector.as_string()
                 w_compiledmethod._likely_methodname = selector
-        self.version = Version()
+        if self.s_class:
+            self.s_class.version = Version()
         self.invalid = False
 
 
diff --git a/spyvm/test/test_shadow.py b/spyvm/test/test_shadow.py
--- a/spyvm/test/test_shadow.py
+++ b/spyvm/test/test_shadow.py
@@ -248,8 +248,8 @@
             or s_class.lookup(key) is bar.as_compiledmethod_get_shadow(space))
     # change that entry
     w_array = s_class.w_methoddict()._fetch(constants.METHODDICT_VALUES_INDEX)
-    version = s_methoddict.version
+    version = s_class.version
     w_array.atput0(space, i, baz)
 
     assert s_class.lookup(key) is baz.as_compiledmethod_get_shadow(space)
-    assert version is not s_methoddict.version
\ No newline at end of file
+    assert version is not s_class.version
\ No newline at end of file
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to