Author: hager <sven.ha...@uni-duesseldorf.de> Branch: ppc-jit-backend Changeset: r50756:4b2b09579148 Date: 2011-12-20 15:37 +0100 http://bitbucket.org/pypy/pypy/changeset/4b2b09579148/
Log: merge diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py --- a/pypy/jit/backend/llsupport/gc.py +++ b/pypy/jit/backend/llsupport/gc.py @@ -561,26 +561,34 @@ self.fielddescr_tid = get_field_descr(gc_ll_descr, GCClass.HDR, 'tid') # self.jit_wb_if_flag = GCClass.JIT_WB_IF_FLAG - self.jit_wb_if_flag_byteofs, self.jit_wb_if_flag_singlebyte = ( + (self.jit_wb_if_flag_byteofs, + self.jit_wb_if_flag_singlebyte, + self.jit_wb_if_flag_bitpos) = ( self.extract_flag_byte(self.jit_wb_if_flag)) # if hasattr(GCClass, 'JIT_WB_CARDS_SET'): self.jit_wb_cards_set = GCClass.JIT_WB_CARDS_SET self.jit_wb_card_page_shift = GCClass.JIT_WB_CARD_PAGE_SHIFT - self.jit_wb_cards_set_byteofs, self.jit_wb_cards_set_singlebyte = ( + (self.jit_wb_cards_set_byteofs, + self.jit_wb_cards_set_singlebyte, + self.jit_wb_cards_set_bitpos) = ( self.extract_flag_byte(self.jit_wb_cards_set)) else: self.jit_wb_cards_set = 0 def extract_flag_byte(self, flag_word): # if convenient for the backend, we compute the info about - # the flag as (byte-offset, single-byte-flag). + # the flag as (byte-offset, single-byte-flag, bit-position-in-word). + # Note that flag_word == 1 << bit_position_in_word. import struct value = struct.pack("l", flag_word) assert value.count('\x00') == len(value) - 1 # only one byte is != 0 i = 0 while value[i] == '\x00': i += 1 - return (i, struct.unpack('b', value[i])[0]) + bitpos = 0 + while flag_word > (1 << bitpos): bitpos += 1 + assert flag_word == (1 << bitpos) + return (i, struct.unpack('b', value[i])[0], bitpos) def get_write_barrier_fn(self, cpu): llop1 = self.llop1 diff --git a/pypy/jit/backend/ppc/ppcgen/opassembler.py b/pypy/jit/backend/ppc/ppcgen/opassembler.py --- a/pypy/jit/backend/ppc/ppcgen/opassembler.py +++ b/pypy/jit/backend/ppc/ppcgen/opassembler.py @@ -898,22 +898,14 @@ else: self.mc.ld(r.SCRATCH.value, loc_base.value, 0) - # offset to the byte we are interested in - byte_offset = descr.jit_wb_if_flag_byteofs - single_byte = descr.jit_wb_if_flag_singlebyte - - # examine which bit in the byte is set - for i in range(8): - if 1 << i == single_byte: - n = i - break + # get the position of the bit we want to test + bitpos = descr.jit_wb_if_flag_bitpos if IS_PPC_32: - # compute the position of the bit we want to test - bitpos = (3 - byte_offset) * 8 + n - # ^^^^^^^^^^^^^^^ due to endianess # put this bit to the rightmost bitposition of r0 - self.mc.rlwinm(r.SCRATCH.value, r.SCRATCH.value, 32 - bitpos, 31, 31) + if bitpos > 0: + self.mc.rlwinm(r.SCRATCH.value, r.SCRATCH.value, + 32 - bitpos, 31, 31) # test whether this bit is set self.mc.cmpwi(0, r.SCRATCH.value, 1) else: diff --git a/pypy/jit/backend/test/runner_test.py b/pypy/jit/backend/test/runner_test.py --- a/pypy/jit/backend/test/runner_test.py +++ b/pypy/jit/backend/test/runner_test.py @@ -1961,6 +1961,7 @@ jit_wb_if_flag = 4096 jit_wb_if_flag_byteofs = struct.pack("i", 4096).index('\x10') jit_wb_if_flag_singlebyte = 0x10 + jit_wb_if_flag_bitpos = 12 def get_write_barrier_fn(self, cpu): return funcbox.getint() # @@ -1998,6 +1999,7 @@ jit_wb_if_flag = 4096 jit_wb_if_flag_byteofs = struct.pack("i", 4096).index('\x10') jit_wb_if_flag_singlebyte = 0x10 + jit_wb_if_flag_bitpos = 12 jit_wb_cards_set = 0 def get_write_barrier_from_array_fn(self, cpu): return funcbox.getint() @@ -2044,9 +2046,11 @@ jit_wb_if_flag = 4096 jit_wb_if_flag_byteofs = struct.pack("i", 4096).index('\x10') jit_wb_if_flag_singlebyte = 0x10 + jit_wb_if_flag_bitpos = 12 jit_wb_cards_set = 8192 jit_wb_cards_set_byteofs = struct.pack("i", 8192).index('\x20') jit_wb_cards_set_singlebyte = 0x20 + jit_wb_cards_set_bitpos = 13 jit_wb_card_page_shift = 7 def get_write_barrier_from_array_fn(self, cpu): return funcbox.getint() _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit