forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwasi-cppheap-pointer-table-stub.h
More file actions
67 lines (53 loc) · 2.14 KB
/
wasi-cppheap-pointer-table-stub.h
File metadata and controls
67 lines (53 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef WASI_CPPHEAP_POINTER_TABLE_STUB_H_
#define WASI_CPPHEAP_POINTER_TABLE_STUB_H_
#ifdef __wasi__
#include <cstddef>
#include <cstdint>
namespace v8 {
namespace internal {
#ifndef V8_CPPHEAP_POINTER_HANDLE_TYPE_DEFINED
#define V8_CPPHEAP_POINTER_HANDLE_TYPE_DEFINED
using CppHeapPointerHandle = uint32_t;
#endif
#ifndef V8_NULL_CPPHEAP_POINTER_HANDLE_DEFINED
#define V8_NULL_CPPHEAP_POINTER_HANDLE_DEFINED
constexpr CppHeapPointerHandle kNullCppHeapPointerHandle = 0;
#endif
#ifndef V8_CPPHEAP_POINTER_TABLE_SIZE
#define V8_CPPHEAP_POINTER_TABLE_SIZE
constexpr size_t kCppHeapPointerTableReservationSize = 1024 * 1024; // 1MB
#endif
#ifndef V8_MAX_CPPHEAP_POINTERS
#define V8_MAX_CPPHEAP_POINTERS
constexpr size_t kMaxCppHeapPointers = 65536;
#endif
#ifndef V8_CPPHEAP_POINTER_SHIFTS_DEFINED
#define V8_CPPHEAP_POINTER_SHIFTS_DEFINED
constexpr int kCppHeapPointerIndexShift = 0;
constexpr int kCppHeapPointerPayloadShift = 1;
constexpr int kCppHeapPointerTagShift = 1;
#endif
#ifdef __wasi__
// Minimal stub entry type to satisfy template instantiations on WASI builds.
struct CppHeapPointerTableEntry {
inline void MakePointerEntry(Address /*value*/, CppHeapPointerTag /*tag*/, bool /*mark*/) {}
inline Address GetPointer(CppHeapPointerTagRange /*tag_range*/) const { return 0; }
inline void SetPointer(Address /*value*/, CppHeapPointerTag /*tag*/) {}
inline bool HasPointer(CppHeapPointerTagRange /*tag_range*/) const { return false; }
inline void MakeZappedEntry() {}
inline void MakeFreelistEntry(uint32_t /*next_entry_index*/) {}
inline uint32_t GetNextFreelistEntryIndex() const { return 0; }
inline void MakeEvacuationEntry(Address /*handle_location*/) {}
inline bool HasEvacuationEntry() const { return false; }
inline void Evacuate(CppHeapPointerTableEntry& /*dest*/) {}
inline void Mark() {}
static constexpr bool IsWriteProtected = false;
private:
uint64_t payload_ = 0; // keep size consistent with non-WASI builds
};
static_assert(sizeof(CppHeapPointerTableEntry) == 8, "WASI stub size must be 8");
#endif // __wasi__
} // namespace internal
} // namespace v8
#endif // __wasi__
#endif // WASI_CPPHEAP_POINTER_TABLE_STUB_H_