Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
24 additions
and
0 deletions.
-
+21
−0
tests/utils/test_ordereddict.py
-
+3
−0
topaz/utils/ordereddict.py
|
|
@@ -1,3 +1,5 @@ |
|
|
from rpython.jit.metainterp.test.support import LLJitMixin |
|
|
from rpython.rlib.jit import JitDriver |
|
|
from rpython.rtyper.test.test_llinterp import interpret |
|
|
|
|
|
from topaz.utils.ordereddict import OrderedDict |
|
@@ -328,3 +330,22 @@ def inner(arg0=-1, arg1=-1): |
|
|
else: |
|
|
raise NotImplementedError(args) |
|
|
setattr(cls, func.__name__, make_caller(i)) |
|
|
|
|
|
|
|
|
class TestOrderedDictJIT(LLJitMixin): |
|
|
def test_dict_virtual(self): |
|
|
jd = JitDriver(greens=[], reds='auto') |
|
|
|
|
|
def f(n): |
|
|
d = OrderedDict() |
|
|
while n > 0: |
|
|
jd.jit_merge_point() |
|
|
if n % 10 == 0: |
|
|
n -= len(d) |
|
|
d = OrderedDict() |
|
|
d["a"] = n |
|
|
n -= 1 |
|
|
return len(d) |
|
|
|
|
|
self.meta_interp(f, [100]) |
|
|
self.check_simple_loop(call_may_force=0, call=0, new=0) |
|
@@ -3,6 +3,7 @@ |
|
|
|
|
|
from rpython.annotator import model |
|
|
from rpython.annotator.bookkeeper import getbookkeeper |
|
|
from rpython.rlib import jit |
|
|
from rpython.rlib.objectmodel import hlinvoke |
|
|
from rpython.rlib.rarithmetic import r_uint, intmask, LONG_BIT |
|
|
from rpython.rtyper.extregistry import ExtRegistryEntry |
|
@@ -480,6 +481,8 @@ def ll_len(d): |
|
|
return d.num_items |
|
|
|
|
|
@staticmethod |
|
|
@jit.look_inside_iff(lambda d, key, hash: |
|
|
jit.isvirtual(d) and jit.isconstant(key)) |
|
|
def ll_lookup(d, key, hash): |
|
|
entries = d.entries |
|
|
mask = len(entries) - 1 |
|
|