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

Reimplement CustomAutoRooter hierarchy #382

Merged
merged 10 commits into from
Dec 1, 2017

Conversation

Xanewok
Copy link
Contributor

@Xanewok Xanewok commented Nov 27, 2017

This is an attempt at servo/servo#16678. It doesn't yet contain conversion code that's described here: servo/servo#16678 (comment).

I wanted to see if the design is somewhat sound and ergonomic. Tried to make CustomAutoRooter a convenient generic type that could support tracing arbitrary types, just like C++ equivalent does, albeit with generics, since we can't just use C++ inheritance.

Here SequenceRooter<T> is implemented as a simple alias for CustomAutoRooter<Vec<T>>.

cc @jdm


This change is Reviewable

Copy link
Member

@jdm jdm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

src/rust.rs Outdated
@@ -463,6 +464,185 @@ macro_rules! rooted {
}
}

use jsapi::AutoGCRooter_jspubtd_h_unnamed_1 as AutoGCRooterTag;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this up with the other use statements.

src/rust.rs Outdated
}
}

pub unsafe fn add_to_root_stack(&mut self, cx: *mut JSContext) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be public.

src/rust.rs Outdated
}

pub unsafe fn add_to_root_stack(&mut self, cx: *mut JSContext) {
let autoGCRooters: &mut _ = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the &mut _ here necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because we need a pointer to the autoGCRooters_ stack list itself (which is also represented as a pointer).
The stackTop member is initialized with it in C++: https://dxr.mozilla.org/mozilla-central/source/js/public/RootingAPI.h#839.

src/rust.rs Outdated
*self.stackTop = self;
}

pub unsafe fn remove_from_root_stack(&mut self) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be public.

src/rust.rs Outdated
}

