Author: Lars Wassermann <[email protected]>
Branch: 
Changeset: r118:20243a9dbe6b
Date: 2013-03-04 17:40 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/20243a9dbe6b/

Log:    added some annotations and temporary variables to enable
        virtualizable contexts added comments which include the code for
        virtualizables. unfortunately, the return-implementations forbids
        virtualizables

diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -29,6 +29,7 @@
     jit_driver = jit.JitDriver(
         greens=['pc', 'self', 'method'],
         reds=['s_active_context', 'w_active_context'],
+        #virtualizables=['s_active_context'],
         get_printable_location=get_printable_location
     )
     
@@ -695,7 +696,7 @@
         prefix = "el"
     code.append("bytecode_step_translated._always_inline_ = True")
     source = py.code.Source("\n".join(code))
-    print source
+    #print source
     miniglob = {}
     exec source.compile() in miniglob
     return miniglob["bytecode_step_translated"]
diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -312,6 +312,12 @@
 
     __metaclass__ = extendabletype
 
+    # _virtualizable2_ = [
+    #     "_w_sender", "_pc", "_w_sender",
+    #     "_temps_and_stack[*]", "_stack_ptr",
+    #     "_w_self", "_w_self_size"
+    # ]
+
     def __init__(self, space, w_self):
 
         self._w_sender = space.w_nil
@@ -331,7 +337,9 @@
         if n0 == constants.CTXPART_STACKP_INDEX:
             return self.wrap_stackpointer()
         if self.stackstart() <= n0 < self.external_stackpointer():
-            return self.peek(self.stackdepth() - (n0-self.stackstart()) - 1)
+            temp_i = self.stackdepth() - (n0-self.stackstart()) - 1
+            assert temp_i >= 0
+            return self.peek(temp_i)
         if self.external_stackpointer() <= n0 < self.stackend():
             return self.space.w_nil
         else:
@@ -345,10 +353,10 @@
             return self.store_unwrap_pc(w_value)
         if n0 == constants.CTXPART_STACKP_INDEX:
             return self.unwrap_store_stackpointer(w_value)
-        if self.stackstart() <= n0 < self.external_stackpointer():
-            return self.set_top(w_value,
-                                       self.stackdepth() - 
(n0-self.stackstart()) - 1)
-            return
+        if self.stackstart() <= n0 < self.external_stackpointer(): # XXX can 
be simplified?
+            temp_i = self.stackdepth() - (n0-self.stackstart()) - 1
+            assert temp_i >= 0
+            return self.set_top(w_value, temp_i)
         if self.external_stackpointer() <= n0 < self.stackend():
             return
         else:
@@ -553,6 +561,7 @@
         contextsize = w_home.as_methodcontext_get_shadow(space).myblocksize()
         w_result = model.W_PointersObject(space.w_BlockContext, contextsize)
         s_result = BlockContextShadow(space, w_result)
+        s_result = jit.hint(s_result, access_directly=True, 
fresh_virtualizable=True)
         w_result.store_shadow(s_result)
         s_result.store_expected_argument_count(argcnt)
         s_result.store_initialip(initialip)
@@ -581,6 +590,7 @@
         else:
             return ContextPartShadow.store(self, n0, w_value)
 
+    @jit.dont_look_inside
     def attach_shadow(self):
         # Make sure the home context is updated first
         self.copy_from_w_self(constants.BLKCTX_HOME_INDEX)
@@ -637,6 +647,7 @@
 
 class MethodContextShadow(ContextPartShadow):
 
+
     def __init__(self, space, w_self):
         self.w_closure_or_nil = space.w_nil
         self._w_receiver = None
@@ -655,6 +666,8 @@
         # into the right places in the W_PointersObject
         # XXX could hack some more to never have to create the _vars of 
w_result
         s_result = MethodContextShadow(space, w_result)
+        s_result = jit.hint(s_result, access_directly=True, 
fresh_virtualizable=True)
+        
         w_result.store_shadow(s_result)
         if closure is not None: 
             s_result.w_closure_or_nil = closure._w_self
@@ -681,8 +694,9 @@
             return self.w_closure_or_nil
         if n0 == constants.MTHDCTX_RECEIVER:
             return self.w_receiver()
-        if (0 <= n0-constants.MTHDCTX_TEMP_FRAME_START < self.tempsize()):
-            return self.gettemp(n0-constants.MTHDCTX_TEMP_FRAME_START)
+        temp_i = n0-constants.MTHDCTX_TEMP_FRAME_START
+        if (0 <= temp_i < self.tempsize()):
+            return self.gettemp(temp_i)
         else:
             return ContextPartShadow.fetch(self, n0)
 
@@ -695,13 +709,13 @@
         if n0 == constants.MTHDCTX_RECEIVER:
             self.store_w_receiver(w_value)
             return
-        if (0 <= n0-constants.MTHDCTX_TEMP_FRAME_START <
-                 self.tempsize()):
-            return self.settemp(n0-constants.MTHDCTX_TEMP_FRAME_START,
-                                w_value)
+        temp_i = n0-constants.MTHDCTX_TEMP_FRAME_START
+        if (0 <=  temp_i < self.tempsize()):
+            return self.settemp(temp_i, w_value)
         else:
             return ContextPartShadow.store(self, n0, w_value)
     
+    @jit.dont_look_inside
     def attach_shadow(self):
         # Make sure the method is updated first
         self.copy_from_w_self(constants.MTHDCTX_METHOD)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to