Align base::Pickle allocations to 4k boundaries

Currently the growth logic of base::Pickle (the one that kicks
in exceeding the current capacity when writing) is as follows:
new_payload_capacity = current_payload_capacity * 2
with an initial payload capacity of 64 bytes.

However, the size of the heap held by Pickle (the one which gets
realloc-ated on each growth) is:
payload_capacity + header_size (typically 4-20 bytes).

In practice, this means that when the Pickle is expanded, the
size of its underlying heap becomes a power of two plus some extra.
This causes funky behaviors of realloc, which makes extremely
difficult to estimate the size of a pickle (for the sake of
memory profiling, Pickle is used to store TracedValue(s)).

This CL adds a small adjustment to the Pickle growth strategy,
making the underlying realloc sizes close to a full page size.
This in turn makes the realloc behavior much more predictable.

As a bonus this CL refactors the use of "Align", moving it to
base/bits.h

BUG=512383

Review URL: https://codereview.chromium.org/1249643007

Cr-Commit-Position: refs/heads/master@{#340318}


CrOS-Libchrome-Original-Commit: 32a7f50559fbaf7319a32048383d4c790f2a3c20
diff --git a/base/bits.h b/base/bits.h
index b2209e8..505d2c8 100644
--- a/base/bits.h
+++ b/base/bits.h
@@ -41,6 +41,12 @@
   }
 }
 
+// Round up |size| to a multiple of alignment, which must be a power of two.
+inline size_t Align(size_t size, size_t alignment) {
+  DCHECK_EQ(alignment & (alignment - 1), 0u);
+  return (size + alignment - 1) & ~(alignment - 1);
+}
+
 }  // namespace bits
 }  // namespace base