Commit b9c0893b authored by Vitaly Buka's avatar Vitaly Buka Committed by Commit Bot

Disable -ftrivial-auto-var-init=pattern on performance critical code

STACK_UNINITIALIZED is __attribute__((uninitialized)) and it disables
-ftrivial-auto-var-init=pattern on a particular variable.
-ftrivial-auto-var-init=pattern inserts initialization of all
local variables including those which are not required by
language standard. Additional initialization usually can be
optimized out by compiled, however in cases when code is too
complicated for optimizer we can see performance regression.

To avoid that we need either to rewrite code or just disabled
initialization with the attribute. Particularly here I don't see
a reasonable way to restructure the code to preserve performance
without loosing readability.

hit-test-lots-of-layers of blink_perf.events was 12% slower.
Before: https://pinpoint-dot-chromeperf.appspot.com/job/15069da7220000
After: https://pinpoint-dot-chromeperf.appspot.com/job/117e2deb220000

Bug: 977230

Change-Id: I92f64956f71e46ec613dbec31bb1eb545b7e9b05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1955030
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723573}
parent 4697b75a
......@@ -2052,7 +2052,7 @@ PaintLayer* PaintLayer::HitTestLayer(PaintLayer* root_layer,
// The natural thing would be to keep HitTestingTransformState on the stack,
// but it's big, so we heap-allocate.
HitTestingTransformState* local_transform_state = nullptr;
base::Optional<HitTestingTransformState> storage;
STACK_UNINITIALIZED base::Optional<HitTestingTransformState> storage;
if (applied_transform) {
// We computed the correct state in the caller (above code), so just
......@@ -2071,7 +2071,7 @@ PaintLayer* PaintLayer::HitTestLayer(PaintLayer* root_layer,
// Check for hit test on backface if backface-visibility is 'hidden'
if (local_transform_state && layout_object.StyleRef().BackfaceVisibility() ==
EBackfaceVisibility::kHidden) {
TransformationMatrix inverted_matrix =
STACK_UNINITIALIZED TransformationMatrix inverted_matrix =
local_transform_state->accumulated_transform_.Inverse();
// If the z-vector of the matrix is negative, the back is facing towards the
// viewer.
......@@ -2080,7 +2080,8 @@ PaintLayer* PaintLayer::HitTestLayer(PaintLayer* root_layer,
}
HitTestingTransformState* unflattened_transform_state = local_transform_state;
base::Optional<HitTestingTransformState> unflattened_storage;
STACK_UNINITIALIZED base::Optional<HitTestingTransformState>
unflattened_storage;
if (local_transform_state && !Preserves3D()) {
// Keep a copy of the pre-flattening state, for computing z-offsets for the
// container
......@@ -2111,7 +2112,7 @@ PaintLayer* PaintLayer::HitTestLayer(PaintLayer* root_layer,
// Collect the fragments. This will compute the clip rectangles for each
// layer fragment.
base::Optional<PaintLayerFragments> layer_fragments;
STACK_UNINITIALIZED base::Optional<PaintLayerFragments> layer_fragments;
if (recursion_data.intersects_location) {
layer_fragments.emplace();
if (applied_transform) {
......@@ -2189,8 +2190,8 @@ PaintLayer* PaintLayer::HitTestLayer(PaintLayer* root_layer,
DisplayLockLifecycleTarget::kChildren)) {
// Hit test with a temporary HitTestResult, because we only want to commit
// to 'result' if we know we're frontmost.
HitTestResult temp_result(result.GetHitTestRequest(),
recursion_data.original_location);
STACK_UNINITIALIZED HitTestResult temp_result(
result.GetHitTestRequest(), recursion_data.original_location);
temp_result.SetInertNode(result.InertNode());
bool inside_fragment_foreground_rect = false;
......@@ -2237,8 +2238,8 @@ PaintLayer* PaintLayer::HitTestLayer(PaintLayer* root_layer,
return candidate_layer;
if (recursion_data.intersects_location && IsSelfPaintingLayer()) {
HitTestResult temp_result(result.GetHitTestRequest(),
recursion_data.original_location);
STACK_UNINITIALIZED HitTestResult temp_result(
result.GetHitTestRequest(), recursion_data.original_location);
temp_result.SetInertNode(result.InertNode());
bool inside_fragment_background_rect = false;
if (HitTestContentsForFragments(*layer_fragments, offset, temp_result,
......@@ -2469,8 +2470,8 @@ PaintLayer* PaintLayer::HitTestChildren(
}
PaintLayer* hit_layer = nullptr;
HitTestResult temp_result(result.GetHitTestRequest(),
recursion_data.original_location);
STACK_UNINITIALIZED HitTestResult temp_result(
result.GetHitTestRequest(), recursion_data.original_location);
temp_result.SetInertNode(result.InertNode());
hit_layer = child_layer->HitTestLayer(
root_layer, this, temp_result, recursion_data, false, transform_state,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment