Author: Lars Wassermann <[email protected]>
Branch: 
Changeset: r166:03270ab317f2
Date: 2013-03-12 18:16 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/03270ab317f2/

Log:    patched the MethodDictShadow to save compiledmethod shadows instead
        of w_compiled methods

diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -273,8 +273,7 @@
         jit.promote(self)
         version = self.version
         jit.promote(version)
-        w_method = self.safe_lookup(w_selector, version)
-        return w_method.as_compiledmethod_get_shadow(self.space)
+        return self.safe_lookup(w_selector, version)
 
     @jit.elidable
     def safe_lookup(self, w_selector, version):
@@ -282,9 +281,9 @@
         look_in_shadow = self
         jit.promote(w_selector)
         while look_in_shadow is not None:
-            w_method = look_in_shadow.s_methoddict().find_selector(w_selector)
-            if w_method is not None:
-                return w_method
+            s_method = look_in_shadow.s_methoddict().find_selector(w_selector)
+            if s_method is not None:
+                return s_method
             look_in_shadow = look_in_shadow._s_superclass
         raise MethodNotFound(self, w_selector)
 
@@ -314,10 +313,10 @@
         "NOT_RPYTHON"     # this is only for testing.
         assert not isinstance(w_selector, str)
         self.initialize_methoddict()
-        self.s_methoddict().methoddict[w_selector] = w_method
+        s_method = w_method.as_compiledmethod_get_shadow(self.space)
+        self.s_methoddict().methoddict[w_selector] = s_method
         if isinstance(w_method, model.W_CompiledMethod):
-            method = w_method.as_compiledmethod_get_shadow(self.space)
-            method.w_compiledin = self.w_self()
+            s_method.w_compiledin = self.w_self()
 
 class MethodDictionaryShadow(AbstractShadow):
 
@@ -366,7 +365,7 @@
                                        "CompiledMethods only, for now. "
                                        "If the value observed is nil, our "
                                        "invalidating mechanism may be broken.")
-                self.methoddict[w_selector] = w_compiledmethod
+                self.methoddict[w_selector] = 
w_compiledmethod.as_compiledmethod_get_shadow(self.space)
                 selector = w_selector.as_string()
                 w_compiledmethod._likely_methodname = selector
         if self.s_class:
diff --git a/spyvm/test/jit.py b/spyvm/test/jit.py
--- a/spyvm/test/jit.py
+++ b/spyvm/test/jit.py
@@ -58,7 +58,7 @@
         
         image = create_testimage(space)
         interp = interpreter.Interpreter(space, image)
-        w_selector = interp.perform(space.wrap_string('loopTest3'), "asSymbol")
+        w_selector = interp.perform(space.wrap_string('loopTest2'), "asSymbol")
         assert isinstance(w_selector, model.W_BytesObject)
         def interp_w():
             interp.perform(model.W_SmallInteger(1000), w_selector)
diff --git a/spyvm/test/test_interpreter.py b/spyvm/test/test_interpreter.py
--- a/spyvm/test/test_interpreter.py
+++ b/spyvm/test/test_interpreter.py
@@ -428,7 +428,7 @@
         assert s_active_context.w_sender() == w_frame
         assert s_active_context.stack() == []
         assert 
w_active_context.as_methodcontext_get_shadow(space).w_receiver().is_same_object(w_object)
-        assert 
w_active_context.as_methodcontext_get_shadow(space).w_method().is_same_object(shadow.s_methoddict().methoddict[w_foo])
+        assert 
w_active_context.as_methodcontext_get_shadow(space).w_method().is_same_object(shadow.s_methoddict().methoddict[w_foo].w_self())
         assert s_frame.stack() == []
         step_in_interp(s_active_context)
         w_active_context = step_in_interp(s_active_context)
@@ -599,7 +599,7 @@
     s_frame.push(space.w_one)
     w_active_context = step_in_interp(s_frame)
     s_active_context = w_active_context.as_context_get_shadow(space)
-    assert w_active_context.as_methodcontext_get_shadow(space).w_method() == 
shadow.s_methoddict().methoddict[w_symbol]
+    assert w_active_context.as_methodcontext_get_shadow(space).s_method() == 
shadow.s_methoddict().methoddict[w_symbol]
     assert s_active_context.w_receiver() is w_object
     assert 
w_active_context.as_methodcontext_get_shadow(space).gettemp(0).is_same_object(space.w_one)
     assert s_active_context.stack() == []
@@ -660,7 +660,7 @@
         assert s_active_context.stack() == []
         assert 
w_active_context.as_methodcontext_get_shadow(space).w_receiver() == w_object
         meth = 
w_specificclass.as_class_get_shadow(space).s_methoddict().methoddict[foo]
-        assert s_active_context.w_method() == meth
+        assert s_active_context.w_method() == meth.w_self()
         assert s_caller_context.stack() == []
 
 def test_secondExtendedSendBytecode():
diff --git a/spyvm/test/test_miniimage.py b/spyvm/test/test_miniimage.py
--- a/spyvm/test/test_miniimage.py
+++ b/spyvm/test/test_miniimage.py
@@ -298,9 +298,6 @@
     perform(w(10).getclass(space), "compile:classified:notifying:", 
w(sourcecode), w('pypy'), w(None))
     assert perform(w(10), "fib").is_same_object(w(89))
 
-def test_get_env():
-    import pdb; pdb.set_trace()
-
 def test_step_run_something():
     from spyvm.test import test_miniimage
     setup_module(test_miniimage, filename='running-something-mini.image')
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
@@ -73,7 +73,7 @@
     methoddict = classshadow.s_methoddict().methoddict
     assert len(methods) == len(methoddict)
     for w_key, value in methoddict.items():
-        assert methods[w_key.as_string()] is value
+        assert methods[w_key.as_string()].as_compiledmethod_get_shadow(space) 
is value
 
 def method(tempsize=3,argsize=2, bytes="abcde"):
     w_m = model.W_CompiledMethod()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to