[pypy-commit] pypy default: Fix COND_CALL_GC_WB_ARRAY. Sorry, I messed up argument order
arigo
noreply at buildbot.pypy.org
Tue Jun 14 10:00:00 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r44930:44c7d862250e
Date: 2011-06-14 10:02 +0200
http://bitbucket.org/pypy/pypy/changeset/44c7d862250e/
Log: Fix COND_CALL_GC_WB_ARRAY. Sorry, I messed up argument order and
the tests didn't catch it...
diff --git a/pypy/jit/backend/llgraph/llimpl.py b/pypy/jit/backend/llgraph/llimpl.py
--- a/pypy/jit/backend/llgraph/llimpl.py
+++ b/pypy/jit/backend/llgraph/llimpl.py
@@ -136,6 +136,7 @@
'call' : (('ref', 'varargs'), 'intorptr'),
'call_assembler' : (('varargs',), 'intorptr'),
'cond_call_gc_wb' : (('ptr', 'ptr'), None),
+ 'cond_call_gc_wb_array': (('ptr', 'int', 'ptr'), None),
'oosend' : (('varargs',), 'intorptr'),
'oosend_pure' : (('varargs',), 'intorptr'),
'guard_true' : (('bool',), None),
@@ -857,6 +858,9 @@
def op_cond_call_gc_wb(self, descr, a, b):
py.test.skip("cond_call_gc_wb not supported")
+ def op_cond_call_gc_wb_array(self, descr, a, b, c):
+ py.test.skip("cond_call_gc_wb_array not supported")
+
def op_oosend(self, descr, obj, *args):
raise NotImplementedError("oosend for lltype backend??")
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
@@ -476,6 +476,7 @@
return cpu.cast_adr_to_int(funcaddr)
def get_write_barrier_from_array_fn(self, cpu):
+ # returns a function with arguments [array, index, newvalue]
llop1 = self.llop1
funcptr = llop1.get_write_barrier_from_array_failing_case(
self.WB_ARRAY_FUNCPTR)
@@ -778,7 +779,7 @@
length = known_lengths.get(v_base, LARGE)
if length >= LARGE:
# unknown or too big: produce a write_barrier_from_array
- args = [v_base, v_value, v_index]
+ args = [v_base, v_index, v_value]
newops.append(ResOperation(rop.COND_CALL_GC_WB_ARRAY, args,
None,
descr=self.write_barrier_descr))
diff --git a/pypy/jit/backend/llsupport/test/test_gc.py b/pypy/jit/backend/llsupport/test/test_gc.py
--- a/pypy/jit/backend/llsupport/test/test_gc.py
+++ b/pypy/jit/backend/llsupport/test/test_gc.py
@@ -560,8 +560,8 @@
else:
assert operations[0].getopnum() == rop.COND_CALL_GC_WB_ARRAY
assert operations[0].getarg(0) == v_base
- assert operations[0].getarg(1) == v_value
- assert operations[0].getarg(2) == v_index
+ assert operations[0].getarg(1) == v_index
+ assert operations[0].getarg(2) == v_value
assert operations[0].result is None
#
assert operations[1].getopnum() == rop.SETARRAYITEM_RAW
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
@@ -1694,12 +1694,13 @@
assert record == []
def test_cond_call_gc_wb_array(self):
- def func_void(a, b):
- record.append((a, b))
+ def func_void(a, b, c):
+ record.append((a, b, c))
record = []
#
S = lltype.GcStruct('S', ('tid', lltype.Signed))
- FUNC = self.FuncType([lltype.Ptr(S), lltype.Signed], lltype.Void)
+ FUNC = self.FuncType([lltype.Ptr(S), lltype.Signed, lltype.Ptr(S)],
+ lltype.Void)
func_ptr = llhelper(lltype.Ptr(FUNC), func_void)
funcbox = self.get_funcbox(self.cpu, func_ptr)
class WriteBarrierDescr(AbstractDescr):
@@ -1719,11 +1720,11 @@
s.tid = value
sgcref = lltype.cast_opaque_ptr(llmemory.GCREF, s)
del record[:]
- self.execute_operation(rop.COND_CALL_GC_WB,
- [BoxPtr(sgcref), ConstInt(123)],
- 'void', descr=WriteBarrierDescr())
+ self.execute_operation(rop.COND_CALL_GC_WB_ARRAY,
+ [BoxPtr(sgcref), ConstInt(123), BoxPtr(sgcref)],
+ 'void', descr=WriteBarrierDescr())
if cond:
- assert record == [(s, 123)]
+ assert record == [(s, 123, s)]
else:
assert record == []
diff --git a/pypy/jit/backend/x86/regalloc.py b/pypy/jit/backend/x86/regalloc.py
--- a/pypy/jit/backend/x86/regalloc.py
+++ b/pypy/jit/backend/x86/regalloc.py
@@ -884,18 +884,12 @@
def consider_cond_call_gc_wb(self, op):
assert op.result is None
args = op.getarglist()
- loc_newvalue = self.rm.make_sure_var_in_reg(op.getarg(1), args)
- # ^^^ we force loc_newvalue in a reg (unless it's a Const),
- # because it will be needed anyway by the following setfield_gc.
- # It avoids loading it twice from the memory.
- loc_base = self.rm.make_sure_var_in_reg(op.getarg(0), args)
- #
- if len(args) == 2:
- arglocs = [loc_base, loc_newvalue] # cond_call_gc_wb
- else:
- # cond_call_gc_wb_array
- loc_arrayindex = self.rm.make_sure_var_in_reg(op.getarg(2), args)
- arglocs = [loc_base, loc_newvalue, loc_arrayindex]
+ N = len(args)
+ # we force all arguments in a reg (unless they are Consts),
+ # because it will be needed anyway by the following setfield_gc
+ # or setarrayitem_gc. It avoids loading it twice from the memory.
+ arglocs = [self.rm.make_sure_var_in_reg(op.getarg(i), args)
+ for i in range(N)]
# add eax, ecx and edx as extra "arguments" to ensure they are
# saved and restored. Fish in self.rm to know which of these
# registers really need to be saved (a bit of a hack). Moreover,
diff --git a/pypy/jit/metainterp/resoperation.py b/pypy/jit/metainterp/resoperation.py
--- a/pypy/jit/metainterp/resoperation.py
+++ b/pypy/jit/metainterp/resoperation.py
@@ -478,7 +478,7 @@
'UNICODESETITEM/3',
#'RUNTIMENEW/1', # ootype operation
'COND_CALL_GC_WB/2d', # [objptr, newvalue] (for the write barrier)
- 'COND_CALL_GC_WB_ARRAY/3d', # [objptr, newvalue, arrayindex] (write barr.)
+ 'COND_CALL_GC_WB_ARRAY/3d', # [objptr, arrayindex, newvalue] (write barr.)
'DEBUG_MERGE_POINT/*', # debugging only
'JIT_DEBUG/*', # debugging only
'VIRTUAL_REF_FINISH/2', # removed before it's passed to the backend
More information about the pypy-commit
mailing list