Author: Antonio Cuni <[email protected]>
Branch: virtual-raw-mallocs
Changeset: r59528:244019cd16fd
Date: 2012-12-20 17:54 +0100
http://bitbucket.org/pypy/pypy/changeset/244019cd16fd/
Log: hg merge default; this fixes the problem with raw_malloc and
integers, they are now optimized as well
diff --git a/README b/README
deleted file mode 100644
--- a/README
+++ /dev/null
@@ -1,24 +0,0 @@
-=====================================
-PyPy: Python in Python Implementation
-=====================================
-
-Welcome to PyPy!
-
-PyPy is both an implementation of the Python programming language, and
-an extensive compiler framework for dynamic language implementations.
-You can build self-contained Python implementations which execute
-independently from CPython.
-
-The home page is:
-
- http://pypy.org/
-
-The getting-started document will help guide you:
-
- http://doc.pypy.org/en/latest/getting-started.html
-
-It will also point you to the rest of the documentation which is generated
-from files in the pypy/doc directory within the source repositories. Enjoy
-and send us feedback!
-
- the pypy-dev team <[email protected]>
diff --git a/README.rst b/README.rst
new file mode 100644
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,24 @@
+=====================================
+PyPy: Python in Python Implementation
+=====================================
+
+Welcome to PyPy!
+
+PyPy is both an implementation of the Python programming language, and
+an extensive compiler framework for dynamic language implementations.
+You can build self-contained Python implementations which execute
+independently from CPython.
+
+The home page is:
+
+ http://pypy.org/
+
+The getting-started document will help guide you:
+
+ http://doc.pypy.org/en/latest/getting-started.html
+
+It will also point you to the rest of the documentation which is generated
+from files in the pypy/doc directory within the source repositories. Enjoy
+and send us feedback!
+
+ the pypy-dev team <[email protected]>
diff --git a/lib-python/2.7/timeit.py b/lib-python/2.7/timeit.py
--- a/lib-python/2.7/timeit.py
+++ b/lib-python/2.7/timeit.py
@@ -190,7 +190,8 @@
else:
it = [None] * number
gcold = gc.isenabled()
- gc.disable()
+ if '__pypy__' not in sys.builtin_module_names:
+ gc.disable() # only do that on CPython
try:
timing = self.inner(it, self.timer)
finally:
diff --git a/pypy/annotation/annrpython.py b/pypy/annotation/annrpython.py
--- a/pypy/annotation/annrpython.py
+++ b/pypy/annotation/annrpython.py
@@ -8,7 +8,7 @@
from pypy.objspace.flow.model import (Variable, Constant, FunctionGraph,
c_last_exception, checkgraph)
from pypy.translator import simplify, transform
-from pypy.annotation import model as annmodel, signature
+from pypy.annotation import model as annmodel, signature, unaryop, binaryop
from pypy.annotation.bookkeeper import Bookkeeper
import py
log = py.log.Producer("annrpython")
@@ -453,12 +453,12 @@
# occour for this specific, typed operation.
if block.exitswitch == c_last_exception:
op = block.operations[-1]
- if op.opname in annmodel.BINARY_OPERATIONS:
+ if op.opname in binaryop.BINARY_OPERATIONS:
arg1 = self.binding(op.args[0])
arg2 = self.binding(op.args[1])
binop = getattr(pair(arg1, arg2), op.opname, None)
can_only_throw = annmodel.read_can_only_throw(binop, arg1,
arg2)
- elif op.opname in annmodel.UNARY_OPERATIONS:
+ elif op.opname in unaryop.UNARY_OPERATIONS:
arg1 = self.binding(op.args[0])
opname = op.opname
if opname == 'contains': opname = 'op_contains'
@@ -629,10 +629,10 @@
return self.bookkeeper.newdict()
- def _registeroperations(cls, model):
+ def _registeroperations(cls, unary_ops, binary_ops):
# All unary operations
d = {}
- for opname in model.UNARY_OPERATIONS:
+ for opname in unary_ops:
fnname = 'consider_op_' + opname
exec py.code.Source("""
def consider_op_%s(self, arg, *args):
@@ -640,7 +640,7 @@
""" % (opname, opname)).compile() in globals(), d
setattr(cls, fnname, d[fnname])
# All binary operations
- for opname in model.BINARY_OPERATIONS:
+ for opname in binary_ops:
fnname = 'consider_op_' + opname
exec py.code.Source("""
def consider_op_%s(self, arg1, arg2, *args):
@@ -650,7 +650,7 @@
_registeroperations = classmethod(_registeroperations)
# register simple operations handling
-RPythonAnnotator._registeroperations(annmodel)
+RPythonAnnotator._registeroperations(unaryop.UNARY_OPERATIONS,
binaryop.BINARY_OPERATIONS)
class BlockedInference(Exception):
diff --git a/pypy/annotation/binaryop.py b/pypy/annotation/binaryop.py
--- a/pypy/annotation/binaryop.py
+++ b/pypy/annotation/binaryop.py
@@ -7,7 +7,7 @@
from pypy.tool.pairtype import pair, pairtype
from pypy.annotation.model import SomeObject, SomeInteger, SomeBool, s_Bool
from pypy.annotation.model import SomeString, SomeChar, SomeList, SomeDict
-from pypy.annotation.model import SomeUnicodeCodePoint, SomeStringOrUnicode
+from pypy.annotation.model import SomeUnicodeCodePoint, SomeUnicodeString
from pypy.annotation.model import SomeTuple, SomeImpossibleValue,
s_ImpossibleValue
from pypy.annotation.model import SomeInstance, SomeBuiltin, SomeIterator
from pypy.annotation.model import SomePBC, SomeFloat, s_None
@@ -19,7 +19,6 @@
from pypy.annotation.model import read_can_only_throw
from pypy.annotation.model import add_knowntypedata, merge_knowntypedata
from pypy.annotation.model import SomeGenericCallable
-from pypy.annotation.model import SomeUnicodeString
from pypy.annotation.bookkeeper import getbookkeeper
from pypy.objspace.flow.model import Variable, Constant
from pypy.rlib import rarithmetic
@@ -458,7 +457,8 @@
for s_item in s_tuple.items:
if isinstance(s_item, SomeFloat):
pass # or s_item is a subclass, like SomeInteger
- elif isinstance(s_item, SomeStringOrUnicode) and s_item.no_nul:
+ elif (isinstance(s_item, SomeString) or
+ isinstance(s_item, SomeUnicodeString)) and s_item.no_nul:
pass
else:
no_nul = False
diff --git a/pypy/annotation/model.py b/pypy/annotation/model.py
--- a/pypy/annotation/model.py
+++ b/pypy/annotation/model.py
@@ -202,11 +202,16 @@
self.knowntypedata = knowntypedata
class SomeStringOrUnicode(SomeObject):
+ """Base class for shared implementation of SomeString and
SomeUnicodeString.
+
+ Cannot be an annotation."""
+
immutable = True
can_be_None=False
no_nul = False # No NUL character in the string.
def __init__(self, can_be_None=False, no_nul=False):
+ assert type(self) is not SomeStringOrUnicode
if can_be_None:
self.can_be_None = True
if no_nul:
@@ -225,20 +230,17 @@
d2 = d2.copy(); d2['no_nul'] = 0 # ignored
return d1 == d2
+ def nonnoneify(self):
+ return self.__class__(can_be_None=False, no_nul=self.no_nul)
+
class SomeString(SomeStringOrUnicode):
"Stands for an object which is known to be a string."
knowntype = str
- def nonnoneify(self):
- return SomeString(can_be_None=False, no_nul=self.no_nul)
-
class SomeUnicodeString(SomeStringOrUnicode):
"Stands for an object which is known to be an unicode string"
knowntype = unicode
- def nonnoneify(self):
- return SomeUnicodeString(can_be_None=False, no_nul=self.no_nul)
-
class SomeChar(SomeString):
"Stands for an object known to be a string of length 1."
can_be_None = False
@@ -773,7 +775,3 @@
else:
raise RuntimeError("The annotator relies on 'assert' statements from
the\n"
"\tannotated program: you cannot run it with 'python
-O'.")
-
-# this has the side-effect of registering the unary and binary operations
-from pypy.annotation.unaryop import UNARY_OPERATIONS
-from pypy.annotation.binaryop import BINARY_OPERATIONS
diff --git a/pypy/annotation/signature.py b/pypy/annotation/signature.py
--- a/pypy/annotation/signature.py
+++ b/pypy/annotation/signature.py
@@ -151,4 +151,9 @@
actualtypes[:] = params_s
def enforce_signature_return(funcdesc, sigtype, inferredtype):
- return finish_type(sigtype, funcdesc.bookkeeper, funcdesc.pyobj)
+ s_sigret = finish_type(sigtype, funcdesc.bookkeeper, funcdesc.pyobj)
+ if not s_sigret.contains(inferredtype):
+ raise Exception("%r return value:\n"
+ "expected %s,\n"
+ " got %s" % (funcdesc, s_sigret, inferredtype))
+ return s_sigret
diff --git a/pypy/doc/config/objspace.usemodules.time.txt
b/pypy/doc/config/objspace.usemodules.time.txt
--- a/pypy/doc/config/objspace.usemodules.time.txt
+++ b/pypy/doc/config/objspace.usemodules.time.txt
@@ -1,4 +1,5 @@
Use the 'time' module.
Obsolete; use :config:`objspace.usemodules.rctime` for our up-to-date version
-of the application-level 'time' module.
+of the application-level 'time' module, at least for C-like targets (the C
+and LLVM backends).
diff --git a/pypy/module/_cffi_backend/misc.py
b/pypy/module/_cffi_backend/misc.py
--- a/pypy/module/_cffi_backend/misc.py
+++ b/pypy/module/_cffi_backend/misc.py
@@ -1,7 +1,7 @@
from __future__ import with_statement
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.rpython.lltypesystem import lltype, llmemory, rffi
-from pypy.rlib.rarithmetic import r_uint, r_ulonglong
+from pypy.rlib.rarithmetic import r_uint, r_ulonglong, is_signed_integer_type
from pypy.rlib.unroll import unrolling_iterable
from pypy.rlib.objectmodel import keepalive_until_here, specialize
from pypy.rlib import jit
@@ -64,10 +64,16 @@
@specialize.argtype(1)
def write_raw_integer_data(target, source, size):
- for TP, TPP in _prim_unsigned_types:
- if size == rffi.sizeof(TP):
- rffi.cast(TPP, target)[0] = rffi.cast(TP, source)
- return
+ if is_signed_integer_type(lltype.typeOf(source)):
+ for TP, TPP in _prim_signed_types:
+ if size == rffi.sizeof(TP):
+ rffi.cast(TPP, target)[0] = rffi.cast(TP, source)
+ return
+ else:
+ for TP, TPP in _prim_unsigned_types:
+ if size == rffi.sizeof(TP):
+ rffi.cast(TPP, target)[0] = rffi.cast(TP, source)
+ return
raise NotImplementedError("bad integer size")
def write_raw_float_data(target, source, size):
diff --git a/pypy/module/_hashlib/interp_hashlib.py
b/pypy/module/_hashlib/interp_hashlib.py
--- a/pypy/module/_hashlib/interp_hashlib.py
+++ b/pypy/module/_hashlib/interp_hashlib.py
@@ -20,9 +20,10 @@
+ rffi.sizeof(ropenssl.EVP_MD) * 2 + 208
class W_Hash(Wrappable):
- ctx = lltype.nullptr(ropenssl.EVP_MD_CTX.TO)
+ NULL_CTX = lltype.nullptr(ropenssl.EVP_MD_CTX.TO)
+ ctx = NULL_CTX
- def __init__(self, space, name):
+ def __init__(self, space, name, copy_from=NULL_CTX):
self.name = name
digest_type = self.digest_type_by_name(space)
self.digest_size = rffi.getintfield(digest_type, 'c_md_size')
@@ -35,14 +36,16 @@
ctx = lltype.malloc(ropenssl.EVP_MD_CTX.TO, flavor='raw')
rgc.add_memory_pressure(HASH_MALLOC_SIZE + self.digest_size)
try:
- ropenssl.EVP_DigestInit(ctx, digest_type)
+ if copy_from:
+ ropenssl.EVP_MD_CTX_copy(ctx, copy_from)
+ else:
+ ropenssl.EVP_DigestInit(ctx, digest_type)
self.ctx = ctx
except:
lltype.free(ctx, flavor='raw')
raise
def __del__(self):
- # self.lock.free()
if self.ctx:
ropenssl.EVP_MD_CTX_cleanup(self.ctx)
lltype.free(self.ctx, flavor='raw')
@@ -68,10 +71,8 @@
def copy(self, space):
"Return a copy of the hash object."
- w_hash = W_Hash(space, self.name)
with self.lock:
- ropenssl.EVP_MD_CTX_copy(w_hash.ctx, self.ctx)
- return w_hash
+ return W_Hash(space, self.name, copy_from=self.ctx)
def digest(self, space):
"Return the digest value as a string of binary data."
diff --git a/pypy/module/cpyext/src/pythread.c
b/pypy/module/cpyext/src/pythread.c
--- a/pypy/module/cpyext/src/pythread.c
+++ b/pypy/module/cpyext/src/pythread.c
@@ -37,13 +37,13 @@
int
PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
{
- return RPyThreadAcquireLock((struct RPyOpaqueThreadLock*)lock, waitflag);
+ return RPyThreadAcquireLock((struct RPyOpaque_ThreadLock*)lock, waitflag);
}
void
PyThread_release_lock(PyThread_type_lock lock)
{
- RPyThreadReleaseLock((struct RPyOpaqueThreadLock*)lock);
+ RPyThreadReleaseLock((struct RPyOpaque_ThreadLock*)lock);
}
diff --git a/pypy/module/fcntl/test/test_fcntl.py
b/pypy/module/fcntl/test/test_fcntl.py
--- a/pypy/module/fcntl/test/test_fcntl.py
+++ b/pypy/module/fcntl/test/test_fcntl.py
@@ -11,7 +11,7 @@
os.unlink(i)
class AppTestFcntl:
- spaceconfig = dict(usemodules=('fcntl', 'array', 'struct', 'termios',
'select', 'time'))
+ spaceconfig = dict(usemodules=('fcntl', 'array', 'struct', 'termios',
'select', 'rctime'))
def setup_class(cls):
tmpprefix = str(udir.ensure('test_fcntl', dir=1).join('tmp_'))
cls.w_tmp = cls.space.wrap(tmpprefix)
@@ -191,8 +191,11 @@
if child_pid == 0:
# We're the child
time.sleep(1)
- return
+ os._exit(0)
try:
+ # We're the parent, we want TIOCGPGRP calls after child started
but before it dies
+ time.sleep(0)
+
buf = array.array('i', [0])
res = fcntl.ioctl(mfd, TIOCGPGRP, buf, True)
assert res == 0
diff --git a/pypy/module/imp/test/test_import.py
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -1268,7 +1268,7 @@
class AppTestMultithreadedImp(object):
- spaceconfig = dict(usemodules=['thread', 'time'])
+ spaceconfig = dict(usemodules=['thread', 'rctime'])
def setup_class(cls):
#if not conftest.option.runappdirect:
diff --git a/pypy/module/thread/test/support.py
b/pypy/module/thread/test/support.py
--- a/pypy/module/thread/test/support.py
+++ b/pypy/module/thread/test/support.py
@@ -35,7 +35,7 @@
class GenericTestThread:
- spaceconfig = dict(usemodules=('thread', 'time', 'signal'))
+ spaceconfig = dict(usemodules=('thread', 'rctime', 'signal'))
def setup_class(cls):
if cls.runappdirect:
diff --git a/pypy/rlib/objectmodel.py b/pypy/rlib/objectmodel.py
--- a/pypy/rlib/objectmodel.py
+++ b/pypy/rlib/objectmodel.py
@@ -132,11 +132,12 @@
def decorator(f):
def get_annotation(t):
from pypy.annotation.signature import annotation
- from pypy.annotation.model import SomeObject, SomeStringOrUnicode
+ from pypy.annotation.model import SomeObject, SomeString,
SomeUnicodeString
if isinstance(t, SomeObject):
return t
s_result = annotation(t)
- if isinstance(s_result, SomeStringOrUnicode):
+ if (isinstance(s_result, SomeString) or
+ isinstance(s_result, SomeUnicodeString)):
return s_result.__class__(can_be_None=True)
return s_result
def get_type_descr_of_argument(arg):
diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -246,6 +246,17 @@
return r_class(0)
most_neg_value_of._annspecialcase_ = 'specialize:memo'
+def is_signed_integer_type(tp):
+ from pypy.rpython.lltypesystem import lltype, rffi
+ if tp is lltype.Signed:
+ return True
+ try:
+ r_class = rffi.platform.numbertype_to_rclass[tp]
+ return r_class.SIGNED
+ except KeyError:
+ return False # not an integer type
+is_signed_integer_type._annspecialcase_ = 'specialize:memo'
+
def highest_bit(n):
"""
Calculates the highest set bit in n. This function assumes that n is a
diff --git a/pypy/rlib/test/test_rarithmetic.py
b/pypy/rlib/test/test_rarithmetic.py
--- a/pypy/rlib/test/test_rarithmetic.py
+++ b/pypy/rlib/test/test_rarithmetic.py
@@ -364,6 +364,17 @@
assert most_neg_value_of_same_type(r_longlong(123)) == llmin
assert most_neg_value_of_same_type(r_ulonglong(123)) == 0
+def test_is_signed_integer_type():
+ from pypy.rpython.lltypesystem import lltype, rffi
+ assert is_signed_integer_type(lltype.Signed)
+ assert is_signed_integer_type(rffi.SIGNEDCHAR)
+ assert is_signed_integer_type(lltype.SignedLongLong)
+ assert not is_signed_integer_type(lltype.Unsigned)
+ assert not is_signed_integer_type(lltype.UnsignedLongLong)
+ assert not is_signed_integer_type(lltype.Char)
+ assert not is_signed_integer_type(lltype.UniChar)
+ assert not is_signed_integer_type(lltype.Bool)
+
def test_r_ulonglong():
x = r_longlong(-1)
y = r_ulonglong(x)
diff --git a/pypy/rlib/test/test_signature.py b/pypy/rlib/test/test_signature.py
--- a/pypy/rlib/test/test_signature.py
+++ b/pypy/rlib/test/test_signature.py
@@ -3,12 +3,14 @@
from pypy.rlib import types
from pypy.annotation import model
from pypy.translator.translator import TranslationContext, graphof
+from pypy.rpython.lltypesystem import rstr
+from pypy.rpython.annlowlevel import LowLevelAnnotatorPolicy
-def annotate_at(f):
+def annotate_at(f, policy=None):
t = TranslationContext()
- a = t.buildannotator()
- a.annotate_helper(f, [model.s_ImpossibleValue]*f.func_code.co_argcount)
+ a = t.buildannotator(policy=policy)
+ a.annotate_helper(f, [model.s_ImpossibleValue]*f.func_code.co_argcount,
policy=policy)
return a
def sigof(a, f):
@@ -16,8 +18,8 @@
g = graphof(a.translator, f)
return [a.bindings[v] for v in g.startblock.inputargs] +
[a.bindings[g.getreturnvar()]]
-def getsig(f):
- a = annotate_at(f)
+def getsig(f, policy=None):
+ a = annotate_at(f, policy=policy)
return sigof(a, f)
def check_annotator_fails(caller):
@@ -25,7 +27,7 @@
assert caller.func_name in repr(exc.args)
-def test_signature_bookkeeping():
+def test_bookkeeping():
@signature('x', 'y', returns='z')
def f(a, b):
return a + len(b)
@@ -35,13 +37,13 @@
assert f.foo == 'foo'
assert f(1, 'hello') == 6
-def test_signature_basic():
+def test_basic():
@signature(types.int(), types.str(), returns=types.char())
def f(a, b):
return b[a]
assert getsig(f) == [model.SomeInteger(), model.SomeString(),
model.SomeChar()]
-def test_signature_arg_errors():
+def test_arg_errors():
@signature(types.int(), types.str(), returns=types.int())
def f(a, b):
return a + len(b)
@@ -52,7 +54,7 @@
def bad_for_body(): # would give error inside 'f' body, instead errors at
call
f('a', 'b')
-def test_signature_return():
+def test_return():
@signature(returns=types.str())
def f():
return 'a'
@@ -66,37 +68,66 @@
a = annotate_at(g)
assert sigof(a, f) == [model.SomeString(), model.SomeString()]
-def test_signature_return_errors():
+def test_return_errors():
@check_annotator_fails
@signature(returns=types.int())
def int_not_char():
return 'a'
+
@check_annotator_fails
@signature(types.str(), returns=types.int())
def str_to_int(s):
return s
+ @signature(returns=types.str())
+ def str_not_None():
+ return None
+ @check_annotator_fails
+ def caller_of_str_not_None():
+ return str_not_None()
-def test_signature_none():
[email protected]
+def test_return_errors_xfail():
+ @check_annotator_fails
+ @signature(returns=types.str())
+ def str_not_None():
+ return None
+
+
+def test_none():
@signature(returns=types.none())
def f():
pass
assert getsig(f) == [model.s_None]
-def test_signature_float():
+def test_float():
@signature(types.longfloat(), types.singlefloat(), returns=types.float())
def f(a, b):
return 3.0
assert getsig(f) == [model.SomeLongFloat(), model.SomeSingleFloat(),
model.SomeFloat()]
-def test_signature_unicode():
+def test_unicode():
@signature(types.unicode(), returns=types.int())
def f(u):
return len(u)
assert getsig(f) == [model.SomeUnicodeString(), model.SomeInteger()]
-def test_signature_list():
+def test_ptr():
+ policy = LowLevelAnnotatorPolicy()
+ @signature(types.ptr(rstr.STR), returns=types.none())
+ def f(buf):
+ pass
+ argtype = getsig(f, policy=policy)[0]
+ assert isinstance(argtype, model.SomePtr)
+ assert argtype.ll_ptrtype.TO == rstr.STR
+
+ def g():
+ f(rstr.mallocstr(10))
+ getsig(g, policy=policy)
+
+
+def test_list():
@signature(types.list(types.int()), returns=types.int())
def f(a):
return len(a)
@@ -133,7 +164,7 @@
l.append('b')
getsig(can_append)
-def test_signature_array():
+def test_array():
@signature(returns=types.array(types.int()))
def f():
return [1]
@@ -148,7 +179,7 @@
l.append(2)
check_annotator_fails(try_append)
-def test_signature_dict():
+def test_dict():
@signature(returns=types.dict(types.str(), types.int()))
def f():
return {'a': 1, 'b': 2}
@@ -158,7 +189,7 @@
assert rettype.dictdef.dictvalue.s_value == model.SomeInteger()
-def test_signature_instance():
+def test_instance():
class C1(object):
pass
class C2(C1):
@@ -182,7 +213,7 @@
def bad_for_body():
f(C1())
-def test_signature_self():
+def test_self():
@finishsigs
class C(object):
@signature(types.self(), types.self(), returns=types.none())
@@ -201,7 +232,7 @@
assert isinstance(argtype, model.SomeInstance)
assert argtype.classdef.classdesc.pyobj == C
-def test_signature_self_error():
+def test_self_error():
class C(object):
@signature(types.self(), returns=types.none())
def incomplete_sig_meth(self):
diff --git a/pypy/rlib/types.py b/pypy/rlib/types.py
--- a/pypy/rlib/types.py
+++ b/pypy/rlib/types.py
@@ -31,6 +31,11 @@
return model.SomeChar()
+def ptr(ll_type):
+ from pypy.rpython.lltypesystem.lltype import Ptr
+ return model.SomePtr(Ptr(ll_type))
+
+
def list(element):
listdef = ListDef(None, element, mutated=True, resized=True)
return model.SomeList(listdef)
diff --git a/pypy/rpython/lltypesystem/lltype.py
b/pypy/rpython/lltypesystem/lltype.py
--- a/pypy/rpython/lltypesystem/lltype.py
+++ b/pypy/rpython/lltypesystem/lltype.py
@@ -1965,12 +1965,12 @@
assert n is None
o = _opaque(T, initialization=initialization)
else:
- raise TypeError, "malloc for Structs and Arrays only"
- if T._gckind != 'gc' and not immortal and flavor.startswith('gc'):
+ raise TypeError, "malloc: unmallocable type"
+ if flavor == 'gc' and T._gckind != 'gc' and not immortal:
raise TypeError, "gc flavor malloc of a non-GC non-immortal structure"
if flavor == "raw" and not immortal and track_allocation:
leakfinder.remember_malloc(o, framedepth=2)
- solid = immortal or not flavor.startswith('gc') # immortal or non-gc case
+ solid = immortal or flavor == 'raw'
return _ptr(Ptr(T), o, solid)
def free(p, flavor, track_allocation=True):
diff --git a/pypy/rpython/rmodel.py b/pypy/rpython/rmodel.py
--- a/pypy/rpython/rmodel.py
+++ b/pypy/rpython/rmodel.py
@@ -1,5 +1,5 @@
from pypy.tool.pairtype import pairtype, extendabletype, pair
-from pypy.annotation import model as annmodel
+from pypy.annotation import model as annmodel, unaryop, binaryop
from pypy.annotation import description
from pypy.objspace.flow.model import Constant
from pypy.rpython.lltypesystem.lltype import \
@@ -310,10 +310,10 @@
"'%s' on %r" % (opname, self))
setattr(rcls, attr, missing_rtype_operation)
-for opname in annmodel.UNARY_OPERATIONS:
+for opname in unaryop.UNARY_OPERATIONS:
make_missing_op(Repr, opname)
-for opname in annmodel.BINARY_OPERATIONS:
+for opname in binaryop.BINARY_OPERATIONS:
make_missing_op(pairtype(Repr, Repr), opname)
# not in BINARY_OPERATIONS
diff --git a/pypy/rpython/rtyper.py b/pypy/rpython/rtyper.py
--- a/pypy/rpython/rtyper.py
+++ b/pypy/rpython/rtyper.py
@@ -14,7 +14,7 @@
import os
import py
from pypy.tool.pairtype import pair
-from pypy.annotation import model as annmodel
+from pypy.annotation import model as annmodel, unaryop, binaryop
from pypy.annotation.annrpython import FAIL
from pypy.objspace.flow.model import Variable, Constant
from pypy.objspace.flow.model import SpaceOperation, c_last_exception
@@ -592,10 +592,10 @@
# __________ regular operations __________
- def _registeroperations(cls, model):
+ def _registeroperations(cls, unary_ops, binary_ops):
d = {}
# All unary operations
- for opname in model.UNARY_OPERATIONS:
+ for opname in unary_ops:
fnname = 'translate_op_' + opname
exec py.code.compile("""
def translate_op_%s(self, hop):
@@ -604,7 +604,7 @@
""" % (opname, opname)) in globals(), d
setattr(cls, fnname, d[fnname])
# All binary operations
- for opname in model.BINARY_OPERATIONS:
+ for opname in binary_ops:
fnname = 'translate_op_' + opname
exec py.code.compile("""
def translate_op_%s(self, hop):
@@ -714,7 +714,7 @@
attachRuntimeTypeInfo(GCSTRUCT, funcptr, destrptr, None)
# register operations from annotation model
-RPythonTyper._registeroperations(annmodel)
+RPythonTyper._registeroperations(unaryop.UNARY_OPERATIONS,
binaryop.BINARY_OPERATIONS)
# ____________________________________________________________
diff --git a/pypy/rpython/test/test_rbool.py b/pypy/rpython/test/test_rbool.py
--- a/pypy/rpython/test/test_rbool.py
+++ b/pypy/rpython/test/test_rbool.py
@@ -1,5 +1,5 @@
from pypy.translator.translator import TranslationContext
-from pypy.annotation import model as annmodel
+from pypy.annotation import unaryop, binaryop
from pypy.rpython.test import snippet
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
@@ -25,12 +25,12 @@
def DONTtest_unary_operations(self):
# XXX TODO test if all unary operations are implemented
- for opname in annmodel.UNARY_OPERATIONS:
+ for opname in unaryop.UNARY_OPERATIONS:
print 'UNARY_OPERATIONS:', opname
def DONTtest_binary_operations(self):
# XXX TODO test if all binary operations are implemented
- for opname in annmodel.BINARY_OPERATIONS:
+ for opname in binaryop.BINARY_OPERATIONS:
print 'BINARY_OPERATIONS:', opname
class BaseTestRbool(BaseRtypingTest):
diff --git a/pypy/rpython/test/test_rfloat.py b/pypy/rpython/test/test_rfloat.py
--- a/pypy/rpython/test/test_rfloat.py
+++ b/pypy/rpython/test/test_rfloat.py
@@ -1,5 +1,6 @@
import sys
from pypy.translator.translator import TranslationContext
+from pypy.annotation import unaryop, binaryop
from pypy.rpython.test import snippet
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
from pypy.rlib.rarithmetic import (
@@ -28,12 +29,12 @@
def DONTtest_unary_operations(self):
# XXX TODO test if all unary operations are implemented
- for opname in annmodel.UNARY_OPERATIONS:
+ for opname in unaryop.UNARY_OPERATIONS:
print 'UNARY_OPERATIONS:', opname
def DONTtest_binary_operations(self):
# XXX TODO test if all binary operations are implemented
- for opname in annmodel.BINARY_OPERATIONS:
+ for opname in binaryop.BINARY_OPERATIONS:
print 'BINARY_OPERATIONS:', opname
class BaseTestRfloat(BaseRtypingTest):
@@ -404,5 +405,5 @@
def test_formatd_huge(self):
skip('formatd is broken on ootype')
- def test_string_to_float(self):
- skip('string_to_float is broken on ootype')
+ def test_parts_to_float(self):
+ skip('parts_to_float is broken on ootype')
diff --git a/pypy/rpython/test/test_rint.py b/pypy/rpython/test/test_rint.py
--- a/pypy/rpython/test/test_rint.py
+++ b/pypy/rpython/test/test_rint.py
@@ -1,7 +1,7 @@
import py
import sys, operator
from pypy.translator.translator import TranslationContext
-from pypy.annotation import model as annmodel
+from pypy.annotation import unaryop, binaryop
from pypy.rpython.test import snippet
from pypy.rlib.rarithmetic import r_int, r_uint, r_longlong, r_ulonglong
from pypy.rlib.rarithmetic import ovfcheck, r_int64, intmask, int_between
@@ -34,12 +34,12 @@
def DONTtest_unary_operations(self):
# XXX TODO test if all unary operations are implemented
- for opname in annmodel.UNARY_OPERATIONS:
+ for opname in unaryop.UNARY_OPERATIONS:
print 'UNARY_OPERATIONS:', opname
def DONTtest_binary_operations(self):
# XXX TODO test if all binary operations are implemented
- for opname in annmodel.BINARY_OPERATIONS:
+ for opname in binaryop.BINARY_OPERATIONS:
print 'BINARY_OPERATIONS:', opname
diff --git a/pypy/tool/genstatistic.py b/pypy/tool/genstatistic.py
--- a/pypy/tool/genstatistic.py
+++ b/pypy/tool/genstatistic.py
@@ -7,7 +7,8 @@
pypydir = py.path.local(autopath.pypydir)
def isdocfile(p):
- return p.ext == '.txt' or p.basename in ('README', 'NOTES', 'LICENSE')
+ return (p.ext in ('.txt', '.rst') or
+ p.basename in ('README', 'NOTES', 'LICENSE'))
def istestfile(p):
if not p.check(file=1, ext='.py'):
diff --git a/pypy/tool/pytest/objspace.py b/pypy/tool/pytest/objspace.py
--- a/pypy/tool/pytest/objspace.py
+++ b/pypy/tool/pytest/objspace.py
@@ -49,6 +49,9 @@
if key == 'usemodules':
if info is not None:
for modname in value:
+ if modname == 'time':
+ continue # always either 'time' or 'rctime',
+ # and any is fine
ok = info.get('objspace.usemodules.%s' % modname,
False)
if not ok:
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
@@ -93,7 +93,7 @@
shutil.copytree(str(basedir.join('lib_pypy')),
str(pypydir.join('lib_pypy')),
ignore=ignore_patterns('.svn', 'py', '*.pyc', '*~'))
- for file in ['LICENSE', 'README']:
+ for file in ['LICENSE', 'README.rst']:
shutil.copy(str(basedir.join(file)), str(pypydir))
pypydir.ensure('include', dir=True)
if sys.platform == 'win32':
diff --git a/pypy/tool/release/test/test_package.py
b/pypy/tool/release/test/test_package.py
--- a/pypy/tool/release/test/test_package.py
+++ b/pypy/tool/release/test/test_package.py
@@ -33,7 +33,7 @@
assert not prefix.join('lib_pypy', 'py').check()
assert not prefix.join('lib_pypy', 'ctypes_configure').check()
assert prefix.join('LICENSE').check()
- assert prefix.join('README').check()
+ assert prefix.join('README.rst').check()
if package.USE_ZIPFILE_MODULE:
zh = zipfile.ZipFile(str(builddir.join('%s.zip' % test)))
assert zh.open('%s/lib_pypy/syslog.py' % test)
diff --git a/pypy/translator/c/gcc/trackgcroot.py
b/pypy/translator/c/gcc/trackgcroot.py
--- a/pypy/translator/c/gcc/trackgcroot.py
+++ b/pypy/translator/c/gcc/trackgcroot.py
@@ -495,6 +495,9 @@
'movz',
# locked operations should not move GC pointers, at least so far
'lock', 'pause',
+ # non-temporal moves should be reserved for areas containing
+ # raw data, not GC pointers
+ 'movnt', 'mfence', 'lfence', 'sfence',
])
# a partial list is hopefully good enough for now; it's all to support
diff --git a/pypy/translator/cli/test/test_float.py
b/pypy/translator/cli/test/test_float.py
--- a/pypy/translator/cli/test/test_float.py
+++ b/pypy/translator/cli/test/test_float.py
@@ -24,3 +24,15 @@
def test_r_singlefloat(self):
py.test.skip("not implemented: single-precision floats")
+
+ def test_formatd(self):
+ py.test.skip('formatd is broken on ootype')
+
+ def test_formatd_repr(self):
+ py.test.skip('formatd is broken on ootype')
+
+ def test_formatd_huge(self):
+ py.test.skip('formatd is broken on ootype')
+
+ def test_parts_to_float(self):
+ py.test.skip('parts_to_float is broken on ootype')
diff --git a/pypy/translator/jvm/genjvm.py b/pypy/translator/jvm/genjvm.py
--- a/pypy/translator/jvm/genjvm.py
+++ b/pypy/translator/jvm/genjvm.py
@@ -9,22 +9,22 @@
import sys
import py
+from pypy.rpython.ootypesystem import ootype
from pypy.tool.udir import udir
-from pypy.translator.translator import TranslationContext
-from pypy.translator.oosupport.genoo import GenOO
from pypy.translator.backendopt.all import backend_optimizations
from pypy.translator.backendopt.checkvirtual import check_virtual_methods
+from pypy.translator.oosupport.genoo import GenOO
+from pypy.translator.translator import TranslationContext
+from pypy.translator.jvm.constant import (
+ JVMConstantGenerator, JVMStaticMethodConst, JVMCustomDictConst,
+ JVMWeakRefConst)
+from pypy.translator.jvm.database import Database
from pypy.translator.jvm.generator import JasminGenerator
-from pypy.translator.jvm.option import getoption
-from pypy.translator.jvm.database import Database
from pypy.translator.jvm.log import log
from pypy.translator.jvm.node import EntryPoint, Function
from pypy.translator.jvm.opcodes import opcodes
-from pypy.rpython.ootypesystem import ootype
-from pypy.translator.jvm.constant import \
- JVMConstantGenerator, JVMStaticMethodConst, JVMCustomDictConst, \
- JVMWeakRefConst
+from pypy.translator.jvm.option import getoption
from pypy.translator.jvm.prebuiltnodes import create_interlink_node
MIN_JAVA_VERSION = '1.6.0'
@@ -46,17 +46,17 @@
def __str__(self):
return "Error code %d running %s" % (self.res, repr(self.args))
-
+
def pretty_print(self):
JvmError.pretty_print(self)
print "vvv Stdout vvv\n"
print self.stdout
print "vvv Stderr vvv\n"
print self.stderr
-
+
class JvmGeneratedSource(object):
-
+
"""
An object which represents the generated sources. Contains methods
to find out where they are located, to compile them, and to execute
@@ -85,13 +85,13 @@
self.package = package
self.compiled = False
self.jasmin_files = None
-
+
# Determine various paths:
self.thisdir = py.path.local(__file__).dirpath()
self.rootdir = self.thisdir.join('src')
self.srcdir = self.rootdir.join('pypy')
self.jnajar = self.rootdir.join('jna.jar')
- self.jasminjar = self.rootdir.join('jasmin.jar')
+ self.jasminjar = self.rootdir.join('jasmin.jar')
# Compute directory where .j files are
self.javadir = self.tmpdir
@@ -142,10 +142,11 @@
Compiles the .java sources into .class files, ready for execution.
"""
jascmd = [
- getoption('java'),
+ getoption('java'),
+ '-Djava.awt.headless=true',
'-jar', str(self.jasminjar),
- '-g',
- '-d',
+ '-g',
+ '-d',
str(self.javadir)]
def split_list(files):
@@ -156,7 +157,7 @@
# path_to_jre/java -jar path_to_jasmin/jasmin.jar $*
# So we limit the length of arguments files to:
MAXLINE = 1500
-
+
chunk = []
chunklen = 0
for f in files:
@@ -174,7 +175,7 @@
#print "Invoking jasmin on %s" % files
self._invoke(jascmd + files, False)
#print "... completed!"
-
+
self.compiled = True
self._compile_helper()
@@ -193,6 +194,7 @@
strargs = [self._make_str(a) for a in args]
cmd = [getoption('java'),
'-Xmx256M', # increase the heapsize so the microbenchmarks run
+ '-Djava.awt.headless=true',
'-cp',
str(self.javadir)+os.pathsep+str(self.jnajar),
self.package+".Main"] + strargs
@@ -203,13 +205,13 @@
return stdout, stderr, retval
def generate_source_for_function(func, annotation, backendopt=False):
-
+
"""
Given a Python function and some hints about its argument types,
generates JVM sources that call it and print the result. Returns
the JvmGeneratedSource object.
"""
-
+
if hasattr(func, 'im_func'):
func = func.im_func
t = TranslationContext()
@@ -263,7 +265,7 @@
generate_source(). *You can not use one of these objects more than
once.* """
- TypeSystem = lambda X, db: db # TypeSystem and Database are the same
object
+ TypeSystem = lambda X, db: db # TypeSystem and Database are the same object
Function = Function
Database = Database
opcodes = opcodes
@@ -273,7 +275,7 @@
CustomDictConst = JVMCustomDictConst
StaticMethodConst = JVMStaticMethodConst
WeakRefConst = JVMWeakRefConst
-
+
def __init__(self, tmpdir, translator, entrypoint):
"""
'tmpdir' --- where the generated files will go. In fact, we will
@@ -299,5 +301,3 @@
configuration. Right now, however, there is only one kind of
generator: JasminGenerator """
return JasminGenerator(self.db, self.jvmsrc.javadir)
-
-
diff --git a/pypy/translator/jvm/test/test_float.py
b/pypy/translator/jvm/test/test_float.py
--- a/pypy/translator/jvm/test/test_float.py
+++ b/pypy/translator/jvm/test/test_float.py
@@ -33,3 +33,15 @@
res = self.interpret(fn, [1])
assert res == "10.0"
+
+ def test_formatd(self):
+ py.test.skip('formatd is broken on ootype')
+
+ def test_formatd_repr(self):
+ py.test.skip('formatd is broken on ootype')
+
+ def test_formatd_huge(self):
+ py.test.skip('formatd is broken on ootype')
+
+ def test_parts_to_float(self):
+ py.test.skip('parts_to_float is broken on ootype')
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit