[pypy-svn] r77215 - in pypy/branch/smaller-writebarrier/pypy/jit: backend/llgraph backend/llsupport backend/llsupport/test backend/test backend/x86 metainterp
arigo at codespeak.net
arigo at codespeak.net
Mon Sep 20 18:18:03 CEST 2010
Author: arigo
Date: Mon Sep 20 18:18:01 2010
New Revision: 77215
Modified:
pypy/branch/smaller-writebarrier/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/smaller-writebarrier/pypy/jit/backend/llsupport/gc.py
pypy/branch/smaller-writebarrier/pypy/jit/backend/llsupport/test/test_gc.py
pypy/branch/smaller-writebarrier/pypy/jit/backend/test/runner_test.py
pypy/branch/smaller-writebarrier/pypy/jit/backend/x86/assembler.py
pypy/branch/smaller-writebarrier/pypy/jit/backend/x86/regalloc.py
pypy/branch/smaller-writebarrier/pypy/jit/metainterp/resoperation.py
Log:
Fix write_barrier calls in the JIT.
Modified: pypy/branch/smaller-writebarrier/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/smaller-writebarrier/pypy/jit/backend/llgraph/llimpl.py (original)
+++ pypy/branch/smaller-writebarrier/pypy/jit/backend/llgraph/llimpl.py Mon Sep 20 18:18:01 2010
@@ -129,7 +129,7 @@
'arraylen_gc' : (('ref',), 'int'),
'call' : (('ref', 'varargs'), 'intorptr'),
'call_assembler' : (('varargs',), 'intorptr'),
- 'cond_call_gc_wb' : (('ptr', 'ptr'), None),
+ 'cond_call_gc_wb' : (('ptr',), None),
'oosend' : (('varargs',), 'intorptr'),
'oosend_pure' : (('varargs',), 'intorptr'),
'guard_true' : (('bool',), None),
@@ -810,7 +810,7 @@
FLOAT: 0.0}
return d[calldescr.typeinfo]
- def op_cond_call_gc_wb(self, descr, a, b):
+ def op_cond_call_gc_wb(self, descr, a):
py.test.skip("cond_call_gc_wb not supported")
def op_oosend(self, descr, obj, *args):
Modified: pypy/branch/smaller-writebarrier/pypy/jit/backend/llsupport/gc.py
==============================================================================
--- pypy/branch/smaller-writebarrier/pypy/jit/backend/llsupport/gc.py (original)
+++ pypy/branch/smaller-writebarrier/pypy/jit/backend/llsupport/gc.py Mon Sep 20 18:18:01 2010
@@ -394,7 +394,7 @@
self.GC_MALLOC_BASIC = lltype.Ptr(lltype.FuncType(
[lltype.Signed, lltype.Signed], llmemory.GCREF))
self.WB_FUNCPTR = lltype.Ptr(lltype.FuncType(
- [llmemory.Address, llmemory.Address], lltype.Void))
+ [llmemory.Address], lltype.Void))
self.write_barrier_descr = WriteBarrierDescr(self)
#
def malloc_array(itemsize, tid, num_elem):
@@ -540,8 +540,7 @@
# the GC, and call it immediately
llop1 = self.llop1
funcptr = llop1.get_write_barrier_failing_case(self.WB_FUNCPTR)
- funcptr(llmemory.cast_ptr_to_adr(gcref_struct),
- llmemory.cast_ptr_to_adr(gcref_newptr))
+ funcptr(llmemory.cast_ptr_to_adr(gcref_struct))
def rewrite_assembler(self, cpu, operations):
# Perform two kinds of rewrites in parallel:
@@ -580,7 +579,7 @@
v = op.args[1]
if isinstance(v, BoxPtr) or (isinstance(v, ConstPtr) and
bool(v.value)): # store a non-NULL
- self._gen_write_barrier(newops, op.args[0], v)
+ self._gen_write_barrier(newops, op.args[0])
op = ResOperation(rop.SETFIELD_RAW, op.args, None,
descr=op.descr)
# ---------- write barrier for SETARRAYITEM_GC ----------
@@ -588,7 +587,9 @@
v = op.args[2]
if isinstance(v, BoxPtr) or (isinstance(v, ConstPtr) and
bool(v.value)): # store a non-NULL
- self._gen_write_barrier(newops, op.args[0], v)
+ # XXX detect when we should produce a
+ # write_barrier_from_array
+ self._gen_write_barrier(newops, op.args[0])
op = ResOperation(rop.SETARRAYITEM_RAW, op.args, None,
descr=op.descr)
# ----------
@@ -596,8 +597,8 @@
del operations[:]
operations.extend(newops)
- def _gen_write_barrier(self, newops, v_base, v_value):
- args = [v_base, v_value]
+ def _gen_write_barrier(self, newops, v_base):
+ args = [v_base]
newops.append(ResOperation(rop.COND_CALL_GC_WB, args, None,
descr=self.write_barrier_descr))
Modified: pypy/branch/smaller-writebarrier/pypy/jit/backend/llsupport/test/test_gc.py
==============================================================================
--- pypy/branch/smaller-writebarrier/pypy/jit/backend/llsupport/test/test_gc.py (original)
+++ pypy/branch/smaller-writebarrier/pypy/jit/backend/llsupport/test/test_gc.py Mon Sep 20 18:18:01 2010
@@ -141,8 +141,8 @@
repr(offset_to_length), p))
return p
- def _write_barrier_failing_case(self, adr_struct, adr_newptr):
- self.record.append(('barrier', adr_struct, adr_newptr))
+ def _write_barrier_failing_case(self, adr_struct):
+ self.record.append(('barrier', adr_struct))
def get_write_barrier_failing_case(self, FPTRTYPE):
return llhelper(FPTRTYPE, self._write_barrier_failing_case)
@@ -238,7 +238,6 @@
s_gcref = lltype.cast_opaque_ptr(llmemory.GCREF, s)
r_gcref = lltype.cast_opaque_ptr(llmemory.GCREF, r)
s_adr = llmemory.cast_ptr_to_adr(s)
- r_adr = llmemory.cast_ptr_to_adr(r)
#
s_hdr.tid &= ~gc_ll_descr.GCClass.JIT_WB_IF_FLAG
gc_ll_descr.do_write_barrier(s_gcref, r_gcref)
@@ -246,7 +245,7 @@
#
s_hdr.tid |= gc_ll_descr.GCClass.JIT_WB_IF_FLAG
gc_ll_descr.do_write_barrier(s_gcref, r_gcref)
- assert self.llop1.record == [('barrier', s_adr, r_adr)]
+ assert self.llop1.record == [('barrier', s_adr)]
def test_gen_write_barrier(self):
gc_ll_descr = self.gc_ll_descr
@@ -254,13 +253,12 @@
#
newops = []
v_base = BoxPtr()
- v_value = BoxPtr()
- gc_ll_descr._gen_write_barrier(newops, v_base, v_value)
+ gc_ll_descr._gen_write_barrier(newops, v_base)
assert llop1.record == []
assert len(newops) == 1
assert newops[0].opnum == rop.COND_CALL_GC_WB
assert newops[0].args[0] == v_base
- assert newops[0].args[1] == v_value
+ assert len(newops[0].args) == 1
assert newops[0].result is None
wbdescr = newops[0].descr
assert isinstance(wbdescr.jit_wb_if_flag, int)
@@ -358,7 +356,7 @@
#
assert operations[0].opnum == rop.COND_CALL_GC_WB
assert operations[0].args[0] == v_base
- assert operations[0].args[1] == v_value
+ assert len(operations[0].args) == 1
assert operations[0].result is None
#
assert operations[1].opnum == rop.SETFIELD_RAW
@@ -381,7 +379,7 @@
#
assert operations[0].opnum == rop.COND_CALL_GC_WB
assert operations[0].args[0] == v_base
- assert operations[0].args[1] == v_value
+ assert len(operations[0].args) == 1
assert operations[0].result is None
#
assert operations[1].opnum == rop.SETARRAYITEM_RAW
Modified: pypy/branch/smaller-writebarrier/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/smaller-writebarrier/pypy/jit/backend/test/runner_test.py (original)
+++ pypy/branch/smaller-writebarrier/pypy/jit/backend/test/runner_test.py Mon Sep 20 18:18:01 2010
@@ -1404,8 +1404,8 @@
assert not excvalue
def test_cond_call_gc_wb(self):
- def func_void(a, b):
- record.append((a, b))
+ def func_void(a):
+ record.append(a)
record = []
#
S = lltype.GcStruct('S', ('tid', lltype.Signed))
@@ -1430,10 +1430,10 @@
sgcref = lltype.cast_opaque_ptr(llmemory.GCREF, s)
del record[:]
self.execute_operation(rop.COND_CALL_GC_WB,
- [BoxPtr(sgcref), ConstInt(-2121)],
+ [BoxPtr(sgcref)],
'void', descr=WriteBarrierDescr())
if cond:
- assert record == [(s, -2121)]
+ assert record == [s]
else:
assert record == []
Modified: pypy/branch/smaller-writebarrier/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/smaller-writebarrier/pypy/jit/backend/x86/assembler.py (original)
+++ pypy/branch/smaller-writebarrier/pypy/jit/backend/x86/assembler.py Mon Sep 20 18:18:01 2010
@@ -1768,6 +1768,7 @@
jz_location = self.mc.get_relative_pos()
# the following is supposed to be the slow path, so whenever possible
# we choose the most compact encoding over the most efficient one.
+ # XXX improve a bit, particularly for IS_X86_64.
for i in range(len(arglocs)-1, -1, -1):
loc = arglocs[i]
if isinstance(loc, RegLoc):
@@ -1780,12 +1781,11 @@
self.mc.PUSH_i32(loc.getint())
if IS_X86_64:
- # We clobber these registers to pass the arguments, but that's
+ # We clobber this register to pass the arguments, but that's
# okay, because consider_cond_call_gc_wb makes sure that any
# caller-save registers with values in them are present in arglocs,
# so they are saved on the stack above and restored below
self.mc.MOV_rs(edi.value, 0)
- self.mc.MOV_rs(esi.value, 8)
# misaligned stack in the call, but it's ok because the write barrier
# is not going to call anything more. Also, this assumes that the
Modified: pypy/branch/smaller-writebarrier/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/smaller-writebarrier/pypy/jit/backend/x86/regalloc.py (original)
+++ pypy/branch/smaller-writebarrier/pypy/jit/backend/x86/regalloc.py Mon Sep 20 18:18:01 2010
@@ -682,13 +682,9 @@
def consider_cond_call_gc_wb(self, op):
assert op.result is None
- loc_newvalue = self.rm.make_sure_var_in_reg(op.args[1], op.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.args[0], op.args,
imm_fine=False)
- arglocs = [loc_base, loc_newvalue]
+ arglocs = [loc_base]
# 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,
Modified: pypy/branch/smaller-writebarrier/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/smaller-writebarrier/pypy/jit/metainterp/resoperation.py (original)
+++ pypy/branch/smaller-writebarrier/pypy/jit/metainterp/resoperation.py Mon Sep 20 18:18:01 2010
@@ -219,7 +219,7 @@
'UNICODESETITEM/3',
'NEWUNICODE/1',
#'RUNTIMENEW/1', # ootype operation
- 'COND_CALL_GC_WB', # [objptr, newvalue] (for the write barrier)
+ 'COND_CALL_GC_WB', # [objptr] (for the write barrier)
'DEBUG_MERGE_POINT/1', # debugging only
'VIRTUAL_REF_FINISH/2', # removed before it's passed to the backend
More information about the Pypy-commit
mailing list