Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for loop protocols for jit #14

Open
thautwarm opened this issue Oct 7, 2020 · 1 comment
Open

for loop protocols for jit #14

thautwarm opened this issue Oct 7, 2020 · 1 comment
Labels

Comments

@thautwarm
Copy link
Owner

Dynjit inherits the identical semantics from python bytecode, which is using GET_ITER and FOR_ITER to implement loops:

for i in xs:
   # do some

under dynjit, it is identical to

tmp = iter(xs)
while True:
   try:
      i = next(iter)
   except StopIteration:
      goto l:
   # do some
l:

The key point is, finding a protocol for, switching from pure Python code to optimized code when the types of iter and i got known.

Question: Should we follow the Python loop implementation, i.e., using __iter__? If so, exception check makes it impossible to make a positive enough performance gain. Even if __iter__ is jitted, exception check is still a disaster.

@thautwarm thautwarm added the defer label Nov 3, 2020
@thautwarm
Copy link
Owner Author

This have to been deferred until we implement bytecode -> untyped DIO IR transformation.
I don't believe this is the most urgent.
Efforts will be allocated for supporting JITing the most builtins and language features already allowed in DIO-JIT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant