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

conversions: Implement FromJSValConvertible for Vec<T> - #226

Closed
emilio wants to merge 3 commits into
servo:masterfrom
emilio:convert-vec
Closed

emilio wants to merge 3 commits into
servo:masterfrom
emilio:convert-vec

Conversation

@emilio

@emilio emilio commented Dec 23, 2015

Copy link
Copy Markdown
Member

This will allow us to finally implement WebIDL sequence arguments
(servo/servo#544).

Review on Reviewable

@Ms2ger

Ms2ger commented Dec 23, 2015

Copy link
Copy Markdown
Contributor

This should implement the spec for "An ECMAScript value V is converted to an IDL sequence value" at https://heycam.github.io/webidl/#es-sequence. SpiderMonkey has the ForOfIterator struct to help with that. You'll need to initialize it to match

    explicit ForOfIterator(JSContext* cx) : cx_(cx), iterator(cx_), index(NOT_ARRAY) { }
    static const uint32_t NOT_ARRAY = UINT32_MAX;

See https://mxr.mozilla.org/mozilla-central/source/dom/bindings/Codegen.py?rev=151ce2b0e3f6#4514 for how Gecko calls it.

bors-servo pushed a commit to servo/servo that referenced this pull request Dec 23, 2015
Implement WebIDL sequence argument

And use it for `WebGLRenderingContext#uniform1fv`.

Blocked on servo/rust-mozjs#226

Fixes #544

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9056)
<!-- Reviewable:end -->
@emilio

emilio commented Dec 23, 2015

Copy link
Copy Markdown
Member Author

@Ms2ger

Added a minimal test case, that works if we remove the Rooted<T> destructor.

So... it seems that the hidden state Drop adds to Rooted<T> is what is corrupting our stack when interacting with SM, causing the trap an the latter assertion failure.

I don't think we can remove the Rooted destructor, so I don't think there's any way to circumvent this, at least for now.

Would it be ok to leave the first commit for now to land servo/servo#9056 (so there's basic support for sequences and people can work on that kind of stuff), and leave this until we have a way to solve it using ForOfIterator?

If that sounds good, I'll make sure the corresponding issues are filled (both in here and in servo/servo).

I'd want to hear @jdm's opinion too.

@emilio

emilio commented Dec 23, 2015

Copy link
Copy Markdown
Member Author

Also, pinging @michaelwu in case he knows any way to circumvent this issue.

@Ms2ger

Ms2ger commented Dec 24, 2015

Copy link
Copy Markdown
Contributor

Ah, crap. @tschneidereit, do you have thoughts on this?

Does the drop flag end up at the end or the start of the Rooted? If it's at the end, maybe a quick hack would be to move the fields of ForOfIterator around.

@Ms2ger

Ms2ger commented Dec 24, 2015

Copy link
Copy Markdown
Contributor

Alternatively, can't we opt out of the drop flag?

@Manishearth

Copy link
Copy Markdown
Member

#[unsafe_no_drop_flag], however it's then up to you to maintain the drop flag invariants yourself

@emilio

emilio commented Dec 25, 2015

Copy link
Copy Markdown
Member Author

I did a quick try moving the iterator to the end of ForOfIterator (both here and in mozjs) and no luck so far: it doesn't crash with SIGTRAP, but still crashes with our assertion in Drop.

Also tested with #[unsafe_no_drop_flag], but it seems even in "simple" cases like that test we don't maintain the drop invariants and we drop many times, causing a segfault.

@nox

nox commented Dec 26, 2015

Copy link
Copy Markdown
Contributor

#227 should fix that.

@emilio

emilio commented Dec 26, 2015

Copy link
Copy Markdown
Member Author

I just pushed a patch based on #227, but testing against the drop bitfield rust uses instead (see comment).

It works, but feels too hacky though. And we must touch the jsapi_* files manually too...

@bors-servo

Copy link
Copy Markdown
Contributor

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

This actually fails with a trap (at the assertion in `Rooted<T>::drop`).
It works this way, even though we can't do this :(
This actually works, even though it feels too hacky...
@bors-servo

Copy link
Copy Markdown
Contributor

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

bors-servo pushed a commit to servo/servo that referenced this pull request Jan 12, 2016
Implement WebIDL sequence arguments

And use it for `WebGLRenderingContext#uniform1fv`.

Blocked on servo/rust-mozjs#226

Fixes #544

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9056)
<!-- Reviewable:end -->
@Ms2ger

Ms2ger commented Feb 17, 2016

Copy link
Copy Markdown
Contributor

#229

@Ms2ger Ms2ger closed this Feb 17, 2016
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 1, 2019
…:sequence-args); r=nox

And use it for `WebGLRenderingContext#uniform1fv`.

Blocked on servo/rust-mozjs#226

Fixes #544

Source-Repo: https://github.com/servo/servo
Source-Revision: c97d557720b2ef312b964534bd511d45161a2729

UltraBlame original commit: 7f9c2bb6cf2009b63f77e937263181f1799b6eb6
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 1, 2019
…:sequence-args); r=nox

And use it for `WebGLRenderingContext#uniform1fv`.

Blocked on servo/rust-mozjs#226

Fixes #544

Source-Repo: https://github.com/servo/servo
Source-Revision: c97d557720b2ef312b964534bd511d45161a2729

UltraBlame original commit: 7f9c2bb6cf2009b63f77e937263181f1799b6eb6
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 1, 2019
…:sequence-args); r=nox

And use it for `WebGLRenderingContext#uniform1fv`.

Blocked on servo/rust-mozjs#226

Fixes #544

Source-Repo: https://github.com/servo/servo
Source-Revision: c97d557720b2ef312b964534bd511d45161a2729

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

5 participants