[pypy-commit] pypy faster-traceback: fixes

2016-03-29 Thread fijal
Author: fijal
Branch: faster-traceback
Changeset: r83413:02b7658fdc94
Date: 2016-03-29 08:58 +0200
http://bitbucket.org/pypy/pypy/changeset/02b7658fdc94/

Log:fixes

diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -354,7 +354,7 @@
 # don't intern float constants
 self._consts_float += 1
 v = (len(self._floats) << 1) | 1
-self._floats.append(box.getfloat())
+self._floats.append(box.getfloatstorage())
 return tag(TAGCONSTOTHER, v)
 else:
 self._consts_ptr += 1
diff --git a/rpython/rlib/rvmprof/cintf.py b/rpython/rlib/rvmprof/cintf.py
--- a/rpython/rlib/rvmprof/cintf.py
+++ b/rpython/rlib/rvmprof/cintf.py
@@ -56,7 +56,7 @@
 compilation_info=eci,
 _nowrapper=True)
 vmprof_get_stack_trace_default = rffi.llexternal(
-"vmprof_get_stack_trace_default",
+"get_stack_trace_default",
 [rffi.CArrayPtr(lltype.Signed), rffi.INT],
 rffi.INT, compilation_info=eci, releasegil=False)
 return CInterface(locals())
diff --git a/rpython/rlib/rvmprof/src/vmprof_common.h 
b/rpython/rlib/rvmprof/src/vmprof_common.h
--- a/rpython/rlib/rvmprof/src/vmprof_common.h
+++ b/rpython/rlib/rvmprof/src/vmprof_common.h
@@ -120,7 +120,7 @@
 }
 #endif
 
-static int get_stack_trace_default(intptr_t *result, int max_depth)
+int get_stack_trace_default(intptr_t *result, int max_depth)
 {
 return get_stack_trace(get_vmprof_stack(), result, max_depth, 0);
 }
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Test and fix: we could get in obscure cases an AssertionError that

2016-03-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r83414:bd677c5dd9b8
Date: 2016-03-29 10:50 +0200
http://bitbucket.org/pypy/pypy/changeset/bd677c5dd9b8/

Log:Test and fix: we could get in obscure cases an AssertionError that
should really be just an InvalidLoop

diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py 
b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -7,6 +7,7 @@
 from rpython.jit.metainterp.resoperation import rop, AbstractResOp, 
GuardResOp,\
  OpHelpers, ResOperation
 from rpython.jit.metainterp.optimizeopt import info
+from rpython.jit.metainterp.optimize import InvalidLoop
 from rpython.jit.metainterp.typesystem import llhelper
 from rpython.rlib.objectmodel import specialize, we_are_translated
 from rpython.rlib.debug import debug_print
@@ -411,11 +412,14 @@
 def make_constant(self, box, constbox):
 assert isinstance(constbox, Const)
 box = self.get_box_replacement(box)
-if not we_are_translated():# safety-check
-if (box.get_forwarded() is not None and
-isinstance(constbox, ConstInt) and
-not isinstance(box.get_forwarded(), info.AbstractRawPtrInfo)):
-assert box.get_forwarded().contains(constbox.getint())
+# safety-check: if the constant is outside the bounds for the
+# box, then it is an invalid loop
+if (box.get_forwarded() is not None and
+isinstance(constbox, ConstInt) and
+not isinstance(box.get_forwarded(), info.AbstractRawPtrInfo)):
+if not box.get_forwarded().contains(constbox.getint()):
+raise InvalidLoop("a box is turned into constant that is "
+  "outside the range allowed for that box")
 if box.is_constant():
 return
 if box.type == 'r' and box.get_forwarded() is not None:
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py 
b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -3072,6 +3072,16 @@
 """
 self.raises(InvalidLoop, self.optimize_loop, ops, ops)
 
+def test_invalid_guard_value_after_bounds(self):
+ops = """
+[i0]
+i1 = int_gt(i0, 5)
+guard_true(i1) []
+guard_value(i0, 2) []
+jump()
+"""
+self.raises(InvalidLoop, self.optimize_loop, ops, ops)
+
 def test_guard_class_oois(self):
 ops = """
 [p1]
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix warning

2016-03-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r83415:3fc855a83e91
Date: 2016-03-29 14:14 +0200
http://bitbucket.org/pypy/pypy/changeset/3fc855a83e91/

Log:Fix warning

diff --git a/rpython/rlib/rvmprof/src/vmprof_main.h 
b/rpython/rlib/rvmprof/src/vmprof_main.h
--- a/rpython/rlib/rvmprof/src/vmprof_main.h
+++ b/rpython/rlib/rvmprof/src/vmprof_main.h
@@ -290,7 +290,7 @@
 
 static int close_profile(void)
 {
-unsigned char marker = MARKER_TRAILER;
+char marker = MARKER_TRAILER;
 
 if (_write_all(&marker, 1) < 0)
 return -1;
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy faster-traceback: remove outermost enter/leave frame, see what happens

2016-03-29 Thread fijal
Author: fijal
Branch: faster-traceback
Changeset: r83416:88009e2e49fb
Date: 2016-03-29 14:15 +0200
http://bitbucket.org/pypy/pypy/changeset/88009e2e49fb/

Log:remove outermost enter/leave frame, see what happens

diff --git a/rpython/jit/metainterp/pyjitpl.py 
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -1945,16 +1945,17 @@
 jitcode.jitdriver_sd.jitdriver.is_recursive)
 #return self.jitdriver_sd is not None and jitcode is 
self.jitdriver_sd.mainjitcode
 
-def newframe(self, jitcode, greenkey=None):
+def newframe(self, jitcode, greenkey=None, enter_portal_frame=True):
 if jitcode.jitdriver_sd:
 self.portal_call_depth += 1
 self.call_ids.append(self.current_call_id)
