Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract some of CGClassConstructHook to utils.rs #25432

Merged
merged 1 commit into from Jun 3, 2020

Conversation

@warren-fisher
Copy link
Contributor

warren-fisher commented Jan 5, 2020

Moving some of the functionality from the massive tripled quoted string in CGClassConstructHook in components/script/dom/bindings/codegen/CodegenRust.py to components/script/dom/bindings/utils.rs. Must be made unsafe because of UnwrapObjectDynamic and other functions. Added imports as necessary as well, as well as cleaning up using test-tidy.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #25395 (GitHub issue number if applicable)
  • There are tests for these changes OR
  • These changes do not require tests because the issue says so
@highfive
Copy link

highfive commented Jan 5, 2020

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @paulrouget (or someone else) soon.

@highfive
Copy link

highfive commented Jan 5, 2020

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/bindings/codegen/CodegenRust.py, components/script/dom/bindings/utils.rs
  • @KiChjang: components/script/dom/bindings/codegen/CodegenRust.py, components/script/dom/bindings/utils.rs
@highfive
Copy link

highfive commented Jan 5, 2020

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify script code, but no tests are modified. Please consider adding a test!
@jdm jdm assigned jdm and unassigned paulrouget Jan 5, 2020
Copy link
Member

jdm left a comment

This is definitely an improvement!

components/script/dom/bindings/utils.rs Outdated Show resolved Hide resolved
components/script/dom/bindings/utils.rs Outdated Show resolved Hide resolved
components/script/dom/bindings/utils.rs Outdated Show resolved Hide resolved
@bors-servo
Copy link
Contributor

bors-servo commented Jan 12, 2020

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

@warren-fisher warren-fisher force-pushed the warren-fisher:HTMLConstructor branch from 515c950 to 68c476a Jan 14, 2020
}
// Wrap prototype in this context since it is from the newTarget compartment
if !JS_WrapObject(*cx, RawMutableHandle::from(prototype.handle_mut())) {
return Err(Error::Type("false".to_owned()));

This comment has been minimized.

@warren-fisher

warren-fisher Jan 14, 2020

Author Contributor

Same thing

This comment has been minimized.

@jdm

jdm Jan 14, 2020

Member

Error::JSFailed.

components/script/dom/bindings/htmlconstructor.rs Outdated Show resolved Hide resolved
b"prototype\\0".as_ptr() as *const _,
proto_val.handle_mut(),
) {
return Err(Error::Type("false".to_owned()));

This comment has been minimized.

@warren-fisher

warren-fisher Jan 14, 2020

Author Contributor

I am not sure what type of error is appropriate to return here. Previously it was a return false when it was within the monolithic function. For the sake of getting something "working" I made this placeholder error. Perhaps it is not suitable to throw an error here, and in that case I am not sure the best way of handling this.

This comment has been minimized.

@jdm

jdm Jan 14, 2020

Member

This should return Error::JSFailed, instead.

Copy link
Member

jdm left a comment

Almost there!

b"prototype\\0".as_ptr() as *const _,
proto_val.handle_mut(),
) {
return Err(Error::Type("false".to_owned()));

This comment has been minimized.

@jdm

jdm Jan 14, 2020

Member

This should return Error::JSFailed, instead.

}
// Wrap prototype in this context since it is from the newTarget compartment
if !JS_WrapObject(*cx, RawMutableHandle::from(prototype.handle_mut())) {
return Err(Error::Type("false".to_owned()));

This comment has been minimized.

@jdm

jdm Jan 14, 2020

Member

Error::JSFailed.

components/script/dom/bindings/htmlconstructor.rs Outdated Show resolved Hide resolved
components/script/dom/bindings/htmlconstructor.rs Outdated Show resolved Hide resolved
@jdm
Copy link
Member

jdm commented Jan 14, 2020

In principle I understand that monomorphizing anything that is not needed adds complexity and slows down compile times. Would you say these are the main reasons for avoiding monomorphizing code unnecessarily?

It's both compile time and the size of the generated code - monomorphization can easily end up duplicating large blocks of code that do not depend on any generic types, and relying on the compiler to notice this and de-duplicate them doesn't always work.

@jdm
Copy link
Member

jdm commented Jan 14, 2020

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Jan 14, 2020

Trying commit 02dbb50 with merge ee2a80a...

bors-servo added a commit that referenced this pull request Jan 14, 2020
Extract some of CGClassConstructHook to utils.rs

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

Moving some of the functionality from the massive tripled quoted string in CGClassConstructHook in `components/script/dom/bindings/codegen/CodegenRust.py` to `components/script/dom/bindings/utils.rs`. Must be made unsafe because of UnwrapObjectDynamic and other functions. Added imports as necessary as well, as well as cleaning up using test-tidy.

---
<!-- 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 #25395 (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because the issue says so

<!-- 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. -->
@warren-fisher warren-fisher force-pushed the warren-fisher:HTMLConstructor branch from 02dbb50 to f2f2738 Jan 14, 2020
@warren-fisher
Copy link
Contributor Author

warren-fisher commented Jan 14, 2020

I fixed up the commit history a bit. Not sure if that will cause bors-servo to mess up at all.

@bors-servo
Copy link
Contributor

bors-servo commented Jun 3, 2020

📌 Commit edfc47e has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Jun 3, 2020

Testing commit edfc47e with merge 2b62650...

bors-servo added a commit that referenced this pull request Jun 3, 2020
Extract some of CGClassConstructHook to utils.rs

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

Moving some of the functionality from the massive tripled quoted string in CGClassConstructHook in `components/script/dom/bindings/codegen/CodegenRust.py` to `components/script/dom/bindings/utils.rs`. Must be made unsafe because of UnwrapObjectDynamic and other functions. Added imports as necessary as well, as well as cleaning up using test-tidy.

---
<!-- 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 #25395 (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because the issue says so

<!-- 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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 3, 2020

💔 Test failed - status-taskcluster

@jdm jdm force-pushed the warren-fisher:HTMLConstructor branch from edfc47e to 2da07ed Jun 3, 2020
@jdm
Copy link
Member

jdm commented Jun 3, 2020

@bors-servo
Copy link
Contributor

bors-servo commented Jun 3, 2020

📌 Commit 2da07ed has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Jun 3, 2020

Testing commit 2da07ed with merge eb21264...

bors-servo added a commit that referenced this pull request Jun 3, 2020
Extract some of CGClassConstructHook to utils.rs

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

Moving some of the functionality from the massive tripled quoted string in CGClassConstructHook in `components/script/dom/bindings/codegen/CodegenRust.py` to `components/script/dom/bindings/utils.rs`. Must be made unsafe because of UnwrapObjectDynamic and other functions. Added imports as necessary as well, as well as cleaning up using test-tidy.

---
<!-- 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 #25395 (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because the issue says so

<!-- 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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 3, 2020

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Jun 3, 2020

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Jun 3, 2020

Testing commit 2da07ed with merge 7758d4f...

@bors-servo
Copy link
Contributor

bors-servo commented Jun 3, 2020

☀️ Test successful - status-taskcluster
Approved by: jdm
Pushing 7758d4f to master...

@bors-servo bors-servo merged commit 7758d4f into servo:master Jun 3, 2020
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

6 participants
You can’t perform that action at this time.