forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert of Refactor thread_local.h's TLS Implementation to use ThreadL…
…ocalStorage (patchset #2 id:60001 of https://codereview.chromium.org/1726203002/ ) Reason for revert: Reverting to consider this leak in base_unittests and unit_tests Leak_DefinitelyLost 8,192 bytes in 4 blocks are definitely lost in loss record 40,719 of 40,770 operator new[](unsigned long) (m_replacemalloc/vg_replace_malloc.c:1144) (anonymous namespace)::ConstructTlsVector() (base/threading/thread_local_storage.cc:107) base::ThreadLocalStorage::StaticSlot::Set(void*) (base/threading/thread_local_storage.cc:246) base::ThreadLocalPointer<void>::Set(void*) (base/threading/thread_local.h:69) 50 new files were left in /tmp: Fix the tests to clean up themselves. base::ThreadLocalBoolean::Set(bool) (base/threading/thread_local.h:88) base::(anonymous namespace)::WorkerThread::ThreadMain() (base/threading/worker_pool_posix.cc:79) base::(anonymous namespace)::ThreadFunc(void*) (base/threading/platform_thread_posix.cc:68) Suppression (error hash=#F6EC67ECF9CF9B28#): For more info on using suppressions see http://dev.chromium.org/developers/tree-sheriffs/sheriff-details-chromium/memory-sheriff#TOC-Suppressing-memory-reports { <insert_a_suppression_name_here> Memcheck:Leak fun:_Zna* fun:_ZN12_GLOBAL__N_118ConstructTlsVectorEv fun:_ZN4base18ThreadLocalStorage10StaticSlot3SetEPv fun:_ZN4base18ThreadLocalPointerIvE3SetEPv fun:_ZN4base18ThreadLocalBoolean3SetEb fun:_ZN4base12_GLOBAL__N_112WorkerThread10ThreadMainEv fun:_ZN4base12_GLOBAL__N_110ThreadFuncEPv } Original issue's description: > Refactor thread_local.h's TLS Implemetation to use ThreadLocalStorage > > thread_local_*'s implementation of TLS was redundant with > thread_local_storage_*'s implementation. > > This change reduces the number of implementations by one. > > BUG=588824 > > Committed: https://crrev.com/8f0b97ae15609cee6fe67d2b0b958ef37cffb1e0 > Cr-Commit-Position: refs/heads/master@{#377774} TBR=brettw@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=588824 Review URL: https://codereview.chromium.org/1743693002 Cr-Commit-Position: refs/heads/master@{#377927}
- Loading branch information
robliao
authored and
Commit bot
committed
Feb 26, 2016
1 parent
a66f599
commit 16b727d
Showing
7 changed files
with
187 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "base/threading/thread_local.h" | ||
|
||
namespace base { | ||
namespace internal { | ||
|
||
// static | ||
void ThreadLocalPlatform::AllocateSlot(SlotType* slot) { | ||
slot->Initialize(nullptr); | ||
} | ||
|
||
// static | ||
void ThreadLocalPlatform::FreeSlot(SlotType slot) { | ||
slot.Free(); | ||
} | ||
|
||
// static | ||
void* ThreadLocalPlatform::GetValueFromSlot(SlotType slot) { | ||
return slot.Get(); | ||
} | ||
|
||
// static | ||
void ThreadLocalPlatform::SetValueInSlot(SlotType slot, void* value) { | ||
slot.Set(value); | ||
} | ||
|
||
} // namespace internal | ||
} // namespace base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2011 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "base/threading/thread_local.h" | ||
|
||
#include <pthread.h> | ||
|
||
#include "base/logging.h" | ||
#include "build/build_config.h" | ||
|
||
#if !defined(OS_ANDROID) | ||
|
||
namespace base { | ||
namespace internal { | ||
|
||
// static | ||
void ThreadLocalPlatform::AllocateSlot(SlotType* slot) { | ||
int error = pthread_key_create(slot, NULL); | ||
CHECK_EQ(error, 0); | ||
} | ||
|
||
// static | ||
void ThreadLocalPlatform::FreeSlot(SlotType slot) { | ||
int error = pthread_key_delete(slot); | ||
DCHECK_EQ(0, error); | ||
} | ||
|
||
// static | ||
void* ThreadLocalPlatform::GetValueFromSlot(SlotType slot) { | ||
return pthread_getspecific(slot); | ||
} | ||
|
||
// static | ||
void ThreadLocalPlatform::SetValueInSlot(SlotType slot, void* value) { | ||
int error = pthread_setspecific(slot, value); | ||
DCHECK_EQ(error, 0); | ||
} | ||
|
||
} // namespace internal | ||
} // namespace base | ||
|
||
#endif // !defined(OS_ANDROID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2010 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "base/threading/thread_local.h" | ||
|
||
#include <windows.h> | ||
|
||
#include "base/logging.h" | ||
|
||
namespace base { | ||
namespace internal { | ||
|
||
// static | ||
void ThreadLocalPlatform::AllocateSlot(SlotType* slot) { | ||
*slot = TlsAlloc(); | ||
CHECK_NE(*slot, TLS_OUT_OF_INDEXES); | ||
} | ||
|
||
// static | ||
void ThreadLocalPlatform::FreeSlot(SlotType slot) { | ||
if (!TlsFree(slot)) { | ||
NOTREACHED() << "Failed to deallocate tls slot with TlsFree()."; | ||
} | ||
} | ||
|
||
// static | ||
void* ThreadLocalPlatform::GetValueFromSlot(SlotType slot) { | ||
return TlsGetValue(slot); | ||
} | ||
|
||
// static | ||
void ThreadLocalPlatform::SetValueInSlot(SlotType slot, void* value) { | ||
if (!TlsSetValue(slot, value)) { | ||
LOG(FATAL) << "Failed to TlsSetValue()."; | ||
} | ||
} | ||
|
||
} // namespace internal | ||
} // namespace base |