Skip to content

Commit 52039ad

Browse files
Merge pull request #221 from Distributive-Network/philippe/176-211-201-cleanup
TODOS for improved memory management and minor improvements
2 parents 92d512b + 84645ab commit 52039ad

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

.github/workflows/test-and-publish.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
with:
4141
path: |
4242
./_spidermonkey_install/*
43-
key: spidermonkey115.1.0-${{ runner.os }}-${{ runner.arch }}
43+
key: spidermonkey115.7.0-${{ runner.os }}-${{ runner.arch }}
4444
lookup-only: true # skip download
4545
- name: Setup XCode
4646
if: ${{ matrix.os == 'macos-13' && steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
@@ -60,7 +60,7 @@ jobs:
6060
with:
6161
path: |
6262
./_spidermonkey_install/*
63-
key: spidermonkey115.1.0-${{ runner.os }}-${{ runner.arch }}
63+
key: spidermonkey115.7.0-${{ runner.os }}-${{ runner.arch }}
6464
lookup-only: true # skip download
6565
- name: Install dependencies
6666
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
@@ -141,7 +141,7 @@ jobs:
141141
with:
142142
path: |
143143
./_spidermonkey_install/*
144-
key: spidermonkey115.1.0-${{ runner.os }}-${{ runner.arch }}
144+
key: spidermonkey115.7.0-${{ runner.os }}-${{ runner.arch }}
145145
fail-on-cache-miss: true # SpiderMonkey is expected to be cached in its dedicated job
146146
- name: Build pminit
147147
run: |

build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def run_cmake_build():
4040
if platform.system() == "Windows":
4141
execute("cmake .. -T ClangCL", cwd=BUILD_DIR) # use Clang/LLVM toolset for Visual Studio
4242
else:
43-
execute("cmake ..", cwd=BUILD_DIR)
43+
execute("cmake .. -DPYTHON_INCLUDE_DIR=$(python -c 'import sysconfig; print(sysconfig.get_path('include'))') -DPYTHON_LIBRARY=$(python -c 'import sysconfig; print(sysconfig.get_config_var('LIBDIR'))')", cwd=BUILD_DIR)
4444
execute(f"cmake --build . -j{CPUS} --config Release", cwd=BUILD_DIR)
4545

4646
def copy_artifacts():

src/PyDictProxyHandler.cc

+12-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,18 @@ bool PyDictProxyHandler::getOwnEnumerablePropertyKeys(
167167
return this->ownPropertyKeys(cx, proxy, props);
168168
}
169169

170-
// @TODO (Caleb Aikens) implement this
171-
void PyDictProxyHandler::finalize(JS::GCContext *gcx, JSObject *proxy) const {}
170+
// TODO not needed at this time since only called as part of cleanup function's js::DestroyContext call which is only called at cpython exit Py_AtExit in PyInit_pythonmonkey
171+
// put in some combination of the commented-out code below
172+
void PyDictProxyHandler::finalize(JS::GCContext *gcx, JSObject *proxy) const {
173+
/*PyThreadState *state = PyThreadState_Get();
174+
PyThreadState *state = PyGILState_GetThisThreadState();
175+
if (state) {
176+
PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot);
177+
PyGILState_STATE state = PyGILState_Ensure();
178+
Py_DECREF(self);
179+
PyGILState_Release(state);
180+
}*/
181+
}
172182

173183
bool PyDictProxyHandler::defineProperty(JSContext *cx, JS::HandleObject proxy,
174184
JS::HandleId id,

src/PyListProxyHandler.cc

+10-1
Original file line numberDiff line numberDiff line change
@@ -2098,8 +2098,17 @@ bool PyListProxyHandler::getOwnPropertyDescriptor(
20982098
return true;
20992099
}
21002100

2101+
// TODO not needed at this time since only called as part of cleanup function's js::DestroyContext call which is only called at cpython exit Py_AtExit in PyInit_pythonmonkey
2102+
// put in some combination of the commented-out code below
21012103
void PyListProxyHandler::finalize(JS::GCContext *gcx, JSObject *proxy) const {
2102-
JS::SetReservedSlot(proxy, PyObjectSlot, JS::PrivateValue(nullptr));
2104+
/*PyThreadState *state = PyThreadState_Get();
2105+
PyThreadState *state = PyGILState_GetThisThreadState();
2106+
if (state) {
2107+
PyObject *self = JS::GetMaybePtrFromReservedSlot<PyObject>(proxy, PyObjectSlot);
2108+
PyGILState_STATE state = PyGILState_Ensure();
2109+
Py_DECREF(self);
2110+
PyGILState_Release(state);
2111+
}*/
21032112
}
21042113

21052114
bool PyListProxyHandler::defineProperty(

0 commit comments

Comments
 (0)