Author: Alex Gaynor <[email protected]>
Branch: unroll-if-alt
Changeset: r47347:c0f24c23e46b
Date: 2011-09-19 08:28 -0400
http://bitbucket.org/pypy/pypy/changeset/c0f24c23e46b/
Log: merged default in.
diff --git a/pypy/jit/metainterp/blackhole.py b/pypy/jit/metainterp/blackhole.py
--- a/pypy/jit/metainterp/blackhole.py
+++ b/pypy/jit/metainterp/blackhole.py
@@ -1455,7 +1455,7 @@
def resume_in_blackhole(metainterp_sd, jitdriver_sd, resumedescr,
all_virtuals=None):
from pypy.jit.metainterp.resume import blackhole_from_resumedata
- debug_start('jit-blackhole')
+ #debug_start('jit-blackhole')
metainterp_sd.profiler.start_blackhole()
blackholeinterp = blackhole_from_resumedata(
metainterp_sd.blackholeinterpbuilder,
@@ -1474,12 +1474,12 @@
_run_forever(blackholeinterp, current_exc)
finally:
metainterp_sd.profiler.end_blackhole()
- debug_stop('jit-blackhole')
+ #debug_stop('jit-blackhole')
def convert_and_run_from_pyjitpl(metainterp, raising_exception=False):
# Get a chain of blackhole interpreters and fill them by copying
# 'metainterp.framestack'.
- debug_start('jit-blackhole')
+ #debug_start('jit-blackhole')
metainterp_sd = metainterp.staticdata
metainterp_sd.profiler.start_blackhole()
nextbh = None
@@ -1502,4 +1502,4 @@
_run_forever(firstbh, current_exc)
finally:
metainterp_sd.profiler.end_blackhole()
- debug_stop('jit-blackhole')
+ #debug_stop('jit-blackhole')
diff --git a/pypy/jit/metainterp/heapcache.py b/pypy/jit/metainterp/heapcache.py
--- a/pypy/jit/metainterp/heapcache.py
+++ b/pypy/jit/metainterp/heapcache.py
@@ -9,7 +9,10 @@
def reset(self):
# contains boxes where the class is already known
self.known_class_boxes = {}
- # store the boxes that contain newly allocated objects:
+ # store the boxes that contain newly allocated objects, this maps the
+ # boxes to a bool, the bool indicates whether or not the object has
+ # escaped the trace or not, its presences in the mapping shows that it
+ # was allocated inside the trace
self.new_boxes = {}
# contains frame boxes that are not virtualizables
self.nonstandard_virtualizables = {}
@@ -23,6 +26,17 @@
self.length_cache = {}
def invalidate_caches(self, opnum, descr, argboxes):
+ self.mark_escaped(opnum, argboxes)
+ self.clear_caches(opnum, descr, argboxes)
+
+ def mark_escaped(self, opnum, argboxes):
+ for idx, box in enumerate(argboxes):
+ # setfield_gc and setarrayitem_gc don't escape their first argument
+ if not (idx == 0 and opnum in [rop.SETFIELD_GC,
rop.SETARRAYITEM_GC]):
+ if box in self.new_boxes:
+ self.new_boxes[box] = False
+
+ def clear_caches(self, opnum, descr, argboxes):
if opnum == rop.SETFIELD_GC:
return
if opnum == rop.SETARRAYITEM_GC:
@@ -73,8 +87,11 @@
def nonstandard_virtualizables_now_known(self, box):
self.nonstandard_virtualizables[box] = None
+ def is_unescaped(self, box):
+ return self.new_boxes.get(box, False)
+
def new(self, box):
- self.new_boxes[box] = None
+ self.new_boxes[box] = True
def new_array(self, box, lengthbox):
self.new(box)
@@ -146,7 +163,6 @@
indexcache = cache.get(index, None)
cache[index] = self._do_write_with_aliasing(indexcache, box, valuebox)
-
def arraylen(self, box):
return self.length_cache.get(box, None)
diff --git a/pypy/jit/metainterp/test/test_heapcache.py
b/pypy/jit/metainterp/test/test_heapcache.py
--- a/pypy/jit/metainterp/test/test_heapcache.py
+++ b/pypy/jit/metainterp/test/test_heapcache.py
@@ -326,3 +326,22 @@
[None, None, box2, None, None]
)
assert h.getarrayitem(box4, descr1, index1) is None
+
+ def test_unescaped(self):
+ h = HeapCache()
+ assert not h.is_unescaped(box1)
+ h.new(box2)
+ assert h.is_unescaped(box2)
+ h.invalidate_caches(rop.SETFIELD_GC, None, [box2, box1])
+ assert h.is_unescaped(box2)
+ h.invalidate_caches(rop.SETFIELD_GC, None, [box1, box2])
+ assert not h.is_unescaped(box2)
+
+ def test_unescaped_array(self):
+ h = HeapCache()
+ h.new_array(box1, lengthbox1)
+ assert h.is_unescaped(box1)
+ h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box1, index1, box2])
+ assert h.is_unescaped(box1)
+ h.invalidate_caches(rop.SETARRAYITEM_GC, None, [box2, index1, box1])
+ assert not h.is_unescaped(box1)
\ No newline at end of file
diff --git a/pypy/jit/metainterp/warmstate.py b/pypy/jit/metainterp/warmstate.py
--- a/pypy/jit/metainterp/warmstate.py
+++ b/pypy/jit/metainterp/warmstate.py
@@ -367,9 +367,9 @@
# ---------- execute assembler ----------
while True: # until interrupted by an exception
metainterp_sd.profiler.start_running()
- debug_start("jit-running")
+ #debug_start("jit-running")
fail_descr = warmrunnerdesc.execute_token(loop_token)
- debug_stop("jit-running")
+ #debug_stop("jit-running")
metainterp_sd.profiler.end_running()
loop_token = None # for test_memmgr
if vinfo is not None:
diff --git a/pypy/module/_continuation/test/support.py
b/pypy/module/_continuation/test/support.py
--- a/pypy/module/_continuation/test/support.py
+++ b/pypy/module/_continuation/test/support.py
@@ -9,4 +9,4 @@
import pypy.rlib.rstacklet
except CompilationError, e:
py.test.skip("cannot import rstacklet: %s" % e)
- cls.space = gettestobjspace(usemodules=['_continuation'])
+ cls.space = gettestobjspace(usemodules=['_continuation'],
continuation=True)
diff --git a/pypy/module/pyexpat/interp_pyexpat.py
b/pypy/module/pyexpat/interp_pyexpat.py
--- a/pypy/module/pyexpat/interp_pyexpat.py
+++ b/pypy/module/pyexpat/interp_pyexpat.py
@@ -12,6 +12,7 @@
from pypy.translator.platform import platform
import sys
+import weakref
import py
if sys.platform == "win32":
@@ -180,7 +181,7 @@
class CallbackData(Wrappable):
def __init__(self, space, parser):
self.space = space
- self.parser = parser
+ self.parser = weakref.ref(parser)
SETTERS = {}
for index, (name, params) in enumerate(HANDLERS.items()):
@@ -257,7 +258,7 @@
id = rffi.cast(lltype.Signed, %(ll_id)s)
userdata = global_storage.get_object(id)
space = userdata.space
- parser = userdata.parser
+ parser = userdata.parser()
handler = parser.handlers[%(index)s]
if not handler:
@@ -292,7 +293,7 @@
id = rffi.cast(lltype.Signed, ll_userdata)
userdata = global_storage.get_object(id)
space = userdata.space
- parser = userdata.parser
+ parser = userdata.parser()
name = rffi.charp2str(name)
diff --git a/pypy/module/test_lib_pypy/test_greenlet.py
b/pypy/module/test_lib_pypy/test_greenlet.py
--- a/pypy/module/test_lib_pypy/test_greenlet.py
+++ b/pypy/module/test_lib_pypy/test_greenlet.py
@@ -3,7 +3,7 @@
class AppTestGreenlet:
def setup_class(cls):
- cls.space = gettestobjspace(usemodules=['_continuation'])
+ cls.space = gettestobjspace(usemodules=['_continuation'],
continuation=True)
def test_simple(self):
from greenlet import greenlet
diff --git a/pypy/rlib/rstacklet.py b/pypy/rlib/rstacklet.py
--- a/pypy/rlib/rstacklet.py
+++ b/pypy/rlib/rstacklet.py
@@ -1,4 +1,6 @@
from pypy.rlib import _rffi_stacklet as _c
+from pypy.rlib import jit
+from pypy.rlib.objectmodel import we_are_translated
from pypy.rpython.lltypesystem import lltype, llmemory
DEBUG = False
@@ -6,8 +8,9 @@
class StackletThread(object):
+ @jit.dont_look_inside
def __init__(self, config):
- self._gcrootfinder = _getgcrootfinder(config)
+ self._gcrootfinder = _getgcrootfinder(config, we_are_translated())
self._thrd = _c.newthread()
if not self._thrd:
raise MemoryError
@@ -16,6 +19,7 @@
assert debug.sthread is None, "multithread debug support missing"
debug.sthread = self
+ @jit.dont_look_inside
def new(self, callback, arg=llmemory.NULL):
if DEBUG:
callback = _debug_wrapper(callback)
@@ -25,6 +29,7 @@
return h
new._annspecialcase_ = 'specialize:arg(1)'
+ @jit.dont_look_inside
def switch(self, stacklet):
if DEBUG:
debug.remove(stacklet)
@@ -33,6 +38,7 @@
debug.add(h)
return h
+ @jit.dont_look_inside
def destroy(self, stacklet):
if DEBUG:
debug.remove(stacklet)
@@ -62,7 +68,13 @@
# ____________________________________________________________
-def _getgcrootfinder(config):
+def _getgcrootfinder(config, translated):
+ if translated:
+ assert config is not None, ("you have to pass a valid config, "
+ "e.g. from 'driver.config'")
+ if config is not None:
+ assert config.translation.continuation, (
+ "stacklet: you have to translate with --continuation")
if (config is None or
config.translation.gc in ('ref', 'boehm', 'none')): # for tests
gcrootfinder = 'n/a'
diff --git a/pypy/rpython/memory/gctransform/framework.py
b/pypy/rpython/memory/gctransform/framework.py
--- a/pypy/rpython/memory/gctransform/framework.py
+++ b/pypy/rpython/memory/gctransform/framework.py
@@ -812,6 +812,7 @@
resultvar=op.result)
def gct_gc_shadowstackref_destroy(self, hop):
+ op = hop.spaceop
hop.genop("direct_call",
[self.root_walker.gc_shadowstackref_destroy_ptr, op.args[0]])
diff --git a/pypy/rpython/memory/gctransform/test/test_framework.py
b/pypy/rpython/memory/gctransform/test/test_framework.py
--- a/pypy/rpython/memory/gctransform/test/test_framework.py
+++ b/pypy/rpython/memory/gctransform/test/test_framework.py
@@ -139,7 +139,8 @@
cbuild = CStandaloneBuilder(t, entrypoint, t.config,
gcpolicy=FrameworkGcPolicy2)
f = py.test.raises(Exception, cbuild.generate_graphs_for_llinterp)
- assert str(f.value) == 'no_collect function can trigger collection: g'
+ expected = "'no_collect' function can trigger collection: <function g at "
+ assert str(f.value).startswith(expected)
class WriteBarrierTransformer(FrameworkGCTransformer):
clean_sets = {}
diff --git a/pypy/tool/logparser.py b/pypy/tool/logparser.py
--- a/pypy/tool/logparser.py
+++ b/pypy/tool/logparser.py
@@ -75,9 +75,9 @@
if verbose:
sys.stderr.write('loaded\n')
if performance_log and time_decrase:
- raise Exception("The time decreases! The log file may have been"
- " produced on a multi-CPU machine and the process"
- " moved between CPUs.")
+ print ("The time decreases! The log file may have been"
+ " produced on a multi-CPU machine and the process"
+ " moved between CPUs.")
return log
def extract_category(log, catprefix='', toplevel=False):
diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -52,14 +52,15 @@
pypy_c_dir = basedir.join('pypy', 'translator', 'goal')
pypy_c = pypy_c_dir.join('pypy-c.exe')
libpypy_c = pypy_c_dir.join('libpypy-c.dll')
- libexpat = pypy_c_dir.join('libexpat.dll')
- if not libexpat.check():
- libexpat = py.path.local.sysfind('libexpat.dll')
- assert libexpat, "libexpat.dll not found"
- print "Picking %s" % libexpat
binaries = [(pypy_c, pypy_c.basename),
- (libpypy_c, libpypy_c.basename),
- (libexpat, libexpat.basename)]
+ (libpypy_c, libpypy_c.basename)]
+ for extra in ['libexpat.dll', 'sqlite3.dll']:
+ p = pypy_c_dir.join(extra)
+ if not p.check():
+ p = py.path.local.sysfind(extra)
+ assert p, "%s not found" % (extra,)
+ print "Picking %s" % p
+ binaries.append((p, p.basename))
else:
basename = 'pypy-c'
if override_pypy_c is None:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit