Example #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
Example #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
Example #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
Example #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])
Example #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
Example #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])
Example #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
Example #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)
Example #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)
Example #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
Example #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)
Example #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
Example #13
0
File: util.py Project: 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
Example #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
Example #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
Example #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
Example #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
Example #18
0
File: util.py Project: 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
Example #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
Example #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
Example #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
Example #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
Example #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)
Example #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
Example #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)
Example #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)
Example #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))
Example #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)
Example #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)
Example #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
Example #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
Example #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())
Example #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
Example #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
Example #35
0
 def __init__(self, byte, extradata):
     self.byte = byte
     self.extradata = extradata
     make_sure_not_resized(extradata)
Example #36
0
 def __init__(self, space, containing_scope, functions):
     self.space = space
     self.scope = containing_scope
     self.functions = debug.make_sure_not_resized(functions)
Example #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
Example #38
0
def packimm8(i):
    if i < 0:
        i += 256
    lst = [chr(i)]
    make_sure_not_resized(lst)
    return lst
Example #39
0
 def __init__(w_self, wrappeditems):
     make_sure_not_resized(wrappeditems)
     w_self.wrappeditems = wrappeditems   # a list of wrapped values
Example #40
0
 def __init__(self, byte, extradata):
     self.byte = byte
     self.extradata = extradata
     make_sure_not_resized(extradata)
Example #41
0
 def __init__(w_self, wrappeditems):
     make_sure_not_resized(wrappeditems)
     w_self.wrappeditems = wrappeditems  # a list of wrapped values
Example #42
0
def packimm8(i):
    if i < 0:
        i += 256
    lst = [chr(i)]
    make_sure_not_resized(lst)
    return lst
Example #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)
Example #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
Example #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
Example #46
0
 def f():
     result = [1,2,3]
     make_sure_not_resized(result)
     result.append(4)
     return len(result)
Example #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)
Example #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)
Example #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
Example #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())
Example #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)
Example #52
0
 def f():
     result = [1, 2, 3]
     make_sure_not_resized(result)
     result.append(4)
     return len(result)
Example #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)[:])