impl<T> CustomAutoRooter<T> {
pub unsafe fn add_to_root_stack(&mut self, cx: *mut JSContext) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't need to be public.

src/rust.rs Outdated
pub type SequenceRooter<T> = CustomAutoRooter<Vec<T>>;

/// TODO: Document me (similar to Rooted)
pub struct SequenceRooterGuard<'a, T: 'a + RootKind + GCMethods> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some of the work that the rest of your group is doing, we will want to make this more general. I'm fine if you want to make this follow-up work.

Since there is nothing special about sequences here, let's make this more general: RooterGuard<T> where T: StackRoot (which can be a new type that provides add_to_root_stack and remove_from_stack, as well as a way to access the contained data).

* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#![cfg(feature = "debugmozjs")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this so the test is always run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, JS_SetGCZeal needed that and I thought I stumbled upon this also with JS_GC, but that's not the case and it's not needed here. Will do, thanks!


unsafe impl CustomTrace for TestStruct {
fn trace(&self, _: *mut JSTracer) {
unsafe { TRACE_FN_WAS_CALLED = true; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could store a Cell<bool> inside CustomTrace instead of using static mut for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we talked, #[cfg(test)] code is not compiled in a library target that's used by a Cargo integration test, so we can't modify the CustomTrace trait here.

I can extract the boilerplate code to a macro that declares the static variable and the impl block, if that works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I meant to says TestStruct instead of CustomTrace.


unsafe impl CustomTrace for TestStruct {
fn trace(&self, _: *mut JSTracer) {
unsafe { TRACE_FN_WAS_CALLED = true; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment.


rooted.add_to_root_stack(rt.cx());
JS_GC(rt.rt());
rooted.remove_from_root_stack();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test would benefit from the generalization I suggested earlier.

@Xanewok
Copy link
Contributor Author

Xanewok commented Nov 28, 2017

Addressed feedback and pushed related changes.

@Xanewok
Copy link
Contributor Author

Xanewok commented Nov 29, 2017

@jdm pushed a commit that uses Cell instead of static mut variable. Could you take another look at it and tell me if this needs more work still?

Copy link
Member

@jdm jdm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

src/rust.rs Outdated
let $name = __root.root($cx);
};
(in($cx:expr) let mut $name:ident = $init:expr) => {
let mut __root = $crate::rust::SequenceRooter::new($init);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of these is CustomAutoRooter, and one is SequenceRooter. That's surprising!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Fixed that now, renamed the macro to a more general auto_root name, to be used with CustomAutoRooter itself.

@jdm
Copy link
Member

jdm commented Nov 29, 2017

@bors-servo: r+
Thanks!

@bors-servo
Copy link
Contributor

📌 Commit 03b62d3 has been approved by jdm

@bors-servo
Copy link
Contributor

⌛ Testing commit 03b62d3 with merge bc49851...

bors-servo pushed a commit that referenced this pull request Nov 29, 2017
Reimplement CustomAutoRooter hierarchy

This is an attempt at servo/servo#16678. It doesn't yet contain conversion code that's described here: servo/servo#16678 (comment).

I wanted to see if the design is somewhat sound and ergonomic. Tried to make CustomAutoRooter a convenient generic type that could support tracing arbitrary types, just like C++ equivalent does, albeit with generics, since we can't just use C++ inheritance.

Here `SequenceRooter<T>` is implemented as a simple [alias](https://github.com/Xanewok/rust-mozjs/blob/custom-auto-rooter/src/rust.rs#L592) for `CustomAutoRooter<Vec<T>>`.

cc @jdm

<!-- 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/382)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

💔 Test failed - status-appveyor

@jdm
Copy link
Member

jdm commented Nov 29, 2017

Ah, having both new tests in the same file is hitting the usual error.

thread 'root_macro' panicked at 'called `Result::unwrap()` on an `Err` value: ()', src\libcore\result.rs:906:4

@Xanewok
Copy link
Contributor Author

Xanewok commented Nov 29, 2017

Darn it, I tried to reproduce it and ran cargo test ~2000 times on Ubuntu 16.10 on i7-3770K, but couldn't reproduce it in the end.
@jdm do you think we can proceed with this and work in the meantime on bulletproofing the testing infra? Maybe we can do a test run with cargo test -- --test-threads=1 on CI to see if that helps?

@jdm
Copy link
Member

jdm commented Nov 29, 2017

If you move the second new test into a separate file, it should avoid the problem entirely.

@Xanewok
Copy link
Contributor Author

Xanewok commented Nov 29, 2017

Done. However I'm not sure if that's a good idea moving forward, since linking and producing separate binary for each test takes considerable amount of time, so if each test doesn't need a completely separate process, it'd probably be faster and easier to maintain to run tests using only a single thread instead in fewer test binaries.

@jdm
Copy link
Member

jdm commented Nov 29, 2017

@bors-servo: r+

@bors-servo
Copy link
Contributor

📌 Commit d88d93a has been approved by jdm

@bors-servo
Copy link
Contributor

⌛ Testing commit d88d93a with merge 0551c14...

bors-servo pushed a commit that referenced this pull request Nov 29, 2017
Reimplement CustomAutoRooter hierarchy

This is an attempt at servo/servo#16678. It doesn't yet contain conversion code that's described here: servo/servo#16678 (comment).

I wanted to see if the design is somewhat sound and ergonomic. Tried to make CustomAutoRooter a convenient generic type that could support tracing arbitrary types, just like C++ equivalent does, albeit with generics, since we can't just use C++ inheritance.

Here `SequenceRooter<T>` is implemented as a simple [alias](https://github.com/Xanewok/rust-mozjs/blob/custom-auto-rooter/src/rust.rs#L592) for `CustomAutoRooter<Vec<T>>`.

cc @jdm

<!-- 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/382)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

💔 Test failed - status-travis

@Xanewok
Copy link
Contributor Author

Xanewok commented Nov 30, 2017

Same as #381 (comment), Travis couldn't start macOS debugmozjs job for a long time and when it did, it couldn't set up the environment:

error: toolchain 'nightly' is not installed
info: caused by: not a directory: '/Users/travis/.rustup/toolchains/nightly-x86_64-apple-darwin'

https://travis-ci.org/servo/rust-mozjs/jobs/309158923

@bors-servo
Copy link
Contributor

☀️ Test successful - status-appveyor, status-travis
Approved by: jdm
Pushing 0551c14 to master...

@bors-servo bors-servo merged commit d88d93a into servo:master Dec 1, 2017
@Xanewok Xanewok deleted the custom-auto-rooter branch December 1, 2017 07:00
bors-servo pushed a commit to servo/servo that referenced this pull request Jan 5, 2018
Root sequence<any> params using CustomAutoRooter

<!-- Please describe your changes on the following line: -->

Attempt at #16678. At the moment this pulls an external [remove-handle-conv](https://github.com/Xanewok/rust-mozjs/tree/remove-handle-conv) branch for rust-mozjs (removing `FromJSValConvertible` implementation for `HandleValue` and adding one for `*mut JSObject`)

In short, this roots the `sequence<any>` and `sequence<object>` function arguments using `CustomAutoRooter` (introduced in servo/rust-mozjs#382).

As per #16678 (comment) the underlying vector contains raw gc thing pointers instead of handles. To do that, this introduces new possible `isMember = "AutoRoot"` value in CodegenRust.py.
The rooted argument is passed to a function wrapped in a `CustomAutoRooterGuard` [RAII root guard](https://github.com/servo/rust-mozjs/blob/ed5e37a288b5738d9b571b8100b4a22a2c00f075/src/rust.rs#L586-L588) (e.g. as `CustomAutoRooterGuard<Vec<JSVal>>`)

I felt quite out of my depth when trying to adapt CodegenRust.py code, so I'd appreciate any help with how can be done better/in a more clean manner.
Also the name `CustomAutoRooterGuard` is quite lengthy, so I'm also open to changing it (`AutoRoot`? `AutoRootGuard`?)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #16678  (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19644)
<!-- Reviewable:end -->
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Jan 6, 2018
…r (from Xanewok:root-seq-any); r=jdm

<!-- Please describe your changes on the following line: -->

Attempt at servo/servo#16678. At the moment this pulls an external [remove-handle-conv](https://github.com/Xanewok/rust-mozjs/tree/remove-handle-conv) branch for rust-mozjs (removing `FromJSValConvertible` implementation for `HandleValue` and adding one for `*mut JSObject`)

In short, this roots the `sequence<any>` and `sequence<object>` function arguments using `CustomAutoRooter` (introduced in servo/rust-mozjs#382).

As per servo/servo#16678 (comment) the underlying vector contains raw gc thing pointers instead of handles. To do that, this introduces new possible `isMember = "AutoRoot"` value in CodegenRust.py.
The rooted argument is passed to a function wrapped in a `CustomAutoRooterGuard` [RAII root guard](https://github.com/servo/rust-mozjs/blob/ed5e37a288b5738d9b571b8100b4a22a2c00f075/src/rust.rs#L586-L588) (e.g. as `CustomAutoRooterGuard<Vec<JSVal>>`)

I felt quite out of my depth when trying to adapt CodegenRust.py code, so I'd appreciate any help with how can be done better/in a more clean manner.
Also the name `CustomAutoRooterGuard` is quite lengthy, so I'm also open to changing it (`AutoRoot`? `AutoRootGuard`?)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #16678  (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 989d2fd53267d063212ef3b7b7f13f2402943c4a

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 1d2081536bfa13c32a50b4862abbe3a03f305da3
xeonchen pushed a commit to xeonchen/gecko-cinnabar that referenced this pull request Jan 6, 2018
…r (from Xanewok:root-seq-any); r=jdm

<!-- Please describe your changes on the following line: -->

Attempt at servo/servo#16678. At the moment this pulls an external [remove-handle-conv](https://github.com/Xanewok/rust-mozjs/tree/remove-handle-conv) branch for rust-mozjs (removing `FromJSValConvertible` implementation for `HandleValue` and adding one for `*mut JSObject`)

In short, this roots the `sequence<any>` and `sequence<object>` function arguments using `CustomAutoRooter` (introduced in servo/rust-mozjs#382).

As per servo/servo#16678 (comment) the underlying vector contains raw gc thing pointers instead of handles. To do that, this introduces new possible `isMember = "AutoRoot"` value in CodegenRust.py.
The rooted argument is passed to a function wrapped in a `CustomAutoRooterGuard` [RAII root guard](https://github.com/servo/rust-mozjs/blob/ed5e37a288b5738d9b571b8100b4a22a2c00f075/src/rust.rs#L586-L588) (e.g. as `CustomAutoRooterGuard<Vec<JSVal>>`)

I felt quite out of my depth when trying to adapt CodegenRust.py code, so I'd appreciate any help with how can be done better/in a more clean manner.
Also the name `CustomAutoRooterGuard` is quite lengthy, so I'm also open to changing it (`AutoRoot`? `AutoRootGuard`?)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #16678  (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 989d2fd53267d063212ef3b7b7f13f2402943c4a
aethanyc pushed a commit to aethanyc/gecko-dev that referenced this pull request Jan 9, 2018
…r (from Xanewok:root-seq-any); r=jdm

<!-- Please describe your changes on the following line: -->

Attempt at servo/servo#16678. At the moment this pulls an external [remove-handle-conv](https://github.com/Xanewok/rust-mozjs/tree/remove-handle-conv) branch for rust-mozjs (removing `FromJSValConvertible` implementation for `HandleValue` and adding one for `*mut JSObject`)

In short, this roots the `sequence<any>` and `sequence<object>` function arguments using `CustomAutoRooter` (introduced in servo/rust-mozjs#382).

As per servo/servo#16678 (comment) the underlying vector contains raw gc thing pointers instead of handles. To do that, this introduces new possible `isMember = "AutoRoot"` value in CodegenRust.py.
The rooted argument is passed to a function wrapped in a `CustomAutoRooterGuard` [RAII root guard](https://github.com/servo/rust-mozjs/blob/ed5e37a288b5738d9b571b8100b4a22a2c00f075/src/rust.rs#L586-L588) (e.g. as `CustomAutoRooterGuard<Vec<JSVal>>`)

I felt quite out of my depth when trying to adapt CodegenRust.py code, so I'd appreciate any help with how can be done better/in a more clean manner.
Also the name `CustomAutoRooterGuard` is quite lengthy, so I'm also open to changing it (`AutoRoot`? `AutoRootGuard`?)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #16678  (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 989d2fd53267d063212ef3b7b7f13f2402943c4a
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 2, 2019
…r (from Xanewok:root-seq-any); r=jdm

<!-- Please describe your changes on the following line: -->

Attempt at servo/servo#16678. At the moment this pulls an external [remove-handle-conv](https://github.com/Xanewok/rust-mozjs/tree/remove-handle-conv) branch for rust-mozjs (removing `FromJSValConvertible` implementation for `HandleValue` and adding one for `*mut JSObject`)

In short, this roots the `sequence<any>` and `sequence<object>` function arguments using `CustomAutoRooter` (introduced in servo/rust-mozjs#382).

As per servo/servo#16678 (comment) the underlying vector contains raw gc thing pointers instead of handles. To do that, this introduces new possible `isMember = "AutoRoot"` value in CodegenRust.py.
The rooted argument is passed to a function wrapped in a `CustomAutoRooterGuard` [RAII root guard](https://github.com/servo/rust-mozjs/blob/ed5e37a288b5738d9b571b8100b4a22a2c00f075/src/rust.rs#L586-L588) (e.g. as `CustomAutoRooterGuard<Vec<JSVal>>`)

I felt quite out of my depth when trying to adapt CodegenRust.py code, so I'd appreciate any help with how can be done better/in a more clean manner.
Also the name `CustomAutoRooterGuard` is quite lengthy, so I'm also open to changing it (`AutoRoot`? `AutoRootGuard`?)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #16678  (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 989d2fd53267d063212ef3b7b7f13f2402943c4a

UltraBlame original commit: cdc2693ba485669c0fbd4e63de6a394b6cfca8a0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 2, 2019
…r (from Xanewok:root-seq-any); r=jdm

<!-- Please describe your changes on the following line: -->

Attempt at servo/servo#16678. At the moment this pulls an external [remove-handle-conv](https://github.com/Xanewok/rust-mozjs/tree/remove-handle-conv) branch for rust-mozjs (removing `FromJSValConvertible` implementation for `HandleValue` and adding one for `*mut JSObject`)

In short, this roots the `sequence<any>` and `sequence<object>` function arguments using `CustomAutoRooter` (introduced in servo/rust-mozjs#382).

As per servo/servo#16678 (comment) the underlying vector contains raw gc thing pointers instead of handles. To do that, this introduces new possible `isMember = "AutoRoot"` value in CodegenRust.py.
The rooted argument is passed to a function wrapped in a `CustomAutoRooterGuard` [RAII root guard](https://github.com/servo/rust-mozjs/blob/ed5e37a288b5738d9b571b8100b4a22a2c00f075/src/rust.rs#L586-L588) (e.g. as `CustomAutoRooterGuard<Vec<JSVal>>`)

I felt quite out of my depth when trying to adapt CodegenRust.py code, so I'd appreciate any help with how can be done better/in a more clean manner.
Also the name `CustomAutoRooterGuard` is quite lengthy, so I'm also open to changing it (`AutoRoot`? `AutoRootGuard`?)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #16678  (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 989d2fd53267d063212ef3b7b7f13f2402943c4a

UltraBlame original commit: cdc2693ba485669c0fbd4e63de6a394b6cfca8a0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 2, 2019
…r (from Xanewok:root-seq-any); r=jdm

<!-- Please describe your changes on the following line: -->

Attempt at servo/servo#16678. At the moment this pulls an external [remove-handle-conv](https://github.com/Xanewok/rust-mozjs/tree/remove-handle-conv) branch for rust-mozjs (removing `FromJSValConvertible` implementation for `HandleValue` and adding one for `*mut JSObject`)

In short, this roots the `sequence<any>` and `sequence<object>` function arguments using `CustomAutoRooter` (introduced in servo/rust-mozjs#382).

As per servo/servo#16678 (comment) the underlying vector contains raw gc thing pointers instead of handles. To do that, this introduces new possible `isMember = "AutoRoot"` value in CodegenRust.py.
The rooted argument is passed to a function wrapped in a `CustomAutoRooterGuard` [RAII root guard](https://github.com/servo/rust-mozjs/blob/ed5e37a288b5738d9b571b8100b4a22a2c00f075/src/rust.rs#L586-L588) (e.g. as `CustomAutoRooterGuard<Vec<JSVal>>`)

I felt quite out of my depth when trying to adapt CodegenRust.py code, so I'd appreciate any help with how can be done better/in a more clean manner.
Also the name `CustomAutoRooterGuard` is quite lengthy, so I'm also open to changing it (`AutoRoot`? `AutoRootGuard`?)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [x] These changes fix #16678  (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 989d2fd53267d063212ef3b7b7f13f2402943c4a

UltraBlame original commit: cdc2693ba485669c0fbd4e63de6a394b6cfca8a0
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

3 participants