Skip to content

Commit

Permalink
Merge 7d965b4 into 7dc713c
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Aug 1, 2014
2 parents 7dc713c + 7d965b4 commit 6fce265
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/utils/test_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
Expand Down Expand Up @@ -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_setitem_on_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 changes: 3 additions & 0 deletions topaz/utils/ordereddict.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6fce265

Please sign in to comment.