v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
thread-local-storage.h
Go to the documentation of this file.
1
// Copyright 2024 the V8 project authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef V8_COMMON_THREAD_LOCAL_STORAGE_H_
6
#define V8_COMMON_THREAD_LOCAL_STORAGE_H_
7
8
#include "
include/v8config.h
"
9
10
#if defined(COMPONENT_BUILD) || defined(V8_TLS_USED_IN_LIBRARY)
11
#define V8_TLS_LIBRARY_MODE 1
12
#else
13
#define V8_TLS_LIBRARY_MODE 0
14
#endif
15
16
// In shared libraries always hide the thread_local variable behind a call.
17
// This avoids complexity with "global-dyn" and allows to use "local-dyn"
18
// instead, across all platforms. On non-shared (release) builds, don't hide
19
// the variable behind the call (to improve performance in access time), but use
20
// different tls models on different platforms. On Windows, since chrome is
21
// linked into the chrome.dll which is always linked to chrome.exe at static
22
// link time (DT_NEEDED in ELF terms), use "init-exec". On Android, since the
23
// library can be opened with "dlopen" (through JNI), use "local-dyn". On other
24
// systems (Linux/ChromeOS/MacOS) use the fastest "local-exec".
25
26
// |_____component_____|___non-component___|
27
// ________|_tls_model__|_hide_|_tls_model__|_hide_|
28
// Windows | local-dyn | yes | init-exec | no |
29
// Android | local-dyn | yes | local-dyn | no |
30
// Other | local-dyn | yes | local-exec | no |
31
#if V8_TLS_LIBRARY_MODE
32
#define V8_TLS_MODEL "local-dynamic"
33
#else
34
#if defined(V8_TARGET_OS_WIN)
35
#define V8_TLS_MODEL "initial-exec"
36
#elif defined(V8_TARGET_OS_ANDROID)
37
#define V8_TLS_MODEL "local-dynamic"
38
#else
39
#define V8_TLS_MODEL "local-exec"
40
#endif
41
#endif
42
43
#if V8_TLS_LIBRARY_MODE
44
45
#define V8_TLS_DECLARE_GETTER(Name, Type, Member) \
46
static V8_NOINLINE Type Name();
47
#define V8_TLS_DEFINE_GETTER(Name, Type, Member) \
48
V8_NOINLINE Type Name() { return Member; }
49
50
#else
// !V8_TLS_LIBRARY_MODE
51
52
#define V8_TLS_DECLARE_GETTER(Name, Type, Member) \
53
static V8_INLINE Type Name() { return Member; }
54
#define V8_TLS_DEFINE_GETTER(Name, Type, Member)
55
56
#endif
// V8_TLS_LIBRARY_MODE
57
58
#endif
// V8_COMMON_THREAD_LOCAL_STORAGE_H_
v8config.h
src
common
thread-local-storage.h
Generated on Sun Apr 6 2025 21:08:51 for v8 by
1.12.0