Armin Rigo avatar Armin Rigo committed b2f2645

Rename 'call_malloc_nursery_varsize_small' to '..varsize_frame', to
match more precisely its only usage. Optimize a bit the code
generation of this operation.

Comments (0)

Files changed (9)

rpython/jit/backend/arm/opassembler.py

             )
         self._alignment_check()
         return fcond
-    emit_op_call_malloc_nursery_varsize_small = emit_op_call_malloc_nursery
+    emit_op_call_malloc_nursery_varsize_frame = emit_op_call_malloc_nursery
 
 
     def _alignment_check(self):

rpython/jit/backend/arm/regalloc.py

         self.possibly_free_var(t)
         return [imm(size)]
 
-    def prepare_op_call_malloc_nursery_varsize_small(self, op, fcond):
+    def prepare_op_call_malloc_nursery_varsize_frame(self, op, fcond):
         size_box = op.getarg(0)
         assert isinstance(size_box, BoxInt)
 

rpython/jit/backend/llsupport/rewrite.py

                                size_box,
                                descr=descrs.jfi_frame_size)
             self.newops.append(op0)
-            self.gen_malloc_nursery_varsize_small(size_box, frame)
+            self.gen_malloc_nursery_varsize_frame(size_box, frame)
             self.gen_initialize_tid(frame, descrs.arraydescr.tid)
             length_box = history.BoxInt()
             op1 = ResOperation(rop.GETFIELD_GC, [history.ConstInt(frame_info)],
         self.recent_mallocs[v_result] = None
         return True
 
-    def gen_malloc_nursery_varsize_small(self, sizebox, v_result):
-        """ Generate CALL_MALLOC_NURSERY_VARSIZE_SMALL
+    def gen_malloc_nursery_varsize_frame(self, sizebox, v_result):
+        """ Generate CALL_MALLOC_NURSERY_VARSIZE_FRAME
         """
         self.emitting_an_operation_that_can_collect()
-        op = ResOperation(rop.CALL_MALLOC_NURSERY_VARSIZE_SMALL,
+        op = ResOperation(rop.CALL_MALLOC_NURSERY_VARSIZE_FRAME,
                           [sizebox],
                           v_result)
 

rpython/jit/backend/llsupport/test/test_gc_integration.py

         # slowpath never called
         assert gc_ll_descr.calls == []
 
-    def test_malloc_nursery_varsize_small(self):
+    def test_malloc_nursery_varsize_frame(self):
         self.cpu = self.getcpu(None)
         ops = '''
         [i0, i1, i2]
-        p0 = call_malloc_nursery_varsize_small(i0)
-        p1 = call_malloc_nursery_varsize_small(i1)
-        p2 = call_malloc_nursery_varsize_small(i2)
+        p0 = call_malloc_nursery_varsize_frame(i0)
+        p1 = call_malloc_nursery_varsize_frame(i1)
+        p2 = call_malloc_nursery_varsize_frame(i2)
         guard_true(i0) [p0, p1, p2]
         '''
         self.interpret(ops, [16, 32, 16])

rpython/jit/backend/llsupport/test/test_rewrite.py

         """, """
         [i0, f0]
         i1 = getfield_gc(ConstClass(frame_info), descr=jfi_frame_size)
-        p1 = call_malloc_nursery_varsize_small(i1)
+        p1 = call_malloc_nursery_varsize_frame(i1)
         setfield_gc(p1, 0, descr=tiddescr)
         i2 = getfield_gc(ConstClass(frame_info), descr=jfi_frame_depth)
         setfield_gc(p1, i2, descr=framelendescr)

rpython/jit/backend/x86/assembler.py

         self.mc.overwrite(jmp_adr-1, chr(offset))
         self.mc.MOV(heap(nursery_free_adr), edi)
 
-    def malloc_cond_varsize_small(self, nursery_free_adr, nursery_top_adr,
+    def malloc_cond_varsize_frame(self, nursery_free_adr, nursery_top_adr,
                                   sizeloc, gcmap):
-        self.mc.MOV(edi, heap(nursery_free_adr))
-        self.mc.MOV(eax, edi)
-        self.mc.ADD(edi, sizeloc)
+        if not isinstance(sizeloc, RegLoc) or sizeloc is eax:
+            self.mc.MOV(edi, sizeloc)
+            sizeloc = edi
+        self.mc.MOV(eax, heap(nursery_free_adr))
+        if sizeloc is edi:
+            self.mc.ADD_rr(edi.value, eax.value)
+        else:
+            self.mc.LEA_ra(edi.value, (eax.value, sizeloc.value, 0, 0))
         self.mc.CMP(edi, heap(nursery_top_adr))
         self.mc.J_il8(rx86.Conditions['NA'], 0) # patched later
         jmp_adr = self.mc.get_relative_pos()
         assert isinstance(arraydescr, ArrayDescr)
 
         self.mc.CMP(lengthloc, imm(maxlength))
-        self.mc.J_il8(rx86.Conditions['G'], 0) # patched later
+        self.mc.J_il8(rx86.Conditions['A'], 0) # patched later
         jmp_adr0 = self.mc.get_relative_pos()
         self.mc.MOV(eax, heap(nursery_free_adr))
         self.mc.MOV(edi, lengthloc)

rpython/jit/backend/x86/regalloc.py

         # looking at the result
         self.rm.force_allocate_reg(op.result, selected_reg=eax)
         #
-        # We need edx as a temporary, but otherwise don't save any more
+        # We need edi as a temporary, but otherwise don't save any more
         # register.  See comments in _build_malloc_slowpath().
         tmp_box = TempBox()
         self.rm.force_allocate_reg(tmp_box, selected_reg=edi)
             gc_ll_descr.get_nursery_top_addr(),
             size, gcmap)
 
-    def consider_call_malloc_nursery_varsize_small(self, op):
+    def consider_call_malloc_nursery_varsize_frame(self, op):
         size_box = op.getarg(0)
         assert isinstance(size_box, BoxInt) # we cannot have a const here!
-        # looking at the result
+        # size_box can be anywhere (including the stack, or eax, or edi)
+        sizeloc = self.rm.loc(size_box)
+        self.rm.possibly_free_var(size_box)
+        # the result will be in eax
         self.rm.force_allocate_reg(op.result, selected_reg=eax)
-        #
-        # We need edx as a temporary, but otherwise don't save any more
-        # register.  See comments in _build_malloc_slowpath().
+        # we need edi as a temporary
         tmp_box = TempBox()
         self.rm.force_allocate_reg(tmp_box, selected_reg=edi)
-        sizeloc = self.rm.make_sure_var_in_reg(size_box, [op.result, tmp_box])
         gcmap = self.get_gcmap([eax, edi]) # allocate the gcmap *before*
         self.rm.possibly_free_var(tmp_box)
         #
         gc_ll_descr = self.assembler.cpu.gc_ll_descr
-        self.assembler.malloc_cond_varsize_small(
+        self.assembler.malloc_cond_varsize_frame(
             gc_ll_descr.get_nursery_free_addr(),
             gc_ll_descr.get_nursery_top_addr(),
             sizeloc, gcmap)

rpython/jit/metainterp/executor.py

                          rop.CALL_MALLOC_GC,
                          rop.CALL_MALLOC_NURSERY,
                          rop.CALL_MALLOC_NURSERY_VARSIZE,
-                         rop.CALL_MALLOC_NURSERY_VARSIZE_SMALL,
+                         rop.CALL_MALLOC_NURSERY_VARSIZE_FRAME,
                          rop.LABEL,
                          ):      # list of opcodes never executed by pyjitpl
                 continue

rpython/jit/metainterp/resoperation.py

     'CALL_MALLOC_GC/*d',      # like CALL, but NULL => propagate MemoryError
     'CALL_MALLOC_NURSERY/1',  # nursery malloc, const number of bytes, zeroed
     'CALL_MALLOC_NURSERY_VARSIZE/3d',
-    'CALL_MALLOC_NURSERY_VARSIZE_SMALL/1',
+    'CALL_MALLOC_NURSERY_VARSIZE_FRAME/1',
     # nursery malloc, non-const number of bytes, zeroed
     # note that the number of bytes must be well known to be small enough
     # to fulfill allocating in the nursery rules (and no card markings)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.