Commit 4abefc8f authored by Carl Friedrich Bolz's avatar Carl Friedrich Bolz

replace for loop by while loop

in theory, an rpython for x in range loop should be exactly equivalent
to a while loop. The only difference is if it contains a JIT driver, in
which case the for loop is slower :-(
parent e6acc57b
...@@ -221,20 +221,23 @@ def _toDo(ivkbl, frame, interpreter): ...@@ -221,20 +221,23 @@ def _toDo(ivkbl, frame, interpreter):
block = frame.pop() block = frame.pop()
limit = frame.pop() limit = frame.pop()
self = frame.pop() # we do leave it on there self = frame.pop() # we do leave it on there
block_method = block.get_method() block_method = block.get_method()
context = block.get_context() context = block.get_context()
for i in range(self.get_embedded_integer(), limit.get_embedded_integer() + 1): i = self.get_embedded_integer()
top = limit.get_embedded_integer()
while i <= top:
jitdriver.jit_merge_point(interpreter=interpreter, jitdriver.jit_merge_point(interpreter=interpreter,
block_method=block_method) block_method=block_method)
b = universe.new_block(block_method, context) b = universe.new_block(block_method, context)
frame.push(b) frame.push(b)
frame.push(universe.new_integer(i)) frame.push(universe.new_integer(i))
block_evaluate(b, interpreter, frame) block_evaluate(b, interpreter, frame)
frame.pop() frame.pop()
i += 1
frame.push(self) frame.push(self)
class IntegerPrimitives(Primitives): class IntegerPrimitives(Primitives):
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment