Commits

Armin Rigo committed b749e3d

Another round of fixes for the front-end, getting close.

  • Participants
  • Parent commits d994a82
  • Branches remove-globals-in-jit

Comments (0)

Files changed (4)

File pypy/jit/backend/llgraph/runner.py

         def reset_vable(jd, vable):
             if jd.index_of_virtualizable != -1:
                 fielddescr = jd.vable_token_descr
-                do_setfield_gc_int(vable, fielddescr.ofs, 0)
+                self.cpu.bh_setfield_gc(vable, 0, fielddescr)
         faildescr = self.cpu.get_latest_descr(pframe)
         failindex = self.cpu.get_fail_descr_number(faildescr)
         if failindex == self.cpu.done_with_this_frame_int_v:
         try:
             return assembler_helper_ptr(pframe, vable)
         except LLException, lle:
-            assert _last_exception is None, "exception left behind"
-            _last_exception = lle
+            assert self.last_exception is None, "exception left behind"
+            self.last_exception = lle
             # fish op
-            xxxxxxxxxxxx
-            op = self.loop.operations[self.opindex]
-            if op.result is not None:
-                return 0
+            op = self.current_op
+            return op.result and op.result.value
 
     def execute_same_as(self, _, x):
         return x
     def execute_cond_call_gc_wb_array(self, descr, a, b, c):
         py.test.skip("cond_call_gc_wb_array not supported")
 
+    def execute_keepalive(self, descr, x):
+        pass
+
 def _getdescr(op):
     d = op.getdescr()
     if d is not None:

File pypy/jit/metainterp/compile.py

 from pypy.objspace.flow.model import Constant, Variable
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.debug import debug_start, debug_stop, debug_print
-from pypy.rlib import rstack
+from pypy.rlib import rstack, rerased
 from pypy.rlib.jit import JitDebugInfo, Counters
 from pypy.conftest import option
 from pypy.tool.sourcetools import func_with_new_name
         # the virtualrefs and virtualizable have been forced by
         # handle_async_forcing() just a moment ago.
         from pypy.jit.metainterp.blackhole import resume_in_blackhole
-        token = metainterp_sd.cpu.get_latest_force_token()
-        all_virtuals = self.fetch_data(token)
+        hidden_all_virtuals = metainterp_sd.cpu.get_savedata_ref(deadframe)
+        all_virtuals = av_unerase(hidden_all_virtuals)
         if all_virtuals is None:
             all_virtuals = []
         assert jitdriver_sd is self.jitdriver_sd
-        resume_in_blackhole(metainterp_sd, jitdriver_sd, self, all_virtuals)
+        resume_in_blackhole(metainterp_sd, jitdriver_sd, self, deadframe,
+                            all_virtuals)
         assert 0, "unreachable"
 
     @staticmethod
         # an inconsistent state
         rstack._stack_criticalcode_start()
         try:
-            faildescr = cpu.force(token)
+            deadframe = cpu.force(token)
+            faildescr = cpu.get_latest_descr(deadframe)
             assert isinstance(faildescr, ResumeGuardForcedDescr)
-            faildescr.handle_async_forcing(token)
+            faildescr.handle_async_forcing(deadframe)
         finally:
             rstack._stack_criticalcode_stop()
 
-    def handle_async_forcing(self, force_token):
+    def handle_async_forcing(self, deadframe):
         from pypy.jit.metainterp.resume import force_from_resumedata
         metainterp_sd = self.metainterp_sd
         vinfo = self.jitdriver_sd.virtualizable_info
         ginfo = self.jitdriver_sd.greenfield_info
-        all_virtuals = force_from_resumedata(metainterp_sd, self, vinfo, ginfo)
+        all_virtuals = force_from_resumedata(metainterp_sd, self, deadframe,
+                                             vinfo, ginfo)
         # The virtualizable data was stored on the real virtualizable above.
         # Handle all_virtuals: keep them for later blackholing from the
         # future failure of the GUARD_NOT_FORCED
-        self.save_data(force_token, all_virtuals)
-
-    def save_data(self, key, value):
-        globaldata = self.metainterp_sd.globaldata
-        if we_are_translated():
-            assert key not in globaldata.resume_virtuals
-            globaldata.resume_virtuals[key] = value
-        else:
-            rv = globaldata.resume_virtuals_not_translated
-            for key1, value1 in rv:
-                assert key1 != key
-            rv.append((key, value))
+        hidden_all_virtuals = av_erase(all_virtuals)
+        metainterp_sd.cpu.set_savedata_ref(deadframe, hidden_all_virtuals)
 
     def fetch_data(self, key):
         globaldata = self.metainterp_sd.globaldata
         self.copy_all_attributes_into(res)
         return res
 
+av_erase, av_unerase = rerased.new_erasing_pair('all_virtuals')
+
 
 class AbstractResumeGuardCounters(object):
     # Completely custom algorithm for now: keep 5 pairs (value, counter),

File pypy/jit/metainterp/pyjitpl.py

         self.indirectcall_dict = None
         self.addr2name = None
         self.loopnumbering = 0
-        self.resume_virtuals = {}
-        self.resume_virtuals_not_translated = []
 
 # ____________________________________________________________
 

File pypy/jit/metainterp/resume.py

             break
     return firstbh
 
-def force_from_resumedata(metainterp_sd, storage, vinfo, ginfo):
-    resumereader = ResumeDataDirectReader(metainterp_sd, storage)
+def force_from_resumedata(metainterp_sd, storage, deadframe, vinfo, ginfo):
+    resumereader = ResumeDataDirectReader(metainterp_sd, storage, deadframe)
     resumereader.handling_async_forcing()
     vrefinfo = metainterp_sd.virtualref_info
     resumereader.consume_vref_and_vable(vrefinfo, vinfo, ginfo)