[pypy-svn] r73954 - in pypy/branch/asmgcc-64/pypy: rpython/memory/gctransform translator/c translator/c/src
arigo at codespeak.net
arigo at codespeak.net
Thu Apr 22 09:52:58 CEST 2010
Author: arigo
Date: Thu Apr 22 09:52:55 2010
New Revision: 73954
Modified:
pypy/branch/asmgcc-64/pypy/rpython/memory/gctransform/asmgcroot.py
pypy/branch/asmgcc-64/pypy/translator/c/gc.py
pypy/branch/asmgcc-64/pypy/translator/c/src/mem.h
Log:
Check-in intermediate changes.
Modified: pypy/branch/asmgcc-64/pypy/rpython/memory/gctransform/asmgcroot.py
==============================================================================
--- pypy/branch/asmgcc-64/pypy/rpython/memory/gctransform/asmgcroot.py (original)
+++ pypy/branch/asmgcc-64/pypy/rpython/memory/gctransform/asmgcroot.py Thu Apr 22 09:52:55 2010
@@ -28,21 +28,11 @@
return livevars
def pop_roots(self, hop, livevars):
- if not livevars:
- return
- # mark the values as gc roots
- for var in livevars:
- v_adr = gen_cast(hop.llops, llmemory.Address, var)
- v_newaddr = hop.genop("direct_call", [c_asm_gcroot, v_adr],
- resulttype=llmemory.Address)
- hop.genop("gc_reload_possibly_moved", [v_newaddr, var])
+ hop.genop("gc_asmgcroot", livevars)
def build_root_walker(self):
return AsmStackRootWalker(self)
- def mark_call_cannotcollect(self, hop, name):
- hop.genop("direct_call", [c_asm_nocollect, name])
-
def gct_direct_call(self, hop):
fnptr = hop.spaceop.args[0].value
try:
@@ -483,19 +473,6 @@
c_asm_stackwalk = Constant(pypy_asm_stackwalk,
lltype.typeOf(pypy_asm_stackwalk))
-pypy_asm_gcroot = rffi.llexternal('pypy_asm_gcroot',
- [llmemory.Address],
- llmemory.Address,
- sandboxsafe=True,
- _nowrapper=True)
-c_asm_gcroot = Constant(pypy_asm_gcroot, lltype.typeOf(pypy_asm_gcroot))
-
-pypy_asm_nocollect = rffi.llexternal('pypy_asm_gc_nocollect',
- [rffi.CCHARP], lltype.Void,
- sandboxsafe=True,
- _nowrapper=True)
-c_asm_nocollect = Constant(pypy_asm_nocollect, lltype.typeOf(pypy_asm_nocollect))
-
QSORT_CALLBACK_PTR = lltype.Ptr(lltype.FuncType([llmemory.Address,
llmemory.Address], rffi.INT))
qsort = rffi.llexternal('qsort',
Modified: pypy/branch/asmgcc-64/pypy/translator/c/gc.py
==============================================================================
--- pypy/branch/asmgcc-64/pypy/translator/c/gc.py (original)
+++ pypy/branch/asmgcc-64/pypy/translator/c/gc.py Thu Apr 22 09:52:55 2010
@@ -326,12 +326,30 @@
def convert_weakref_to(self, ptarget):
return framework.convert_weakref_to(ptarget)
- def OP_GC_RELOAD_POSSIBLY_MOVED(self, funcgen, op):
- if isinstance(op.args[1], Constant):
- return '/* %s */' % (op,)
- else:
- args = [funcgen.expr(v) for v in op.args]
- return '%s = %s; /* for moving GCs */' % (args[1], args[0])
+ def OP_GC_ASMGCROOT(self, funcgen, op):
+ # The following pseudo-instruction is used by --gcrootfinder=asmgcc
+ # just after a call to tell gcc to put a GCROOT mark on each gc-pointer
+ # local variable. In practice the asm statement is often a no-op
+ # in the final machine code and doesn't prevent most optimizations,
+ # except that so far it forces its arguments to be in memory (instead
+ # of in the registers that are preserved by the call).
+ lines = []
+ regs = []
+ def generate(end=True):
+ bodylines = ['GCROOT %' + str(i) for i in range(len(regs))]
+ if end:
+ bodylines.append('GCREND')
+ lines.append('asm volatile ("%s" : :%s : "memory");' % (
+ '\\n\\t'.join(bodylines), ','.join(regs)))
+ del regs[:]
+ #
+ for v in op.args:
+ if not isinstance(v, Constant):
+ if len(regs) == 8:
+ generate(end=False)
+ regs.append(' "m"(%s)' % funcgen.expr(v))
+ generate()
+ return ''.join(lines)
def common_gcheader_definition(self, defnode):
return defnode.db.gctransformer.gc_fields()
Modified: pypy/branch/asmgcc-64/pypy/translator/c/src/mem.h
==============================================================================
--- pypy/branch/asmgcc-64/pypy/translator/c/src/mem.h (original)
+++ pypy/branch/asmgcc-64/pypy/translator/c/src/mem.h Thu Apr 22 09:52:55 2010
@@ -10,33 +10,6 @@
extern long pypy_asm_stackwalk(void*);
#define __gcnoreorderhack __gcmapend
-/* The following pseudo-instruction is used by --gcrootfinder=asmgcc
- just after a call to tell gcc to put a GCROOT mark on each gc-pointer
- local variable. All such local variables need to go through a "v =
- pypy_asm_gcroot(v)". The old value should not be used any more by
- the C code; this prevents the following case from occurring: gcc
- could make two copies of the local variable (e.g. one in the stack
- and one in a register), pass one to GCROOT, and later use the other
- one. In practice the pypy_asm_gcroot() is often a no-op in the final
- machine code and doesn't prevent most optimizations. */
-
-/* With gcc, getting the asm() right was tricky, though. The asm() is
- not volatile so that gcc is free to delete it if the output variable
- is not used at all. We need to prevent gcc from moving the asm()
- *before* the call that could cause a collection; this is the purpose
- of the (unused) __gcnoreorderhack input argument. Any memory input
- argument would have this effect: as far as gcc knows the call
- instruction can modify arbitrary memory, thus creating the order
- dependency that we want. */
-
-#define pypy_asm_gcroot(p) ({void*_r; \
- asm ("/* GCROOT %0 */" : "=g" (_r) : \
- "0" (p), "m" (__gcnoreorderhack)); \
- _r; })
-
-#define pypy_asm_gc_nocollect(f) asm volatile ("/* GC_NOCOLLECT " #f " */" \
- : : )
-
#define pypy_asm_keepalive(v) asm volatile ("/* keepalive %0 */" : : \
"g" (v))
More information about the Pypy-commit
mailing list