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

wip: improve ics #1262

Open
wants to merge 4,580 commits into
base: master
Choose a base branch
from
Open

wip: improve ics #1262

wants to merge 4,580 commits into from

Conversation

undingen
Copy link
Contributor

No description provided.

kmod and others added 30 commits May 6, 2016 22:58
The Rewriter will automatically refcount objects represented as RewriterVar's,
but if you store one as an attribute somewhere, it can't keep track of that.
So add a registerOwnedAttribute() function that lets you say that there is
a reference that lives in an attribute (stored in a memory offset) of another RewriterVar.
They were both failing on master:
- test_dumbdbm was failing in a test case that writes out some data to a database,
  closes it, then reopens the db and expects to be able to read the data.
- test_memoryview expected some weakrefs to get cleared at the right time.

test_socket.py appears to "pass" -- it exits with code 0, but it spams a bunch of
error messages from other threads.
Fix the lost-ref-from-oargs issue
We were missing a guard and we ended up calling the wrong function :/

Still some other issuse with this test
Marius fixed the propagate-C++-exception case, and this commit
adds the to- and from-CAPI cases as well.
It was failing on master due to some of the test cases checking for immediate destruction.
This time it was if __eq__ throws.
It fetches a webpage from a third-party server ("example.com")
and verifies the return code.  For some reason it's failing,
both for us and for CPython.
refcounting fixes for numpy in PyTuple_GetSlice, PyErr_SetExcInfo and PyErr_GetExcInfo
This time it was from trying to look at the result of isUnwinding()
to determine if the function terminated successfully or via an exception.
(And in the exception case, to decref some values that would have been returned.)

This got tripped up in a case where we through an exception, this triggers
an AUTO_DECREF which takes an object to zero decrefs, which has a custom destructor,
and calls code that ends up calling isUnwinding().  This is all happening from inside
a C++ destructor, so this counts as isUnwinding().

We had some code to try to keep isUnwinding() meaning what we wanted to use it for,
but it was only for certain cases.  I think we might be able to extend it to more cases,
but it seems like that would be a losing battle since it's hard to say when "unwinding"
ends and then we are suddenly not unwinding.

So instead, I just disabled isUnwinding() (except in debug mode where it can be somewhat
useful for writing "assert(foo || isUnwinding())"), and then used a different way to
try to determine if the function exited normally.
Since the unwinder now supports throwing exceptions inside destructors (as long
as they don't propagate out).

This is the same change that C++17 makes, from "bool uncaught_exception()" to
"int uncaught_exceptions()".
The part that tests that certain dicts compare a given way.  We don't
have consistent dict comparisons yet (pyston#1135)
Another run-arbitrary-code-during-unwinding issue
Haven't been able to test them all extensively but I tried
to only pick things refcount-related.
This just copy the CPython implementation, so some NumPy tests could pass.
But most of types in Pyston didn't implement '__sizeof__' attribute yet.
Bitset iteration micro optimize
copy CPython sys.getsizeof implementation with some Pyston changes
Undo a bunch of Pyston changes to cpython code
But still some in test/integration
At least what I added here is what CPython does.
undingen and others added 2 commits June 17, 2016 17:27
rewriter+bjit: remove duplicate getattrs, misc codegen improvements
@undingen undingen added the wip label Jun 23, 2016


The function PyCFunction_GetFunction(func) check func type should be
exactly PyCFunction_Type. PyCFunction_GET_FUNCTION(func) does not check
func type. But assumes func layout starts with PyCFunctionObject. i.e.
for allowing func to be PyCFunction_Type subclass.

This way an extension which subclasses PyCFunctionObject will get
into trouble using PyCFunction_GET_FUNCTION() on Pyston
@undingen undingen force-pushed the improve_ics branch 2 times, most recently from 0574400 to 32c71ec Compare June 24, 2016 15:39
kmod and others added 4 commits June 24, 2016 19:33
enable the clang travis CI build again
In Pyston, has_getattribute got set if __getattribute__ is overridden,
but only tp_getattro is supposed to set __getattribute__ and tp_getattr
will not set it. So add a check to update_one_slot, if type->tp_getattr
is not NULL, don't set has_getattribute to False.
kmod and others added 4 commits June 27, 2016 11:05
Enable function.func_closure and function.__new__
before this change we had a fixed number of equal size slots inside an IC.
Because of the large difference in rewrite sizes a fixed slot size is not ideal.
We often ended up with too large slots which prevented us from emitting more slots.
(or very large ICs in general which are bad for memory usage and the instruction cache)

With this commit we will start with a single slot with the size of the whole IC and then decreasing its size to the actual bytes emitted
and creating a new slot which starts directly at the end of the previous slot.
We will repeat to to this until the space left is smaller than the number of bytes the last slot required.
This makes it a little bit less likely that we will be successful in overwritting an existing slot
but our benchmarks show that it is still a large win on all our benchmarks.

Some notable changes are:
- we pick the slot to rewrite much earlier now and prevent it from getting rewritten while we rewrite using num_inside = 1
  the reason is that we would otherwise not know how big the slot is
- when we resize a slot we have to patch the failing guard jumps to the address of the next slot
@undingen undingen force-pushed the improve_ics branch 2 times, most recently from 949b9cc to 476b91a Compare June 28, 2016 20:36
sizeoftank and others added 8 commits June 29, 2016 13:55
Get test/tests/dict_comparisons.py working.
change test timeout -t75 to -t90
CPython has quite a bit more logic than just 'try __cmp__'
OSR can fail in some cases and we have to continue with interpreting in this cases.
Add type.__basicsize__, type.__itemsize__
@kmod kmod force-pushed the master branch 2 times, most recently from 352fd89 to 6488a3e Compare October 28, 2020 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants