Ejemplo n.º 1
0
 def __init__(self, space, code, w_globals, outer_func):
     if not we_are_translated():
         assert type(self) in (space.FrameClass, CPythonFrame), (
             "use space.FrameClass(), not directly PyFrame()")
     self = hint(self, access_directly=True, fresh_virtualizable=True)
     assert isinstance(code, pycode.PyCode)
     self.pycode = code
     eval.Frame.__init__(self, space, w_globals)
     self.locals_stack_w = [None] * (code.co_nlocals + code.co_stacksize)
     
     # Symbolic stack, globals tracker and constraint stack
     self.locals_stack_w_s = [None] * (code.co_nlocals + code.co_stacksize)
     self.w_globals_s = w_globals
     
     self.valuestackdepth = code.co_nlocals
     self.lastblock = None
     make_sure_not_resized(self.locals_stack_w)
     check_nonneg(self.valuestackdepth)
     #
     if space.config.objspace.honor__builtins__:
         self.builtin = space.builtin.pick_builtin(w_globals)
     # regular functions always have CO_OPTIMIZED and CO_NEWLOCALS.
     # class bodies only have CO_NEWLOCALS.
     self.initialize_frame_scopes(outer_func, code)
     self.f_lineno = code.co_firstlineno
Ejemplo n.º 2
0
 def overwrite(self, pos, listofchars):
     make_sure_not_resized(listofchars)
     assert pos + len(listofchars) <= self._size
     for c in listofchars:
         self._data[pos] = c
         pos += 1
     return pos
Ejemplo n.º 3
0
def packimm32(i):
    lst = [chr(i & 0xFF),
           chr((i >> 8) & 0xFF),
           chr((i >> 16) & 0xFF),
           chr((i >> 24) & 0xFF)]
    make_sure_not_resized(lst)
    return lst
Ejemplo n.º 4
0
 def pushrevvalues(self, n, values_w): # n should be len(values_w)
     make_sure_not_resized(values_w)
     while True:
         n -= 1
         if n < 0:
             break
         self.pushvalue(values_w[n])
Ejemplo n.º 5
0
 def overwrite(self, pos, listofchars):
     make_sure_not_resized(listofchars)
     assert pos + len(listofchars) <= self._size
     for c in listofchars:
         self._data[pos] = c
         pos += 1
     return pos
Ejemplo n.º 6
0
 def pushrevvalues(self, n, values_w):  # n should be len(values_w)
     make_sure_not_resized(values_w)
     while True:
         n -= 1
         if n < 0:
             break
         self.pushvalue(values_w[n])
Ejemplo n.º 7
0
    def __init__(self, space, code, w_globals, outer_func):
        if not we_are_translated():
            assert type(self) in (space.FrameClass, CPythonFrame), (
                "use space.FrameClass(), not directly PyFrame()")
        self = hint(self, access_directly=True, fresh_virtualizable=True)
        assert isinstance(code, pycode.PyCode)
        self.pycode = code
        eval.Frame.__init__(self, space, w_globals)
        self.locals_stack_w = [None] * (code.co_nlocals + code.co_stacksize)

        # Symbolic stack, globals tracker and constraint stack
        self.locals_stack_w_s = [None] * (code.co_nlocals + code.co_stacksize)
        self.w_globals_s = w_globals

        self.valuestackdepth = code.co_nlocals
        self.lastblock = None
        make_sure_not_resized(self.locals_stack_w)
        check_nonneg(self.valuestackdepth)
        #
        if space.config.objspace.honor__builtins__:
            self.builtin = space.builtin.pick_builtin(w_globals)
        # regular functions always have CO_OPTIMIZED and CO_NEWLOCALS.
        # class bodies only have CO_NEWLOCALS.
        self.initialize_frame_scopes(outer_func, code)
        self.f_lineno = code.co_firstlineno
Ejemplo n.º 8
0
 def __init__(self, opnum, args, result, descr=None):
     make_sure_not_resized(args)
     assert isinstance(opnum, int)
     self.opnum = opnum
     self.args = list(args)
     make_sure_not_resized(self.args)
     assert not isinstance(result, list)
     self.result = result
     self.setdescr(descr)
Ejemplo n.º 9
0
 def __init__(self, space, dim, dtype):
     self.dim = dim
     self.space = space
     # ignore dtype for now
     size = 1
     for el in dim:
         size *= el
     self.storage = [0] * size
     make_sure_not_resized(self.storage)
