Alex Gaynor avatar Alex Gaynor committed ce8caa1

It didn't work because array's have a fixed length and the JIT is very smart. Rewrite the test to ues an attribute (could have also used a non-fixed-size array), it fails before this patch and passes afterwords.

Comments (0)

Files changed (2)

pypy/jit/metainterp/optimizeopt/__init__.py

 
     optimizations, unroll = build_opt_chain(metainterp_sd, enable_opts,
                                             inline_short_preamble, retraced)
-
     if unroll:
         optimize_unroll(metainterp_sd, loop, optimizations)
     else:

pypy/jit/metainterp/test/test_ajit.py

             @dont_look_inside
             def release(self):
                 external(lltype.nullptr(T.TO))
+        class X(object):
+            def __init__(self, idx):
+                self.field = idx
         @dont_look_inside
-        def get_lst():
-            return [0]
-        myjitdriver = JitDriver(greens=[], reds=["n", "l", "lock"])
-        def f(n):
+        def get_obj(z):
+            return X(z)
+        myjitdriver = JitDriver(greens=[], reds=["n", "l", "z", "lock"])
+        def f(n, z):
             lock = Lock()
             l = 0
             while n > 0:
-                myjitdriver.jit_merge_point(lock=lock, l=l, n=n)
-                x = get_lst()
-                l += len(x)
+                myjitdriver.jit_merge_point(lock=lock, l=l, n=n, z=z)
+                x = get_obj(z)
+                l += x.field
                 lock.acquire()
                 # This must not reuse the previous one.
-                n -= len(x)
+                n -= x.field
                 lock.release()
             return n
-        res = self.meta_interp(f, [10])
-        self.check_loops(arraylen_gc=2)
+        res = self.meta_interp(f, [10, 1])
+        self.check_loops(getfield_gc=2)
 
 
 class TestLLtype(BaseLLtypeTests, LLJitMixin):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.