-unique_id = -1
-if greenkey is not None:
-unique_id = jitcode.jitdriver_sd.warmstate.get_unique_id(
-greenkey)
-jd_no = jitcode.jitdriver_sd.index
-self.enter_portal_frame(jd_no, unique_id)
+if enter_portal_frame:
+unique_id = -1
+if greenkey is not None:
+unique_id = jitcode.jitdriver_sd.warmstate.get_unique_id(
+greenkey)
+jd_no = jitcode.jitdriver_sd.index
+self.enter_portal_frame(jd_no, unique_id)
 self.current_call_id += 1
 if greenkey is not None and self.is_main_jitcode(jitcode):
 self.portal_trace_positions.append(
@@ -1995,6 +1996,8 @@
 def finishframe(self, resultbox, leave_portal_frame=True):
 # handle a non-exceptional return from the current frame
 self.last_exc_value = lltype.nullptr(rclass.OBJECT)
+if leave_portal_frame and len(self.framestack) == 1:
+leave_portal_frame = False # don't emit for the last one
 self.popframe(leave_portal_frame=leave_portal_frame)
 if self.framestack:
 if resultbox is not None:
@@ -2033,7 +2036,8 @@
 target = ord(code[position+1]) | (ord(code[position+2])<<8)
 frame.pc = target
 raise ChangeFrame
-self.popframe()
+# emit leave_portal_frame for all but last
+self.popframe(leave_portal_frame=bool(self.framestack))
 try:
 self.compile_exit_frame_with_exception(self.last_exc_box)
 except SwitchToBlackhole, stb:
@@ -2714,7 +2718,8 @@
 # - make a new frame -
 self.portal_call_depth = -1 # always one portal around
 self.framestack = []
-f = self.newframe(self.jitdriver_sd.mainjitcode)
+f = self.newframe(self.jitdriver_sd.mainjitcode,
+  enter_portal_frame=False)
 f.setup_call(original_boxes)
 assert self.portal_call_depth == 0
 self.virtualref_boxes = []
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix the test

2016-03-29 Thread fijal
Author: fijal
Branch: 
Changeset: r83417:7abe7ba251e5
Date: 2016-03-29 14:16 +0200
http://bitbucket.org/pypy/pypy/changeset/7abe7ba251e5/

Log:fix the test

diff --git a/rpython/jit/metainterp/test/test_jitiface.py 
b/rpython/jit/metainterp/test/test_jitiface.py
--- a/rpython/jit/metainterp/test/test_jitiface.py
+++ b/rpython/jit/metainterp/test/test_jitiface.py
@@ -18,12 +18,12 @@
 reasons = []
 
 class MyJitIface(JitHookInterface):
-def on_abort(self, reason, jitdriver, greenkey, greenkey_repr, 
logops, trace):
+def on_abort(self, reason, jitdriver, greenkey, greenkey_repr, 
logops, ops):
 assert jitdriver is myjitdriver
 assert len(greenkey) == 1
 reasons.append(reason)
 assert greenkey_repr == 'blah'
-assert trace.length() > 1
+assert len(ops) > 1
 
 iface = MyJitIface()
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: promote the result of elidable_compatible if the other arguments are constant

2016-03-29 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r83418:a208c212e736
Date: 2016-03-29 13:11 +0200
http://bitbucket.org/pypy/pypy/changeset/a208c212e736/

Log:promote the result of elidable_compatible if the other arguments are
constant

diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -156,16 +156,28 @@
 """
 def decorate(func):
 elidable(func)
+def _all_args_const(*args):
+if len(args) == 0:
+return True
+if len(args) == 1:
+return isconstant(args[0])
+return isconstant(args[0]) and _all_args_const(*args[1:])
 def wrapped_func(x, *args):
 assert x is not None
 x = hint(x, promote_compatible=True)
 if quasi_immut_field_name_for_second_arg is not None:
-return func(x, getattr(x, 
quasi_immut_field_name_for_second_arg), *args)
-return func(x, *args)
+result = func(x, getattr(x, 
quasi_immut_field_name_for_second_arg), *args)
+else:
+result = func(x, *args)
+if _all_args_const(*args):
+promote(result) # make the tracer treat it as a constant
+return result
+wrapped_func.func_name = "elidable_compatible_%s" % (func.func_name, )
 return wrapped_func
 return decorate
 
 
+
 def dont_look_inside(func):
 """ Make sure the JIT does not trace inside decorated function
 (it becomes a call instead)
diff --git a/rpython/rlib/test/test_jit.py b/rpython/rlib/test/test_jit.py
--- a/rpython/rlib/test/test_jit.py
+++ b/rpython/rlib/test/test_jit.py
@@ -143,7 +143,7 @@
 res = self.interpret(f, [2])
 assert res == 5
 
-def test_elidable_promote(self):
+def test_elidable_compatible(self):
 class A(object):
 pass
 a1 = A()
@@ -153,16 +153,21 @@
 @elidable_compatible()
 def g(a):
 return a.x
+@elidable_compatible()
+def h(a, b, c):
+return a.x + b + c
 def f(x):
 if x == 1:
 a = a1
 else:
 a = a2
-return g(a)
+return g(a) + h(a, 2, 0)
+assert f(1) == 4
+assert f(4) == 6
 res = self.interpret(f, [1])
-assert res == 1
+assert res == 4
 res = self.interpret(f, [4])
-assert res == 2
+assert res == 6
 
 def test_elidable_promote_args(self):
 @elidable_promote(promote_args='0')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: fix translation

2016-03-29 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r83419:7bb835521a2e
Date: 2016-03-29 12:18 +0100
http://bitbucket.org/pypy/pypy/changeset/7bb835521a2e/

Log:fix translation

diff --git a/rpython/jit/metainterp/compatible.py 
b/rpython/jit/metainterp/compatible.py
--- a/rpython/jit/metainterp/compatible.py
+++ b/rpython/jit/metainterp/compatible.py
@@ -36,7 +36,7 @@
 if oldcond.same_cond(cond, res):
 return
 cond.activate(res, optimizer)
-if self.conditions and self.conditions.debug_mp_str == 
cond.debug_mp_str:
+if self.conditions and self.conditions[-1].debug_mp_str == 
cond.debug_mp_str:
 cond.debug_mp_str = ''
 self.conditions.append(cond)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: For a "func-in-small-set" attribute, initialize the class vtable to

2016-03-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r83421:1f344b91d8ab
Date: 2016-03-29 17:26 +0200
http://bitbucket.org/pypy/pypy/changeset/1f344b91d8ab/

Log:For a "func-in-small-set" attribute, initialize the class vtable to
'\xff' if there is no corresponding function, instead of the default
of 0 which will map to a random function.

diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -310,10 +310,15 @@
 # setup class attributes: for each attribute name at the level
 # of 'r_parentcls', look up its value in the class
 def assign(mangled_name, value):
-if (isinstance(value, Constant) and
-isinstance(value.value, staticmethod)):
-value = Constant(value.value.__get__(42))   # staticmethod => 
bare function
-llvalue = r.convert_desc_or_const(value)
+if value is None:
+llvalue = r.special_uninitialized_value()
+if llvalue is None:
+return
+else:
+if (isinstance(value, Constant) and
+isinstance(value.value, staticmethod)):
+value = Constant(value.value.__get__(42))   # staticmethod 
=> bare function
+llvalue = r.convert_desc_or_const(value)
 setattr(vtable, mangled_name, llvalue)
 
 for fldname in r_parentcls.clsfields:
@@ -321,8 +326,7 @@
 if r.lowleveltype is Void:
 continue
 value = self.classdef.classdesc.read_attribute(fldname, None)
-if value is not None:
-assign(mangled_name, value)
+assign(mangled_name, value)
 # extra PBC attributes
 for (access_set, attr), (mangled_name, r) in 
r_parentcls.pbcfields.items():
 if self.classdef.classdesc not in access_set.descs:
@@ -330,8 +334,7 @@
 if r.lowleveltype is Void:
 continue
 attrvalue = self.classdef.classdesc.read_attribute(attr, None)
-if attrvalue is not None:
-assign(mangled_name, attrvalue)
+assign(mangled_name, attrvalue)
 
 def fill_vtable_root(self, vtable):
 """Initialize the head of the vtable."""
diff --git a/rpython/rtyper/rmodel.py b/rpython/rtyper/rmodel.py
--- a/rpython/rtyper/rmodel.py
+++ b/rpython/rtyper/rmodel.py
@@ -125,6 +125,9 @@
 self, value))
 return value
 
+def special_uninitialized_value(self):
+return None
+
 def get_ll_eq_function(self):
 """Return an eq(x,y) function to use to compare two low-level
 values of this Repr.
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -431,10 +431,14 @@
 if isinstance(value, types.MethodType) and value.im_self is None:
 value = value.im_func   # unbound method -> bare function
 if value is None:
+assert self.descriptions[0] is None
 return chr(0)
 funcdesc = self.rtyper.annotator.bookkeeper.getdesc(value)
 return self.convert_desc(funcdesc)
 
+def special_uninitialized_value(self):
+return chr(0xFF)
+
 def dispatcher(self, shape, index, argtypes, resulttype):
 key = shape, index, tuple(argtypes), resulttype
 if key in self._dispatch_cache:
diff --git a/rpython/rtyper/test/test_rpbc.py b/rpython/rtyper/test/test_rpbc.py
--- a/rpython/rtyper/test/test_rpbc.py
+++ b/rpython/rtyper/test/test_rpbc.py
@@ -1947,6 +1947,30 @@
 kwds['config'] = self.config
 return TestRPBC.interpret(fn, args, **kwds)
 
+def test_class_missing_base_method_should_crash(self):
+class Base(object):
+pass   # no method 'm' here
+class A(Base):
+def m(self):
+return 42
+class B(Base):
+def m(self):
+return 63
+def g(n):
+if n == 1:
+return A()
+elif n == 2:
+return B()
+else:
+return Base()
+def f(n):
+return g(n).m()
+
+assert self.interpret(f, [1]) == 42
+assert self.interpret(f, [2]) == 63
+e = py.test.raises(ValueError, self.interpret, f, [3])
+assert str(e.value).startswith(r"exit case '\xff' not found")
+
 def test_smallfuncsets_basic():
 from rpython.translator.translator import TranslationContext, graphof
 from rpython.config.translationoption import 
get_combined_translation_config
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: On 32-bit we get mini-functions called '__x86.get_pc_thunk.*' at the

2016-03-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r83422:c98b94183543
Date: 2016-03-29 17:37 +0200
http://bitbucket.org/pypy/pypy/changeset/c98b94183543/

Log:On 32-bit we get mini-functions called '__x86.get_pc_thunk.*' at the
end of some assembler files, when compiled *without* optimizations.
These functions don't have a '.size' closing them. Skip them.

diff --git a/rpython/translator/c/gcc/trackgcroot.py 
b/rpython/translator/c/gcc/trackgcroot.py
--- a/rpython/translator/c/gcc/trackgcroot.py
+++ b/rpython/translator/c/gcc/trackgcroot.py
@@ -1507,7 +1507,8 @@
 functionlines = []
 in_function = False
 for line in iterlines:
-if self.FunctionGcRootTracker.r_functionstart.match(line):
+match = self.FunctionGcRootTracker.r_functionstart.match(line)
+if match and not match.group(1).startswith('__x86.get_pc_thunk.'):
 assert not in_function, (
 "missed the end of the previous function")
 yield False, functionlines
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge heads

2016-03-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r83424:a7bb9851bb51
Date: 2016-03-29 18:26 +0200
http://bitbucket.org/pypy/pypy/changeset/a7bb9851bb51/

Log:merge heads

diff --git a/rpython/translator/c/gcc/trackgcroot.py 
b/rpython/translator/c/gcc/trackgcroot.py
--- a/rpython/translator/c/gcc/trackgcroot.py
+++ b/rpython/translator/c/gcc/trackgcroot.py
@@ -1123,7 +1123,7 @@
 REG2LOC = dict((_reg, LOC_REG | ((_i+1)<<2))
for _i, _reg in enumerate(CALLEE_SAVE_REGISTERS))
 OPERAND = r'(?:[-\w$%+.:@"]+(?:[(][\w%,]+[)])?|[(][\w%,]+[)])'
-LABEL   = r'([a-zA-Z_$.][a-zA-Z0-9_$@.]*)'
+LABEL   = r'([a-zA-Z_$.][a-zA-Z0-9_$.]*)(?:@[@a-zA-Z0-9_$.]*)?'
 OFFSET_LABELS   = 2**30
 TOP_OF_STACK_MINUS_WORD = '-4(%esp)'
 
@@ -1185,7 +1185,7 @@
 REG2LOC = dict((_reg, LOC_REG | ((_i+1)<<2))
for _i, _reg in enumerate(CALLEE_SAVE_REGISTERS))
 OPERAND = r'(?:[-\w$%+.:@"]+(?:[(][\w%,]+[)])?|[(][\w%,]+[)])'
-LABEL   = r'([a-zA-Z_$.][a-zA-Z0-9_$@.]*)'
+LABEL   = r'([a-zA-Z_$.][a-zA-Z0-9_$.]*)(?:@[@a-zA-Z0-9_$.]*)?'
 OFFSET_LABELS   = 2**30
 TOP_OF_STACK_MINUS_WORD = '-8(%rsp)'
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Don't capture the '@xxx' part of labels inside the label itself. It means a ".long

2016-03-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r83423:7c96ec092272
Date: 2016-03-29 13:31 +0200
http://bitbucket.org/pypy/pypy/changeset/7c96ec092272/

Log:Don't capture the '@xxx' part of labels inside the label itself. It
means a ".long .L123@GOTOFF" fails to match a ".L123:" somewhere
else.

diff --git a/rpython/translator/c/gcc/trackgcroot.py 
b/rpython/translator/c/gcc/trackgcroot.py
--- a/rpython/translator/c/gcc/trackgcroot.py
+++ b/rpython/translator/c/gcc/trackgcroot.py
@@ -1123,7 +1123,7 @@
 REG2LOC = dict((_reg, LOC_REG | ((_i+1)<<2))
for _i, _reg in enumerate(CALLEE_SAVE_REGISTERS))
 OPERAND = r'(?:[-\w$%+.:@"]+(?:[(][\w%,]+[)])?|[(][\w%,]+[)])'
-LABEL   = r'([a-zA-Z_$.][a-zA-Z0-9_$@.]*)'
+LABEL   = r'([a-zA-Z_$.][a-zA-Z0-9_$.]*)(?:@[@a-zA-Z0-9_$.]*)?'
 OFFSET_LABELS   = 2**30
 TOP_OF_STACK_MINUS_WORD = '-4(%esp)'
 
@@ -1185,7 +1185,7 @@
 REG2LOC = dict((_reg, LOC_REG | ((_i+1)<<2))
for _i, _reg in enumerate(CALLEE_SAVE_REGISTERS))
 OPERAND = r'(?:[-\w$%+.:@"]+(?:[(][\w%,]+[)])?|[(][\w%,]+[)])'
-LABEL   = r'([a-zA-Z_$.][a-zA-Z0-9_$@.]*)'
+LABEL   = r'([a-zA-Z_$.][a-zA-Z0-9_$.]*)(?:@[@a-zA-Z0-9_$.]*)?'
 OFFSET_LABELS   = 2**30
 TOP_OF_STACK_MINUS_WORD = '-8(%rsp)'
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the C sources to avoid exporting the CPython-like names to

2016-03-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r83425:0ac7c9d76839
Date: 2016-03-29 18:55 +0200
http://bitbucket.org/pypy/pypy/changeset/0ac7c9d76839/

Log:Fix the C sources to avoid exporting the CPython-like names to
common_header.h

diff --git a/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h 
b/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h
--- a/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h
+++ b/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h
@@ -10,6 +10,7 @@
 #define _CJKCODECS_H_
 
 #include "src/cjkcodecs/multibytecodec.h"
+#include "src/cjkcodecs/fixnames.h"
 
 
 /* a unicode "undefined" codepoint */
diff --git a/pypy/module/_multibytecodec/src/cjkcodecs/fixnames.h 
b/pypy/module/_multibytecodec/src/cjkcodecs/fixnames.h
new file mode 100644
--- /dev/null
+++ b/pypy/module/_multibytecodec/src/cjkcodecs/fixnames.h
@@ -0,0 +1,9 @@
+
+/* this is only included from the .c files in this directory: rename
+   these pypymbc-prefixed names to locally define the CPython names */
+typedef pypymbc_ssize_t Py_ssize_t;
+#define PY_SSIZE_T_MAX   ((Py_ssize_t)(((size_t) -1) >> 1))
+#define Py_UNICODE_SIZE pypymbc_UNICODE_SIZE
+typedef pypymbc_wchar_t Py_UNICODE;
+typedef pypymbc_ucs4_t ucs4_t;
+typedef pypymbc_ucs2_t ucs2_t, DBCHAR;
diff --git a/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.c 
b/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.c
--- a/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.c
+++ b/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.c
@@ -1,6 +1,7 @@
 #include 
 #include 
 #include "src/cjkcodecs/multibytecodec.h"
+#include "src/cjkcodecs/fixnames.h"
 
 
 struct pypy_cjk_dec_s *pypy_cjk_dec_new(const MultibyteCodec *codec)
diff --git a/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.h 
b/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.h
--- a/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.h
+++ b/pypy/module/_multibytecodec/src/cjkcodecs/multibytecodec.h
@@ -9,31 +9,28 @@
 #include 
 
 #ifdef _WIN64
-typedef __int64 ssize_t
+typedef __int64 pypymbc_ssize_t
 #elif defined(_WIN32)
-typedef int ssize_t;
+typedef int pypymbc_ssize_t;
 #else
 #include 
-#endif
-
-#ifndef Py_UNICODE_SIZE
-#ifdef _WIN32
-#define Py_UNICODE_SIZE 2
-#else
-#define Py_UNICODE_SIZE 4
-#endif
-typedef wchar_t Py_UNICODE;
-typedef ssize_t Py_ssize_t;
-#define PY_SSIZE_T_MAX   ((Py_ssize_t)(((size_t) -1) >> 1))
+typedef ssize_t pypymbc_ssize_t;
 #endif
 
 #ifdef _WIN32
-typedef unsigned int ucs4_t;
-typedef unsigned short ucs2_t, DBCHAR;
+#define pypymbc_UNICODE_SIZE 2
+#else
+#define pypymbc_UNICODE_SIZE 4
+#endif
+typedef wchar_t pypymbc_wchar_t;
+
+#ifdef _WIN32
+typedef unsigned int pypymbc_ucs4_t;
+typedef unsigned short pypymbc_ucs2_t;
 #else
 #include 
-typedef uint32_t ucs4_t;
-typedef uint16_t ucs2_t, DBCHAR;
+typedef uint32_t pypymbc_ucs4_t;
+typedef uint16_t pypymbc_ucs2_t;
 #endif
 
 
@@ -42,28 +39,28 @@
 void *p;
 int i;
 unsigned char c[8];
-ucs2_t u2[4];
-ucs4_t u4[2];
+pypymbc_ucs2_t u2[4];
+pypymbc_ucs4_t u4[2];
 } MultibyteCodec_State;
 
 typedef int (*mbcodec_init)(const void *config);
-typedef Py_ssize_t (*mbencode_func)(MultibyteCodec_State *state,
+typedef pypymbc_ssize_t (*mbencode_func)(MultibyteCodec_State *state,
 const void *config,
-const Py_UNICODE **inbuf, Py_ssize_t inleft,
-unsigned char **outbuf, Py_ssize_t outleft,
+const pypymbc_wchar_t **inbuf, pypymbc_ssize_t inleft,
+unsigned char **outbuf, pypymbc_ssize_t outleft,
 int flags);
 typedef int (*mbencodeinit_func)(MultibyteCodec_State *state,
  const void *config);
-typedef Py_ssize_t (*mbencodereset_func)(MultibyteCodec_State *state,
+typedef pypymbc_ssize_t (*mbencodereset_func)(MultibyteCodec_State *state,
 const void *config,
-unsigned char **outbuf, Py_ssize_t outleft);
-typedef Py_ssize_t (*mbdecode_func)(MultibyteCodec_State *state,
+unsigned char **outbuf, pypymbc_ssize_t outleft);
+typedef pypymbc_ssize_t (*mbdecode_func)(MultibyteCodec_State *state,
 const void *config,
-const unsigned char **inbuf, Py_ssize_t inleft,
-Py_UNICODE **outbuf, Py_ssize_t outleft);
+const unsigned char **inbuf, pypymbc_ssize_t inleft,
+pypymbc_wchar_t **outbuf, pypymbc_ssize_t outleft);
 typedef int (*mbdecodeinit_func)(MultibyteCodec_State *state,
  const void *config);
-typedef Py_ssize_t (*mbdecodereset_func)(MultibyteCodec_State *state,
+typedef pypymbc_ssize_t (*mbdecodereset_func)(MultibyteCodec_State *state,
  const void *config);
 
 typedef struct MultibyteCodec_s {
@@ -94,59 +91,59 @@

[pypy-commit] pypy default: Hack for "make"ing asmgcc programs in debug mode: this helps on linux32

2016-03-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r83426:424023029f67
Date: 2016-03-29 19:13 +0200
http://bitbucket.org/pypy/pypy/changeset/424023029f67/

Log:Hack for "make"ing asmgcc programs in debug mode: this helps on
linux32

diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -414,10 +414,12 @@
 if self.config.translation.gcrootfinder == 'asmgcc':
 if self.translator.platform.name == 'msvc':
 raise Exception("msvc no longer supports asmgcc")
+_extra = ''
 if self.config.translation.shared:
-mk.definition('DEBUGFLAGS', '-O2 -fomit-frame-pointer -g 
-fPIC')
-else:
-mk.definition('DEBUGFLAGS', '-O2 -fomit-frame-pointer -g')
+_extra = ' -fPIC'
+_extra += ' -fdisable-tree-fnsplit'   # seems to help
+mk.definition('DEBUGFLAGS',
+'-O2 -fomit-frame-pointer -g'+ _extra)
 
 if self.config.translation.shared:
 mk.definition('PYPY_MAIN_FUNCTION', "pypy_main_startup")
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Document ffi.list_types()

2016-03-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r2654:0e5d809db377
Date: 2016-03-29 20:08 +0200
http://bitbucket.org/cffi/cffi/changeset/0e5d809db377/

Log:Document ffi.list_types()

diff --git a/doc/source/using.rst b/doc/source/using.rst
--- a/doc/source/using.rst
+++ b/doc/source/using.rst
@@ -1228,6 +1228,11 @@
 
 .. __: https://bitbucket.org/cffi/cffi/issues/233/
 
+**ffi.list_types()**: builds and returns a list of all user type names
+known in this FFI instance.  The list contains typedef names (sorted in
+alphabetical order), followed by the 'struct xxx' (sorted) and finally
+the 'union xxx' (sorted as well).  *New in version 1.6.*
+
 
 .. _`Preparing and Distributing modules`: cdef.html#loading-libraries
 
diff --git a/doc/source/whatsnew.rst b/doc/source/whatsnew.rst
--- a/doc/source/whatsnew.rst
+++ b/doc/source/whatsnew.rst
@@ -3,6 +3,12 @@
 ==
 
 
+v1.6
+
+
+* ffi.list_types()
+
+
 v1.5.2
 ==
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: With ffi.compile(verbose=True), also print the name of the C (or Python)

2016-03-29 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r2653:f58f14dad850
Date: 2016-03-29 20:04 +0200
http://bitbucket.org/cffi/cffi/changeset/f58f14dad850/

Log:With ffi.compile(verbose=True), also print the name of the C (or
Python) file being generated

diff --git a/cffi/recompiler.py b/cffi/recompiler.py
--- a/cffi/recompiler.py
+++ b/cffi/recompiler.py
@@ -1319,7 +1319,9 @@
 s = s.encode('ascii')
 super(NativeIO, self).write(s)
 
-def _make_c_or_py_source(ffi, module_name, preamble, target_file):
+def _make_c_or_py_source(ffi, module_name, preamble, target_file, verbose):
+if verbose:
+print("generating %s" % (target_file,))
 recompiler = Recompiler(ffi, module_name,
 target_is_python=(preamble is None))
 recompiler.collect_type_table()
@@ -1331,6 +1333,8 @@
 with open(target_file, 'r') as f1:
 if f1.read(len(output) + 1) != output:
 raise IOError
+if verbose:
+print("(already up-to-date)")
 return False # already up-to-date
 except IOError:
 tmp_file = '%s.~%d' % (target_file, os.getpid())
@@ -1343,12 +1347,14 @@
 os.rename(tmp_file, target_file)
 return True
 
-def make_c_source(ffi, module_name, preamble, target_c_file):
+def make_c_source(ffi, module_name, preamble, target_c_file, verbose=False):
 assert preamble is not None
-return _make_c_or_py_source(ffi, module_name, preamble, target_c_file)
+return _make_c_or_py_source(ffi, module_name, preamble, target_c_file,
+verbose)
 
-def make_py_source(ffi, module_name, target_py_file):
-return _make_c_or_py_source(ffi, module_name, None, target_py_file)
+def make_py_source(ffi, module_name, target_py_file, verbose=False):
+return _make_c_or_py_source(ffi, module_name, None, target_py_file,
+verbose)
 
 def _modname_to_file(outputdir, modname, extension):
 parts = modname.split('.')
@@ -1438,7 +1444,8 @@
 target = '*'
 #
 ext = ffiplatform.get_extension(ext_c_file, module_name, **kwds)
-updated = make_c_source(ffi, module_name, preamble, c_file)
+updated = make_c_source(ffi, module_name, preamble, c_file,
+verbose=compiler_verbose)
 if call_c_compiler:
 patchlist = []
 cwd = os.getcwd()
@@ -1458,7 +1465,8 @@
 else:
 if c_file is None:
 c_file, _ = _modname_to_file(tmpdir, module_name, '.py')
-updated = make_py_source(ffi, module_name, c_file)
+updated = make_py_source(ffi, module_name, c_file,
+ verbose=compiler_verbose)
 if call_c_compiler:
 return c_file
 else:
diff --git a/demo/gmp_build.py b/demo/gmp_build.py
--- a/demo/gmp_build.py
+++ b/demo/gmp_build.py
@@ -23,5 +23,4 @@
  libraries=['gmp', 'm'])
 
 if __name__ == '__main__':
-ffi.compile()
-
+ffi.compile(verbose=True)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit