Пример #1
0
 def fn():
     d2 = D()
     return (compute_hash(d2),
             current_object_addr_as_int(d2),
             compute_hash(c),
             compute_hash(d),
             compute_hash(("Hi", None, (7.5, 2, d))))
Пример #2
0
 def f1():
     d2 = D()
     # xxx we assume that current_object_addr_as_int is defined as
     # simply returning the identity hash
     current_identityhash = current_object_addr_as_int(d2)
     instance_hash = compute_identity_hash(d2)
     return current_identityhash == instance_hash
Пример #3
0
 def _index_cache(self, selector):
     space = self.space
     cache = space.fromcache(IndexCache)
     SHIFT2 = r_uint.BITS - space.config.objspace.std.methodcachesizeexp
     SHIFT1 = SHIFT2 - 5
     attrs_as_int = objectmodel.current_object_addr_as_int(self)
     # ^^^Note: see comment in typeobject.py for
     # _pure_lookup_where_with_method_cache()
     hash_selector = objectmodel.compute_hash(selector)
     product = intmask(attrs_as_int * hash_selector)
     index_hash = (r_uint(product) ^ (r_uint(product) << SHIFT1)) >> SHIFT2
     # ^^^Note2: same comment too
     cached_attr = cache.attrs[index_hash]
     if cached_attr is self:
         cached_selector = cache.selectors[index_hash]
         if cached_selector == selector:
             index = cache.indices[index_hash]
             if space.config.objspace.std.withmethodcachecounter:
                 name = selector[0]
                 cache.hits[name] = cache.hits.get(name, 0) + 1
             return index
     index = self._index(selector)
     cache.attrs[index_hash] = self
     cache.selectors[index_hash] = selector
     cache.indices[index_hash] = index
     if space.config.objspace.std.withmethodcachecounter:
         name = selector[0]
         cache.misses[name] = cache.misses.get(name, 0) + 1
     return index
Пример #4
0
    def _pure_lookup_where_with_method_cache(w_self, name, version_tag):
        space = w_self.space
        SHIFT = r_uint.BITS - space.config.objspace.std.methodcachesizeexp
        version_tag_as_int = current_object_addr_as_int(version_tag)
        # ^^^Note: if the version_tag object is moved by a moving GC, the
        # existing method cache entries won't be found any more; new
        # entries will be created based on the new address.  The
        # assumption is that the version_tag object won't keep moving all
        # the time - so using the fast current_object_addr_as_int() instead
        # of a slower solution like hash() is still a good trade-off.
        hash_name = compute_hash(name)
        method_hash = r_uint(intmask(version_tag_as_int * hash_name)) >> SHIFT
        cached_version_tag = space.method_cache_versions[method_hash]
        if cached_version_tag is version_tag:
            cached_name = space.method_cache_names[method_hash]
            if cached_name is name:
                tup = space.method_cache_lookup_where[method_hash]
                if space.config.objspace.std.withmethodcachecounter:
                    space.method_cache_hits[name] = \
                            space.method_cache_hits.get(name, 0) + 1
#                print "hit", w_self, name
                return tup
        tup = w_self._lookup_where(name)
        space.method_cache_versions[method_hash] = version_tag
        space.method_cache_names[method_hash] = name
        space.method_cache_lookup_where[method_hash] = tup
        if space.config.objspace.std.withmethodcachecounter:
            space.method_cache_misses[name] = \
                    space.method_cache_misses.get(name, 0) + 1
#        print "miss", w_self, name
        return tup
Пример #5
0
 def fn():
     d2 = D()
     return (compute_hash(d2),
             current_object_addr_as_int(d2),
             compute_hash(c),
             compute_hash(d),
             compute_hash(("Hi", None, (7.5, 2, d))))
Пример #6
0
 def f1():
     d2 = D()
     # xxx we assume that current_object_addr_as_int is defined as
     # simply returning the identity hash
     current_identityhash = current_object_addr_as_int(d2)
     instance_hash = compute_identity_hash(d2)
     return current_identityhash == instance_hash
Пример #7
0
    def _pure_lookup_where_with_method_cache(w_self, name, version_tag):
        space = w_self.space
        SHIFT = r_uint.BITS - space.config.objspace.std.methodcachesizeexp
        version_tag_as_int = current_object_addr_as_int(version_tag)
        # ^^^Note: if the version_tag object is moved by a moving GC, the
        # existing method cache entries won't be found any more; new
        # entries will be created based on the new address.  The
        # assumption is that the version_tag object won't keep moving all
        # the time - so using the fast current_object_addr_as_int() instead
        # of a slower solution like hash() is still a good trade-off.
        hash_name = compute_hash(name)
        method_hash = r_uint(intmask(version_tag_as_int * hash_name)) >> SHIFT
        cached_version_tag = space.method_cache_versions[method_hash]
        if cached_version_tag is version_tag:
            cached_name = space.method_cache_names[method_hash]
            if cached_name is name:
                tup = space.method_cache_lookup_where[method_hash]
                if space.config.objspace.std.withmethodcachecounter:
                    space.method_cache_hits[name] = \
                            space.method_cache_hits.get(name, 0) + 1
