Skip to content
Permalink
Browse files

Merge 7d965b4 into 7dc713c

  • Loading branch information
alex committed Aug 1, 2014
2 parents 7dc713c + 7d965b4 commit 6fce2658489a9cb8c80d6abef3158d5e45b4b577
Showing with 24 additions and 0 deletions.
  1. +21 −0 tests/utils/test_ordereddict.py
  2. +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_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,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

0 comments on commit 6fce265

Please sign in to comment.
You can’t perform that action at this time.