Exemplo n.º 1
0
 def test_mark_gc_roots(self):
     cpu = CPU(None, None)
     cpu.setup_once()
     regalloc = RegAlloc(MockAssembler(cpu, MockGcDescr(False)))
     regalloc.assembler.datablockwrapper = 'fakedatablockwrapper'
     boxes = [BoxPtr() for i in range(len(X86RegisterManager.all_regs))]
     longevity = {}
     for box in boxes:
         longevity[box] = (0, 1)
     regalloc.fm = X86FrameManager()
     regalloc.rm = X86RegisterManager(longevity,
                                      regalloc.fm,
                                      assembler=regalloc.assembler)
     regalloc.xrm = X86XMMRegisterManager(longevity,
                                          regalloc.fm,
                                          assembler=regalloc.assembler)
     cpu = regalloc.assembler.cpu
     for box in boxes:
         regalloc.rm.try_allocate_reg(box)
     TP = lltype.FuncType([], lltype.Signed)
     calldescr = cpu.calldescrof(TP, TP.ARGS, TP.RESULT,
                                 EffectInfo.MOST_GENERAL)
     regalloc.rm._check_invariants()
     box = boxes[0]
     regalloc.position = 0
     regalloc.consider_call(
         ResOperation(rop.CALL, [box], BoxInt(), calldescr))
     assert len(regalloc.assembler.movs) == 3
     #
     mark = regalloc.get_mark_gc_roots(cpu.gc_ll_descr.gcrootmap)
     assert mark[0] == 'compressed'
     base = -WORD * FRAME_FIXED_SIZE
     expected = ['ebx', 'esi', 'edi', base, base - WORD, base - WORD * 2]
     assert dict.fromkeys(mark[1:]) == dict.fromkeys(expected)
Exemplo n.º 2
0
 def test_mark_gc_roots(self):
     cpu = CPU(None, None)
     regalloc = RegAlloc(MockAssembler(cpu, MockGcDescr(False)))
     boxes = [BoxPtr() for i in range(len(X86RegisterManager.all_regs))]
     longevity = {}
     for box in boxes:
         longevity[box] = (0, 1)
     regalloc.sm = X86StackManager()
     regalloc.rm = X86RegisterManager(longevity,
                                      regalloc.sm,
                                      assembler=regalloc.assembler)
     regalloc.xrm = X86XMMRegisterManager(longevity,
                                          regalloc.sm,
                                          assembler=regalloc.assembler)
     cpu = regalloc.assembler.cpu
     for box in boxes:
         regalloc.rm.try_allocate_reg(box)
     TP = lltype.FuncType([], lltype.Signed)
     calldescr = cpu.calldescrof(TP, TP.ARGS, TP.RESULT)
     regalloc.rm._check_invariants()
     box = boxes[0]
     regalloc.position = 0
     regalloc.consider_call(
         ResOperation(rop.CALL, [box], BoxInt(), calldescr), None)
     assert len(regalloc.assembler.movs) == 3
     #
     mark = regalloc.get_mark_gc_roots(cpu.gc_ll_descr.gcrootmap)
     assert mark[0] == 'compressed'
     expected = ['ebx', 'esi', 'edi', -16, -20, -24]
     assert dict.fromkeys(mark[1:]) == dict.fromkeys(expected)
Exemplo n.º 3
0
 def test_mark_gc_roots(self):
     cpu = CPU(None, None)
     cpu.setup_once()
     regalloc = RegAlloc(MockAssembler(cpu, MockGcDescr(False)))
     regalloc.assembler.datablockwrapper = 'fakedatablockwrapper'
     boxes = [BoxPtr() for i in range(len(X86RegisterManager.all_regs))]
     longevity = {}
     for box in boxes:
         longevity[box] = (0, 1)
     regalloc.fm = X86FrameManager()
     regalloc.rm = X86RegisterManager(longevity, regalloc.fm,
                                      assembler=regalloc.assembler)
     regalloc.xrm = X86XMMRegisterManager(longevity, regalloc.fm,
                                          assembler=regalloc.assembler)
     cpu = regalloc.assembler.cpu
     for box in boxes:
         regalloc.rm.try_allocate_reg(box)
     TP = lltype.FuncType([], lltype.Signed)
     calldescr = cpu.calldescrof(TP, TP.ARGS, TP.RESULT)
     regalloc.rm._check_invariants()
     box = boxes[0]
     regalloc.position = 0
     regalloc.consider_call(ResOperation(rop.CALL, [box], BoxInt(),
                                         calldescr))
     assert len(regalloc.assembler.movs) == 3
     #
     mark = regalloc.get_mark_gc_roots(cpu.gc_ll_descr.gcrootmap)
     assert mark[0] == 'compressed'
     base = -WORD * FRAME_FIXED_SIZE
     expected = ['ebx', 'esi', 'edi', base, base-WORD, base-WORD*2]
     assert dict.fromkeys(mark[1:]) == dict.fromkeys(expected)
