Commit 1598ab89 authored by David 'Digit' Turner's avatar David 'Digit' Turner Committed by Commit Bot

base: inline ThreadSafeRefCounted destructor in release builds.

For some reason, the ThreadSafeRefCounted destructor was not
inlined in release builds. The end result was a completely empty
function, that was called in many many places.

This tells the compiler that, for release build, the destructor
is inlined and doesn't do anything. This tiny patch reduces the
final (compressed) size of the following Android APKs:

  - Chrome.apk       -60 KiB  (from 45 MiB)
  - Monochrone.apk  -152 KiB  (from 69 MiB)

Note that the destructor is kept non-inlined for debug builds,
since it must perform relevant debug checks.

R=tzik@chromium.org,thakis@chromium.org,dcheng@chromium.org,agrieves@chromium.org
BUG=NONE

Change-Id: I45c9e87851a3c71861034bde8906b59d1033c455
Reviewed-on: https://chromium-review.googlesource.com/702301Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarTaiju Tsuiki <tzik@chromium.org>
Commit-Queue: David Turner <digit@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506786}
parent 3760196f
...@@ -21,12 +21,12 @@ bool RefCountedThreadSafeBase::HasOneRef() const { ...@@ -21,12 +21,12 @@ bool RefCountedThreadSafeBase::HasOneRef() const {
return ref_count_.IsOne(); return ref_count_.IsOne();
} }
RefCountedThreadSafeBase::~RefCountedThreadSafeBase() {
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
RefCountedThreadSafeBase::~RefCountedThreadSafeBase() {
DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without " DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without "
"calling Release()"; "calling Release()";
#endif
} }
#endif
#if defined(ARCH_CPU_64_BIT) #if defined(ARCH_CPU_64_BIT)
void RefCountedBase::AddRefImpl() const { void RefCountedBase::AddRefImpl() const {
......
...@@ -167,7 +167,11 @@ class BASE_EXPORT RefCountedThreadSafeBase { ...@@ -167,7 +167,11 @@ class BASE_EXPORT RefCountedThreadSafeBase {
#endif #endif
} }
#if DCHECK_IS_ON()
~RefCountedThreadSafeBase(); ~RefCountedThreadSafeBase();
#else
~RefCountedThreadSafeBase() = default;
#endif
// Release and AddRef are suitable for inlining on X86 because they generate // Release and AddRef are suitable for inlining on X86 because they generate
// very small code sequences. On other platforms (ARM), it causes a size // very small code sequences. On other platforms (ARM), it causes a size
......
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