#                print "hit", w_self, name
                return tup
        tup = w_self._lookup_where_all_typeobjects(name)
        space.method_cache_versions[method_hash] = version_tag
        space.method_cache_names[method_hash] = name
        space.method_cache_lookup_where[method_hash] = tup
        if space.config.objspace.std.withmethodcachecounter:
            space.method_cache_misses[name] = \
                    space.method_cache_misses.get(name, 0) + 1
#        print "miss", w_self, name
        return tup
Пример #8
0
 def _index_cache(self, selector):
     space = self.space
     cache = space.fromcache(IndexCache)
     SHIFT2 = r_uint.BITS - space.config.objspace.std.methodcachesizeexp
     SHIFT1 = SHIFT2 - 5
     attrs_as_int = objectmodel.current_object_addr_as_int(self)
     # ^^^Note: see comment in typeobject.py for
     # _pure_lookup_where_with_method_cache()
     hash_selector = objectmodel.compute_hash(selector)
     product = intmask(attrs_as_int * hash_selector)
     index_hash = (r_uint(product) ^ (r_uint(product) << SHIFT1)) >> SHIFT2
     # ^^^Note2: same comment too
     cached_attr = cache.attrs[index_hash]
     if cached_attr is self:
         cached_selector = cache.selectors[index_hash]
         if cached_selector == selector:
             index = cache.indices[index_hash]
             if space.config.objspace.std.withmethodcachecounter:
                 name = selector[0]
                 cache.hits[name] = cache.hits.get(name, 0) + 1
             return index
     index = self._index(selector)
     cache.attrs[index_hash] = self
     cache.selectors[index_hash] = selector
     cache.indices[index_hash] = index
     if space.config.objspace.std.withmethodcachecounter:
         name = selector[0]
         cache.misses[name] = cache.misses.get(name, 0) + 1
     return index
Пример #9
0
 def f1():
     d2 = D()
     # xxx we assume that the identityhash doesn't change from
     #     one line to the next
     current_identityhash = current_object_addr_as_int(d2)
     instance_hash = hash(d2)
     return ((current_identityhash & sys.maxint) ==
             (instance_hash & sys.maxint))
Пример #10
0
 def f():
     d2 = D()
     return (
         compute_identity_hash(d2),
         current_object_addr_as_int(d2),
         compute_identity_hash(c),
         compute_identity_hash(d),
     )
Пример #11
0
 def f1():
     d2 = D()
     # xxx we assume that the identityhash doesn't change from
     #     one line to the next
     current_identityhash = current_object_addr_as_int(d2)
     instance_hash = hash(d2)
     return ((current_identityhash & sys.maxint) == (instance_hash
                                                     & sys.maxint))
Пример #12
0
 def entry_point(loops):
     g = rpystone.g
     g.IntGlob = 0
     g.BoolGlob = 0
     g.Char1Glob = '\0'
     g.Char2Glob = '\0'
     for i in range(51):
         g.Array1Glob[i] = 0
     for i in range(51):
         for j in range(51):
             g.Array2Glob[i][j] = 0
     g.PtrGlb = None
     g.PtrGlbNext = None
     return rpystone.pystones(loops), current_object_addr_as_int(g)
Пример #13
0
 def entry_point(loops):
     g = rpystone.g
     g.IntGlob = 0
     g.BoolGlob = 0
     g.Char1Glob = "\0"
     g.Char2Glob = "\0"
     for i in range(51):
         g.Array1Glob[i] = 0
     for i in range(51):
         for j in range(51):
             g.Array2Glob[i][j] = 0
     g.PtrGlb = None
     g.PtrGlbNext = None
     return rpystone.pystones(loops), current_object_addr_as_int(g)
