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

layout: Remove cached thread local context from LayoutContext, and use LayoutContext for assign_inline_sizes() #15417

Merged
merged 2 commits into from Feb 8, 2017

Conversation

@stshine
Copy link
Contributor

stshine commented Feb 7, 2017

According to #3069 the cached thread local context is introduced for green threads. Now green threads has gone, and the existence of cache force us to create a LayoutContext, an AssignISizes and an AssignBSizes for each flow during parallel layout, so the pull request tries to remove it. And it also switch assign_inline_sizes() to accept a LayoutContext parameter, as according to my current design we need to do full layout to some flex items for column flexbox during assign isize traversal.

Part of #14123.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because refactoring

This change is Reviewable

@highfive
Copy link

highfive commented Feb 7, 2017

Heads up! This PR modifies the following files:

  • @emilio: components/layout/display_list_builder.rs, components/layout/table_rowgroup.rs, components/layout/table_wrapper.rs, components/layout/block.rs, components/layout/table_row.rs, components/layout/animation.rs, components/layout/table_caption.rs, components/layout/flex.rs, components/layout/parallel.rs, components/layout/context.rs, components/layout/table_cell.rs, components/layout/traversal.rs, components/layout/table_colgroup.rs, components/layout/construct.rs, components/layout/sequential.rs, components/layout/inline.rs, components/layout/flow.rs, components/layout/multicol.rs, components/layout/fragment.rs, components/layout/list_item.rs, components/layout/generated_content.rs, components/layout/table.rs, components/layout/query.rs
@highfive
Copy link

highfive commented Feb 7, 2017

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify layout code, but no tests are modified. Please consider adding a test!
@stshine
Copy link
Contributor Author

stshine commented Feb 7, 2017

The main concern of this pull request is that it changed how we access thread local layout context. Now we may need to access tls several times for each text fragment, compare to one time for each flow previously. But @pcwalton said tls access is very fast(three instructions), so this may be small. And it simplifies our parallel layout code, so it may have its value.

Would love to know how to make this better. Please criticise!

r? @pcwalton or @emilio

@highfive highfive assigned pcwalton and unassigned glennw Feb 7, 2017
@stshine
Copy link
Contributor Author

stshine commented Feb 7, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Feb 7, 2017

Trying commit 9372a79 with merge 8892cb2...

bors-servo added a commit that referenced this pull request Feb 7, 2017
layout: Remove cached thread local context from LayoutContext, and use LayoutContext for assign_inline_sizes()

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

According to #3069 the cached thread local context is introduced for green threads. Now green threads has gone, and the existence of cache force us to create a `LayoutContext`, an `AssignISizes` and an `AssignBSizes` for each flow, so the pull request tries to remove it. And it also switch `assign_inline_sizes()` to accept a `LayoutContext` parameter, as according to my current design we need to do full layout to some flex items for column flexbox.

Part of #14123.

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

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

<!-- 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/15417)
<!-- Reviewable:end -->
@Ms2ger
Copy link
Contributor

Ms2ger commented Feb 7, 2017

@bors-servo try- clean try retry

@emilio
emilio approved these changes Feb 7, 2017
Copy link
Member

emilio left a comment

Looks great, thanks for the cleanup @stshine!

I don't feel too strongly about my two following comments, so feel free to land this addressing them or not.

*r = Some(context.clone());
context
pub fn with_font_context<F, R>(layout_context: &LayoutContext, f: F) -> R
where F: FnOnce(&mut FontContext) -> R {

This comment has been minimized.

Copy link
@emilio

emilio Feb 7, 2017

Member

nit: Brace on a newline after where.

let context = PersistentThreadLocalLayoutContext::new(shared);
*r = Some(context.clone());
context
pub fn with_font_context<F, R>(layout_context: &LayoutContext, f: F) -> R

This comment has been minimized.

Copy link
@emilio

emilio Feb 7, 2017

Member

Maybe rename to with_thread_local_font_context or something, so it's clear what's going on?

@emilio
Copy link
Member

emilio commented Feb 7, 2017

@bors-servo delegate+

@bors-servo
Copy link
Contributor

bors-servo commented Feb 7, 2017

✌️ @stshine can now approve this pull request

Remove cached thread local context from LayoutContext, use LayoutContext for
assign_inline_sizes(), and simplify the parallel flow traversal code.
@stshine stshine force-pushed the stshine:column-flexbox branch from 9372a79 to 336aa79 Feb 8, 2017
@stshine
Copy link
Contributor Author

stshine commented Feb 8, 2017

Comments addressed. Thank you @emilio :)
But I give my main thanks to rustc, without you I would not dare to touch code like this.

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

bors-servo commented Feb 8, 2017

📌 Commit 336aa79 has been approved by emilio

@highfive highfive assigned emilio and unassigned pcwalton Feb 8, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Feb 8, 2017

Testing commit 336aa79 with merge e2b494b...

bors-servo added a commit that referenced this pull request Feb 8, 2017
layout: Remove cached thread local context from LayoutContext, and use LayoutContext for assign_inline_sizes()

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

According to #3069 the cached thread local context is introduced for green threads. Now green threads has gone, and the existence of cache force us to create a `LayoutContext`, an `AssignISizes` and an `AssignBSizes` for each flow during parallel layout, so the pull request tries to remove it. And it also switch `assign_inline_sizes()` to accept a `LayoutContext` parameter, as according to my current design we need to do full layout to some flex items for column flexbox during assign isize traversal.

Part of #14123.

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

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

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

bors-servo commented Feb 8, 2017

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-gnu-dev, windows-msvc-dev
Approved by: emilio
Pushing e2b494b to master...

@bors-servo bors-servo merged commit 336aa79 into servo:master Feb 8, 2017
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
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.

None yet

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