Commits

Maciej Fijalkowski committed 1589099

initial checkin - a branch to try to compile the JIT separately from the
interpreter

  • Participants
  • Parent commits 0524dae
  • Branches separate-jit-compilation

Comments (0)

Files changed (4)

File rpython/jit/metainterp/pyjitpl.py

                     self.staticdata.log(sys.exc_info()[0].__name__)
                 raise
 
-    @specialize.arg(1)
-    def compile_and_run_once(self, jitdriver_sd, *args):
+    def compile_and_run_once(self, jitdriver_sd,
+                             green_args_i, green_args_r, green_args_f,
+                             args_i, args_r, args_f):
         # NB. we pass explicity 'jitdriver_sd' around here, even though it
         # is also available as 'self.jitdriver_sd', because we need to
         # specialize this function and a few other ones for the '*args'.
         self.staticdata.try_to_free_some_loops()
         self.create_empty_history()
         try:
-            original_boxes = self.initialize_original_boxes(jitdriver_sd, *args)
+            original_boxes = self.initialize_original_boxes(
+                jitdriver_sd, green_args_i, green_args_r, green_args_f,
+                args_i, args_r, args_f)
             return self._compile_and_run_once(original_boxes)
         finally:
             self.staticdata.profiler.end_tracing()
         if target_token is not token:
             compile.giveup()
 
-    @specialize.arg(1)
-    def initialize_original_boxes(self, jitdriver_sd, *args):
+    def initialize_original_boxes(self, jitdriver_sd,
+                                  greens_i, greens_r, greens_f,
+                                  args_i, args_r, args_f):
         original_boxes = []
         self._fill_original_boxes(jitdriver_sd, original_boxes,
-                                  jitdriver_sd.num_green_args, *args)
+                                  greens_i, greens_r, greens_f, args_i, args_r,
+                                  args_f)
         return original_boxes
 
-    @specialize.arg(1)
-    def _fill_original_boxes(self, jitdriver_sd, original_boxes,
-                             num_green_args, *args):
-        if args:
-            from rpython.jit.metainterp.warmstate import wrap
-            box = wrap(self.cpu, args[0], num_green_args > 0)
+    def _fill_original_boxes(self, jitdriver_sd, original_boxes, greens_i,
+                             greens_r, greens_f, args_i, args_r, args_f):
+        from rpython.jit.metainterp.warmstate import wrap
+
+        for ival in greens_i:
+            box = wrap(self.cpu, ival, True)
             original_boxes.append(box)
-            self._fill_original_boxes(jitdriver_sd, original_boxes,
-                                      num_green_args-1, *args[1:])
+        for rval in greens_r:
+            box = wrap(self.cpu, rval, True)
+            original_boxes.append(box)
+        for fval in greens_f:
+            box = wrap(self.cpu, fval, True)
+            original_boxes.append(box)
+        for ival in args_i:
+            box = wrap(self.cpu, ival, False)
+            original_boxes.append(box)
+        for rval in args_r:
+            box = wrap(self.cpu, rval, False)
+            original_boxes.append(box)
+        for fval in args_f:
+            box = wrap(self.cpu, fval, False)
+            original_boxes.append(box)
 
     def initialize_state_from_start(self, original_boxes):
         # ----- make a new frame -----

File rpython/jit/metainterp/warmspot.py

         ALLARGS = [v.concretetype for v in (greens_v + reds_v)]
         jd._green_args_spec = [v.concretetype for v in greens_v]
         jd.red_args_types = [history.getkind(v.concretetype) for v in reds_v]
+        jd.green_args_types = [history.getkind(v.concretetype)
+                               for v in greens_v]
         jd.num_green_args = len(jd._green_args_spec)
         jd.num_red_args = len(jd.red_args_types)
         RESTYPE = graph.getreturnvar().concretetype

File rpython/jit/metainterp/warmstate.py

         vinfo = jitdriver_sd.virtualizable_info
         index_of_virtualizable = jitdriver_sd.index_of_virtualizable
         num_green_args = jitdriver_sd.num_green_args
+        num_green_ints = 0
+        num_green_refs = 0
+        for kind in jitdriver_sd.green_args_types:
+            if kind == 'int':
+                num_green_ints += 1
+            elif kind == 'ref':
+                num_green_refs += 1
+        num_green_floats = num_green_args - num_green_ints - num_green_refs
+        range_green_ints = unrolling_iterable(enumerate(range(num_green_ints)))
+        range_green_refs = unrolling_iterable(enumerate(
+            range(num_green_ints, num_green_ints + num_green_refs)))
+        range_green_floats = unrolling_iterable(enumerate(
+            range(num_green_ints + num_green_refs, num_green_args)))
         JitCell = self.make_jitcell_subclass()
         self.make_jitdriver_callbacks()
         confirm_enter_jit = self.confirm_enter_jit
             range(num_green_args, num_green_args + jitdriver_sd.num_red_args))
         # get a new specialized copy of the method
         ARGS = []
+        num_red_ints = 0
+        num_red_refs = 0
+        num_red_floats = 0
         for kind in jitdriver_sd.red_args_types:
             if kind == 'int':
+                num_red_ints += 1
                 ARGS.append(lltype.Signed)
             elif kind == 'ref':
+                num_red_refs += 1
                 ARGS.append(llmemory.GCREF)
             elif kind == 'float':
+                num_red_floats += 1
                 ARGS.append(longlong.FLOATSTORAGE)
             else:
                 assert 0, kind
         cpu = self.cpu
         jitcounter = self.warmrunnerdesc.jitcounter
 
+        range_red_ints = unrolling_iterable(enumerate(
+            range(num_green_args, num_green_args + num_red_ints)))
+        range_red_refs = unrolling_iterable(enumerate(
+            range(num_green_args + num_red_ints,
+                  num_green_args + num_red_ints + num_red_refs)))
+        range_red_floats = unrolling_iterable(enumerate(
+            range(num_green_args + num_red_ints + num_red_refs,
+                  jitdriver_sd.num_red_args)))
+
         def execute_assembler(loop_token, *args):
             # Call the backend to run the 'looptoken' with the given
             # input args.
                 jitcounter.install_new_cell(hash, cell)
             cell.flags |= JC_TRACING
             try:
-                metainterp.compile_and_run_once(jitdriver_sd, *args)
+                green_ints = [0] * num_green_ints
+                green_refs = [lltype.nullptr(llmemory.GCREF.TO)] * num_green_refs
+                green_floats = [longlong.getfloatstorage(0.0)] * num_green_floats
+                red_ints = [0] * num_red_ints
+                red_refs = [lltype.nullptr(llmemory.GCREF.TO)] * num_red_refs
+                red_floats = [longlong.getfloatstorage(0.0)] * num_red_floats
+                for i, num in range_green_ints:
+                    green_ints[i] = args[num]
+                for i, num in range_green_refs:
+                    green_refs[i] = args[num]
+                for i, num in range_green_floats:
+                    green_floats[i] = args[num]
+                for i, num in range_red_ints:
+                    red_ints[i] = args[num]
+                for i, num in range_red_refs:
+                    red_refs[i] = args[num]
+                for i, num in range_red_floats:
+                    red_floats[i] = args[num]
+                metainterp.compile_and_run_once(jitdriver_sd, green_ints,
+                    green_refs, green_floats, red_ints, red_refs, red_floats)
             finally:
                 cell.flags &= ~JC_TRACING
 

File rpython/rlib/jit.py

         # if reds are automatic, they won't be passed to jit_merge_point, so
         # _check_arguments will receive only the green ones (i.e., the ones
         # which are listed explicitly). So, it is fine to just ignore reds
-        self._somelivevars = set([name for name in
+        self._somelivevars = set([_name for _name in
                                   self.greens + (self.reds or [])
-                                  if '.' not in name])
+                                  if '.' not in _name])
         self._heuristic_order = {}   # check if 'reds' and 'greens' are ordered
         self._make_extregistryentries()
         assert get_jitcell_at is None, "get_jitcell_at no longer used"