Commit 2f86076a authored by Brian White's avatar Brian White

Don't create TLS vector on Get.

Previously, TLS::Slot::Get() would create the TLS vector if it doesn't
yet exist and then return the slot value which of course is null since
it was just created.

Now, just return null instead of creating the vector.  The vector will
be created by Set() if it doesn't exist.

This allows clients to make use of an existing slot in dangerous
situations (such as exception handling) without necessarily creating
the underlying vector at that time.

Bug: 821494
Change-Id: I404524ec7ccf0da4ea5451eea25b49783a711c04
Reviewed-on: https://chromium-review.googlesource.com/1007682
Commit-Queue: Brian White <bcwhite@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549979}
parent 62774a22
...@@ -364,7 +364,7 @@ void* ThreadLocalStorage::Slot::Get() const { ...@@ -364,7 +364,7 @@ void* ThreadLocalStorage::Slot::Get() const {
base::subtle::NoBarrier_Load(&g_native_tls_key))); base::subtle::NoBarrier_Load(&g_native_tls_key)));
DCHECK_NE(tls_data, kDestroyed); DCHECK_NE(tls_data, kDestroyed);
if (!tls_data) if (!tls_data)
tls_data = ConstructTlsVector(); return nullptr;
DCHECK_NE(slot_, kInvalidSlotValue); DCHECK_NE(slot_, kInvalidSlotValue);
DCHECK_LT(slot_, kThreadLocalStorageSize); DCHECK_LT(slot_, kThreadLocalStorageSize);
// Version mismatches means this slot was previously freed. // Version mismatches means this slot was previously freed.
......
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