-
Notifications
You must be signed in to change notification settings - Fork 122
Implement maybe_wrap_object_value without OOL calls #301
Conversation
#[inline] | ||
pub unsafe fn maybe_wrap_value(cx: *mut JSContext, rval: MutableHandleValue) { | ||
if rval.is_object_or_null() { | ||
maybe_wrap_object_value(cx, rval); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe_wrap_object_or_null_value
#[inline] | ||
unsafe fn get_object_group(obj: *mut JSObject) -> *mut ObjectGroup { | ||
assert!(!obj.is_null()); | ||
(*(obj as *mut Object)).group |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be more readable if you added a separate let
binding for obj as *mut Object
.
Amended all the things. |
Code looks okay to me; I'd like @jdm to agree we want to go this way, though. (Also, some documentation might be useful.) |
} | ||
|
||
#[inline] | ||
pub unsafe fn maybe_wrap_value(cx: *mut JSContext, rval: MutableHandleValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is different than Gecko's, which special-cases strings and objects but otherwise avoids wrapping: https://dxr.mozilla.org/mozilla-central/rev/82d0a583a9a39bf0b0000bccbf6d5c9ec2596bcc/dom/bindings/BindingUtils.h#852
return try_to_outerize(rval); | ||
} | ||
} | ||
assert!(JS_WrapValue(cx, rval)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We miss a fast path here where the compartment is the same and it's a non-WebIDL object.
☔ The latest upstream changes (presumably #305) made this pull request unmergeable. Please resolve the merge conflicts. |
Planning to finish this up, @nox? |
The only remaining OOL calls are ToWindowIfWindowProxy and JS_WrapValue, like in the equivalent Gecko function.
@bors-servo: r+ |
📌 Commit f32c5ac has been approved by |
Implement maybe_wrap_object_value without OOL calls The only remaining OOL calls are ToWindowIfWindowProxy and JS_WrapValue, like in the equivalent Gecko function. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-mozjs/301) <!-- Reviewable:end -->
☀️ Test successful - status-appveyor, status-travis |
The only remaining OOL calls are ToWindowIfWindowProxy and JS_WrapValue,
like in the equivalent Gecko function.
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)