forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwasi-v8-api-stubs.h
More file actions
193 lines (150 loc) Β· 5.11 KB
/
wasi-v8-api-stubs.h
File metadata and controls
193 lines (150 loc) Β· 5.11 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#ifndef WASI_V8_API_STUBS_H_
#define WASI_V8_API_STUBS_H_
#include <memory>
#include <cstdint>
#include <cstddef>
// Comprehensive V8 API stubs for WASI build
// Additional cppgc namespace stubs (must be before v8 namespace)
// Only define if V8 headers haven't been included
#if !defined(CPPGC_STUBS_DEFINED) && !defined(INCLUDE_V8_CPPGC_H_) && !defined(INCLUDE_CPPGC_CUSTOM_SPACE_H_)
#define CPPGC_STUBS_DEFINED
namespace cppgc {
// Forward declarations only; real definitions come from cppgc headers.
class CustomSpaceBase;
} // namespace cppgc
#endif // CPPGC_STUBS_DEFINED
namespace v8 {
// Template forward declarations
template<typename T> class Local;
template<typename T> class MaybeLocal;
// Forward declarations - only declare if not already defined
class Isolate;
class Context;
class Value;
class Object;
class String;
class Function;
class Data;
class Template;
class FunctionTemplate;
class ObjectTemplate;
class EscapableHandleScope;
class TryCatch;
class Message;
class StackTrace;
class StackFrame;
class ScriptOrigin;
class Script;
class Name;
class Module;
class Promise;
class Proxy;
class WasmMemoryObject;
class WasmModuleObject;
class SharedArrayBuffer;
class ArrayBuffer;
class BackingStore;
class Boolean;
class Integer;
class Number;
class BigInt;
class Date;
class RegExp;
class External;
class Signature;
class AccessorSignature;
class Extension;
class Platform;
// SourceLocation is now defined in v8-source-location.h
// Missing QueryObjectPredicate for internal_only_v8.cc
#ifndef V8_QUERY_OBJECT_PREDICATE_DEFINED
#define V8_QUERY_OBJECT_PREDICATE_DEFINED
class QueryObjectPredicate {
public:
virtual ~QueryObjectPredicate() = default;
virtual bool Filter(Local<Object> object) = 0;
};
#endif // V8_QUERY_OBJECT_PREDICATE_DEFINED
// Note: Local and MaybeLocal are template classes that should be defined
// by V8 headers. We only provide stub implementations if they're missing.
// HandleScope stub - prevent redefinition, only define if not already defined
#if !defined(HANDLESCOPE_STUBS_DEFINED) && !defined(V8_HANDLESCOPE_DEFINED)
#define HANDLESCOPE_STUBS_DEFINED
#define V8_HANDLESCOPE_DEFINED
class HandleScope {
public:
explicit HandleScope(Isolate* isolate) {}
~HandleScope() = default;
HandleScope(const HandleScope&) = delete;
void operator=(const HandleScope&) = delete;
static int NumberOfHandles(Isolate* isolate) { return 0; }
Isolate* GetIsolate() const { return nullptr; }
};
// EscapableHandleScope stub
class EscapableHandleScope : public HandleScope {
public:
explicit EscapableHandleScope(Isolate* isolate) : HandleScope(isolate) {}
~EscapableHandleScope() = default;
template <typename T>
Local<T> Escape(Local<T> value) { return value; }
template <typename T>
MaybeLocal<T> EscapeMaybe(MaybeLocal<T> value) { return value; }
};
#endif // HANDLESCOPE_STUBS_DEFINED
// Note: CppHeap and CppHeapCreateParams are provided by V8 headers
// Context methods are defined inline in V8 headers
// Internal namespace additions
namespace internal {
// Forward declarations for internal types
class Isolate;
// PtrComprCageBase is defined in V8 globals.h
// Basic types
#ifndef V8_HAS_ADDRESS_TYPE
using Address = uintptr_t;
#endif
// Note: Internal functions are defined in other WASI compatibility files
// - ShouldThrowOnError is defined in nuclear-fix.h
// - PointerCompressionIsEnabled and SandboxIsEnabled are defined in wasi-v8-initialization-functions.h
// Note: HeapProfiler class is provided by V8 headers
// Note: External pointer tags and table constants are provided by
// deps/v8/include/wasi/nuclear-fix.h
// V8 slot and smi value operations
#ifndef kApiSystemPointerSize
constexpr int kApiSystemPointerSize = sizeof(void*);
#endif
#ifndef kApiDoubleSize
constexpr int kApiDoubleSize = sizeof(double);
#endif
// kApiInt32Size and kApiInt64Size are already defined in v8-wasi-compat.h
// constexpr int kApiInt32Size = sizeof(int32_t);
// constexpr int kApiInt64Size = sizeof(int64_t);
#ifndef kApiSizetSize
constexpr int kApiSizetSize = sizeof(size_t);
#endif
// V8 object slots - only define if not already defined
#ifndef kApiTaggedSize
constexpr int kApiTaggedSize = kApiSystemPointerSize;
#endif
#if !defined(V8_WASI_NUCLEAR_PROVIDES_SMI)
// kSmiTagSize needs to be defined for the code below
constexpr int kSmiTagSize = 1;
// Note: kSmiTagMask is defined in wasi-v8-flags-fix.h
inline int SmiValue(Address value) {
return static_cast<int32_t>(static_cast<intptr_t>(value)) >> kSmiTagSize;
}
// Embedder slot operations
inline void IncrementLongTasksStatsCounter(::v8::Isolate* isolate) {}
inline ::v8::Isolate* TryGetCurrent() { return nullptr; }
// ReadExternalPointerField - stub implementation
template <bool check_statically_enabled>
inline Address ReadExternalPointerField(Address field_address,
const void* cage_base,
ExternalPointerTag tag) {
return 0;
}
#endif // !V8_WASI_NUCLEAR_PROVIDES_SMI
// Isolate methods are defined in V8 headers
} // namespace internal
// Note: Isolate stub methods like New() and SetIdle() are defined in v8-isolate-wasi-ext.h
} // namespace v8
#endif // WASI_V8_API_STUBS_H_