Skip to content
This repository has been archived by the owner on Nov 12, 2022. It is now read-only.

Implement maybe_wrap_object_value without OOL calls #301

Merged
merged 1 commit into from
Nov 15, 2016

Conversation

nox
Copy link
Contributor

@nox nox commented Aug 30, 2016

The only remaining OOL calls are ToWindowIfWindowProxy and JS_WrapValue,
like in the equivalent Gecko function.


This change is Reviewable

@nox nox changed the title Implement maybe_wrap_object_value without OOL calls (Do not merge) Implement maybe_wrap_object_value without OOL calls Aug 30, 2016
@nox nox changed the title (Do not merge) Implement maybe_wrap_object_value without OOL calls Implement maybe_wrap_object_value without OOL calls Aug 31, 2016
#[inline]
pub unsafe fn maybe_wrap_value(cx: *mut JSContext, rval: MutableHandleValue) {
if rval.is_object_or_null() {
maybe_wrap_object_value(cx, rval);
Copy link
Contributor

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
Copy link
Contributor

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.

@nox
Copy link
Contributor Author

nox commented Aug 31, 2016

Amended all the things.

@Ms2ger
Copy link
Contributor

Ms2ger commented Aug 31, 2016

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) {
Copy link
Member

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));
Copy link
Member

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.

@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #305) made this pull request unmergeable. Please resolve the merge conflicts.

@jdm
Copy link
Member

jdm commented Nov 14, 2016

Planning to finish this up, @nox?

The only remaining OOL calls are ToWindowIfWindowProxy and JS_WrapValue,
like in the equivalent Gecko function.
@jdm
Copy link
Member

jdm commented Nov 15, 2016

@bors-servo: r+

@bors-servo
Copy link
Contributor

📌 Commit f32c5ac has been approved by jdm

@bors-servo
Copy link
Contributor

⌛ Testing commit f32c5ac with merge 3ac1492...

bors-servo pushed a commit that referenced this pull request Nov 15, 2016
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 -->
@bors-servo
Copy link
Contributor

☀️ Test successful - status-appveyor, status-travis

@bors-servo bors-servo merged commit f32c5ac into servo:master Nov 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants