Skip to content

Support variadic interface arguments (fixes #8159) - #8197

Merged
bors-servo merged 5 commits into
servo:masterfrom
nox:variadic-interface-argument
Nov 11, 2015
Merged

bors-servo merged 5 commits into
servo:masterfrom
nox:variadic-interface-argument

Conversation

@nox

@nox nox commented Oct 25, 2015

Copy link
Copy Markdown
Contributor

Review on Reviewable

@nox nox added A-content/dom Interacting with the DOM from web content A-content/bindings The DOM bindings labels Oct 25, 2015
@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 25, 2015
@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@nox

nox commented Oct 25, 2015

Copy link
Copy Markdown
Contributor Author
unsafe extern fn passVariadicInterface(cx: *mut JSContext, _obj: HandleObject, this: *const TestBinding, args: *const JSJitMethodCallArgs) -> bool {
    let this = &*this;
    let args = &*args;
    let argc = args._base.argc_;
    let mut arg0 = RootedVec::new();
    *arg0 = Vec::with_capacity((argc - 0) as usize);
    for variadicArg in 0..argc {
        let slot: *const Blob = if args.get(variadicArg).get().is_object() {
            match native_from_handlevalue(args.get(variadicArg)) {
                Ok(val) => val,
                Err(()) => {
                    throw_type_error(cx, "value does not implement interface Blob.");
                    return false;
                }
            }
        } else {
            throw_type_error(cx, "Value is not an object.");
            return false;
        };
        arg0.push(JS::from_ref(&*slot));
    }
    let result: () = this.PassVariadicInterface(arg0.r());

    (result).to_jsval(cx, args.rval());
    return true;
}

@nox
nox force-pushed the variadic-interface-argument branch from 502d542 to 88bf688 Compare October 25, 2015 22:02
@nox

nox commented Oct 25, 2015

Copy link
Copy Markdown
Contributor Author

#8159

@Ms2ger

Ms2ger commented Oct 26, 2015

Copy link
Copy Markdown
Contributor

Not sure I'm a big fan of the branching

@nox

nox commented Oct 26, 2015

Copy link
Copy Markdown
Contributor Author

I have no idea what your remark is about, @Ms2ger.

@nox nox added the C-has-manual-testcase A minimal testcase exists that can be run manually. label Oct 26, 2015
@jdm

jdm commented Oct 27, 2015

Copy link
Copy Markdown
Member

@bors-servo: r+
This looks ok to me and is necessary for #8225. I'll double back and do a thorough post-merge review.

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 88bf688 has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Oct 27, 2015
@jdm

jdm commented Oct 27, 2015

Copy link
Copy Markdown
Member

@bors-servo: r-
The pressure's off. I'll review this properly.

@jdm jdm self-assigned this Oct 27, 2015
@jdm jdm added S-awaiting-review There is new code that needs to be reviewed. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Oct 27, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

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

@highfive highfive added S-needs-rebase There are merge conflict errors. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Oct 28, 2015
@jdm

jdm commented Nov 11, 2015

Copy link
Copy Markdown
Member

Generally looks good! I'd just like to make sure that we're thinking through the changes to the types carefully.
-S-awaiting-review +S-needs-code-changes


Reviewed 10 of 10 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, 1 of 1 files at r4, 7 of 7 files at r5.
Review status: all files reviewed at latest revision, 6 unresolved discussions, some commit checks failed.


components/script/dom/bindings/codegen/CodegenRust.py, line 761 [r4] (raw file):
memberType appears to be unused now. We should remove it if that's the case.


components/script/dom/bindings/codegen/CodegenRust.py, line 1209 [r4] (raw file):
We lost this check; is that a problem? For example, could that end up causing underflow in the earlier subtraction?


components/script/dom/bindings/codegen/CodegenRust.py, line 108 [r5] (raw file):
"Returns a string of the Rust expression..."


components/script/dom/bindings/codegen/CodegenRust.py, line 764 [r5] (raw file):
I guess this else block is why we continue rooting members of dictionaries after this change. I'm concerned that this is both non-obvious and confusing.


components/script/dom/bindings/codegen/Configuration.py, line 166 [r5] (raw file):
I'm slightly concerned that this could make us no longer root dictionary members or something? What's the effect of modifying this and the next line?


components/script/dom/bindings/conversions.rs, line 756 [r5] (raw file):
Let's not make this public if it doesn't need to be. The fewer things expose unsafe pointers the better.


Comments from the review on Reviewable.io

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 11, 2015
nox added 4 commits November 11, 2015 14:19
Functions returning `Root<T>` are prefixed by "root_" and the ones returning
`*const T` by "native_".

Functions taking `*mut JSObject` are now suffixed by "_from_object" and the ones
taking `&T` by "_from_reflector".
Use global_root_from_reflector() instead.
@nox
nox force-pushed the variadic-interface-argument branch from 88bf688 to c765924 Compare November 11, 2015 13:37
@highfive highfive removed the S-needs-code-changes Changes have not yet been made that were requested by a reviewer. label Nov 11, 2015
@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 11, 2015
@nox nox added S-awaiting-answer Someone asked a question that requires an answer. and removed S-needs-rebase There are merge conflict errors. labels Nov 11, 2015
@nox

nox commented Nov 11, 2015

Copy link
Copy Markdown
Contributor Author

-S-needs-rebase +S-awaiting-answer


Review status: all files reviewed at latest revision, 6 unresolved discussions, some commit checks failed.


components/script/dom/bindings/codegen/CodegenRust.py, line 761 [r4] (raw file):
Done.


components/script/dom/bindings/codegen/CodegenRust.py, line 1209 [r4] (raw file):
The number of arguments can never be less than the offset where variadic arguments start, when that code is executed. No underflow can thus happen.


components/script/dom/bindings/codegen/CodegenRust.py, line 108 [r5] (raw file):
Done.


components/script/dom/bindings/codegen/CodegenRust.py, line 764 [r5] (raw file):
So what do you want me to do?


components/script/dom/bindings/codegen/Configuration.py, line 166 [r5] (raw file):
None apart from letting me distinguish variadic interface arguments from variadic union arguments, etc. Dictionary members stay rooted AFAIK. What codegen result do you want me to paste to convince you?


components/script/dom/bindings/conversions.rs, line 756 [r5] (raw file):
Done.


Comments from the review on Reviewable.io

@jdm

jdm commented Nov 11, 2015

Copy link
Copy Markdown
Member

-S-awaiting-review -S-awaiting-answer +S-needs-code-changes


Reviewed 14 of 14 files at r6.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


components/script/dom/bindings/codegen/CodegenRust.py, line 764 [r5] (raw file):
I think my confusion stems from two parts:

  • there's no block that explicitly deals with isMember != "Variadic"
  • we rely on returnType being Root for things that are not conceptually return types
    I would be happy with an elif for the first point that uses returnType but has a comment explaining our reasoning.

Comments from the review on Reviewable.io

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. S-awaiting-answer Someone asked a question that requires an answer. labels Nov 11, 2015
We use a RootedVec value in codegen, of which we use the `r()` method to
pass `&[&T]` to the interface methods.
@nox
nox force-pushed the variadic-interface-argument branch from c765924 to acb13dc Compare November 11, 2015 13:52
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Nov 11, 2015
@jdm

jdm commented Nov 11, 2015

Copy link
Copy Markdown
Member

@bors-servo: r+


Reviewed 1 of 1 files at r7.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from the review on Reviewable.io

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit acb13dc has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 11, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit acb13dc with merge f03a826...

bors-servo pushed a commit that referenced this pull request Nov 11, 2015
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt

@bors-servo
bors-servo merged commit acb13dc into servo:master Nov 11, 2015
nox added a commit to nox/servo that referenced this pull request Nov 12, 2015
bors-servo pushed a commit that referenced this pull request Nov 12, 2015
bors-servo pushed a commit that referenced this pull request Nov 12, 2015
@nox
nox deleted the variadic-interface-argument branch November 13, 2015 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-content/bindings The DOM bindings A-content/dom Interacting with the DOM from web content C-has-manual-testcase A minimal testcase exists that can be run manually. S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants