Reland "[base] Use dummy class to avoid superfluous initialization in Optional"
Apple-clang complains about missing initializer in union. This fixes it. Original change's description: > [base] Use dummy class to avoid superfluous initialization in Optional > > The initialization of "char empty_" union-member in Optional is > redundant and causes the compiler to generate extra code to ensure > zero-initialization. Using an empty Dummy class for the union member is > more optimal, since it guarantees that no code for its initialization is > generated. > > Explicitly touching this char member in the constructor also causes a > problem for conservative GC. Compiler is free to split shared and not > shared parts of the union in separate memory locations on stack (or keep > them in different registers). If a conservative GC is triggered at this > moment, stack scanning may not find the correct object (this is exactly > what happened in the bug 1044331). > > This can be tested in a minimized example: https://godbolt.org/z/t5q5ry. > > Bug: 1046776 > > Change-Id: Idab1a0acf7d7d4f45dc9435a611b23f64e3c3c79 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2027948 > Commit-Queue: Anton Bikineev <bikineev@chromium.org> > Reviewed-by: François Doray <fdoray@chromium.org> > Reviewed-by: Gabriel Charette <gab@chromium.org> > Reviewed-by: Michael Lippautz <mlippautz@chromium.org> > Cr-Commit-Position: refs/heads/master@{#737494} Bug: 1046776 Change-Id: I751878a515647e244059d0ad1ba7bc6542fd1f37 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2033357Reviewed-by:François Doray <fdoray@chromium.org> Commit-Queue: Anton Bikineev <bikineev@chromium.org> Cr-Commit-Position: refs/heads/master@{#737785}
Showing
Please register or sign in to comment