[pypy-commit] pypy stmgc-c4: do_malloc_xx_clear(), used in the JIT
arigo
noreply at buildbot.pypy.org
Tue Sep 10 09:46:57 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c4
Changeset: r66889:0a12aff5926c
Date: 2013-09-10 09:44 +0200
http://bitbucket.org/pypy/pypy/changeset/0a12aff5926c/
Log: do_malloc_xx_clear(), used in the JIT
diff --git a/rpython/translator/stm/inevitable.py b/rpython/translator/stm/inevitable.py
--- a/rpython/translator/stm/inevitable.py
+++ b/rpython/translator/stm/inevitable.py
@@ -29,7 +29,11 @@
GETTERS = set(['getfield', 'getarrayitem', 'getinteriorfield', 'raw_load'])
SETTERS = set(['setfield', 'setarrayitem', 'setinteriorfield', 'raw_store'])
MALLOCS = set(['malloc', 'malloc_varsize',
- 'malloc_nonmovable', 'malloc_nonmovable_varsize'])
+ 'malloc_nonmovable', 'malloc_nonmovable_varsize',
+ 'raw_malloc',
+ 'do_malloc_fixedsize_clear', 'do_malloc_varsize_clear'])
+FREES = set(['free', 'raw_free'])
+
# ____________________________________________________________
def should_turn_inevitable_getter_setter(op, fresh_mallocs):
@@ -66,10 +70,8 @@
#
# Mallocs & Frees
if op.opname in MALLOCS:
- # flags = op.args[1].value
- # return flags['flavor'] != 'gc'
- return False # XXX: Produces memory leaks on aborts
- if op.opname == 'free':
+ return False
+ if op.opname in FREES:
# We can only run a CFG in non-inevitable mode from start
# to end in one transaction (every free gets called once
# for every fresh malloc). No need to turn inevitable.
@@ -77,12 +79,6 @@
# CFG will always run in inevitable mode anyways.
return not fresh_mallocs.is_fresh_malloc(op.args[0])
#
- if op.opname == 'raw_malloc':
- return False # XXX: Produces memory leaks on aborts
- if op.opname == 'raw_free':
- return not fresh_mallocs.is_fresh_malloc(op.args[0])
-
- #
# Function calls
if op.opname == 'direct_call':
funcptr = op.args[0].value._obj
diff --git a/rpython/translator/stm/test/test_inevitable.py b/rpython/translator/stm/test/test_inevitable.py
--- a/rpython/translator/stm/test/test_inevitable.py
+++ b/rpython/translator/stm/test/test_inevitable.py
@@ -1,4 +1,5 @@
from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
+from rpython.rtyper.lltypesystem.lloperation import llop
from rpython.rtyper.llinterp import LLFrame
from rpython.rtyper.test import test_llinterp
from rpython.rtyper.test.test_llinterp import get_interpreter, clear_tcache
@@ -12,6 +13,12 @@
if self.llinterpreter.inevitable_cause is None:
self.llinterpreter.inevitable_cause = info
+ def op_do_malloc_fixedsize_clear(self):
+ pass # just to check that it doesn't turn inevitable
+
+ def op_do_malloc_varsize_clear(self):
+ pass # just to check that it doesn't turn inevitable
+
class TestTransform:
@@ -239,3 +246,12 @@
res = self.interpret_inevitable(f, [2])
assert res == 'free' # not setfield or getfield
+ def test_do_malloc_llops(self):
+ def f(i):
+ # just to check that it doesn't turn inevitable
+ llop.do_malloc_fixedsize_clear(lltype.Void)
+ llop.do_malloc_varsize_clear(lltype.Void)
+ return i
+
+ res = self.interpret_inevitable(f, [2])
+ assert res is None
More information about the pypy-commit
mailing list