Commit 93e1b8dd authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Add comments describing unusual use of Alias

The base::debug::Alias function is normally used to 'fool' the compiler
into retaining an otherwise discardable local variable. In this case
base::debug::Alias is used in a completely different way which initially
seems wrong, but is actually reasonable. A comment will avoid confusion
when auditing uses of Alias.

The initial discussion of using base::debug::Alias is here:
https://codereview.chromium.org/2810833002#msg7

Bug: 756589
Change-Id: Ib00a1444c217680a69178a8bbf6c710179126e86
Reviewed-on: https://chromium-review.googlesource.com/794298Reviewed-by: default avatarBrett Wilson <brettw@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519860}
parent 5de6f5ff
......@@ -91,6 +91,7 @@ void MemoryAblationExperiment::TouchMemory(size_t offset) {
for (; offset < max_offset; offset += page_size) {
memory[offset] = static_cast<uint8_t>(offset);
}
// Make sure compiler doesn't optimize away the writes.
base::debug::Alias(memory_.get());
if (offset < memory_size_) {
ScheduleTouchMemory(offset);
......
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