Commit b5c6f215 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Update threadmodule.c a bit

Will take some more work to actually free thread-locals since we don't expose that
I'm surprised we didn't actually free any of that before!
parent 9b0d08ff
......@@ -144,7 +144,7 @@ PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void) PYSTON_NOEXCEPT;
PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void) PYSTON_NOEXCEPT;
PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *) PYSTON_NOEXCEPT;
PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void) PYSTON_NOEXCEPT;
PyAPI_FUNC(BORROWED(PyObject *)) PyThreadState_GetDict(void) PYSTON_NOEXCEPT;
PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *) PYSTON_NOEXCEPT;
......
......@@ -239,7 +239,7 @@ static PyTypeObject localdummytype = {
/* tp_name */ "_thread._localdummy",
/* tp_basicsize */ sizeof(localdummyobject),
/* tp_itemsize */ 0,
/* tp_dealloc */ (destructor)/*localdummy_dealloc*/ NULL,
/* tp_dealloc */ (destructor)localdummy_dealloc,
/* tp_print */ 0,
/* tp_getattr */ 0,
/* tp_setattr */ 0,
......@@ -392,16 +392,13 @@ local_traverse(localobject *self, visitproc visit, void *arg)
static int
local_clear(localobject *self)
{
// Pyston change:
Py_FatalError("unexpected call to local_clear()");
abort();
#if 0
PyThreadState *tstate;
Py_CLEAR(self->args);
Py_CLEAR(self->kw);
Py_CLEAR(self->dummies);
Py_CLEAR(self->wr_callback);
/* Remove all strong references to dummies from the thread states */
/*
if (self->key
&& (tstate = PyThreadState_Get())
&& tstate->interp) {
......@@ -412,8 +409,9 @@ local_clear(localobject *self)
PyDict_GetItem(tstate->dict, self->key))
PyDict_DelItem(tstate->dict, self->key);
}
*/
printf("threadmodule.c:413: can't really free up the thread-specific dummy storage\n");
return 0;
#endif
}
static void
......@@ -498,7 +496,7 @@ static PyTypeObject localtype = {
/* tp_name */ "thread._local",
/* tp_basicsize */ sizeof(localobject),
/* tp_itemsize */ 0,
/* tp_dealloc */ (destructor)/*local_dealloc*/ NULL,
/* tp_dealloc */ (destructor)local_dealloc,
/* tp_print */ 0,
/* tp_getattr */ 0,
/* tp_setattr */ 0,
......
......@@ -1296,7 +1296,7 @@ extern "C" char* Py_GetPythonHome(void) noexcept {
return home;
}
extern "C" PyObject* PyThreadState_GetDict(void) noexcept {
extern "C" BORROWED(PyObject*) PyThreadState_GetDict(void) noexcept {
Box* dict = cur_thread_state.dict;
if (!dict) {
dict = cur_thread_state.dict = new BoxedDict();
......@@ -1306,7 +1306,11 @@ extern "C" PyObject* PyThreadState_GetDict(void) noexcept {
extern "C" void PyThreadState_Clear(PyThreadState* tstate) noexcept {
assert(tstate == NULL);
Py_CLEAR(cur_thread_state.dict);
Py_CLEAR(cur_thread_state.curexc_type);
Py_CLEAR(cur_thread_state.curexc_value);
Py_CLEAR(cur_thread_state.curexc_traceback);
}
extern "C" int _PyOS_URandom(void* buffer, Py_ssize_t size) noexcept {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment