Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r66920:927908bea004
Date: 2013-09-11 14:17 -0700
http://bitbucket.org/pypy/pypy/changeset/927908bea004/
Log: merge default
diff --git a/lib-python/2.7/argparse.py b/lib-python/2.7/argparse.py
--- a/lib-python/2.7/argparse.py
+++ b/lib-python/2.7/argparse.py
@@ -1780,7 +1780,19 @@
# error if this argument is not allowed with other previously
# seen arguments, assuming that actions that use the default
# value don't really count as "present"
- if argument_values is not action.default:
+
+ # XXX PyPy bug-to-bug compatibility: "is" on primitive types
+ # is not consistent in CPython. We'll assume it is close
+ # enough for ints (which is true only for "small ints"), but
+ # for floats and longs and complexes we'll go for the option
+ # of forcing "is" to say False, like it usually does on
+ # CPython. A fix is pending on CPython trunk
+ # (http://bugs.python.org/issue18943) but that might change
+ # the details of the semantics and so not be applied to 2.7.
+ # See the line AA below.
+
+ if (argument_values is not action.default or
+ type(argument_values) in (float, long, complex)): # AA
seen_non_default_actions.add(action)
for conflict_action in action_conflicts.get(action, []):
if conflict_action in seen_non_default_actions:
diff --git a/pypy/module/thread/test/test_thread.py
b/pypy/module/thread/test/test_thread.py
--- a/pypy/module/thread/test/test_thread.py
+++ b/pypy/module/thread/test/test_thread.py
@@ -187,9 +187,12 @@
skip("this OS supports too many threads to check (> 1000)")
lock = _thread.allocate_lock()
lock.acquire()
+ count = [0]
def f():
+ count[0] += 1
lock.acquire()
lock.release()
+ count[0] -= 1
try:
try:
for i in range(1000):
@@ -197,11 +200,15 @@
finally:
lock.release()
# wait a bit to allow most threads to finish now
- self.busywait(2.0)
+ while count[0] > 10:
+ print(count[0]) # <- releases the GIL
+ print("ok.")
except (_thread.error, MemoryError):
pass
else:
raise Exception("could unexpectedly start 1000 threads")
+ # safety: check that we can start a new thread here
+ thread.start_new_thread(lambda: None, ())
def test_stack_size(self):
import _thread
diff --git a/rpython/jit/codewriter/call.py b/rpython/jit/codewriter/call.py
--- a/rpython/jit/codewriter/call.py
+++ b/rpython/jit/codewriter/call.py
@@ -92,17 +92,6 @@
else:
assert op.opname == 'indirect_call'
graphs = op.args[-1].value
- if graphs is None:
- # special case: handle the indirect call that goes to
- # the 'instantiate' methods. This check is a bit imprecise
- # but it's not too bad if we mistake a random indirect call
- # for the one to 'instantiate'.
- from rpython.rtyper.lltypesystem import rclass
- CALLTYPE = op.args[0].concretetype
- if (op.opname == 'indirect_call' and len(op.args) == 2 and
- CALLTYPE == rclass.OBJECT_VTABLE.instantiate):
- graphs = list(self._graphs_of_all_instantiate())
- #
if graphs is not None:
result = []
for graph in graphs:
@@ -114,11 +103,6 @@
# residual call case: we don't need to look into any graph
return None
- def _graphs_of_all_instantiate(self):
- for vtable in self.rtyper.lltype2vtable.values():
- if vtable.instantiate:
- yield vtable.instantiate._obj.graph
-
def guess_call_kind(self, op, is_candidate=None):
if op.opname == 'direct_call':
funcptr = op.args[0].value
diff --git a/rpython/jit/codewriter/effectinfo.py
b/rpython/jit/codewriter/effectinfo.py
--- a/rpython/jit/codewriter/effectinfo.py
+++ b/rpython/jit/codewriter/effectinfo.py
@@ -166,9 +166,6 @@
EffectInfo.MOST_GENERAL = EffectInfo(None, None, None, None,
EffectInfo.EF_RANDOM_EFFECTS,
can_invalidate=True)
-EffectInfo.LEAST_GENERAL = EffectInfo([], [], [], [],
- EffectInfo.EF_ELIDABLE_CANNOT_RAISE,
- can_invalidate=False)
def effectinfo_from_writeanalyze(effects, cpu,
diff --git a/rpython/jit/metainterp/test/test_ajit.py
b/rpython/jit/metainterp/test/test_ajit.py
--- a/rpython/jit/metainterp/test/test_ajit.py
+++ b/rpython/jit/metainterp/test/test_ajit.py
@@ -1411,7 +1411,6 @@
self.check_resops(call=2)
def test_merge_guardclass_guardvalue(self):
- from rpython.rlib.objectmodel import instantiate
myjitdriver = JitDriver(greens = [], reds = ['x', 'l'])
class A(object):
@@ -1438,7 +1437,6 @@
self.check_resops(guard_class=0, guard_value=6)
def test_merge_guardnonnull_guardclass(self):
- from rpython.rlib.objectmodel import instantiate
myjitdriver = JitDriver(greens = [], reds = ['x', 'l'])
class A(object):
@@ -1468,7 +1466,6 @@
def test_merge_guardnonnull_guardvalue(self):
- from rpython.rlib.objectmodel import instantiate
myjitdriver = JitDriver(greens = [], reds = ['x', 'l'])
class A(object):
@@ -1497,7 +1494,6 @@
def test_merge_guardnonnull_guardvalue_2(self):
- from rpython.rlib.objectmodel import instantiate
myjitdriver = JitDriver(greens = [], reds = ['x', 'l'])
class A(object):
@@ -1526,7 +1522,6 @@
def test_merge_guardnonnull_guardclass_guardvalue(self):
- from rpython.rlib.objectmodel import instantiate
myjitdriver = JitDriver(greens = [], reds = ['x', 'l'])
class A(object):
diff --git a/rpython/rtyper/lltypesystem/rpbc.py
b/rpython/rtyper/lltypesystem/rpbc.py
--- a/rpython/rtyper/lltypesystem/rpbc.py
+++ b/rpython/rtyper/lltypesystem/rpbc.py
@@ -377,11 +377,20 @@
# no __init__ here, AbstractClassesPBCRepr.__init__ is good enough
def _instantiate_runtime_class(self, hop, vtypeptr, r_instance):
- v_instantiate = hop.genop('getfield', [vtypeptr, hop.inputconst(Void,
"instantiate")], resulttype=vtypeptr.concretetype.TO.instantiate)
- possible_graphs = hop.inputconst(Void,
- [desc.getclassdef(None).my_instantiate_graph for desc in
self.s_pbc.descriptions]
- )
- v_inst = hop.genop('indirect_call', [v_instantiate, possible_graphs],
resulttype=vtypeptr.concretetype.TO.instantiate.TO.RESULT)
+ graphs = []
+ for desc in self.s_pbc.descriptions:
+ classdef = desc.getclassdef(None)
+ assert hasattr(classdef, 'my_instantiate_graph')
+ graphs.append(classdef.my_instantiate_graph)
+ c_graphs = hop.inputconst(Void, graphs)
+ #
+ # "my_instantiate = typeptr.instantiate"
+ c_name = hop.inputconst(Void, 'instantiate')
+ v_instantiate = hop.genop('getfield', [vtypeptr, c_name],
+ resulttype = rclass.OBJECT_VTABLE.instantiate)
+ # "my_instantiate()"
+ v_inst = hop.genop('indirect_call', [v_instantiate, c_graphs],
+ resulttype = rclass.OBJECTPTR)
return hop.genop('cast_pointer', [v_inst], resulttype=r_instance)
def getlowleveltype(self):
diff --git a/rpython/rtyper/rbuiltin.py b/rpython/rtyper/rbuiltin.py
--- a/rpython/rtyper/rbuiltin.py
+++ b/rpython/rtyper/rbuiltin.py
@@ -705,10 +705,6 @@
assert isinstance(hop.args_r[0], rclass.InstanceRepr)
return hop.args_r[0].rtype_isinstance(hop)
-def ll_instantiate(typeptr): # NB. used by rpbc.ClassesPBCRepr as well
- my_instantiate = typeptr.instantiate
- return my_instantiate()
-
def rtype_instantiate(hop):
hop.exception_cannot_occur()
s_class = hop.args_s[0]
@@ -716,10 +712,9 @@
if len(s_class.descriptions) != 1:
# instantiate() on a variable class
vtypeptr, = hop.inputargs(rclass.get_type_repr(hop.rtyper))
- v_inst = hop.gendirectcall(ll_instantiate, vtypeptr)
- return hop.genop('cast_pointer', [v_inst], # v_type implicit in
r_result
- resulttype = hop.r_result.lowleveltype)
-
+ r_class = hop.args_r[0]
+ return r_class._instantiate_runtime_class(hop, vtypeptr,
+ hop.r_result.lowleveltype)
classdef = s_class.any_description().getuniqueclassdef()
return rclass.rtype_new_instance(hop.rtyper, classdef, hop.llops)
diff --git a/rpython/translator/backendopt/gilanalysis.py
b/rpython/translator/backendopt/gilanalysis.py
--- a/rpython/translator/backendopt/gilanalysis.py
+++ b/rpython/translator/backendopt/gilanalysis.py
@@ -26,9 +26,6 @@
return False
else:
return False
-
- def analyze_instantiate_call(self, seen=None):
- return False
def analyze_simple_operation(self, op, graphinfo):
return False
diff --git a/rpython/translator/backendopt/graphanalyze.py
b/rpython/translator/backendopt/graphanalyze.py
--- a/rpython/translator/backendopt/graphanalyze.py
+++ b/rpython/translator/backendopt/graphanalyze.py
@@ -68,9 +68,6 @@
result, self.analyze_direct_call(graph, seen))
return result
- def analyze_instantiate_call(self, seen=None):
- return self.top_result()
-
def analyze_link(self, graph, link):
return self.bottom_result()
@@ -79,7 +76,7 @@
def compute_graph_info(self, graph):
return None
- def analyze(self, op, seen=None, graphinfo=None, block=None):
+ def analyze(self, op, seen=None, graphinfo=None):
if op.opname == "direct_call":
graph = get_graph(op.args[0], self.translator)
if graph is None:
@@ -94,18 +91,6 @@
elif op.opname == "indirect_call":
graphs = op.args[-1].value
if graphs is None:
- if block is not None:
- v_func = op.args[0]
- for op1 in block.operations:
- if (v_func is op1.result and
- op1.opname == 'getfield' and
- op1.args[0].concretetype == rclass.CLASSTYPE and
- op1.args[1].value == 'instantiate'):
- x = self.analyze_instantiate_call(seen)
- if self.verbose and x:
- self.dump_info('analyze_instantiate(%s): %r' %
(
- graphs, x))
- return x
if self.verbose:
self.dump_info('%s to unknown' % (op,))
return self.top_result()
@@ -143,7 +128,7 @@
for op in block.operations:
result = self.add_to_result(
result,
- self.analyze(op, seen, graphinfo, block=block)
+ self.analyze(op, seen, graphinfo)
)
if self.is_top_result(result):
break
@@ -177,7 +162,7 @@
graphs = self.translator.graphs
for graph in graphs:
for block, op in graph.iterblockops():
- self.analyze(op, block=block)
+ self.analyze(op)
class Dependency(object):
diff --git a/rpython/translator/backendopt/test/test_writeanalyze.py
b/rpython/translator/backendopt/test/test_writeanalyze.py
--- a/rpython/translator/backendopt/test/test_writeanalyze.py
+++ b/rpython/translator/backendopt/test/test_writeanalyze.py
@@ -169,8 +169,6 @@
assert not wa.analyze(op_call_m)
def test_instantiate(self):
- # instantiate is interesting, because it leads to one of the few cases
of
- # an indirect call without a list of graphs
from rpython.rlib.objectmodel import instantiate
class A:
pass
@@ -187,7 +185,7 @@
t, wa = self.translate(f, [int])
fgraph = graphof(t, f)
result = wa.analyze(fgraph.startblock.operations[0])
- assert result is top_set
+ assert not result
def test_llexternal(self):
from rpython.rtyper.lltypesystem.rffi import llexternal
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit