Skip to content

Conversation

@sagudev
Copy link
Member

@sagudev sagudev commented Nov 13, 2025

In #650 I did implemented global wrongly and cast hide the problem (*const != *const *mut). To fix things properly I added JSObject *const * JS::CurrentGlobal(JSContext* cx) to jsapi which returns JSObject *const * (CurrentGlobalOrNull already deref the handle to return the object directly, which makes it harder to return handle again).

Also existing code made use of Handle very hard as we cannot use &mut realm as it's already borrowed by handle, but the only reason we bound the lifetime to handle is to not outlive the realm. So by creating global_and_reborrow(&'_ mut self) -> (Handle<'_, *mut JSObject>, &'_ mut Self) we return "reborrowed" realm, handle will not outlive original realm borrow and we can still use &mut realm.

The callback test is using these new global_and_reborrow so we know it's working now.

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
@sagudev sagudev marked this pull request as ready for review November 13, 2025 16:34
@sagudev sagudev requested a review from jdm November 13, 2025 18:07
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