Commit 2d53370e authored by Taiju Tsuiki's avatar Taiju Tsuiki Committed by Commit Bot

Revert "Oilpan: Reduce the size of heap_page.h."

This reverts commit c4662e1a.

Reason for revert:
This seems to gain the binary size by 0.3~0.9% on mac and win.

Original change's description:
> Oilpan: Reduce the size of heap_page.h.
> 
> heap_page.h is used in 6,000+ compilation units, and this CL reduces its
> estimated expanded size from 1.72MB to 1.40MB.
> 
> Bug: 242216
> Change-Id: I0f53c3f57511378289a841b89c6e01c4a2748d4a
> Reviewed-on: https://chromium-review.googlesource.com/1104080
> Reviewed-by: Keishi Hattori <keishi@chromium.org>
> Commit-Queue: Kent Tamura <tkent@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#567972}

TBR=keishi@chromium.org,tkent@chromium.org

Change-Id: I54c95f8102aadf8459a833db0d27b970d291eb93
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 242216, 853703
Reviewed-on: https://chromium-review.googlesource.com/1104357Reviewed-by: default avatarTaiju Tsuiki <tzik@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567981}
parent 00891b67
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "third_party/blink/renderer/platform/heap/heap_page.h" #include "third_party/blink/renderer/platform/heap/heap_page.h"
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/process_memory_dump.h" #include "base/trace_event/process_memory_dump.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h" #include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h"
...@@ -1771,54 +1770,4 @@ bool LargeObjectPage::Contains(Address object) { ...@@ -1771,54 +1770,4 @@ bool LargeObjectPage::Contains(Address object) {
} }
#endif #endif
ALWAYS_INLINE uint32_t RotateLeft16(uint32_t x) {
#if defined(COMPILER_MSVC)
return _lrotr(x, 16);
#else
// http://blog.regehr.org/archives/1063
return (x << 16) | (x >> (-16 & 31));
#endif
}
uint32_t ComputeRandomMagic() {
// Ignore C4319: It is OK to 0-extend into the high-order bits of the uintptr_t
// on 64-bit, in this case.
#if defined(COMPILER_MSVC)
#pragma warning(push)
#pragma warning(disable : 4319)
#endif
const uintptr_t random1 = ~(RotateLeft16(reinterpret_cast<uintptr_t>(
base::trace_event::MemoryAllocatorDump::kNameSize)));
#if defined(OS_WIN)
const uintptr_t random2 =
~(RotateLeft16(reinterpret_cast<uintptr_t>(::ReadFile)));
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
const uintptr_t random2 =
~(RotateLeft16(reinterpret_cast<uintptr_t>(::read)));
#endif
#if defined(ARCH_CPU_64_BITS)
static_assert(sizeof(uintptr_t) == sizeof(uint64_t),
"uintptr_t is not uint64_t");
const uint32_t random = static_cast<uint32_t>(
(random1 & 0x0FFFFULL) | ((random2 >> 32) & 0x0FFFF0000ULL));
#elif defined(ARCH_CPU_32_BITS)
// Although we don't use heap metadata canaries on 32-bit due to memory
// pressure, keep this code around just in case we do, someday.
static_assert(sizeof(uintptr_t) == sizeof(uint32_t),
"uintptr_t is not uint32_t");
const uint32_t random = (random1 & 0x0FFFFUL) | (random2 & 0xFFFF0000UL);
#else
#error architecture not supported
#endif
#if defined(COMPILER_MSVC)
#pragma warning(pop)
#endif
return random;
}
} // namespace blink } // namespace blink
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <stdint.h> #include <stdint.h>
#include "base/bits.h" #include "base/bits.h"
#include "base/trace_event/memory_allocator_dump.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "third_party/blink/renderer/platform/heap/blink_gc.h" #include "third_party/blink/renderer/platform/heap/blink_gc.h"
#include "third_party/blink/renderer/platform/heap/gc_info.h" #include "third_party/blink/renderer/platform/heap/gc_info.h"
...@@ -46,12 +47,6 @@ ...@@ -46,12 +47,6 @@
#include "third_party/blink/renderer/platform/wtf/container_annotations.h" #include "third_party/blink/renderer/platform/wtf/container_annotations.h"
#include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/forward.h"
namespace base {
namespace trace_event {
class MemoryAllocatorDump;
} // namespace trace_event
} // namespace base
namespace blink { namespace blink {
// TODO(palmer): Document the reason for 17. // TODO(palmer): Document the reason for 17.
...@@ -141,7 +136,7 @@ class BaseArena; ...@@ -141,7 +136,7 @@ class BaseArena;
// should be fast and small, and should have the benefit of requiring // should be fast and small, and should have the benefit of requiring
// attackers to discover and use 2 independent weak infoleak bugs, or 1 // attackers to discover and use 2 independent weak infoleak bugs, or 1
// arbitrary infoleak bug (used twice). // arbitrary infoleak bug (used twice).
PLATFORM_EXPORT uint32_t ComputeRandomMagic(); inline uint32_t GetRandomMagic();
// HeapObjectHeader is a 64-bit (64-bit platforms) or 32-bit (32-bit platforms) // HeapObjectHeader is a 64-bit (64-bit platforms) or 32-bit (32-bit platforms)
// object that has the following layout: // object that has the following layout:
...@@ -252,10 +247,7 @@ class PLATFORM_EXPORT HeapObjectHeader { ...@@ -252,10 +247,7 @@ class PLATFORM_EXPORT HeapObjectHeader {
#if defined(ARCH_CPU_64_BITS) #if defined(ARCH_CPU_64_BITS)
// Returns a random magic value. // Returns a random magic value.
uint32_t GetMagic() const { uint32_t GetMagic() const { return GetRandomMagic() ^ 0x6e0b6ead; }
static const uint32_t magic = ComputeRandomMagic() ^ 0x6e0b6ead;
return magic;
}
uint32_t magic_; uint32_t magic_;
#endif // defined(ARCH_CPU_64_BITS) #endif // defined(ARCH_CPU_64_BITS)
...@@ -426,10 +418,7 @@ class BasePage { ...@@ -426,10 +418,7 @@ class BasePage {
private: private:
// Returns a random magic value. // Returns a random magic value.
uint32_t GetMagic() const { uint32_t GetMagic() const { return GetRandomMagic() ^ 0xba5e4a9e; }
static const uint32_t magic = ComputeRandomMagic() ^ 0xba5e4a9e;
return magic;
}
uint32_t const magic_; uint32_t const magic_;
PageMemory* const storage_; PageMemory* const storage_;
...@@ -962,6 +951,57 @@ inline void HeapObjectHeader::CheckFromPayload(const void* payload) { ...@@ -962,6 +951,57 @@ inline void HeapObjectHeader::CheckFromPayload(const void* payload) {
(void)FromPayload(payload); (void)FromPayload(payload);
} }
ALWAYS_INLINE uint32_t RotateLeft16(uint32_t x) {
#if defined(COMPILER_MSVC)
return _lrotr(x, 16);
#else
// http://blog.regehr.org/archives/1063
return (x << 16) | (x >> (-16 & 31));
#endif
}
inline uint32_t GetRandomMagic() {
// Ignore C4319: It is OK to 0-extend into the high-order bits of the uintptr_t
// on 64-bit, in this case.
#if defined(COMPILER_MSVC)
#pragma warning(push)
#pragma warning(disable : 4319)
#endif
static const uintptr_t random1 = ~(RotateLeft16(reinterpret_cast<uintptr_t>(
base::trace_event::MemoryAllocatorDump::kNameSize)));
#if defined(OS_WIN)
static const uintptr_t random2 =
~(RotateLeft16(reinterpret_cast<uintptr_t>(::ReadFile)));
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
static const uintptr_t random2 =
~(RotateLeft16(reinterpret_cast<uintptr_t>(::read)));
#endif
#if defined(ARCH_CPU_64_BITS)
static_assert(sizeof(uintptr_t) == sizeof(uint64_t),
"uintptr_t is not uint64_t");
static const uint32_t random = static_cast<uint32_t>(
(random1 & 0x0FFFFULL) | ((random2 >> 32) & 0x0FFFF0000ULL));
#elif defined(ARCH_CPU_32_BITS)
// Although we don't use heap metadata canaries on 32-bit due to memory
// pressure, keep this code around just in case we do, someday.
static_assert(sizeof(uintptr_t) == sizeof(uint32_t),
"uintptr_t is not uint32_t");
static const uint32_t random =
(random1 & 0x0FFFFUL) | (random2 & 0xFFFF0000UL);
#else
#error architecture not supported
#endif
#if defined(COMPILER_MSVC)
#pragma warning(pop)
#endif
return random;
}
NO_SANITIZE_ADDRESS inline bool HeapObjectHeader::IsWrapperHeaderMarked() NO_SANITIZE_ADDRESS inline bool HeapObjectHeader::IsWrapperHeaderMarked()
const { const {
CheckHeader(); CheckHeader();
......
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