Skip to content

Conversation

@kmod
Copy link
Collaborator

@kmod kmod commented Aug 8, 2015

A lot of our remaining C++ exceptions are being thrown from one Python frame and caught by another. We handle things caught by Python frames well, and this adds the ability to propagate them as CAPI exceptions.

I'm not stressing about the minor perf impact of these changes too much, but at least this set looks (randomly?) positive:

      django_template3.py             3.3s (4)             3.3s (4)  -0.5%
            pyxl_bench.py             2.9s (4)             2.9s (4)  -0.6%
sqlalchemy_imperative2.py             3.3s (4)             3.2s (4)  -1.0%
                  geomean                 3.1s                 3.1s  -0.7%

kmod and others added 2 commits August 8, 2015 06:19
Which piggy-back on the integration tests for getting their dependencies.
Our IR doesn't explicitly represent the data transfer between an Invoke
statement and its corresponding LandingPad.  We use a couple different
techniques to pass it through: in the ast interpreter/bjit, we stash it
into an interpreter-local variable and then pull it back out.  Previous
to this change, in the LLVM tier we would pass it directly through
an exception, using either the C++ or CAPI exception-passing mechanism.

This works but is a pain, since it requires coordination between the invoke
and the landingpad.  These live in different basic blocks, so we ended up
having this other code that lives separate from the normal irgen that has
to decide which exception style to use, and it has to respect certain
restrictions within irgen (ie it has to be careful to not request CAPI
exceptions for cases that we haven't added support for yet).

This commit changes the approach so that the exception data is passed
directly as LLVM Values, and its up to the Invoke to figure out how
to get it into that form.  This adds a bit more complexity to the invoke,
but it should make the interface easier to extend (such as in the next commit).
@kmod
Copy link
Collaborator Author

kmod commented Aug 8, 2015

Oh I should mention, this new throw-capi-exceptions gets turned on if function_name == "next" which is surprisingly effective.

@kmod kmod force-pushed the throw_capis3 branch 2 times, most recently from 1941186 to 4224420 Compare August 8, 2015 22:20
kmod added 3 commits August 8, 2015 22:22
In theory should help with pyxl which throws a decent number
of StopIterations from calling generator.next() directly, but
pretty few of those calls actually make it into the llvm JIT
to benefit from this.
kmod added a commit that referenced this pull request Aug 8, 2015
Be able to jit functions that throw CAPI exceptions
@kmod kmod merged commit fb2eef6 into pyston:master Aug 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant