|
|
DescriptionCheck if value changed when setting nested fields in ComputedStyleBase.
Many of the setters in ComputedStyle use a macro called SET_VAR, which
sets the value of a field stored in a subgroup on ComputedStyle. SET_VAR
first checks if the new value is different to the old value. Only when
the value changes does it modify the field using the Access() method on
the subgroup. Since Access() could potentially do a copy, we would like
to call it as rarely as possible. Hence, SET_VAR is an optimisation that
skips a call to Access() when it is not necessary.
For example, the setter for the 'left' property might look like:
void SetLeft(const Length& v) {
if (surround_data_->left_ != v)
surround_data_->Access()->left_ = v;
}
As we can see, we only call Access() when the values are different,
potentially saving a copy.
However, the generated setters on ComputedStyleBase do not perform this
optimisation. This patch changes the generator to use the same
optimisation in ComputedStyleBase.
No behavioural changes are expected, but there should be less memory
allocations in ComputedStyle.
Diff of generated files:
https://gist.github.com/darrnshn/47e96b81c2ade55cb337fd658f0d6785/revisions
BUG=628043
Review-Url: https://codereview.chromium.org/2879493003
Cr-Commit-Position: refs/heads/master@{#470873}
Committed: https://chromium.googlesource.com/chromium/src/+/e8e5df6b838075a0dc6e584853f1f795ac5af0b3
Patch Set 1 #Patch Set 2 : Rebase #Patch Set 3 : Address comments #
Total comments: 2
Patch Set 4 : Rebase #
Messages
Total messages: 37 (24 generated)
The CQ bit was checked by shend@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by shend@chromium.org to run a CQ dry run
Description was changed from ========== Check if value changed when setting nested fields in ComputedStyleBase. Many of the setters in ComputedStyle use a macro called SET_VAR, which sets the value of a field stored in a subgroup on ComputedStyle. SET_VAR first checks if the new value is different to the old value. Only when the value changes does it modify the field using the Access() method on the subgroup. Since Access() could potentially do a copy, we would like to call it as rarely as possible. Hence, SET_VAR is an optimisation that skips a call to Access() when it is not necessary. However, the generated setters on ComputedStyleBase do not perform this optimisation. This patch changes the generator to use the same optimisation in ComputedStyleBase. No behavioural changes are expected, but there should be less memory allocations in ComputedStyle. Diff of generated files: https://gist.github.com/darrnshn/141e42763b233fbccd8327ba50dfcbac/revisions BUG=628043 ========== to ========== Check if value changed when setting nested fields in ComputedStyleBase. Many of the setters in ComputedStyle use a macro called SET_VAR, which sets the value of a field stored in a subgroup on ComputedStyle. SET_VAR first checks if the new value is different to the old value. Only when the value changes does it modify the field using the Access() method on the subgroup. Since Access() could potentially do a copy, we would like to call it as rarely as possible. Hence, SET_VAR is an optimisation that skips a call to Access() when it is not necessary. However, the generated setters on ComputedStyleBase do not perform this optimisation. This patch changes the generator to use the same optimisation in ComputedStyleBase. No behavioural changes are expected, but there should be less memory allocations in ComputedStyle. Diff of generated files: https://gist.github.com/ad2f36943a8c11dbd33d45213011fc77/revisions BUG=628043 ==========
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
shend@chromium.org changed reviewers: + nainar@chromium.org
Hi Naina, PTAL
lgtm. nit: to make it clearer maybe add an example inline in the CL desciption?
Description was changed from ========== Check if value changed when setting nested fields in ComputedStyleBase. Many of the setters in ComputedStyle use a macro called SET_VAR, which sets the value of a field stored in a subgroup on ComputedStyle. SET_VAR first checks if the new value is different to the old value. Only when the value changes does it modify the field using the Access() method on the subgroup. Since Access() could potentially do a copy, we would like to call it as rarely as possible. Hence, SET_VAR is an optimisation that skips a call to Access() when it is not necessary. However, the generated setters on ComputedStyleBase do not perform this optimisation. This patch changes the generator to use the same optimisation in ComputedStyleBase. No behavioural changes are expected, but there should be less memory allocations in ComputedStyle. Diff of generated files: https://gist.github.com/ad2f36943a8c11dbd33d45213011fc77/revisions BUG=628043 ========== to ========== Check if value changed when setting nested fields in ComputedStyleBase. Many of the setters in ComputedStyle use a macro called SET_VAR, which sets the value of a field stored in a subgroup on ComputedStyle. SET_VAR first checks if the new value is different to the old value. Only when the value changes does it modify the field using the Access() method on the subgroup. Since Access() could potentially do a copy, we would like to call it as rarely as possible. Hence, SET_VAR is an optimisation that skips a call to Access() when it is not necessary. For example, the setter for the 'left' property might look like: void SetLeft(const Length& v) { if (surround_data_->left_ != v) surround_data_->Access()->left_ = v; } As we can see, we only call Access() when the values are different, potentially saving a copy. However, the generated setters on ComputedStyleBase do not perform this optimisation. This patch changes the generator to use the same optimisation in ComputedStyleBase. No behavioural changes are expected, but there should be less memory allocations in ComputedStyle. Diff of generated files: https://gist.github.com/ad2f36943a8c11dbd33d45213011fc77/revisions BUG=628043 ==========
shend@chromium.org changed reviewers: + meade@chromium.org
done. Eddy, PTAL :)
shend@chromium.org changed reviewers: + alancutter@chromium.org - meade@chromium.org
Redirecting to Alan. PTAL :)
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
Looking at the generated code this looks very wrong: > surround_data_->border_bottom_left_radius_ == std::move(v)
On 2017/05/11 at 04:03:24, alancutter wrote: > Looking at the generated code this looks very wrong: > > > surround_data_->border_bottom_left_radius_ == std::move(v) Oh yeah, I agree that's really weird looking, but it should still work as long as operator== doesn't take a &&. Alternatively, I could just not use the get_if_changed macro for the move setter? Just means a bit more duplicate code.
On 2017/05/11 at 04:11:11, shend wrote: > On 2017/05/11 at 04:03:24, alancutter wrote: > > Looking at the generated code this looks very wrong: > > > > > surround_data_->border_bottom_left_radius_ == std::move(v) > > Oh yeah, I agree that's really weird looking, but it should still work as long as operator== doesn't take a &&. Alternatively, I could just not use the get_if_changed macro for the move setter? Just means a bit more duplicate code. True though I'm still not comfortable with == std::move. I think it should be changed.
The CQ bit was checked by shend@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2017/05/11 at 04:14:51, alancutter wrote: > On 2017/05/11 at 04:11:11, shend wrote: > > On 2017/05/11 at 04:03:24, alancutter wrote: > > > Looking at the generated code this looks very wrong: > > > > > > > surround_data_->border_bottom_left_radius_ == std::move(v) > > > > Oh yeah, I agree that's really weird looking, but it should still work as long as operator== doesn't take a &&. Alternatively, I could just not use the get_if_changed macro for the move setter? Just means a bit more duplicate code. > > True though I'm still not comfortable with == std::move. I think it should be changed. tis done
Description was changed from ========== Check if value changed when setting nested fields in ComputedStyleBase. Many of the setters in ComputedStyle use a macro called SET_VAR, which sets the value of a field stored in a subgroup on ComputedStyle. SET_VAR first checks if the new value is different to the old value. Only when the value changes does it modify the field using the Access() method on the subgroup. Since Access() could potentially do a copy, we would like to call it as rarely as possible. Hence, SET_VAR is an optimisation that skips a call to Access() when it is not necessary. For example, the setter for the 'left' property might look like: void SetLeft(const Length& v) { if (surround_data_->left_ != v) surround_data_->Access()->left_ = v; } As we can see, we only call Access() when the values are different, potentially saving a copy. However, the generated setters on ComputedStyleBase do not perform this optimisation. This patch changes the generator to use the same optimisation in ComputedStyleBase. No behavioural changes are expected, but there should be less memory allocations in ComputedStyle. Diff of generated files: https://gist.github.com/ad2f36943a8c11dbd33d45213011fc77/revisions BUG=628043 ========== to ========== Check if value changed when setting nested fields in ComputedStyleBase. Many of the setters in ComputedStyle use a macro called SET_VAR, which sets the value of a field stored in a subgroup on ComputedStyle. SET_VAR first checks if the new value is different to the old value. Only when the value changes does it modify the field using the Access() method on the subgroup. Since Access() could potentially do a copy, we would like to call it as rarely as possible. Hence, SET_VAR is an optimisation that skips a call to Access() when it is not necessary. For example, the setter for the 'left' property might look like: void SetLeft(const Length& v) { if (surround_data_->left_ != v) surround_data_->Access()->left_ = v; } As we can see, we only call Access() when the values are different, potentially saving a copy. However, the generated setters on ComputedStyleBase do not perform this optimisation. This patch changes the generator to use the same optimisation in ComputedStyleBase. No behavioural changes are expected, but there should be less memory allocations in ComputedStyle. Diff of generated files: https://gist.github.com/darrnshn/47e96b81c2ade55cb337fd658f0d6785/revisions BUG=628043 ==========
https://codereview.chromium.org/2879493003/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl (right): https://codereview.chromium.org/2879493003/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl:13: {{field.name}} = std::move({{value}}); Should this be referencing v instead of {{value}}?
The CQ bit was checked by shend@chromium.org to run a CQ dry run
https://codereview.chromium.org/2879493003/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl (right): https://codereview.chromium.org/2879493003/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/build/scripts/templates/fields/external.tmpl:13: {{field.name}} = std::move({{value}}); On 2017/05/11 at 05:56:38, alancutter wrote: > Should this be referencing v instead of {{value}}? Oops, good catch.
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
lgtm
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by shend@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from nainar@chromium.org Link to the patchset: https://codereview.chromium.org/2879493003/#ps60001 (title: "Rebase")
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch. Bot data: {"patchset_id": 60001, "attempt_start_ts": 1494490087707360, "parent_rev": "e6be43e51ab2b92ae4fa55745bd54c8ee09f155d", "commit_rev": "e8e5df6b838075a0dc6e584853f1f795ac5af0b3"}
Message was sent while issue was closed.
Description was changed from ========== Check if value changed when setting nested fields in ComputedStyleBase. Many of the setters in ComputedStyle use a macro called SET_VAR, which sets the value of a field stored in a subgroup on ComputedStyle. SET_VAR first checks if the new value is different to the old value. Only when the value changes does it modify the field using the Access() method on the subgroup. Since Access() could potentially do a copy, we would like to call it as rarely as possible. Hence, SET_VAR is an optimisation that skips a call to Access() when it is not necessary. For example, the setter for the 'left' property might look like: void SetLeft(const Length& v) { if (surround_data_->left_ != v) surround_data_->Access()->left_ = v; } As we can see, we only call Access() when the values are different, potentially saving a copy. However, the generated setters on ComputedStyleBase do not perform this optimisation. This patch changes the generator to use the same optimisation in ComputedStyleBase. No behavioural changes are expected, but there should be less memory allocations in ComputedStyle. Diff of generated files: https://gist.github.com/darrnshn/47e96b81c2ade55cb337fd658f0d6785/revisions BUG=628043 ========== to ========== Check if value changed when setting nested fields in ComputedStyleBase. Many of the setters in ComputedStyle use a macro called SET_VAR, which sets the value of a field stored in a subgroup on ComputedStyle. SET_VAR first checks if the new value is different to the old value. Only when the value changes does it modify the field using the Access() method on the subgroup. Since Access() could potentially do a copy, we would like to call it as rarely as possible. Hence, SET_VAR is an optimisation that skips a call to Access() when it is not necessary. For example, the setter for the 'left' property might look like: void SetLeft(const Length& v) { if (surround_data_->left_ != v) surround_data_->Access()->left_ = v; } As we can see, we only call Access() when the values are different, potentially saving a copy. However, the generated setters on ComputedStyleBase do not perform this optimisation. This patch changes the generator to use the same optimisation in ComputedStyleBase. No behavioural changes are expected, but there should be less memory allocations in ComputedStyle. Diff of generated files: https://gist.github.com/darrnshn/47e96b81c2ade55cb337fd658f0d6785/revisions BUG=628043 Review-Url: https://codereview.chromium.org/2879493003 Cr-Commit-Position: refs/heads/master@{#470873} Committed: https://chromium.googlesource.com/chromium/src/+/e8e5df6b838075a0dc6e584853f1... ==========
Message was sent while issue was closed.
Committed patchset #4 (id:60001) as https://chromium.googlesource.com/chromium/src/+/e8e5df6b838075a0dc6e584853f1... |