libv8 8.4.255.0-universal-darwin-15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/libv8/.location.yml +1 -0
- data/ext/libv8/location.rb +89 -0
- data/ext/libv8/paths.rb +28 -0
- data/lib/libv8.rb +9 -0
- data/lib/libv8/version.rb +3 -0
- data/vendor/v8/include/cppgc/allocation.h +124 -0
- data/vendor/v8/include/cppgc/garbage-collected.h +192 -0
- data/vendor/v8/include/cppgc/heap.h +50 -0
- data/vendor/v8/include/cppgc/internal/accessors.h +26 -0
- data/vendor/v8/include/cppgc/internal/api-constants.h +44 -0
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +26 -0
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +90 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +43 -0
- data/vendor/v8/include/cppgc/internal/logging.h +50 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +109 -0
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +133 -0
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +31 -0
- data/vendor/v8/include/cppgc/liveness-broker.h +50 -0
- data/vendor/v8/include/cppgc/macros.h +26 -0
- data/vendor/v8/include/cppgc/member.h +206 -0
- data/vendor/v8/include/cppgc/persistent.h +304 -0
- data/vendor/v8/include/cppgc/platform.h +31 -0
- data/vendor/v8/include/cppgc/prefinalizer.h +54 -0
- data/vendor/v8/include/cppgc/source-location.h +59 -0
- data/vendor/v8/include/cppgc/trace-trait.h +67 -0
- data/vendor/v8/include/cppgc/type-traits.h +109 -0
- data/vendor/v8/include/cppgc/visitor.h +137 -0
- data/vendor/v8/include/libplatform/libplatform-export.h +29 -0
- data/vendor/v8/include/libplatform/libplatform.h +85 -0
- data/vendor/v8/include/libplatform/v8-tracing.h +332 -0
- data/vendor/v8/include/v8-fast-api-calls.h +412 -0
- data/vendor/v8/include/v8-inspector-protocol.h +13 -0
- data/vendor/v8/include/v8-inspector.h +327 -0
- data/vendor/v8/include/v8-internal.h +389 -0
- data/vendor/v8/include/v8-platform.h +577 -0
- data/vendor/v8/include/v8-profiler.h +1059 -0
- data/vendor/v8/include/v8-util.h +652 -0
- data/vendor/v8/include/v8-value-serializer-version.h +24 -0
- data/vendor/v8/include/v8-version-string.h +38 -0
- data/vendor/v8/include/v8-version.h +20 -0
- data/vendor/v8/include/v8-wasm-trap-handler-posix.h +31 -0
- data/vendor/v8/include/v8-wasm-trap-handler-win.h +28 -0
- data/vendor/v8/include/v8.h +12018 -0
- data/vendor/v8/include/v8config.h +465 -0
- data/vendor/v8/out.gn/libv8/obj/libv8_libbase.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/libv8_libplatform.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/third_party/icu/libicui18n.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/third_party/icu/libicuuc.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/third_party/zlib/google/libcompression_utils_portable.a +0 -0
- data/vendor/v8/out.gn/libv8/obj/third_party/zlib/libchrome_zlib.a +0 -0
- metadata +138 -0
@@ -0,0 +1,304 @@
|
|
1
|
+
// Copyright 2020 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 INCLUDE_CPPGC_PERSISTENT_H_
|
6
|
+
#define INCLUDE_CPPGC_PERSISTENT_H_
|
7
|
+
|
8
|
+
#include <type_traits>
|
9
|
+
|
10
|
+
#include "cppgc/internal/persistent-node.h"
|
11
|
+
#include "cppgc/internal/pointer-policies.h"
|
12
|
+
#include "cppgc/source-location.h"
|
13
|
+
#include "cppgc/type-traits.h"
|
14
|
+
#include "cppgc/visitor.h"
|
15
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
16
|
+
|
17
|
+
namespace cppgc {
|
18
|
+
namespace internal {
|
19
|
+
|
20
|
+
// The basic class from which all Persistent classes are generated.
|
21
|
+
template <typename T, typename WeaknessPolicy, typename LocationPolicy,
|
22
|
+
typename CheckingPolicy>
|
23
|
+
class BasicPersistent : public LocationPolicy,
|
24
|
+
private WeaknessPolicy,
|
25
|
+
private CheckingPolicy {
|
26
|
+
public:
|
27
|
+
using typename WeaknessPolicy::IsStrongPersistent;
|
28
|
+
using PointeeType = T;
|
29
|
+
|
30
|
+
// Null-state/sentinel constructors.
|
31
|
+
BasicPersistent( // NOLINT
|
32
|
+
const SourceLocation& loc = SourceLocation::Current())
|
33
|
+
: LocationPolicy(loc) {}
|
34
|
+
|
35
|
+
BasicPersistent(std::nullptr_t, // NOLINT
|
36
|
+
const SourceLocation& loc = SourceLocation::Current())
|
37
|
+
: LocationPolicy(loc) {}
|
38
|
+
|
39
|
+
BasicPersistent( // NOLINT
|
40
|
+
SentinelPointer s, const SourceLocation& loc = SourceLocation::Current())
|
41
|
+
: LocationPolicy(loc), raw_(s) {}
|
42
|
+
|
43
|
+
// Raw value contstructors.
|
44
|
+
BasicPersistent(T* raw, // NOLINT
|
45
|
+
const SourceLocation& loc = SourceLocation::Current())
|
46
|
+
: LocationPolicy(loc), raw_(raw) {
|
47
|
+
if (!IsValid()) return;
|
48
|
+
node_ = WeaknessPolicy::GetPersistentRegion(raw_).AllocateNode(
|
49
|
+
this, &BasicPersistent::Trace);
|
50
|
+
this->CheckPointer(Get());
|
51
|
+
}
|
52
|
+
|
53
|
+
BasicPersistent(T& raw, // NOLINT
|
54
|
+
const SourceLocation& loc = SourceLocation::Current())
|
55
|
+
: BasicPersistent(&raw, loc) {}
|
56
|
+
|
57
|
+
// Copy ctor.
|
58
|
+
BasicPersistent(const BasicPersistent& other,
|
59
|
+
const SourceLocation& loc = SourceLocation::Current())
|
60
|
+
: BasicPersistent(other.Get(), loc) {}
|
61
|
+
|
62
|
+
// Heterogeneous ctor.
|
63
|
+
template <typename U, typename OtherWeaknessPolicy,
|
64
|
+
typename OtherLocationPolicy, typename OtherCheckingPolicy,
|
65
|
+
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
66
|
+
BasicPersistent( // NOLINT
|
67
|
+
const BasicPersistent<U, OtherWeaknessPolicy, OtherLocationPolicy,
|
68
|
+
OtherCheckingPolicy>& other,
|
69
|
+
const SourceLocation& loc = SourceLocation::Current())
|
70
|
+
: BasicPersistent(other.Get(), loc) {}
|
71
|
+
|
72
|
+
// Move ctor. The heterogeneous move ctor is not supported since e.g.
|
73
|
+
// persistent can't reuse persistent node from weak persistent.
|
74
|
+
BasicPersistent(
|
75
|
+
BasicPersistent&& other,
|
76
|
+
const SourceLocation& loc = SourceLocation::Current()) noexcept
|
77
|
+
: LocationPolicy(std::move(other)),
|
78
|
+
raw_(std::move(other.raw_)),
|
79
|
+
node_(std::move(other.node_)) {
|
80
|
+
if (!IsValid()) return;
|
81
|
+
node_->UpdateOwner(this);
|
82
|
+
other.raw_ = nullptr;
|
83
|
+
other.node_ = nullptr;
|
84
|
+
this->CheckPointer(Get());
|
85
|
+
}
|
86
|
+
|
87
|
+
// Constructor from member.
|
88
|
+
template <typename U, typename MemberBarrierPolicy,
|
89
|
+
typename MemberWeaknessTag, typename MemberCheckingPolicy,
|
90
|
+
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
91
|
+
BasicPersistent(internal::BasicMember<U, MemberBarrierPolicy, // NOLINT
|
92
|
+
MemberWeaknessTag, MemberCheckingPolicy>
|
93
|
+
member,
|
94
|
+
const SourceLocation& loc = SourceLocation::Current())
|
95
|
+
: BasicPersistent(member.Get(), loc) {}
|
96
|
+
|
97
|
+
~BasicPersistent() { Clear(); }
|
98
|
+
|
99
|
+
// Copy assignment.
|
100
|
+
BasicPersistent& operator=(const BasicPersistent& other) {
|
101
|
+
return operator=(other.Get());
|
102
|
+
}
|
103
|
+
|
104
|
+
template <typename U, typename OtherWeaknessPolicy,
|
105
|
+
typename OtherLocationPolicy, typename OtherCheckingPolicy,
|
106
|
+
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
107
|
+
BasicPersistent& operator=(
|
108
|
+
const BasicPersistent<U, OtherWeaknessPolicy, OtherLocationPolicy,
|
109
|
+
OtherCheckingPolicy>& other) {
|
110
|
+
return operator=(other.Get());
|
111
|
+
}
|
112
|
+
|
113
|
+
// Move assignment.
|
114
|
+
BasicPersistent& operator=(BasicPersistent&& other) {
|
115
|
+
if (this == &other) return *this;
|
116
|
+
Clear();
|
117
|
+
LocationPolicy::operator=(std::move(other));
|
118
|
+
raw_ = std::move(other.raw_);
|
119
|
+
node_ = std::move(other.node_);
|
120
|
+
if (!IsValid()) return *this;
|
121
|
+
node_->UpdateOwner(this);
|
122
|
+
other.raw_ = nullptr;
|
123
|
+
other.node_ = nullptr;
|
124
|
+
this->CheckPointer(Get());
|
125
|
+
return *this;
|
126
|
+
}
|
127
|
+
|
128
|
+
// Assignment from member.
|
129
|
+
template <typename U, typename MemberBarrierPolicy,
|
130
|
+
typename MemberWeaknessTag, typename MemberCheckingPolicy,
|
131
|
+
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
132
|
+
BasicPersistent& operator=(
|
133
|
+
internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
|
134
|
+
MemberCheckingPolicy>
|
135
|
+
member) {
|
136
|
+
return operator=(member.Get());
|
137
|
+
}
|
138
|
+
|
139
|
+
BasicPersistent& operator=(T* other) {
|
140
|
+
Assign(other);
|
141
|
+
return *this;
|
142
|
+
}
|
143
|
+
|
144
|
+
BasicPersistent& operator=(std::nullptr_t) {
|
145
|
+
Clear();
|
146
|
+
return *this;
|
147
|
+
}
|
148
|
+
|
149
|
+
BasicPersistent& operator=(SentinelPointer s) {
|
150
|
+
Assign(s);
|
151
|
+
return *this;
|
152
|
+
}
|
153
|
+
|
154
|
+
explicit operator bool() const { return Get(); }
|
155
|
+
operator T*() const { return Get(); }
|
156
|
+
T* operator->() const { return Get(); }
|
157
|
+
T& operator*() const { return *Get(); }
|
158
|
+
|
159
|
+
T* Get() const { return raw_; }
|
160
|
+
|
161
|
+
void Clear() { Assign(nullptr); }
|
162
|
+
|
163
|
+
T* Release() {
|
164
|
+
T* result = Get();
|
165
|
+
Clear();
|
166
|
+
return result;
|
167
|
+
}
|
168
|
+
|
169
|
+
private:
|
170
|
+
static void Trace(Visitor* v, const void* ptr) {
|
171
|
+
const auto* persistent = static_cast<const BasicPersistent*>(ptr);
|
172
|
+
v->TraceRoot(*persistent, persistent->Location());
|
173
|
+
}
|
174
|
+
|
175
|
+
bool IsValid() const {
|
176
|
+
// Ideally, handling kSentinelPointer would be done by the embedder. On the
|
177
|
+
// other hand, having Persistent aware of it is beneficial since no node
|
178
|
+
// gets wasted.
|
179
|
+
return raw_ != nullptr && raw_ != kSentinelPointer;
|
180
|
+
}
|
181
|
+
|
182
|
+
void Assign(T* ptr) {
|
183
|
+
if (IsValid()) {
|
184
|
+
if (ptr && ptr != kSentinelPointer) {
|
185
|
+
// Simply assign the pointer reusing the existing node.
|
186
|
+
raw_ = ptr;
|
187
|
+
this->CheckPointer(ptr);
|
188
|
+
return;
|
189
|
+
}
|
190
|
+
WeaknessPolicy::GetPersistentRegion(raw_).FreeNode(node_);
|
191
|
+
node_ = nullptr;
|
192
|
+
}
|
193
|
+
raw_ = ptr;
|
194
|
+
if (!IsValid()) return;
|
195
|
+
node_ = WeaknessPolicy::GetPersistentRegion(raw_).AllocateNode(
|
196
|
+
this, &BasicPersistent::Trace);
|
197
|
+
this->CheckPointer(Get());
|
198
|
+
}
|
199
|
+
|
200
|
+
T* raw_ = nullptr;
|
201
|
+
PersistentNode* node_ = nullptr;
|
202
|
+
};
|
203
|
+
|
204
|
+
template <typename T1, typename WeaknessPolicy1, typename LocationPolicy1,
|
205
|
+
typename CheckingPolicy1, typename T2, typename WeaknessPolicy2,
|
206
|
+
typename LocationPolicy2, typename CheckingPolicy2>
|
207
|
+
bool operator==(const BasicPersistent<T1, WeaknessPolicy1, LocationPolicy1,
|
208
|
+
CheckingPolicy1>& p1,
|
209
|
+
const BasicPersistent<T2, WeaknessPolicy2, LocationPolicy2,
|
210
|
+
CheckingPolicy2>& p2) {
|
211
|
+
return p1.Get() == p2.Get();
|
212
|
+
}
|
213
|
+
|
214
|
+
template <typename T1, typename WeaknessPolicy1, typename LocationPolicy1,
|
215
|
+
typename CheckingPolicy1, typename T2, typename WeaknessPolicy2,
|
216
|
+
typename LocationPolicy2, typename CheckingPolicy2>
|
217
|
+
bool operator!=(const BasicPersistent<T1, WeaknessPolicy1, LocationPolicy1,
|
218
|
+
CheckingPolicy1>& p1,
|
219
|
+
const BasicPersistent<T2, WeaknessPolicy2, LocationPolicy2,
|
220
|
+
CheckingPolicy2>& p2) {
|
221
|
+
return !(p1 == p2);
|
222
|
+
}
|
223
|
+
|
224
|
+
template <typename T1, typename PersistentWeaknessPolicy,
|
225
|
+
typename PersistentLocationPolicy, typename PersistentCheckingPolicy,
|
226
|
+
typename T2, typename MemberWriteBarrierPolicy,
|
227
|
+
typename MemberWeaknessTag, typename MemberCheckingPolicy>
|
228
|
+
bool operator==(const BasicPersistent<T1, PersistentWeaknessPolicy,
|
229
|
+
PersistentLocationPolicy,
|
230
|
+
PersistentCheckingPolicy>& p,
|
231
|
+
BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
|
232
|
+
MemberCheckingPolicy>
|
233
|
+
m) {
|
234
|
+
return p.Get() == m.Get();
|
235
|
+
}
|
236
|
+
|
237
|
+
template <typename T1, typename PersistentWeaknessPolicy,
|
238
|
+
typename PersistentLocationPolicy, typename PersistentCheckingPolicy,
|
239
|
+
typename T2, typename MemberWriteBarrierPolicy,
|
240
|
+
typename MemberWeaknessTag, typename MemberCheckingPolicy>
|
241
|
+
bool operator!=(const BasicPersistent<T1, PersistentWeaknessPolicy,
|
242
|
+
PersistentLocationPolicy,
|
243
|
+
PersistentCheckingPolicy>& p,
|
244
|
+
BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
|
245
|
+
MemberCheckingPolicy>
|
246
|
+
m) {
|
247
|
+
return !(p == m);
|
248
|
+
}
|
249
|
+
|
250
|
+
template <typename T1, typename MemberWriteBarrierPolicy,
|
251
|
+
typename MemberWeaknessTag, typename MemberCheckingPolicy,
|
252
|
+
typename T2, typename PersistentWeaknessPolicy,
|
253
|
+
typename PersistentLocationPolicy, typename PersistentCheckingPolicy>
|
254
|
+
bool operator==(BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
|
255
|
+
MemberCheckingPolicy>
|
256
|
+
m,
|
257
|
+
const BasicPersistent<T1, PersistentWeaknessPolicy,
|
258
|
+
PersistentLocationPolicy,
|
259
|
+
PersistentCheckingPolicy>& p) {
|
260
|
+
return m.Get() == p.Get();
|
261
|
+
}
|
262
|
+
|
263
|
+
template <typename T1, typename MemberWriteBarrierPolicy,
|
264
|
+
typename MemberWeaknessTag, typename MemberCheckingPolicy,
|
265
|
+
typename T2, typename PersistentWeaknessPolicy,
|
266
|
+
typename PersistentLocationPolicy, typename PersistentCheckingPolicy>
|
267
|
+
bool operator!=(BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
|
268
|
+
MemberCheckingPolicy>
|
269
|
+
m,
|
270
|
+
const BasicPersistent<T1, PersistentWeaknessPolicy,
|
271
|
+
PersistentLocationPolicy,
|
272
|
+
PersistentCheckingPolicy>& p) {
|
273
|
+
return !(m == p);
|
274
|
+
}
|
275
|
+
|
276
|
+
template <typename T, typename LocationPolicy, typename CheckingPolicy>
|
277
|
+
struct IsWeak<BasicPersistent<T, internal::WeakPersistentPolicy, LocationPolicy,
|
278
|
+
CheckingPolicy>> : std::true_type {};
|
279
|
+
} // namespace internal
|
280
|
+
|
281
|
+
/**
|
282
|
+
* Persistent is a way to create a strong pointer from an off-heap object to
|
283
|
+
* another on-heap object. As long as the Persistent handle is alive the GC will
|
284
|
+
* keep the object pointed to alive. The Persistent handle is always a GC root
|
285
|
+
* from the point of view of the GC. Persistent must be constructed and
|
286
|
+
* destructed in the same thread.
|
287
|
+
*/
|
288
|
+
template <typename T>
|
289
|
+
using Persistent =
|
290
|
+
internal::BasicPersistent<T, internal::StrongPersistentPolicy>;
|
291
|
+
|
292
|
+
/**
|
293
|
+
* WeakPersistent is a way to create a weak pointer from an off-heap object to
|
294
|
+
* an on-heap object. The pointer is automatically cleared when the pointee gets
|
295
|
+
* collected. WeakPersistent must be constructed and destructed in the same
|
296
|
+
* thread.
|
297
|
+
*/
|
298
|
+
template <typename T>
|
299
|
+
using WeakPersistent =
|
300
|
+
internal::BasicPersistent<T, internal::WeakPersistentPolicy>;
|
301
|
+
|
302
|
+
} // namespace cppgc
|
303
|
+
|
304
|
+
#endif // INCLUDE_CPPGC_PERSISTENT_H_
|
@@ -0,0 +1,31 @@
|
|
1
|
+
// Copyright 2020 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 INCLUDE_CPPGC_PLATFORM_H_
|
6
|
+
#define INCLUDE_CPPGC_PLATFORM_H_
|
7
|
+
|
8
|
+
#include "v8-platform.h" // NOLINT(build/include_directory)
|
9
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
10
|
+
|
11
|
+
namespace cppgc {
|
12
|
+
|
13
|
+
// TODO(v8:10346): Put PageAllocator in a non-V8 include header to avoid
|
14
|
+
// depending on namespace v8.
|
15
|
+
using PageAllocator = v8::PageAllocator;
|
16
|
+
|
17
|
+
// Initializes the garbage collector with the provided platform. Must be called
|
18
|
+
// before creating a Heap.
|
19
|
+
V8_EXPORT void InitializePlatform(PageAllocator* page_allocator);
|
20
|
+
|
21
|
+
// Must be called after destroying the last used heap.
|
22
|
+
V8_EXPORT void ShutdownPlatform();
|
23
|
+
|
24
|
+
namespace internal {
|
25
|
+
|
26
|
+
V8_EXPORT void Abort();
|
27
|
+
|
28
|
+
} // namespace internal
|
29
|
+
} // namespace cppgc
|
30
|
+
|
31
|
+
#endif // INCLUDE_CPPGC_PLATFORM_H_
|
@@ -0,0 +1,54 @@
|
|
1
|
+
// Copyright 2020 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 INCLUDE_CPPGC_PREFINALIZER_H_
|
6
|
+
#define INCLUDE_CPPGC_PREFINALIZER_H_
|
7
|
+
|
8
|
+
#include "cppgc/internal/accessors.h"
|
9
|
+
#include "cppgc/internal/compiler-specific.h"
|
10
|
+
#include "cppgc/internal/prefinalizer-handler.h"
|
11
|
+
#include "cppgc/liveness-broker.h"
|
12
|
+
#include "cppgc/macros.h"
|
13
|
+
|
14
|
+
namespace cppgc {
|
15
|
+
|
16
|
+
namespace internal {
|
17
|
+
|
18
|
+
template <typename T>
|
19
|
+
class PrefinalizerRegistration final {
|
20
|
+
public:
|
21
|
+
explicit PrefinalizerRegistration(T* self) {
|
22
|
+
static_assert(sizeof(&T::InvokePreFinalizer) > 0,
|
23
|
+
"USING_PRE_FINALIZER(T) must be defined.");
|
24
|
+
|
25
|
+
cppgc::internal::PreFinalizerRegistrationDispatcher::RegisterPrefinalizer(
|
26
|
+
internal::GetHeapFromPayload(self), {self, T::InvokePreFinalizer});
|
27
|
+
}
|
28
|
+
|
29
|
+
void* operator new(size_t, void* location) = delete;
|
30
|
+
void* operator new(size_t) = delete;
|
31
|
+
};
|
32
|
+
|
33
|
+
} // namespace internal
|
34
|
+
|
35
|
+
#define CPPGC_USING_PRE_FINALIZER(Class, PreFinalizer) \
|
36
|
+
public: \
|
37
|
+
static bool InvokePreFinalizer(const LivenessBroker& liveness_broker, \
|
38
|
+
void* object) { \
|
39
|
+
static_assert(internal::IsGarbageCollectedTypeV<Class>, \
|
40
|
+
"Only garbage collected objects can have prefinalizers"); \
|
41
|
+
Class* self = static_cast<Class*>(object); \
|
42
|
+
if (liveness_broker.IsHeapObjectAlive(self)) return false; \
|
43
|
+
self->Class::PreFinalizer(); \
|
44
|
+
return true; \
|
45
|
+
} \
|
46
|
+
\
|
47
|
+
private: \
|
48
|
+
CPPGC_NO_UNIQUE_ADDRESS internal::PrefinalizerRegistration<Class> \
|
49
|
+
prefinalizer_dummy_{this}; \
|
50
|
+
friend class internal::__thisIsHereToForceASemicolonAfterThisMacro
|
51
|
+
|
52
|
+
} // namespace cppgc
|
53
|
+
|
54
|
+
#endif // INCLUDE_CPPGC_PREFINALIZER_H_
|
@@ -0,0 +1,59 @@
|
|
1
|
+
// Copyright 2020 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 INCLUDE_CPPGC_SOURCE_LOCATION_H_
|
6
|
+
#define INCLUDE_CPPGC_SOURCE_LOCATION_H_
|
7
|
+
|
8
|
+
#include <string>
|
9
|
+
|
10
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
11
|
+
|
12
|
+
#if defined(__has_builtin)
|
13
|
+
#define CPPGC_SUPPORTS_SOURCE_LOCATION \
|
14
|
+
(__has_builtin(__builtin_FUNCTION) && __has_builtin(__builtin_FILE) && \
|
15
|
+
__has_builtin(__builtin_LINE)) // NOLINT
|
16
|
+
#elif defined(V8_CC_GNU) && __GNUC__ >= 7
|
17
|
+
#define CPPGC_SUPPORTS_SOURCE_LOCATION 1
|
18
|
+
#elif defined(V8_CC_INTEL) && __ICC >= 1800
|
19
|
+
#define CPPGC_SUPPORTS_SOURCE_LOCATION 1
|
20
|
+
#else
|
21
|
+
#define CPPGC_SUPPORTS_SOURCE_LOCATION 0
|
22
|
+
#endif
|
23
|
+
|
24
|
+
namespace cppgc {
|
25
|
+
|
26
|
+
// Encapsulates source location information. Mimics C++20's
|
27
|
+
// std::source_location.
|
28
|
+
class V8_EXPORT SourceLocation final {
|
29
|
+
public:
|
30
|
+
#if CPPGC_SUPPORTS_SOURCE_LOCATION
|
31
|
+
static constexpr SourceLocation Current(
|
32
|
+
const char* function = __builtin_FUNCTION(),
|
33
|
+
const char* file = __builtin_FILE(), size_t line = __builtin_LINE()) {
|
34
|
+
return SourceLocation(function, file, line);
|
35
|
+
}
|
36
|
+
#else
|
37
|
+
static constexpr SourceLocation Current() { return SourceLocation(); }
|
38
|
+
#endif // CPPGC_SUPPORTS_SOURCE_LOCATION
|
39
|
+
|
40
|
+
constexpr SourceLocation() = default;
|
41
|
+
|
42
|
+
constexpr const char* Function() const { return function_; }
|
43
|
+
constexpr const char* FileName() const { return file_; }
|
44
|
+
constexpr size_t Line() const { return line_; }
|
45
|
+
|
46
|
+
std::string ToString() const;
|
47
|
+
|
48
|
+
private:
|
49
|
+
constexpr SourceLocation(const char* function, const char* file, size_t line)
|
50
|
+
: function_(function), file_(file), line_(line) {}
|
51
|
+
|
52
|
+
const char* function_ = nullptr;
|
53
|
+
const char* file_ = nullptr;
|
54
|
+
size_t line_ = 0u;
|
55
|
+
};
|
56
|
+
|
57
|
+
} // namespace cppgc
|
58
|
+
|
59
|
+
#endif // INCLUDE_CPPGC_SOURCE_LOCATION_H_
|