Ejemplo n.º 10
0
def packimm32(i):
    lst = [
        chr(i & 0xFF),
        chr((i >> 8) & 0xFF),
        chr((i >> 16) & 0xFF),
        chr((i >> 24) & 0xFF)
    ]
    make_sure_not_resized(lst)
    return lst
Ejemplo n.º 11
0
 def __init__(self, space, dim, dtype):
     self.dim = dim
     self.space = space
     # ignore dtype for now
     size = 1
     for el in dim:
         size *= el
     self.storage = [0] * size
     make_sure_not_resized(self.storage)
Ejemplo n.º 12
0
 def __init__(self, space, args_w, kwds_w=None,
              w_stararg=None, w_starstararg=None):
     self.space = space
     assert isinstance(args_w, list)
     self.arguments_w = args_w
     from pypy.rlib.debug import make_sure_not_resized
     make_sure_not_resized(self.arguments_w)
     self.kwds_w = kwds_w
     self.w_stararg = w_stararg
     self.w_starstararg = w_starstararg
Ejemplo n.º 13
0
Archivo: util.py Proyecto: njues/Sypy
def args_hash(args):
    make_sure_not_resized(args)
    res = 0x345678
    for arg in args:
        if arg is None:
            y = 17
        else:
            y = arg._get_hash_()
        res = intmask((1000003 * res) ^ y)
    return res
Ejemplo n.º 14
0
def args_hash(args):
    make_sure_not_resized(args)
    res = 0x345678
    for arg in args:
        if arg is None:
            y = 17
        else:
            y = arg._get_hash_()
        res = intmask((1000003 * res) ^ y)
    return res
Ejemplo n.º 15
0
 def __init__(self, space, code, w_globals=None, defs_w=[], closure=None, forcename=None):
     self.space = space
     self.name = forcename or code.co_name
     self.w_doc = None   # lazily read from code.getdocstring()
     self.code = code       # Code instance
     self.w_func_globals = w_globals  # the globals dictionary
     self.closure   = closure    # normally, list of Cell instances or None
     self.defs_w    = defs_w     # list of w_default's
     make_sure_not_resized(self.defs_w)
     self.w_func_dict = None # filled out below if needed
     self.w_module = None
Ejemplo n.º 16
0
def args_hash(args):
    make_sure_not_resized(args)
    res = 0x345678
    for arg in args:
        if arg is None:
            y = 17
        elif isinstance(arg, history.Const):
            y = arg._get_hash_()
        else:
            y = compute_identity_hash(arg)
        res = intmask((1000003 * res) ^ y)
    return res
Ejemplo n.º 17
0
 def __init__(self, space, code, w_globals=None, defs_w=[], closure=None,
              forcename=None):
     self.space = space
     self.name = forcename or code.co_name
     self.w_doc = None   # lazily read from code.getdocstring()
     self.code = code       # Code instance
     self.w_func_globals = w_globals  # the globals dictionary
     self.closure   = closure    # normally, list of Cell instances or None
     self.defs_w    = defs_w     # list of w_default's
     make_sure_not_resized(self.defs_w)
     self.w_func_dict = None # filled out below if needed
     self.w_module = None
Ejemplo n.º 18
0
Archivo: util.py Proyecto: njues/Sypy
def args_eq(args1, args2):
    make_sure_not_resized(args1)
    make_sure_not_resized(args2)
    if len(args1) != len(args2):
        return False
    for i in range(len(args1)):
        arg1 = args1[i]
        arg2 = args2[i]
        if arg1 is None:
            if arg2 is not None:
                return False
        elif not arg1.same_box(arg2):
            return False
    return True
Ejemplo n.º 19
0
def args_eq(args1, args2):
    make_sure_not_resized(args1)
    make_sure_not_resized(args2)
    if len(args1) != len(args2):
        return False
    for i in range(len(args1)):
        arg1 = args1[i]
        arg2 = args2[i]
        if arg1 is None:
            if arg2 is not None:
                return False
        elif not arg1.same_box(arg2):
            return False
    return True
Ejemplo n.º 20
0
 def __init__(self, space, code, w_globals, closure):
     self = hint(self, access_directly=True, fresh_virtualizable=True)
     assert isinstance(code, pycode.PyCode)
     self.pycode = code
     eval.Frame.__init__(self, space, w_globals, code.co_nlocals)
     self.valuestack_w = [None] * code.co_stacksize
     self.valuestackdepth = 0
     self.lastblock = None
     if space.config.objspace.honor__builtins__:
         self.builtin = space.builtin.pick_builtin(w_globals)
     # regular functions always have CO_OPTIMIZED and CO_NEWLOCALS.
     # class bodies only have CO_NEWLOCALS.
     self.initialize_frame_scopes(closure, code)
     self.fastlocals_w = [None] * self.numlocals
     make_sure_not_resized(self.fastlocals_w)
     self.f_lineno = code.co_firstlineno
Ejemplo n.º 21
0
 def __init__(self, space, code, w_globals, closure):
     self = hint(self, access_directly=True, fresh_virtualizable=True)
     assert isinstance(code, pycode.PyCode)
     self.pycode = code
     eval.Frame.__init__(self, space, w_globals, code.co_nlocals)
     self.valuestack_w = [None] * code.co_stacksize
     self.valuestackdepth = 0
     self.lastblock = None
     if space.config.objspace.honor__builtins__:
         self.builtin = space.builtin.pick_builtin(w_globals)
     # regular functions always have CO_OPTIMIZED and CO_NEWLOCALS.
     # class bodies only have CO_NEWLOCALS.
     self.initialize_frame_scopes(closure, code)
     self.fastlocals_w = [None] * self.numlocals
     make_sure_not_resized(self.fastlocals_w)
     self.f_lineno = code.co_firstlineno
Ejemplo n.º 22
0
    def __init__(self, parent, func, pc, max_stack_size, nargs, bc_off, closure):
        self = jit.hint(self, access_directly=True, fresh_virtualizable=True)
        self.parent = parent
        self.stack = [None] * max_stack_size
        debug.make_sure_not_resized(self.stack)
        self.func = func
        self.pc = pc
        self.nargs = nargs # Number of arguments passed to this continuation
        self.bc_off = bc_off # -1 for Py modules
        self.closure = closure
        self.returned = False

        # stackpe always points to the element *after* the end of the stack (this makes a lot of
        # stack-based operations quicker)
        self.stackpe = 0
        # ffp, gfp, and xfp all point *to* the frame they refer to
        self.ffp = self.gfp = self.xfp = -1
Ejemplo n.º 23
0
 def fixedview(self, w_obj, expected_length=-1, unroll=False):
     """ Fast paths
     """
     if isinstance(w_obj, W_TupleObject):
         t = w_obj.wrappeditems
     elif isinstance(w_obj, W_ListObject):
         t = w_obj.wrappeditems[:]
     else:
         if unroll:
             return make_sure_not_resized(ObjSpace.unpackiterable_unroll(
                 self, w_obj, expected_length)[:])
         else:
             return make_sure_not_resized(ObjSpace.unpackiterable(
                 self, w_obj, expected_length)[:])
     if expected_length != -1 and len(t) != expected_length:
         raise self._wrap_expected_length(expected_length, len(t))
     return make_sure_not_resized(t)
Ejemplo n.º 24
0
def args_eq(args1, args2):
    make_sure_not_resized(args1)
    make_sure_not_resized(args2)
    if len(args1) != len(args2):
        return False
    for i in range(len(args1)):
        arg1 = args1[i]
        arg2 = args2[i]
        if isinstance(arg1, history.Const):
            if arg1.__class__ is not arg2.__class__:
                return False
            if not arg1.same_constant(arg2):
                return False
        else:
            if not arg1 is arg2:
                return False
    return True
Ejemplo n.º 25
0
 def fixedview(self, w_obj, expected_length=-1, unroll=False):
     """ Fast paths
     """
     if isinstance(w_obj, W_AbstractTupleObject):
         t = w_obj.tolist()
     elif type(w_obj) is W_ListObject:
         if unroll:
             t = w_obj.getitems_unroll()
         else:
             t = w_obj.getitems_fixedsize()
     else:
         if unroll:
             return make_sure_not_resized(ObjSpace.unpackiterable_unroll(
                 self, w_obj, expected_length))
         else:
             return make_sure_not_resized(ObjSpace.unpackiterable(
                 self, w_obj, expected_length)[:])
     if expected_length != -1 and len(t) != expected_length:
         raise self._wrap_expected_length(expected_length, len(t))
     return make_sure_not_resized(t)
Ejemplo n.º 26
0
 def fixedview(self, w_obj, expected_length=-1, unroll=False):
     """ Fast paths
     """
     if isinstance(w_obj, W_AbstractTupleObject):
         t = w_obj.tolist()
     elif isinstance(w_obj, W_ListObject):
         if unroll:
             t = w_obj.getitems_unroll()
         else:
             t = w_obj.getitems_fixedsize()
     else:
         if unroll:
             return make_sure_not_resized(ObjSpace.unpackiterable_unroll(
                 self, w_obj, expected_length))
         else:
             return make_sure_not_resized(ObjSpace.unpackiterable(
                 self, w_obj, expected_length)[:])
     if expected_length != -1 and len(t) != expected_length:
         raise self._wrap_expected_length(expected_length, len(t))
     return make_sure_not_resized(t)
Ejemplo n.º 27
0
    def __init__(self,
                 space,
                 args_w,
                 keywords=None,
                 keywords_w=None,
                 w_stararg=None,
                 w_starstararg=None,
                 keyword_names_w=None):
        self.space = space
        assert isinstance(args_w, list)
        self.arguments_w = args_w
        self.keywords = keywords
        self.keywords_w = keywords_w
        self.keyword_names_w = keyword_names_w  # matches the tail of .keywords
        if keywords is not None:
            assert keywords_w is not None
            assert len(keywords_w) == len(keywords)
            assert (keyword_names_w is None
                    or len(keyword_names_w) <= len(keywords))
            make_sure_not_resized(self.keywords)
            make_sure_not_resized(self.keywords_w)

        make_sure_not_resized(self.arguments_w)
        if w_stararg is not None:
            self._combine_starargs_wrapped(w_stararg)
        # if we have a call where **args are used at the callsite
        # we shouldn't let the JIT see the argument matching
        self._dont_jit = (w_starstararg is not None and
                          self._combine_starstarargs_wrapped(w_starstararg))
Ejemplo n.º 28
0
    def __init__(self, space, args_w, keywords=None, keywords_w=None,
                 w_stararg=None, w_starstararg=None):
        self.space = space
        assert isinstance(args_w, list)
        self.arguments_w = args_w
        self.keywords = keywords
        self.keywords_w = keywords_w
        if keywords is not None:
            assert keywords_w is not None
            assert len(keywords_w) == len(keywords)
            make_sure_not_resized(self.keywords)
            make_sure_not_resized(self.keywords_w)

        make_sure_not_resized(self.arguments_w)
        if w_stararg is not None or w_starstararg is not None:
            self._combine_wrapped(w_stararg, w_starstararg)
Ejemplo n.º 29
0
    def __init__(self,
                 space,
                 args_w,
                 keywords=None,
                 keywords_w=None,
                 w_stararg=None,
                 w_starstararg=None):
        self.space = space
        assert isinstance(args_w, list)
        self.arguments_w = args_w
        self.keywords = keywords
        self.keywords_w = keywords_w
        if keywords is not None:
            assert keywords_w is not None
            assert len(keywords_w) == len(keywords)
            make_sure_not_resized(self.keywords)
            make_sure_not_resized(self.keywords_w)

        make_sure_not_resized(self.arguments_w)
        if w_stararg is not None or w_starstararg is not None:
            self._combine_wrapped(w_stararg, w_starstararg)
Ejemplo n.º 30
0
    def __init__(self, space, args_w, keywords=None, keywords_w=None,
                 w_stararg=None, w_starstararg=None):
        self.space = space
        assert isinstance(args_w, list)
        self.arguments_w = args_w
        self.keywords = keywords
        self.keywords_w = keywords_w
        if keywords is not None:
            assert keywords_w is not None
            assert len(keywords_w) == len(keywords)
            make_sure_not_resized(self.keywords)
            make_sure_not_resized(self.keywords_w)

        make_sure_not_resized(self.arguments_w)
        if w_stararg is not None or w_starstararg is not None:
            self._combine_wrapped(w_stararg, w_starstararg)
            # if we have a call where * or ** args are used at the callsite
            # we shouldn't let the JIT see the argument matching
            self._dont_jit = True
        else:
            self._dont_jit = False
Ejemplo n.º 31
0
 def __init__(self, space, w_name, bases, w_dict):
     self.name = space.str_w(w_name)
     make_sure_not_resized(bases)
     self.bases_w = bases
     self.w_dict = w_dict
Ejemplo n.º 32
0
 def _init_empty(self, map):
     from pypy.rlib.debug import make_sure_not_resized
     self.map = map
     self.storage = make_sure_not_resized([None] * map.size_estimate())
