Commits

Tobias Pape committed d9a275c

force size of ByteObject to be integer typey; use interpret in jit-grapher

Comments (0)

Files changed (3)

 class W_BytesObject(W_AbstractObjectWithClassReference):
     def __init__(self, w_class, size):
         W_AbstractObjectWithClassReference.__init__(self, w_class)
+        assert isinstance(size, int)
         self.bytes = ['\x00'] * size
 
     def at0(self, space, index0):

spyvm/objspace.py

                 pass
         # XXX is math allowed here?
         import math
-        bytes_len = max(4, int(math.log(val, 0xff)) + 1)
+        bytes_len = int(math.log(val) / math.log(0xff)) + 1
+        bytes_len = 4 if 4 > bytes_len else bytes_len
         w_result = model.W_BytesObject(self.classtable['w_LargePositiveInteger'], bytes_len)
         for i in range(bytes_len):
             w_result.setchar(i, chr(intmask((val >> i*8) & 255)))

spyvm/test/jit.py

 
         interp = tinyBenchmarks()
         def interp_w():
-            counter = 0
-            try:
-                while True:
-                    counter += 1
-                    s_active_context = interp.s_active_context()
-                    interp.bytecode_step_translated(s_active_context)
-                    if counter == 100000:
-                        counter = 0
-            except interpreter.ReturnFromTopLevel, e:
-                w_result = e.object
+            interp.interpret()
 
-        self.meta_interp(interp_w, [], listcomp=True, listops=True, backendopt=True)
+        self.meta_interp(interp_w, [], listcomp=True, listops=True,
+                        #backendopt=True
+                        )