1. Pypy
  2. Untitled project
  3. pypy


Armin Rigo  committed 3e09422

Tweak: except in the simplest cases where the ll_builder remains virtual,
write ll_build() as just a simple residual call

  • Participants
  • Parent commits b451f9d
  • Branches stringbuilder2-perf

Comments (0)

Files changed (2)

File rpython/jit/metainterp/pyjitpl.py

View file
  • Ignore whitespace
             return self.execute_varargs(rop.CALL, allboxes, descr, exc, pure)
     def do_conditional_call(self, condbox, funcbox, argboxes, descr, pc):
+        if isinstance(condbox, ConstInt) and condbox.value == 0:
+            return   # so that the heapcache can keep argboxes virtual
         allboxes = self._build_allboxes(funcbox, argboxes, descr)
         effectinfo = descr.get_extra_info()
         assert not effectinfo.check_forces_virtual_or_virtualizable()

File rpython/rtyper/lltypesystem/rbuilder.py

View file
  • Ignore whitespace
         return ll_builder.total_size - num_chars_missing_from_last_piece
+    @jit.look_inside_iff(lambda ll_builder: jit.isvirtual(ll_builder))
     def ll_build(ll_builder):
-        jit.conditional_call(bool(ll_builder.extra_pieces),
-                             BaseStringBuilderRepr._ll_fold_pieces, ll_builder)
-        # Here is the one remaining "unexpected" branch with the JIT.
-        # Too bad, but it seems it's the only reasonable way to support
-        # both virtual builders and avoid-shrink-if-size-doesn't-change
-        final_size = ll_builder.current_pos
-        if final_size != ll_builder.total_size:
+        # NB. usually the JIT doesn't look inside this function; it does
+        # so only in the simplest example where it could virtualize everything
+        if ll_builder.extra_pieces:
+            BaseStringBuilderRepr._ll_fold_pieces(ll_builder)
+        elif ll_builder.current_pos != ll_builder.total_size:
         return ll_builder.current_buf