Ejemplo n.º 33
0
 def __init__(self, space, w_name, bases, w_dict):
     self.name = space.str_w(w_name)
     make_sure_not_resized(bases)
     self.bases_w = bases
     self.w_dict = w_dict
Ejemplo n.º 34
0
 def getitems_unroll(self):
     """Returns a fixed-size list of all items after wrapping them. The JIT
     will fully unroll this function.  """
     l = self.strategy.getitems_unroll(self)
     debug.make_sure_not_resized(l)
     return l
Ejemplo n.º 35
0
 def __init__(self, byte, extradata):
     self.byte = byte
     self.extradata = extradata
     make_sure_not_resized(extradata)
Ejemplo n.º 36
0
 def __init__(self, space, containing_scope, functions):
     self.space = space
     self.scope = containing_scope
     self.functions = debug.make_sure_not_resized(functions)
Ejemplo n.º 37
0
 def getitems_fixedsize(self):
     """Returns a fixed-size list of all items after wrapping them."""
     l = self.strategy.getitems_fixedsize(self)
     debug.make_sure_not_resized(l)
     return l
Ejemplo n.º 38
0
def packimm8(i):
    if i < 0:
        i += 256
    lst = [chr(i)]
    make_sure_not_resized(lst)
    return lst
Ejemplo n.º 39
0
 def __init__(w_self, wrappeditems):
     make_sure_not_resized(wrappeditems)
     w_self.wrappeditems = wrappeditems   # a list of wrapped values
Ejemplo n.º 40
0
 def __init__(self, byte, extradata):
     self.byte = byte
     self.extradata = extradata
     make_sure_not_resized(extradata)
Ejemplo n.º 41
0
 def __init__(w_self, wrappeditems):
     make_sure_not_resized(wrappeditems)
     w_self.wrappeditems = wrappeditems  # a list of wrapped values
Ejemplo n.º 42
0
def packimm8(i):
    if i < 0:
        i += 256
    lst = [chr(i)]
    make_sure_not_resized(lst)
    return lst
Ejemplo n.º 43
0
 def newtuple(self, list_w):
     from pypy.objspace.std.tupletype import wraptuple
     assert isinstance(list_w, list)
     make_sure_not_resized(list_w)
     return wraptuple(self, list_w)
Ejemplo n.º 44
0
 def getitems_unroll(self):
     """Returns a fixed-size list of all items after wrapping them. The JIT
     will fully unroll this function.  """
     l = self.strategy.getitems_unroll(self)
     debug.make_sure_not_resized(l)
     return l
Ejemplo n.º 45
0
 def getitems_fixedsize(self):
     """Returns a fixed-size list of all items after wrapping them."""
     l = self.strategy.getitems_fixedsize(self)
     debug.make_sure_not_resized(l)
     return l
Ejemplo n.º 46
0
 def f():
     result = [1,2,3]
     make_sure_not_resized(result)
     result.append(4)
     return len(result)
Ejemplo n.º 47
0
 def __init__(self, space, dim, dtype):
     self.dim = dim
     self.space = space
     # ignore dtype for now
     self.storage = [0] * dim
     make_sure_not_resized(self.storage)
Ejemplo n.º 48
0
 def __init__(self, space, dim, dtype):
     self.dim = dim
     self.space = space
     # ignore dtype for now
     self.storage = [0] * dim
     make_sure_not_resized(self.storage)
Ejemplo n.º 49
0
 def __init__(self, digits=None, sign=0):
     if digits is None or len(digits) == 0:
         digits = [0]
     make_sure_not_resized(digits)
     self.digits = digits
     self.sign = sign
Ejemplo n.º 50
0
 def _init_empty(self, map):
     from pypy.rlib.debug import make_sure_not_resized
     self.map = map
     self.storage = make_sure_not_resized([None] * map.size_estimate())
Ejemplo n.º 51
0
 def newtuple(self, list_w):
     from pypy.objspace.std.tupletype import wraptuple
     assert isinstance(list_w, list)
     make_sure_not_resized(list_w)
     return wraptuple(self, list_w)
Ejemplo n.º 52
0
 def f():
     result = [1, 2, 3]
     make_sure_not_resized(result)
     result.append(4)
     return len(result)
Ejemplo n.º 53
0
 def viewiterable(self, w_iterable, expected_length=-1):
     """ More or less the same as unpackiterable, but does not return
     a copy. Please don't modify the result
     """
     return make_sure_not_resized(
         self.unpackiterable(w_iterable, expected_length)[:])