[pypy-svn] r72225 - in pypy/branch/jit-newx86/pypy/jit/backend/newx86: . test
arigo at codespeak.net
arigo at codespeak.net
Sun Mar 14 18:18:51 CET 2010
Author: arigo
Date: Sun Mar 14 18:18:49 2010
New Revision: 72225
Modified:
pypy/branch/jit-newx86/pypy/jit/backend/newx86/codebuf.py
pypy/branch/jit-newx86/pypy/jit/backend/newx86/test/test_codebuf.py
Log:
Bah. Messed up the test checking that all allocated buffers are freed.
Modified: pypy/branch/jit-newx86/pypy/jit/backend/newx86/codebuf.py
==============================================================================
--- pypy/branch/jit-newx86/pypy/jit/backend/newx86/codebuf.py (original)
+++ pypy/branch/jit-newx86/pypy/jit/backend/newx86/codebuf.py Sun Mar 14 18:18:49 2010
@@ -5,19 +5,22 @@
class CodeBufAllocator(object):
+ alloc_count = 0
+
def __init__(self, word):
self.all_data_parts = [] # only if we are not translated
- self.alloc_count = 0
self.cb_class = code_builder_cls[word]
def __del__(self):
- for data, size in self.all_data_parts:
- free(data, size)
- self.alloc_count -= 1
+ if not we_are_translated():
+ for data, size in self.all_data_parts:
+ free(data, size)
+ CodeBufAllocator.alloc_count -= 1
def new_code_buffer(self, map_size):
data = alloc(map_size)
if not we_are_translated():
+ CodeBufAllocator.alloc_count += 1
self.all_data_parts.append((data, map_size))
return self.cb_class(data, map_size)
Modified: pypy/branch/jit-newx86/pypy/jit/backend/newx86/test/test_codebuf.py
==============================================================================
--- pypy/branch/jit-newx86/pypy/jit/backend/newx86/test/test_codebuf.py (original)
+++ pypy/branch/jit-newx86/pypy/jit/backend/newx86/test/test_codebuf.py Sun Mar 14 18:18:49 2010
@@ -10,16 +10,18 @@
WORD = 4
def setup_method(self, meth):
+ CodeBufAllocator.alloc_count = 0
self.cballoc = CodeBufAllocator(self.WORD)
def teardown_method(self, meth):
+ del self.cballoc
for i in range(5):
- if self.cballoc.alloc_count == 0:
+ if CodeBufAllocator.alloc_count == 0:
break
gc.collect()
else:
raise AssertionError("alloc_count == %d" % (
- self.cballoc.alloc_count,))
+ CodeBufAllocator.alloc_count,))
def test_alloc_free(self):
c1 = self.cballoc.new_code_buffer(4096)
More information about the Pypy-commit
mailing list