aha-libv8-node 16.0.0.0-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/libv8-node/.location.yml +1 -0
- data/ext/libv8-node/location.rb +76 -0
- data/ext/libv8-node/paths.rb +30 -0
- data/lib/libv8-node.rb +1 -0
- data/lib/libv8/node.rb +11 -0
- data/lib/libv8/node/version.rb +7 -0
- data/vendor/v8/include/cppgc/allocation.h +229 -0
- data/vendor/v8/include/cppgc/common.h +29 -0
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +345 -0
- data/vendor/v8/include/cppgc/custom-space.h +97 -0
- data/vendor/v8/include/cppgc/default-platform.h +75 -0
- data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
- data/vendor/v8/include/cppgc/garbage-collected.h +116 -0
- data/vendor/v8/include/cppgc/heap-consistency.h +236 -0
- data/vendor/v8/include/cppgc/heap-state.h +59 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +110 -0
- data/vendor/v8/include/cppgc/heap.h +199 -0
- data/vendor/v8/include/cppgc/internal/api-constants.h +47 -0
- data/vendor/v8/include/cppgc/internal/atomic-entry-flag.h +48 -0
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +68 -0
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +38 -0
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +90 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +47 -0
- data/vendor/v8/include/cppgc/internal/logging.h +50 -0
- data/vendor/v8/include/cppgc/internal/name-trait.h +111 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +132 -0
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +143 -0
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +30 -0
- data/vendor/v8/include/cppgc/internal/write-barrier.h +390 -0
- data/vendor/v8/include/cppgc/liveness-broker.h +74 -0
- data/vendor/v8/include/cppgc/macros.h +26 -0
- data/vendor/v8/include/cppgc/member.h +271 -0
- data/vendor/v8/include/cppgc/name-provider.h +65 -0
- data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
- data/vendor/v8/include/cppgc/persistent.h +365 -0
- data/vendor/v8/include/cppgc/platform.h +151 -0
- data/vendor/v8/include/cppgc/prefinalizer.h +52 -0
- data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
- data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
- data/vendor/v8/include/cppgc/source-location.h +91 -0
- data/vendor/v8/include/cppgc/testing.h +50 -0
- data/vendor/v8/include/cppgc/trace-trait.h +116 -0
- data/vendor/v8/include/cppgc/type-traits.h +228 -0
- data/vendor/v8/include/cppgc/visitor.h +340 -0
- data/vendor/v8/include/libplatform/libplatform-export.h +29 -0
- data/vendor/v8/include/libplatform/libplatform.h +117 -0
- data/vendor/v8/include/libplatform/v8-tracing.h +334 -0
- data/vendor/v8/include/v8-cppgc.h +278 -0
- data/vendor/v8/include/v8-fast-api-calls.h +419 -0
- data/vendor/v8/include/v8-inspector-protocol.h +13 -0
- data/vendor/v8/include/v8-inspector.h +336 -0
- data/vendor/v8/include/v8-internal.h +462 -0
- data/vendor/v8/include/v8-metrics.h +189 -0
- data/vendor/v8/include/v8-platform.h +710 -0
- data/vendor/v8/include/v8-profiler.h +1116 -0
- data/vendor/v8/include/v8-unwinder-state.h +30 -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 +12479 -0
- data/vendor/v8/include/v8config.h +521 -0
- data/vendor/v8/out.gn/libv8/obj/libv8_monolith.a +0 -0
- metadata +137 -0
@@ -0,0 +1,68 @@
|
|
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_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_
|
6
|
+
#define INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_
|
7
|
+
|
8
|
+
#include <array>
|
9
|
+
|
10
|
+
#include "cppgc/internal/api-constants.h"
|
11
|
+
#include "cppgc/internal/logging.h"
|
12
|
+
#include "cppgc/platform.h"
|
13
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
14
|
+
|
15
|
+
namespace cppgc {
|
16
|
+
namespace internal {
|
17
|
+
|
18
|
+
class HeapBase;
|
19
|
+
|
20
|
+
#if defined(CPPGC_YOUNG_GENERATION)
|
21
|
+
|
22
|
+
// AgeTable contains entries that correspond to 4KB memory regions. Each entry
|
23
|
+
// can be in one of three states: kOld, kYoung or kUnknown.
|
24
|
+
class AgeTable final {
|
25
|
+
static constexpr size_t kGranularityBits = 12; // 4KiB per byte.
|
26
|
+
|
27
|
+
public:
|
28
|
+
enum class Age : uint8_t { kOld, kYoung, kUnknown };
|
29
|
+
|
30
|
+
static constexpr size_t kEntrySizeInBytes = 1 << kGranularityBits;
|
31
|
+
|
32
|
+
Age& operator[](uintptr_t offset) { return table_[entry(offset)]; }
|
33
|
+
Age operator[](uintptr_t offset) const { return table_[entry(offset)]; }
|
34
|
+
|
35
|
+
void Reset(PageAllocator* allocator);
|
36
|
+
|
37
|
+
private:
|
38
|
+
static constexpr size_t kAgeTableSize =
|
39
|
+
api_constants::kCagedHeapReservationSize >> kGranularityBits;
|
40
|
+
|
41
|
+
size_t entry(uintptr_t offset) const {
|
42
|
+
const size_t entry = offset >> kGranularityBits;
|
43
|
+
CPPGC_DCHECK(table_.size() > entry);
|
44
|
+
return entry;
|
45
|
+
}
|
46
|
+
|
47
|
+
std::array<Age, kAgeTableSize> table_;
|
48
|
+
};
|
49
|
+
|
50
|
+
static_assert(sizeof(AgeTable) == 1 * api_constants::kMB,
|
51
|
+
"Size of AgeTable is 1MB");
|
52
|
+
|
53
|
+
#endif // CPPGC_YOUNG_GENERATION
|
54
|
+
|
55
|
+
struct CagedHeapLocalData final {
|
56
|
+
explicit CagedHeapLocalData(HeapBase* heap_base) : heap_base(heap_base) {}
|
57
|
+
|
58
|
+
bool is_incremental_marking_in_progress = false;
|
59
|
+
HeapBase* heap_base = nullptr;
|
60
|
+
#if defined(CPPGC_YOUNG_GENERATION)
|
61
|
+
AgeTable age_table;
|
62
|
+
#endif
|
63
|
+
};
|
64
|
+
|
65
|
+
} // namespace internal
|
66
|
+
} // namespace cppgc
|
67
|
+
|
68
|
+
#endif // INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_
|
@@ -0,0 +1,38 @@
|
|
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_INTERNAL_COMPILER_SPECIFIC_H_
|
6
|
+
#define INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_
|
7
|
+
|
8
|
+
namespace cppgc {
|
9
|
+
|
10
|
+
#if defined(__has_attribute)
|
11
|
+
#define CPPGC_HAS_ATTRIBUTE(FEATURE) __has_attribute(FEATURE)
|
12
|
+
#else
|
13
|
+
#define CPPGC_HAS_ATTRIBUTE(FEATURE) 0
|
14
|
+
#endif
|
15
|
+
|
16
|
+
#if defined(__has_cpp_attribute)
|
17
|
+
#define CPPGC_HAS_CPP_ATTRIBUTE(FEATURE) __has_cpp_attribute(FEATURE)
|
18
|
+
#else
|
19
|
+
#define CPPGC_HAS_CPP_ATTRIBUTE(FEATURE) 0
|
20
|
+
#endif
|
21
|
+
|
22
|
+
// [[no_unique_address]] comes in C++20 but supported in clang with -std >=
|
23
|
+
// c++11.
|
24
|
+
#if CPPGC_HAS_CPP_ATTRIBUTE(no_unique_address) // NOLINTNEXTLINE
|
25
|
+
#define CPPGC_NO_UNIQUE_ADDRESS [[no_unique_address]]
|
26
|
+
#else
|
27
|
+
#define CPPGC_NO_UNIQUE_ADDRESS
|
28
|
+
#endif
|
29
|
+
|
30
|
+
#if CPPGC_HAS_ATTRIBUTE(unused) // NOLINTNEXTLINE
|
31
|
+
#define CPPGC_UNUSED __attribute__((unused))
|
32
|
+
#else
|
33
|
+
#define CPPGC_UNUSED
|
34
|
+
#endif
|
35
|
+
|
36
|
+
} // namespace cppgc
|
37
|
+
|
38
|
+
#endif // INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_
|
@@ -0,0 +1,90 @@
|
|
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_INTERNAL_FINALIZER_TRAIT_H_
|
6
|
+
#define INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_
|
7
|
+
|
8
|
+
#include <type_traits>
|
9
|
+
|
10
|
+
#include "cppgc/type-traits.h"
|
11
|
+
|
12
|
+
namespace cppgc {
|
13
|
+
namespace internal {
|
14
|
+
|
15
|
+
using FinalizationCallback = void (*)(void*);
|
16
|
+
|
17
|
+
template <typename T, typename = void>
|
18
|
+
struct HasFinalizeGarbageCollectedObject : std::false_type {};
|
19
|
+
|
20
|
+
template <typename T>
|
21
|
+
struct HasFinalizeGarbageCollectedObject<
|
22
|
+
T, void_t<decltype(std::declval<T>().FinalizeGarbageCollectedObject())>>
|
23
|
+
: std::true_type {};
|
24
|
+
|
25
|
+
// The FinalizerTraitImpl specifies how to finalize objects.
|
26
|
+
template <typename T, bool isFinalized>
|
27
|
+
struct FinalizerTraitImpl;
|
28
|
+
|
29
|
+
template <typename T>
|
30
|
+
struct FinalizerTraitImpl<T, true> {
|
31
|
+
private:
|
32
|
+
// Dispatch to custom FinalizeGarbageCollectedObject().
|
33
|
+
struct Custom {
|
34
|
+
static void Call(void* obj) {
|
35
|
+
static_cast<T*>(obj)->FinalizeGarbageCollectedObject();
|
36
|
+
}
|
37
|
+
};
|
38
|
+
|
39
|
+
// Dispatch to regular destructor.
|
40
|
+
struct Destructor {
|
41
|
+
static void Call(void* obj) { static_cast<T*>(obj)->~T(); }
|
42
|
+
};
|
43
|
+
|
44
|
+
using FinalizeImpl =
|
45
|
+
std::conditional_t<HasFinalizeGarbageCollectedObject<T>::value, Custom,
|
46
|
+
Destructor>;
|
47
|
+
|
48
|
+
public:
|
49
|
+
static void Finalize(void* obj) {
|
50
|
+
static_assert(sizeof(T), "T must be fully defined");
|
51
|
+
FinalizeImpl::Call(obj);
|
52
|
+
}
|
53
|
+
};
|
54
|
+
|
55
|
+
template <typename T>
|
56
|
+
struct FinalizerTraitImpl<T, false> {
|
57
|
+
static void Finalize(void* obj) {
|
58
|
+
static_assert(sizeof(T), "T must be fully defined");
|
59
|
+
}
|
60
|
+
};
|
61
|
+
|
62
|
+
// The FinalizerTrait is used to determine if a type requires finalization and
|
63
|
+
// what finalization means.
|
64
|
+
template <typename T>
|
65
|
+
struct FinalizerTrait {
|
66
|
+
private:
|
67
|
+
// Object has a finalizer if it has
|
68
|
+
// - a custom FinalizeGarbageCollectedObject method, or
|
69
|
+
// - a destructor.
|
70
|
+
static constexpr bool kNonTrivialFinalizer =
|
71
|
+
internal::HasFinalizeGarbageCollectedObject<T>::value ||
|
72
|
+
!std::is_trivially_destructible<typename std::remove_cv<T>::type>::value;
|
73
|
+
|
74
|
+
static void Finalize(void* obj) {
|
75
|
+
internal::FinalizerTraitImpl<T, kNonTrivialFinalizer>::Finalize(obj);
|
76
|
+
}
|
77
|
+
|
78
|
+
public:
|
79
|
+
// The callback used to finalize an object of type T.
|
80
|
+
static constexpr FinalizationCallback kCallback =
|
81
|
+
kNonTrivialFinalizer ? Finalize : nullptr;
|
82
|
+
};
|
83
|
+
|
84
|
+
template <typename T>
|
85
|
+
constexpr FinalizationCallback FinalizerTrait<T>::kCallback;
|
86
|
+
|
87
|
+
} // namespace internal
|
88
|
+
} // namespace cppgc
|
89
|
+
|
90
|
+
#endif // INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_
|
@@ -0,0 +1,47 @@
|
|
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_INTERNAL_GC_INFO_H_
|
6
|
+
#define INCLUDE_CPPGC_INTERNAL_GC_INFO_H_
|
7
|
+
|
8
|
+
#include <stdint.h>
|
9
|
+
|
10
|
+
#include "cppgc/internal/finalizer-trait.h"
|
11
|
+
#include "cppgc/internal/name-trait.h"
|
12
|
+
#include "cppgc/trace-trait.h"
|
13
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
14
|
+
|
15
|
+
namespace cppgc {
|
16
|
+
namespace internal {
|
17
|
+
|
18
|
+
using GCInfoIndex = uint16_t;
|
19
|
+
|
20
|
+
class V8_EXPORT RegisteredGCInfoIndex final {
|
21
|
+
public:
|
22
|
+
RegisteredGCInfoIndex(FinalizationCallback finalization_callback,
|
23
|
+
TraceCallback trace_callback,
|
24
|
+
NameCallback name_callback, bool has_v_table);
|
25
|
+
GCInfoIndex GetIndex() const { return index_; }
|
26
|
+
|
27
|
+
private:
|
28
|
+
const GCInfoIndex index_;
|
29
|
+
};
|
30
|
+
|
31
|
+
// Trait determines how the garbage collector treats objects wrt. to traversing,
|
32
|
+
// finalization, and naming.
|
33
|
+
template <typename T>
|
34
|
+
struct GCInfoTrait {
|
35
|
+
static GCInfoIndex Index() {
|
36
|
+
static_assert(sizeof(T), "T must be fully defined");
|
37
|
+
static const RegisteredGCInfoIndex registered_index(
|
38
|
+
FinalizerTrait<T>::kCallback, TraceTrait<T>::Trace,
|
39
|
+
NameTrait<T>::GetName, std::is_polymorphic<T>::value);
|
40
|
+
return registered_index.GetIndex();
|
41
|
+
}
|
42
|
+
};
|
43
|
+
|
44
|
+
} // namespace internal
|
45
|
+
} // namespace cppgc
|
46
|
+
|
47
|
+
#endif // INCLUDE_CPPGC_INTERNAL_GC_INFO_H_
|
@@ -0,0 +1,50 @@
|
|
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_INTERNAL_LOGGING_H_
|
6
|
+
#define INCLUDE_CPPGC_INTERNAL_LOGGING_H_
|
7
|
+
|
8
|
+
#include "cppgc/source-location.h"
|
9
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
10
|
+
|
11
|
+
namespace cppgc {
|
12
|
+
namespace internal {
|
13
|
+
|
14
|
+
void V8_EXPORT DCheckImpl(const char*,
|
15
|
+
const SourceLocation& = SourceLocation::Current());
|
16
|
+
[[noreturn]] void V8_EXPORT
|
17
|
+
FatalImpl(const char*, const SourceLocation& = SourceLocation::Current());
|
18
|
+
|
19
|
+
// Used to ignore -Wunused-variable.
|
20
|
+
template <typename>
|
21
|
+
struct EatParams {};
|
22
|
+
|
23
|
+
#if DEBUG
|
24
|
+
#define CPPGC_DCHECK_MSG(condition, message) \
|
25
|
+
do { \
|
26
|
+
if (V8_UNLIKELY(!(condition))) { \
|
27
|
+
::cppgc::internal::DCheckImpl(message); \
|
28
|
+
} \
|
29
|
+
} while (false)
|
30
|
+
#else
|
31
|
+
#define CPPGC_DCHECK_MSG(condition, message) \
|
32
|
+
(static_cast<void>(::cppgc::internal::EatParams<decltype( \
|
33
|
+
static_cast<void>(condition), message)>{}))
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#define CPPGC_DCHECK(condition) CPPGC_DCHECK_MSG(condition, #condition)
|
37
|
+
|
38
|
+
#define CPPGC_CHECK_MSG(condition, message) \
|
39
|
+
do { \
|
40
|
+
if (V8_UNLIKELY(!(condition))) { \
|
41
|
+
::cppgc::internal::FatalImpl(message); \
|
42
|
+
} \
|
43
|
+
} while (false)
|
44
|
+
|
45
|
+
#define CPPGC_CHECK(condition) CPPGC_CHECK_MSG(condition, #condition)
|
46
|
+
|
47
|
+
} // namespace internal
|
48
|
+
} // namespace cppgc
|
49
|
+
|
50
|
+
#endif // INCLUDE_CPPGC_INTERNAL_LOGGING_H_
|
@@ -0,0 +1,111 @@
|
|
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_INTERNAL_NAME_TRAIT_H_
|
6
|
+
#define INCLUDE_CPPGC_INTERNAL_NAME_TRAIT_H_
|
7
|
+
|
8
|
+
#include <cstddef>
|
9
|
+
|
10
|
+
#include "cppgc/name-provider.h"
|
11
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
12
|
+
|
13
|
+
namespace cppgc {
|
14
|
+
namespace internal {
|
15
|
+
|
16
|
+
#if CPPGC_SUPPORTS_OBJECT_NAMES && defined(__clang__)
|
17
|
+
#define CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME 1
|
18
|
+
|
19
|
+
// Provides constexpr c-string storage for a name of fixed |Size| characters.
|
20
|
+
// Automatically appends terminating 0 byte.
|
21
|
+
template <size_t Size>
|
22
|
+
struct NameBuffer {
|
23
|
+
char name[Size + 1]{};
|
24
|
+
|
25
|
+
static constexpr NameBuffer FromCString(const char* str) {
|
26
|
+
NameBuffer result;
|
27
|
+
for (size_t i = 0; i < Size; ++i) result.name[i] = str[i];
|
28
|
+
result.name[Size] = 0;
|
29
|
+
return result;
|
30
|
+
}
|
31
|
+
};
|
32
|
+
|
33
|
+
template <typename T>
|
34
|
+
const char* GetTypename() {
|
35
|
+
static constexpr char kSelfPrefix[] =
|
36
|
+
"const char *cppgc::internal::GetTypename() [T =";
|
37
|
+
static_assert(__builtin_strncmp(__PRETTY_FUNCTION__, kSelfPrefix,
|
38
|
+
sizeof(kSelfPrefix) - 1) == 0,
|
39
|
+
"The prefix must match");
|
40
|
+
static constexpr const char* kTypenameStart =
|
41
|
+
__PRETTY_FUNCTION__ + sizeof(kSelfPrefix);
|
42
|
+
static constexpr size_t kTypenameSize =
|
43
|
+
__builtin_strlen(__PRETTY_FUNCTION__) - sizeof(kSelfPrefix) - 1;
|
44
|
+
// NameBuffer is an indirection that is needed to make sure that only a
|
45
|
+
// substring of __PRETTY_FUNCTION__ gets materialized in the binary.
|
46
|
+
static constexpr auto buffer =
|
47
|
+
NameBuffer<kTypenameSize>::FromCString(kTypenameStart);
|
48
|
+
return buffer.name;
|
49
|
+
}
|
50
|
+
|
51
|
+
#else
|
52
|
+
#define CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME 0
|
53
|
+
#endif
|
54
|
+
|
55
|
+
struct HeapObjectName {
|
56
|
+
const char* value;
|
57
|
+
bool name_was_hidden;
|
58
|
+
};
|
59
|
+
|
60
|
+
class V8_EXPORT NameTraitBase {
|
61
|
+
protected:
|
62
|
+
static HeapObjectName GetNameFromTypeSignature(const char*);
|
63
|
+
};
|
64
|
+
|
65
|
+
// Trait that specifies how the garbage collector retrieves the name for a
|
66
|
+
// given object.
|
67
|
+
template <typename T>
|
68
|
+
class NameTrait final : public NameTraitBase {
|
69
|
+
public:
|
70
|
+
static HeapObjectName GetName(const void* obj) {
|
71
|
+
return GetNameFor(static_cast<const T*>(obj));
|
72
|
+
}
|
73
|
+
|
74
|
+
private:
|
75
|
+
static HeapObjectName GetNameFor(const NameProvider* name_provider) {
|
76
|
+
return {name_provider->GetName(), false};
|
77
|
+
}
|
78
|
+
|
79
|
+
static HeapObjectName GetNameFor(...) {
|
80
|
+
#if CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
|
81
|
+
return {GetTypename<T>(), false};
|
82
|
+
#elif CPPGC_SUPPORTS_OBJECT_NAMES
|
83
|
+
|
84
|
+
#if defined(V8_CC_GNU)
|
85
|
+
#define PRETTY_FUNCTION_VALUE __PRETTY_FUNCTION__
|
86
|
+
#elif defined(V8_CC_MSVC)
|
87
|
+
#define PRETTY_FUNCTION_VALUE __FUNCSIG__
|
88
|
+
#else
|
89
|
+
#define PRETTY_FUNCTION_VALUE nullptr
|
90
|
+
#endif
|
91
|
+
|
92
|
+
static const HeapObjectName leaky_name =
|
93
|
+
GetNameFromTypeSignature(PRETTY_FUNCTION_VALUE);
|
94
|
+
return leaky_name;
|
95
|
+
|
96
|
+
#undef PRETTY_FUNCTION_VALUE
|
97
|
+
|
98
|
+
#else // !CPPGC_SUPPORTS_OBJECT_NAMES
|
99
|
+
return {NameProvider::kHiddenName, true};
|
100
|
+
#endif // !CPPGC_SUPPORTS_OBJECT_NAMES
|
101
|
+
}
|
102
|
+
};
|
103
|
+
|
104
|
+
using NameCallback = HeapObjectName (*)(const void*);
|
105
|
+
|
106
|
+
} // namespace internal
|
107
|
+
} // namespace cppgc
|
108
|
+
|
109
|
+
#undef CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
|
110
|
+
|
111
|
+
#endif // INCLUDE_CPPGC_INTERNAL_NAME_TRAIT_H_
|
@@ -0,0 +1,132 @@
|
|
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_INTERNAL_PERSISTENT_NODE_H_
|
6
|
+
#define INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_
|
7
|
+
|
8
|
+
#include <array>
|
9
|
+
#include <memory>
|
10
|
+
#include <vector>
|
11
|
+
|
12
|
+
#include "cppgc/internal/logging.h"
|
13
|
+
#include "cppgc/trace-trait.h"
|
14
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
15
|
+
|
16
|
+
namespace cppgc {
|
17
|
+
|
18
|
+
class Visitor;
|
19
|
+
|
20
|
+
namespace internal {
|
21
|
+
|
22
|
+
// PersistentNode represents a variant of two states:
|
23
|
+
// 1) traceable node with a back pointer to the Persistent object;
|
24
|
+
// 2) freelist entry.
|
25
|
+
class PersistentNode final {
|
26
|
+
public:
|
27
|
+
PersistentNode() = default;
|
28
|
+
|
29
|
+
PersistentNode(const PersistentNode&) = delete;
|
30
|
+
PersistentNode& operator=(const PersistentNode&) = delete;
|
31
|
+
|
32
|
+
void InitializeAsUsedNode(void* owner, TraceCallback trace) {
|
33
|
+
owner_ = owner;
|
34
|
+
trace_ = trace;
|
35
|
+
}
|
36
|
+
|
37
|
+
void InitializeAsFreeNode(PersistentNode* next) {
|
38
|
+
next_ = next;
|
39
|
+
trace_ = nullptr;
|
40
|
+
}
|
41
|
+
|
42
|
+
void UpdateOwner(void* owner) {
|
43
|
+
CPPGC_DCHECK(IsUsed());
|
44
|
+
owner_ = owner;
|
45
|
+
}
|
46
|
+
|
47
|
+
PersistentNode* FreeListNext() const {
|
48
|
+
CPPGC_DCHECK(!IsUsed());
|
49
|
+
return next_;
|
50
|
+
}
|
51
|
+
|
52
|
+
void Trace(Visitor* visitor) const {
|
53
|
+
CPPGC_DCHECK(IsUsed());
|
54
|
+
trace_(visitor, owner_);
|
55
|
+
}
|
56
|
+
|
57
|
+
bool IsUsed() const { return trace_; }
|
58
|
+
|
59
|
+
void* owner() const {
|
60
|
+
CPPGC_DCHECK(IsUsed());
|
61
|
+
return owner_;
|
62
|
+
}
|
63
|
+
|
64
|
+
private:
|
65
|
+
// PersistentNode acts as a designated union:
|
66
|
+
// If trace_ != nullptr, owner_ points to the corresponding Persistent handle.
|
67
|
+
// Otherwise, next_ points to the next freed PersistentNode.
|
68
|
+
union {
|
69
|
+
void* owner_ = nullptr;
|
70
|
+
PersistentNode* next_;
|
71
|
+
};
|
72
|
+
TraceCallback trace_ = nullptr;
|
73
|
+
};
|
74
|
+
|
75
|
+
class V8_EXPORT PersistentRegion final {
|
76
|
+
using PersistentNodeSlots = std::array<PersistentNode, 256u>;
|
77
|
+
|
78
|
+
public:
|
79
|
+
PersistentRegion() = default;
|
80
|
+
// Clears Persistent fields to avoid stale pointers after heap teardown.
|
81
|
+
~PersistentRegion();
|
82
|
+
|
83
|
+
PersistentRegion(const PersistentRegion&) = delete;
|
84
|
+
PersistentRegion& operator=(const PersistentRegion&) = delete;
|
85
|
+
|
86
|
+
PersistentNode* AllocateNode(void* owner, TraceCallback trace) {
|
87
|
+
if (!free_list_head_) {
|
88
|
+
EnsureNodeSlots();
|
89
|
+
}
|
90
|
+
PersistentNode* node = free_list_head_;
|
91
|
+
free_list_head_ = free_list_head_->FreeListNext();
|
92
|
+
node->InitializeAsUsedNode(owner, trace);
|
93
|
+
nodes_in_use_++;
|
94
|
+
return node;
|
95
|
+
}
|
96
|
+
|
97
|
+
void FreeNode(PersistentNode* node) {
|
98
|
+
node->InitializeAsFreeNode(free_list_head_);
|
99
|
+
free_list_head_ = node;
|
100
|
+
CPPGC_DCHECK(nodes_in_use_ > 0);
|
101
|
+
nodes_in_use_--;
|
102
|
+
}
|
103
|
+
|
104
|
+
void Trace(Visitor*);
|
105
|
+
|
106
|
+
size_t NodesInUse() const;
|
107
|
+
|
108
|
+
void ClearAllUsedNodes();
|
109
|
+
|
110
|
+
private:
|
111
|
+
void EnsureNodeSlots();
|
112
|
+
|
113
|
+
std::vector<std::unique_ptr<PersistentNodeSlots>> nodes_;
|
114
|
+
PersistentNode* free_list_head_ = nullptr;
|
115
|
+
size_t nodes_in_use_ = 0;
|
116
|
+
};
|
117
|
+
|
118
|
+
// CrossThreadPersistent uses PersistentRegion but protects it using this lock
|
119
|
+
// when needed.
|
120
|
+
class V8_EXPORT PersistentRegionLock final {
|
121
|
+
public:
|
122
|
+
PersistentRegionLock();
|
123
|
+
~PersistentRegionLock();
|
124
|
+
|
125
|
+
static void AssertLocked();
|
126
|
+
};
|
127
|
+
|
128
|
+
} // namespace internal
|
129
|
+
|
130
|
+
} // namespace cppgc
|
131
|
+
|
132
|
+
#endif // INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_
|