Пример #14
0
    def _pure_lookup_where_with_method_cache(w_self, name, version_tag):
        space = w_self.space
        cache = space.fromcache(MethodCache)
        SHIFT2 = r_uint.BITS - space.config.objspace.std.methodcachesizeexp
        SHIFT1 = SHIFT2 - 5
        version_tag_as_int = current_object_addr_as_int(version_tag)
        # ^^^Note: if the version_tag object is moved by a moving GC, the
        # existing method cache entries won't be found any more; new
        # entries will be created based on the new address.  The
        # assumption is that the version_tag object won't keep moving all
        # the time - so using the fast current_object_addr_as_int() instead
        # of a slower solution like hash() is still a good trade-off.
        hash_name = compute_hash(name)
        product = intmask(version_tag_as_int * hash_name)
        method_hash = (r_uint(product) ^ (r_uint(product) << SHIFT1)) >> SHIFT2
        # ^^^Note2: we used to just take product>>SHIFT2, but on 64-bit
        # platforms SHIFT2 is really large, and we loose too much information
        # that way (as shown by failures of the tests that typically have
        # method names like 'f' who hash to a number that has only ~33 bits).
        cached_version_tag = cache.versions[method_hash]
        if cached_version_tag is version_tag:
            cached_name = cache.names[method_hash]
            if cached_name is name:
                tup = cache.lookup_where[method_hash]
                if space.config.objspace.std.withmethodcachecounter:
                    cache.hits[name] = cache.hits.get(name, 0) + 1
#                print "hit", w_self, name
                return tup
        tup = w_self._lookup_where_all_typeobjects(name)
        cache.versions[method_hash] = version_tag
        cache.names[method_hash] = name
        cache.lookup_where[method_hash] = tup
        if space.config.objspace.std.withmethodcachecounter:
            cache.misses[name] = cache.misses.get(name, 0) + 1
#        print "miss", w_self, name
        return tup
Пример #15
0
    def _pure_lookup_where_with_method_cache(w_self, name, version_tag):
        space = w_self.space
        cache = space.fromcache(MethodCache)
        SHIFT2 = r_uint.BITS - space.config.objspace.std.methodcachesizeexp
        SHIFT1 = SHIFT2 - 5
        version_tag_as_int = current_object_addr_as_int(version_tag)
        # ^^^Note: if the version_tag object is moved by a moving GC, the
        # existing method cache entries won't be found any more; new
        # entries will be created based on the new address.  The
        # assumption is that the version_tag object won't keep moving all
        # the time - so using the fast current_object_addr_as_int() instead
        # of a slower solution like hash() is still a good trade-off.
        hash_name = compute_hash(name)
        product = intmask(version_tag_as_int * hash_name)
        method_hash = (r_uint(product) ^ (r_uint(product) << SHIFT1)) >> SHIFT2
        # ^^^Note2: we used to just take product>>SHIFT2, but on 64-bit
        # platforms SHIFT2 is really large, and we loose too much information
        # that way (as shown by failures of the tests that typically have
        # method names like 'f' who hash to a number that has only ~33 bits).
        cached_version_tag = cache.versions[method_hash]
        if cached_version_tag is version_tag:
            cached_name = cache.names[method_hash]
            if cached_name is name:
                tup = cache.lookup_where[method_hash]
                if space.config.objspace.std.withmethodcachecounter:
                    cache.hits[name] = cache.hits.get(name, 0) + 1
#                print "hit", w_self, name
                return tup
        tup = w_self._lookup_where_all_typeobjects(name)
        cache.versions[method_hash] = version_tag
        cache.names[method_hash] = name
        cache.lookup_where[method_hash] = tup
        if space.config.objspace.std.withmethodcachecounter:
            cache.misses[name] = cache.misses.get(name, 0) + 1
#        print "miss", w_self, name
        return tup
Пример #16
0
 def fn():
     a1 = A()
     a2 = A()
     return (compute_unique_id(a1), current_object_addr_as_int(a1),
             compute_unique_id(a2), current_object_addr_as_int(a2))
Пример #17
0
 def f():
     d2 = D()
     return (compute_identity_hash(d2), current_object_addr_as_int(d2),
             compute_identity_hash(c), compute_identity_hash(d))
Пример #18
0
 def f():
     x = FooBar()
     # on lltype, the RPython-level repr of an instance contains the
     # current object address
     return current_object_addr_as_int(x), str(x)
Пример #19
0
 def fn():
     d2 = D()
     return hash(d2), current_object_addr_as_int(d2), hash(c), hash(d)
Пример #20
0
 def fn():
     a1 = A()
     a2 = A()
     return (compute_unique_id(a1), current_object_addr_as_int(a1),
             compute_unique_id(a2), current_object_addr_as_int(a2))
Пример #21
0
 def f():
     x = FooBar()
     # on lltype, the RPython-level repr of an instance contains the
     # current object address
     return current_object_addr_as_int(x), str(x)
Пример #22
0
 def fn():
     d2 = D()
     return hash(d2), current_object_addr_as_int(d2), hash(c), hash(d)