Author: Alex Gaynor <[email protected]>
Branch: unroll-if-alt
Changeset: r47307:74cf1f2c98fa
Date: 2011-09-16 12:41 -0400
http://bitbucket.org/pypy/pypy/changeset/74cf1f2c98fa/
Log: merged default in.
diff --git a/lib_pypy/greenlet.py b/lib_pypy/greenlet.py
--- a/lib_pypy/greenlet.py
+++ b/lib_pypy/greenlet.py
@@ -124,8 +124,7 @@
try:
res = greenlet.run(*args)
finally:
- if greenlet.parent is not _tls.main:
- _continuation.permute(greenlet, greenlet.parent)
+ _continuation.permute(greenlet, greenlet.parent)
return (res,)
def _greenlet_throw(greenlet, exc, value, tb):
@@ -133,5 +132,4 @@
try:
raise exc, value, tb
finally:
- if greenlet.parent is not _tls.main:
- _continuation.permute(greenlet, greenlet.parent)
+ _continuation.permute(greenlet, greenlet.parent)
diff --git a/pypy/module/_continuation/interp_continuation.py
b/pypy/module/_continuation/interp_continuation.py
--- a/pypy/module/_continuation/interp_continuation.py
+++ b/pypy/module/_continuation/interp_continuation.py
@@ -21,16 +21,16 @@
def check_sthread(self):
ec = self.space.getexecutioncontext()
if ec.stacklet_thread is not self.sthread:
- start_state.clear()
+ global_state.clear()
raise geterror(self.space, "inter-thread support is missing")
return ec
def descr_init(self, w_callable, __args__):
if self.sthread is not None:
raise geterror(self.space, "continulet already __init__ialized")
- start_state.origin = self
- start_state.w_callable = w_callable
- start_state.args = __args__
+ global_state.origin = self
+ global_state.w_callable = w_callable
+ global_state.args = __args__
self.bottomframe = make_fresh_frame(self.space)
self.sthread = build_sthread(self.space)
try:
@@ -39,13 +39,13 @@
raise MemoryError
except MemoryError:
self.sthread = None
- start_state.clear()
+ global_state.clear()
raise getmemoryerror(self.space)
def switch(self, w_to):
sthread = self.sthread
if sthread is not None and sthread.is_empty_handle(self.h):
- start_state.clear()
+ global_state.clear()
raise geterror(self.space, "continulet already finished")
to = self.space.interp_w(W_Continulet, w_to, can_be_None=True)
if to is not None and to.sthread is None:
@@ -59,33 +59,33 @@
return get_result() # else: no-op
if to is not None:
if to.sthread is not sthread:
- start_state.clear()
+ global_state.clear()
raise geterror(self.space, "cross-thread double switch")
if self is to: # double-switch to myself: no-op
return get_result()
if sthread.is_empty_handle(to.h):
- start_state.clear()
+ global_state.clear()
raise geterror(self.space, "continulet already finished")
ec = self.check_sthread()
#
- start_state.origin = self
+ global_state.origin = self
if to is None:
# simple switch: going to self.h
- start_state.destination = self
+ global_state.destination = self
else:
# double switch: the final destination is to.h
- start_state.destination = to
+ global_state.destination = to
#
try:
- do_switch(sthread, start_state.destination.h)
+ do_switch(sthread, global_state.destination.h)
except MemoryError:
- start_state.clear()
+ global_state.clear()
raise getmemoryerror(self.space)
#
return get_result()
def descr_switch(self, w_value=None, w_to=None):
- start_state.w_value = w_value
+ global_state.w_value = w_value
return self.switch(w_to)
def descr_throw(self, w_type, w_val=None, w_tb=None, w_to=None):
@@ -100,8 +100,8 @@
#
operr = OperationError(w_type, w_val, tb)
operr.normalize_exception(space)
- start_state.w_value = None
- start_state.propagate_exception = operr
+ global_state.w_value = None
+ global_state.propagate_exception = operr
return self.switch(w_to)
def descr_is_pending(self):
@@ -172,7 +172,7 @@
# ____________________________________________________________
-class StartState: # xxx a single global to pass around the function to start
+class GlobalState:
def clear(self):
self.origin = None
self.destination = None
@@ -180,15 +180,15 @@
self.args = None
self.w_value = None
self.propagate_exception = None
-start_state = StartState()
-start_state.clear()
+global_state = GlobalState()
+global_state.clear()
def new_stacklet_callback(h, arg):
- self = start_state.origin
- w_callable = start_state.w_callable
- args = start_state.args
- start_state.clear()
+ self = global_state.origin
+ w_callable = global_state.w_callable
+ args = global_state.args
+ global_state.clear()
try:
do_switch(self.sthread, h)
except MemoryError:
@@ -198,30 +198,30 @@
try:
assert self.sthread.ec.topframeref() is None
self.sthread.ec.topframeref = jit.non_virtual_ref(self.bottomframe)
- if start_state.propagate_exception is not None:
- raise start_state.propagate_exception # just propagate it further
- if start_state.w_value is not space.w_None:
+ if global_state.propagate_exception is not None:
+ raise global_state.propagate_exception # just propagate it further
+ if global_state.w_value is not space.w_None:
raise OperationError(space.w_TypeError, space.wrap(
"can't send non-None value to a just-started continulet"))
args = args.prepend(self.space.wrap(self))
w_result = space.call_args(w_callable, args)
except Exception, e:
- start_state.propagate_exception = e
+ global_state.propagate_exception = e
else:
- start_state.w_value = w_result
+ global_state.w_value = w_result
self.sthread.ec.topframeref = jit.vref_None
- start_state.origin = self
- start_state.destination = self
+ global_state.origin = self
+ global_state.destination = self
return self.h
def do_switch(sthread, h):
h = sthread.switch(h)
- origin = start_state.origin
- self = start_state.destination
- start_state.origin = None
- start_state.destination = None
+ origin = global_state.origin
+ self = global_state.destination
+ global_state.origin = None
+ global_state.destination = None
self.h, origin.h = origin.h, h
#
current = sthread.ec.topframeref
@@ -230,12 +230,12 @@
origin.bottomframe.f_backref = current
def get_result():
- if start_state.propagate_exception:
- e = start_state.propagate_exception
- start_state.propagate_exception = None
+ if global_state.propagate_exception:
+ e = global_state.propagate_exception
+ global_state.propagate_exception = None
raise e
- w_value = start_state.w_value
- start_state.w_value = None
+ w_value = global_state.w_value
+ global_state.w_value = None
return w_value
def build_sthread(space):
@@ -255,7 +255,7 @@
cont = space.interp_w(W_Continulet, w_cont)
if cont.sthread is not sthread:
if cont.sthread is None:
- raise geterror(space, "got a non-initialized continulet")
+ continue # ignore non-initialized continulets
else:
raise geterror(space, "inter-thread support is missing")
elif sthread.is_empty_handle(cont.h):
diff --git a/pypy/module/_continuation/test/test_stacklet.py
b/pypy/module/_continuation/test/test_stacklet.py
--- a/pypy/module/_continuation/test/test_stacklet.py
+++ b/pypy/module/_continuation/test/test_stacklet.py
@@ -661,6 +661,12 @@
assert res == "done"
main()
+ def test_permute_noninitialized(self):
+ from _continuation import continulet, permute
+ permute(continulet.__new__(continulet)) # ignored
+ permute(continulet.__new__(continulet), # ignored
+ continulet.__new__(continulet))
+
def test_bug_finish_with_already_finished_stacklet(self):
from _continuation import continulet, error
# make an already-finished continulet
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
@@ -409,8 +409,7 @@
if XML_ParserFree: # careful with CPython interpreter shutdown
XML_ParserFree(self.itself)
if global_storage:
- global_storage.free_nonmoving_id(
- rffi.cast(lltype.Signed, self.itself))
+ global_storage.free_nonmoving_id(self.id)
@unwrap_spec(flag=int)
def SetParamEntityParsing(self, space, flag):
diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py
--- a/pypy/rlib/jit.py
+++ b/pypy/rlib/jit.py
@@ -332,10 +332,10 @@
class JitHintError(Exception):
"""Inconsistency in the JIT hints."""
-PARAMETERS = {'threshold': 1032, # just above 1024
- 'function_threshold': 1617, # slightly more than one above
+PARAMETERS = {'threshold': 1039, # just above 1024, prime
+ 'function_threshold': 1619, # slightly more than one above, also
prime
'trace_eagerness': 200,
- 'trace_limit': 12000,
+ 'trace_limit': 6000,
'inlining': 1,
'loop_longevity': 1000,
'retrace_limit': 5,
diff --git a/pypy/rpython/memory/gctransform/asmgcroot.py
b/pypy/rpython/memory/gctransform/asmgcroot.py
--- a/pypy/rpython/memory/gctransform/asmgcroot.py
+++ b/pypy/rpython/memory/gctransform/asmgcroot.py
@@ -663,4 +663,5 @@
QSORT_CALLBACK_PTR],
lltype.Void,
sandboxsafe=True,
+ random_effects_on_gcobjs=False, # but has a callback
_nowrapper=True)
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
@@ -626,8 +626,8 @@
func = getattr(graph, 'func', None)
if func and getattr(func, '_gc_no_collect_', False):
if self.collect_analyzer.analyze_direct_call(graph):
- raise Exception("no_collect function can trigger collection:
%s"
- % func.__name__)
+ raise Exception("'no_collect' function can trigger collection:"
+ " %s" % func)
if self.write_barrier_ptr:
self.clean_sets = (
diff --git a/pypy/rpython/test/test_rlist.py b/pypy/rpython/test/test_rlist.py
--- a/pypy/rpython/test/test_rlist.py
+++ b/pypy/rpython/test/test_rlist.py
@@ -1363,14 +1363,15 @@
def test_hints(self):
from pypy.rlib.objectmodel import newlist
from pypy.rpython.annlowlevel import hlstr
-
- def f(z):
- z = hlstr(z)
+
+ strings = ['abc', 'def']
+ def f(i):
+ z = strings[i]
x = newlist(sizehint=13)
x += z
return ''.join(x)
- res = self.interpret(f, [self.string_to_ll('abc')])
+ res = self.interpret(f, [0])
assert self.ll_to_string(res) == 'abc'
class TestLLtype(BaseTestRlist, LLRtypeMixin):
diff --git a/pypy/translator/backendopt/graphanalyze.py
b/pypy/translator/backendopt/graphanalyze.py
--- a/pypy/translator/backendopt/graphanalyze.py
+++ b/pypy/translator/backendopt/graphanalyze.py
@@ -3,6 +3,8 @@
from pypy.rpython.lltypesystem import lltype
class GraphAnalyzer(object):
+ verbose = False
+
def __init__(self, translator):
self.translator = translator
self.analyzed_calls = {}
@@ -71,12 +73,24 @@
if op.opname == "direct_call":
graph = get_graph(op.args[0], self.translator)
if graph is None:
- return self.analyze_external_call(op, seen)
- return self.analyze_direct_call(graph, seen)
+ x = self.analyze_external_call(op, seen)
+ if self.verbose and x:
+ print '\tanalyze_external_call %s: %r' % (op, x)
+ return x
+ x = self.analyze_direct_call(graph, seen)
+ if self.verbose and x:
+ print '\tanalyze_direct_call(%s): %r' % (graph, x)
+ return x
elif op.opname == "indirect_call":
- if op.args[-1].value is None:
+ graphs = op.args[-1].value
+ if graphs is None:
+ if self.verbose:
+ print '\t%s to unknown' % (op,)
return self.top_result()
- return self.analyze_indirect_call(op.args[-1].value, seen)
+ x = self.analyze_indirect_call(graphs, seen)
+ if self.verbose and x:
+ print '\tanalyze_indirect_call(%s): %r' % (graphs, x)
+ return x
elif op.opname == "oosend":
name = op.args[0].value
TYPE = op.args[1].concretetype
@@ -85,7 +99,10 @@
if graph is None:
return self.analyze_external_method(op, TYPE, meth)
return self.analyze_oosend(TYPE, name, seen)
- return self.analyze_simple_operation(op, graphinfo)
+ x = self.analyze_simple_operation(op, graphinfo)
+ if self.verbose and x:
+ print '\t%s: %r' % (op, x)
+ return x
def analyze_direct_call(self, graph, seen=None):
if graph in self.analyzed_calls:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit