-
Notifications
You must be signed in to change notification settings - Fork 41
caleb/fix/stringdata #417
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
caleb/fix/stringdata #417
Changes from 9 commits
75141d8
d540ed6
fadb7a6
3c585e2
778ca86
1d45ea9
bbcb6c6
4e07043
ca07871
fcb76da
d042b30
1951efc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,10 +48,25 @@ | |
|
||
JS::PersistentRootedObject jsFunctionRegistry; | ||
|
||
void finalizationRegistryGCCallback(JSContext *cx, JSGCStatus status, JS::GCReason reason, void *data) { | ||
void pythonmonkeyGCCallback(JSContext *cx, JSGCStatus status, JS::GCReason reason, void *data) { | ||
if (status == JSGCStatus::JSGC_END) { | ||
JS::ClearKeptObjects(GLOBAL_CX); | ||
while (JOB_QUEUE->runFinalizationRegistryCallbacks(GLOBAL_CX)); | ||
|
||
if (_Py_IsFinalizing()) { | ||
return; // do not move char pointers around if python is finalizing | ||
} | ||
|
||
JS::AutoCheckCannotGC nogc; | ||
for (const JSStringProxy *jsStringProxy: jsStringProxies) { // char buffers may have moved, so we need to re-point our JSStringProxies | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In symmetry to this, would a Python str object move its char buffers, and how to notify the JS land? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know if python string objects move their buffers? As far as I'm aware they never move |
||
JSLinearString *str = (JSLinearString *)(jsStringProxy->jsString->toString()); // jsString is guaranteed to be linear | ||
if (JS::LinearStringHasLatin1Chars(str)) { | ||
(((PyUnicodeObject *)(jsStringProxy))->data.any) = (void *)JS::GetLatin1LinearStringChars(nogc, str); | ||
} | ||
else { // utf16 / ucs2 string | ||
(((PyUnicodeObject *)(jsStringProxy))->data.any) = (void *)JS::GetTwoByteLinearStringChars(nogc, str); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
@@ -547,7 +562,7 @@ PyMODINIT_FUNC PyInit_pythonmonkey(void) | |
return NULL; | ||
} | ||
|
||
JS_SetGCCallback(GLOBAL_CX, finalizationRegistryGCCallback, NULL); | ||
JS_SetGCCallback(GLOBAL_CX, pythonmonkeyGCCallback, NULL); | ||
|
||
JS::RealmCreationOptions creationOptions = JS::RealmCreationOptions(); | ||
JS::RealmBehaviors behaviours = JS::RealmBehaviors(); | ||
|
Uh oh!
There was an error while loading. Please reload this page.