[pypy-commit] pypy lightweight-finalizers: remove one set of hacks to another in order for it to work after translation
fijal
noreply at buildbot.pypy.org
Thu Oct 6 04:05:35 CEST 2011
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: lightweight-finalizers
Changeset: r47838:a85b330c7a9c
Date: 2011-10-04 17:58 +0200
http://bitbucket.org/pypy/pypy/changeset/a85b330c7a9c/
Log: remove one set of hacks to another in order for it to work after
translation as well (OP_TRACK_ALLOC_STOP will be emitted correctly)
diff --git a/pypy/annotation/builtin.py b/pypy/annotation/builtin.py
--- a/pypy/annotation/builtin.py
+++ b/pypy/annotation/builtin.py
@@ -691,7 +691,7 @@
assert isinstance(s_size, SomeInteger) #XXX add noneg...?
return SomeInteger(nonneg=True)
-def raw_free(s_addr, s_track_free=None):
+def raw_free(s_addr):
assert isinstance(s_addr, SomeAddress)
def raw_memclear(s_addr, s_int):
diff --git a/pypy/rpython/lltypesystem/llmemory.py b/pypy/rpython/lltypesystem/llmemory.py
--- a/pypy/rpython/lltypesystem/llmemory.py
+++ b/pypy/rpython/lltypesystem/llmemory.py
@@ -8,7 +8,6 @@
from pypy.rlib.objectmodel import Symbolic
from pypy.rpython.lltypesystem import lltype
from pypy.tool.uid import uid
-from pypy.tool import leakfinder
class AddressOffset(Symbolic):
@@ -781,7 +780,7 @@
raise NotImplementedError(size)
return size._raw_malloc([], zero=False)
-def raw_free(adr, track_free=False):
+def raw_free(adr):
# try to free the whole object if 'adr' is the address of the header
from pypy.rpython.memory.gcheader import GCHeaderBuilder
try:
@@ -791,8 +790,6 @@
else:
raw_free(cast_ptr_to_adr(objectptr))
assert isinstance(adr.ref()._obj, lltype._parentable)
- if track_free:
- leakfinder.remember_free(adr.ptr._as_obj())
adr.ptr._as_obj()._free()
def raw_malloc_usage(size):
diff --git a/pypy/rpython/lltypesystem/lloperation.py b/pypy/rpython/lltypesystem/lloperation.py
--- a/pypy/rpython/lltypesystem/lloperation.py
+++ b/pypy/rpython/lltypesystem/lloperation.py
@@ -400,7 +400,7 @@
'raw_store': LLOp(),
'stack_malloc': LLOp(), # mmh
'track_alloc_start': LLOp(),
- 'track_alloc_stop': LLOp(),
+ 'track_alloc_stop': LLOp(canrun=True),
'adr_add': LLOp(canfold=True),
'adr_sub': LLOp(canfold=True),
'adr_delta': LLOp(canfold=True),
diff --git a/pypy/rpython/lltypesystem/opimpl.py b/pypy/rpython/lltypesystem/opimpl.py
--- a/pypy/rpython/lltypesystem/opimpl.py
+++ b/pypy/rpython/lltypesystem/opimpl.py
@@ -4,6 +4,7 @@
from pypy.rpython.lltypesystem import lltype, llmemory
from pypy.rpython.lltypesystem.lloperation import opimpls
from pypy.rlib import debug
+from pypy.tool import leakfinder
# ____________________________________________________________
# Implementation of the 'canfold' operations
@@ -598,6 +599,9 @@
from pypy.rlib.rtimer import read_timestamp
return read_timestamp()
+def op_track_alloc_stop(addr):
+ leakfinder.remember_free(addr.ptr._obj)
+
# ____________________________________________________________
def get_op_impl(opname):
diff --git a/pypy/rpython/memory/gc/base.py b/pypy/rpython/memory/gc/base.py
--- a/pypy/rpython/memory/gc/base.py
+++ b/pypy/rpython/memory/gc/base.py
@@ -1,4 +1,5 @@
from pypy.rpython.lltypesystem import lltype, llmemory, llarena, rffi
+from pypy.rpython.lltypesystem.lloperation import llop
from pypy.rlib.debug import ll_assert
from pypy.rpython.memory.gcheader import GCHeaderBuilder
from pypy.rpython.memory.support import DEFAULT_CHUNK_SIZE
@@ -357,7 +358,8 @@
typeid = self.get_type_id(addr)
raw_adr = (addr + self.ofs_to_raw_mem_ptr(typeid)).address[0]
if raw_adr:
- llmemory.raw_free(raw_adr, track_free=True)
+ llop.track_alloc_stop(lltype.Void, raw_adr)
+ llmemory.raw_free(raw_adr)
class MovingGCBase(GCBase):
diff --git a/pypy/rpython/rbuiltin.py b/pypy/rpython/rbuiltin.py
--- a/pypy/rpython/rbuiltin.py
+++ b/pypy/rpython/rbuiltin.py
@@ -565,11 +565,11 @@
hop.exception_cannot_occur()
return hop.genop('raw_malloc_usage', [v_size], resulttype=lltype.Signed)
-def rtype_raw_free(hop, i_track_free=None):
+def rtype_raw_free(hop):
s_addr = hop.args_s[0]
if s_addr.is_null_address():
raise TyperError("raw_free(x) where x is the constant NULL")
- v_addr = hop.inputarg(llmemory.Address, 0)
+ v_addr, = hop.inputargs(llmemory.Address)
hop.exception_cannot_occur()
return hop.genop('raw_free', [v_addr])
More information about the pypy-commit
mailing list