Exemplo n.º 4
0
 def assemble_loop(self, inputargs, operations, looptoken):
     """adds the following attributes to looptoken:
            _x86_loop_code       (an integer giving an address)
            _x86_bootstrap_code  (an integer giving an address)
            _x86_stack_depth
            _x86_arglocs
     """
     self.make_sure_mc_exists()
     regalloc = RegAlloc(self, self.cpu.translate_support_code)
     arglocs = regalloc.prepare_loop(inputargs, operations, looptoken)
     looptoken._x86_arglocs = arglocs
     looptoken._x86_bootstrap_code = self.mc.tell()
     adr_stackadjust = self._assemble_bootstrap_code(inputargs, arglocs)
     looptoken._x86_loop_code = self.mc.tell()
     looptoken._x86_stack_depth = -1  # temporarily
     stack_depth = self._assemble(regalloc, operations)
     self._patch_stackadjust(adr_stackadjust, stack_depth)
     looptoken._x86_stack_depth = stack_depth
Exemplo n.º 5
0
 def assemble_loop(self, inputargs, operations, looptoken):
     """adds the following attributes to looptoken:
            _x86_loop_code       (an integer giving an address)
            _x86_bootstrap_code  (an integer giving an address)
            _x86_stack_depth
            _x86_arglocs
     """
     self.make_sure_mc_exists()
     regalloc = RegAlloc(self, self.cpu.translate_support_code)
     arglocs = regalloc.prepare_loop(inputargs, operations, looptoken)
     looptoken._x86_arglocs = arglocs
     looptoken._x86_bootstrap_code = self.mc.tell()
     adr_stackadjust = self._assemble_bootstrap_code(inputargs, arglocs)
     looptoken._x86_loop_code = self.mc.tell()
     looptoken._x86_stack_depth = -1  # temporarily
     stack_depth = self._assemble(regalloc, operations)
     self._patch_stackadjust(adr_stackadjust, stack_depth)
     looptoken._x86_stack_depth = stack_depth
Exemplo n.º 6
0
 def assemble_bridge(self, faildescr, inputargs, operations):
     self.make_sure_mc_exists()
     regalloc = RegAlloc(self, self.cpu.translate_support_code)
     arglocs = faildescr._x86_faillocs
     fail_stack_depth = faildescr._x86_current_stack_depth
     regalloc.prepare_bridge(fail_stack_depth, inputargs, arglocs, operations)
     adr_bridge = self.mc.tell()
     adr_stackadjust = self._patchable_stackadjust()
     stack_depth = self._assemble(regalloc, operations)
     self._patch_stackadjust(adr_stackadjust, stack_depth)
     if not we_are_translated():
         # for the benefit of tests
         faildescr._x86_bridge_stack_depth = stack_depth
     # patch the jump from original guard
     adr_jump_offset = faildescr._x86_adr_jump_offset
     mc = codebuf.InMemoryCodeBuilder(adr_jump_offset, adr_jump_offset + 4)
     mc.write(packimm32(adr_bridge - adr_jump_offset - 4))
     mc.valgrind_invalidated()
     mc.done()
Exemplo n.º 7
0
 def assemble_bridge(self, faildescr, inputargs, operations):
     self.make_sure_mc_exists()
     regalloc = RegAlloc(self, self.cpu.translate_support_code)
     arglocs = faildescr._x86_faillocs
     fail_stack_depth = faildescr._x86_current_stack_depth
     regalloc.prepare_bridge(fail_stack_depth, inputargs, arglocs,
                             operations)
     adr_bridge = self.mc.tell()
     adr_stackadjust = self._patchable_stackadjust()
     stack_depth = self._assemble(regalloc, operations)
     self._patch_stackadjust(adr_stackadjust, stack_depth)
     if not we_are_translated():
         # for the benefit of tests
         faildescr._x86_bridge_stack_depth = stack_depth
     # patch the jump from original guard
     adr_jump_offset = faildescr._x86_adr_jump_offset
     mc = codebuf.InMemoryCodeBuilder(adr_jump_offset, adr_jump_offset + 4)
     mc.write(packimm32(adr_bridge - adr_jump_offset - 4))
     mc.valgrind_invalidated()
     mc.done()
Exemplo n.º 8
0
 def prepare_loop(self, ops):
     loop = self.parse(ops)
     regalloc = RegAlloc(self.cpu.assembler, False)
     regalloc.prepare_loop(loop.inputargs, loop.operations,
                           loop.original_jitcell_token, [])
     return regalloc