libv8-node 16.17.0.0-aarch64-linux → 17.9.1.0-aarch64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libv8-node/paths.rb +1 -1
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/aarch64-linux/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/allocation.h +11 -5
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +78 -26
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +2 -2
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +2 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +90 -10
- data/vendor/v8/include/cppgc/internal/name-trait.h +11 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +44 -12
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +22 -11
- data/vendor/v8/include/cppgc/internal/write-barrier.h +9 -1
- data/vendor/v8/include/cppgc/persistent.h +1 -1
- data/vendor/v8/include/cppgc/prefinalizer.h +1 -1
- data/vendor/v8/include/v8-array-buffer.h +433 -0
- data/vendor/v8/include/v8-callbacks.h +377 -0
- data/vendor/v8/include/v8-container.h +129 -0
- data/vendor/v8/include/v8-context.h +418 -0
- data/vendor/v8/include/v8-cppgc.h +5 -2
- data/vendor/v8/include/v8-data.h +65 -0
- data/vendor/v8/include/v8-date.h +43 -0
- data/vendor/v8/include/v8-debug.h +151 -0
- data/vendor/v8/include/v8-embedder-heap.h +238 -0
- data/vendor/v8/include/v8-exception.h +224 -0
- data/vendor/v8/include/v8-extension.h +62 -0
- data/vendor/v8/include/v8-external.h +37 -0
- data/vendor/v8/include/v8-fast-api-calls.h +63 -11
- data/vendor/v8/include/v8-forward.h +81 -0
- data/vendor/v8/include/v8-function-callback.h +475 -0
- data/vendor/v8/include/v8-function.h +122 -0
- data/vendor/v8/include/v8-initialization.h +282 -0
- data/vendor/v8/include/v8-inspector.h +11 -21
- data/vendor/v8/include/v8-internal.h +85 -22
- data/vendor/v8/include/v8-isolate.h +1662 -0
- data/vendor/v8/include/v8-json.h +47 -0
- data/vendor/v8/include/v8-local-handle.h +459 -0
- data/vendor/v8/include/v8-locker.h +148 -0
- data/vendor/v8/include/v8-maybe.h +137 -0
- data/vendor/v8/include/v8-memory-span.h +43 -0
- data/vendor/v8/include/v8-message.h +241 -0
- data/vendor/v8/include/v8-metrics.h +37 -1
- data/vendor/v8/include/v8-microtask-queue.h +152 -0
- data/vendor/v8/include/v8-microtask.h +28 -0
- data/vendor/v8/include/v8-object.h +770 -0
- data/vendor/v8/include/v8-persistent-handle.h +590 -0
- data/vendor/v8/include/v8-platform.h +41 -17
- data/vendor/v8/include/v8-primitive-object.h +118 -0
- data/vendor/v8/include/v8-primitive.h +858 -0
- data/vendor/v8/include/v8-profiler.h +10 -11
- data/vendor/v8/include/v8-promise.h +174 -0
- data/vendor/v8/include/v8-proxy.h +50 -0
- data/vendor/v8/include/v8-regexp.h +105 -0
- data/vendor/v8/include/v8-script.h +771 -0
- data/vendor/v8/include/v8-snapshot.h +198 -0
- data/vendor/v8/include/v8-statistics.h +215 -0
- data/vendor/v8/include/v8-template.h +1052 -0
- data/vendor/v8/include/v8-traced-handle.h +605 -0
- data/vendor/v8/include/v8-typed-array.h +282 -0
- data/vendor/v8/include/v8-unwinder-state.h +4 -3
- data/vendor/v8/include/v8-unwinder.h +129 -0
- data/vendor/v8/include/v8-util.h +7 -1
- data/vendor/v8/include/v8-value-serializer.h +249 -0
- data/vendor/v8/include/v8-value.h +526 -0
- data/vendor/v8/include/v8-version.h +3 -3
- data/vendor/v8/include/v8-wasm.h +245 -0
- data/vendor/v8/include/v8-weak-callback-info.h +73 -0
- data/vendor/v8/include/v8.h +41 -12604
- metadata +45 -3
@@ -0,0 +1,418 @@
|
|
1
|
+
// Copyright 2021 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_V8_CONTEXT_H_
|
6
|
+
#define INCLUDE_V8_CONTEXT_H_
|
7
|
+
|
8
|
+
#include <stdint.h>
|
9
|
+
|
10
|
+
#include "v8-data.h" // NOLINT(build/include_directory)
|
11
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
12
|
+
#include "v8-snapshot.h" // NOLINT(build/include_directory)
|
13
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
14
|
+
|
15
|
+
namespace v8 {
|
16
|
+
|
17
|
+
class Function;
|
18
|
+
class MicrotaskQueue;
|
19
|
+
class Object;
|
20
|
+
class ObjectTemplate;
|
21
|
+
class Value;
|
22
|
+
class String;
|
23
|
+
|
24
|
+
/**
|
25
|
+
* A container for extension names.
|
26
|
+
*/
|
27
|
+
class V8_EXPORT ExtensionConfiguration {
|
28
|
+
public:
|
29
|
+
ExtensionConfiguration() : name_count_(0), names_(nullptr) {}
|
30
|
+
ExtensionConfiguration(int name_count, const char* names[])
|
31
|
+
: name_count_(name_count), names_(names) {}
|
32
|
+
|
33
|
+
const char** begin() const { return &names_[0]; }
|
34
|
+
const char** end() const { return &names_[name_count_]; }
|
35
|
+
|
36
|
+
private:
|
37
|
+
const int name_count_;
|
38
|
+
const char** names_;
|
39
|
+
};
|
40
|
+
|
41
|
+
/**
|
42
|
+
* A sandboxed execution context with its own set of built-in objects
|
43
|
+
* and functions.
|
44
|
+
*/
|
45
|
+
class V8_EXPORT Context : public Data {
|
46
|
+
public:
|
47
|
+
/**
|
48
|
+
* Returns the global proxy object.
|
49
|
+
*
|
50
|
+
* Global proxy object is a thin wrapper whose prototype points to actual
|
51
|
+
* context's global object with the properties like Object, etc. This is done
|
52
|
+
* that way for security reasons (for more details see
|
53
|
+
* https://wiki.mozilla.org/Gecko:SplitWindow).
|
54
|
+
*
|
55
|
+
* Please note that changes to global proxy object prototype most probably
|
56
|
+
* would break VM---v8 expects only global object as a prototype of global
|
57
|
+
* proxy object.
|
58
|
+
*/
|
59
|
+
Local<Object> Global();
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Detaches the global object from its context before
|
63
|
+
* the global object can be reused to create a new context.
|
64
|
+
*/
|
65
|
+
void DetachGlobal();
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Creates a new context and returns a handle to the newly allocated
|
69
|
+
* context.
|
70
|
+
*
|
71
|
+
* \param isolate The isolate in which to create the context.
|
72
|
+
*
|
73
|
+
* \param extensions An optional extension configuration containing
|
74
|
+
* the extensions to be installed in the newly created context.
|
75
|
+
*
|
76
|
+
* \param global_template An optional object template from which the
|
77
|
+
* global object for the newly created context will be created.
|
78
|
+
*
|
79
|
+
* \param global_object An optional global object to be reused for
|
80
|
+
* the newly created context. This global object must have been
|
81
|
+
* created by a previous call to Context::New with the same global
|
82
|
+
* template. The state of the global object will be completely reset
|
83
|
+
* and only object identify will remain.
|
84
|
+
*/
|
85
|
+
static Local<Context> New(
|
86
|
+
Isolate* isolate, ExtensionConfiguration* extensions = nullptr,
|
87
|
+
MaybeLocal<ObjectTemplate> global_template = MaybeLocal<ObjectTemplate>(),
|
88
|
+
MaybeLocal<Value> global_object = MaybeLocal<Value>(),
|
89
|
+
DeserializeInternalFieldsCallback internal_fields_deserializer =
|
90
|
+
DeserializeInternalFieldsCallback(),
|
91
|
+
MicrotaskQueue* microtask_queue = nullptr);
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Create a new context from a (non-default) context snapshot. There
|
95
|
+
* is no way to provide a global object template since we do not create
|
96
|
+
* a new global object from template, but we can reuse a global object.
|
97
|
+
*
|
98
|
+
* \param isolate See v8::Context::New.
|
99
|
+
*
|
100
|
+
* \param context_snapshot_index The index of the context snapshot to
|
101
|
+
* deserialize from. Use v8::Context::New for the default snapshot.
|
102
|
+
*
|
103
|
+
* \param embedder_fields_deserializer Optional callback to deserialize
|
104
|
+
* internal fields. It should match the SerializeInternalFieldCallback used
|
105
|
+
* to serialize.
|
106
|
+
*
|
107
|
+
* \param extensions See v8::Context::New.
|
108
|
+
*
|
109
|
+
* \param global_object See v8::Context::New.
|
110
|
+
*/
|
111
|
+
static MaybeLocal<Context> FromSnapshot(
|
112
|
+
Isolate* isolate, size_t context_snapshot_index,
|
113
|
+
DeserializeInternalFieldsCallback embedder_fields_deserializer =
|
114
|
+
DeserializeInternalFieldsCallback(),
|
115
|
+
ExtensionConfiguration* extensions = nullptr,
|
116
|
+
MaybeLocal<Value> global_object = MaybeLocal<Value>(),
|
117
|
+
MicrotaskQueue* microtask_queue = nullptr);
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Returns an global object that isn't backed by an actual context.
|
121
|
+
*
|
122
|
+
* The global template needs to have access checks with handlers installed.
|
123
|
+
* If an existing global object is passed in, the global object is detached
|
124
|
+
* from its context.
|
125
|
+
*
|
126
|
+
* Note that this is different from a detached context where all accesses to
|
127
|
+
* the global proxy will fail. Instead, the access check handlers are invoked.
|
128
|
+
*
|
129
|
+
* It is also not possible to detach an object returned by this method.
|
130
|
+
* Instead, the access check handlers need to return nothing to achieve the
|
131
|
+
* same effect.
|
132
|
+
*
|
133
|
+
* It is possible, however, to create a new context from the global object
|
134
|
+
* returned by this method.
|
135
|
+
*/
|
136
|
+
static MaybeLocal<Object> NewRemoteContext(
|
137
|
+
Isolate* isolate, Local<ObjectTemplate> global_template,
|
138
|
+
MaybeLocal<Value> global_object = MaybeLocal<Value>());
|
139
|
+
|
140
|
+
/**
|
141
|
+
* Sets the security token for the context. To access an object in
|
142
|
+
* another context, the security tokens must match.
|
143
|
+
*/
|
144
|
+
void SetSecurityToken(Local<Value> token);
|
145
|
+
|
146
|
+
/** Restores the security token to the default value. */
|
147
|
+
void UseDefaultSecurityToken();
|
148
|
+
|
149
|
+
/** Returns the security token of this context.*/
|
150
|
+
Local<Value> GetSecurityToken();
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Enter this context. After entering a context, all code compiled
|
154
|
+
* and run is compiled and run in this context. If another context
|
155
|
+
* is already entered, this old context is saved so it can be
|
156
|
+
* restored when the new context is exited.
|
157
|
+
*/
|
158
|
+
void Enter();
|
159
|
+
|
160
|
+
/**
|
161
|
+
* Exit this context. Exiting the current context restores the
|
162
|
+
* context that was in place when entering the current context.
|
163
|
+
*/
|
164
|
+
void Exit();
|
165
|
+
|
166
|
+
/** Returns the isolate associated with a current context. */
|
167
|
+
Isolate* GetIsolate();
|
168
|
+
|
169
|
+
/** Returns the microtask queue associated with a current context. */
|
170
|
+
MicrotaskQueue* GetMicrotaskQueue();
|
171
|
+
|
172
|
+
/**
|
173
|
+
* The field at kDebugIdIndex used to be reserved for the inspector.
|
174
|
+
* It now serves no purpose.
|
175
|
+
*/
|
176
|
+
enum EmbedderDataFields { kDebugIdIndex = 0 };
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Return the number of fields allocated for embedder data.
|
180
|
+
*/
|
181
|
+
uint32_t GetNumberOfEmbedderDataFields();
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Gets the embedder data with the given index, which must have been set by a
|
185
|
+
* previous call to SetEmbedderData with the same index.
|
186
|
+
*/
|
187
|
+
V8_INLINE Local<Value> GetEmbedderData(int index);
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Gets the binding object used by V8 extras. Extra natives get a reference
|
191
|
+
* to this object and can use it to "export" functionality by adding
|
192
|
+
* properties. Extra natives can also "import" functionality by accessing
|
193
|
+
* properties added by the embedder using the V8 API.
|
194
|
+
*/
|
195
|
+
Local<Object> GetExtrasBindingObject();
|
196
|
+
|
197
|
+
/**
|
198
|
+
* Sets the embedder data with the given index, growing the data as
|
199
|
+
* needed. Note that index 0 currently has a special meaning for Chrome's
|
200
|
+
* debugger.
|
201
|
+
*/
|
202
|
+
void SetEmbedderData(int index, Local<Value> value);
|
203
|
+
|
204
|
+
/**
|
205
|
+
* Gets a 2-byte-aligned native pointer from the embedder data with the given
|
206
|
+
* index, which must have been set by a previous call to
|
207
|
+
* SetAlignedPointerInEmbedderData with the same index. Note that index 0
|
208
|
+
* currently has a special meaning for Chrome's debugger.
|
209
|
+
*/
|
210
|
+
V8_INLINE void* GetAlignedPointerFromEmbedderData(int index);
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Sets a 2-byte-aligned native pointer in the embedder data with the given
|
214
|
+
* index, growing the data as needed. Note that index 0 currently has a
|
215
|
+
* special meaning for Chrome's debugger.
|
216
|
+
*/
|
217
|
+
void SetAlignedPointerInEmbedderData(int index, void* value);
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Control whether code generation from strings is allowed. Calling
|
221
|
+
* this method with false will disable 'eval' and the 'Function'
|
222
|
+
* constructor for code running in this context. If 'eval' or the
|
223
|
+
* 'Function' constructor are used an exception will be thrown.
|
224
|
+
*
|
225
|
+
* If code generation from strings is not allowed the
|
226
|
+
* V8::AllowCodeGenerationFromStrings callback will be invoked if
|
227
|
+
* set before blocking the call to 'eval' or the 'Function'
|
228
|
+
* constructor. If that callback returns true, the call will be
|
229
|
+
* allowed, otherwise an exception will be thrown. If no callback is
|
230
|
+
* set an exception will be thrown.
|
231
|
+
*/
|
232
|
+
void AllowCodeGenerationFromStrings(bool allow);
|
233
|
+
|
234
|
+
/**
|
235
|
+
* Returns true if code generation from strings is allowed for the context.
|
236
|
+
* For more details see AllowCodeGenerationFromStrings(bool) documentation.
|
237
|
+
*/
|
238
|
+
bool IsCodeGenerationFromStringsAllowed() const;
|
239
|
+
|
240
|
+
/**
|
241
|
+
* Sets the error description for the exception that is thrown when
|
242
|
+
* code generation from strings is not allowed and 'eval' or the 'Function'
|
243
|
+
* constructor are called.
|
244
|
+
*/
|
245
|
+
void SetErrorMessageForCodeGenerationFromStrings(Local<String> message);
|
246
|
+
|
247
|
+
/**
|
248
|
+
* Return data that was previously attached to the context snapshot via
|
249
|
+
* SnapshotCreator, and removes the reference to it.
|
250
|
+
* Repeated call with the same index returns an empty MaybeLocal.
|
251
|
+
*/
|
252
|
+
template <class T>
|
253
|
+
V8_INLINE MaybeLocal<T> GetDataFromSnapshotOnce(size_t index);
|
254
|
+
|
255
|
+
/**
|
256
|
+
* If callback is set, abort any attempt to execute JavaScript in this
|
257
|
+
* context, call the specified callback, and throw an exception.
|
258
|
+
* To unset abort, pass nullptr as callback.
|
259
|
+
*/
|
260
|
+
using AbortScriptExecutionCallback = void (*)(Isolate* isolate,
|
261
|
+
Local<Context> context);
|
262
|
+
void SetAbortScriptExecution(AbortScriptExecutionCallback callback);
|
263
|
+
|
264
|
+
/**
|
265
|
+
* Returns the value that was set or restored by
|
266
|
+
* SetContinuationPreservedEmbedderData(), if any.
|
267
|
+
*/
|
268
|
+
Local<Value> GetContinuationPreservedEmbedderData() const;
|
269
|
+
|
270
|
+
/**
|
271
|
+
* Sets a value that will be stored on continuations and reset while the
|
272
|
+
* continuation runs.
|
273
|
+
*/
|
274
|
+
void SetContinuationPreservedEmbedderData(Local<Value> context);
|
275
|
+
|
276
|
+
/**
|
277
|
+
* Set or clear hooks to be invoked for promise lifecycle operations.
|
278
|
+
* To clear a hook, set it to an empty v8::Function. Each function will
|
279
|
+
* receive the observed promise as the first argument. If a chaining
|
280
|
+
* operation is used on a promise, the init will additionally receive
|
281
|
+
* the parent promise as the second argument.
|
282
|
+
*/
|
283
|
+
void SetPromiseHooks(Local<Function> init_hook, Local<Function> before_hook,
|
284
|
+
Local<Function> after_hook,
|
285
|
+
Local<Function> resolve_hook);
|
286
|
+
|
287
|
+
/**
|
288
|
+
* Stack-allocated class which sets the execution context for all
|
289
|
+
* operations executed within a local scope.
|
290
|
+
*/
|
291
|
+
class V8_NODISCARD Scope {
|
292
|
+
public:
|
293
|
+
explicit V8_INLINE Scope(Local<Context> context) : context_(context) {
|
294
|
+
context_->Enter();
|
295
|
+
}
|
296
|
+
V8_INLINE ~Scope() { context_->Exit(); }
|
297
|
+
|
298
|
+
private:
|
299
|
+
Local<Context> context_;
|
300
|
+
};
|
301
|
+
|
302
|
+
/**
|
303
|
+
* Stack-allocated class to support the backup incumbent settings object
|
304
|
+
* stack.
|
305
|
+
* https://html.spec.whatwg.org/multipage/webappapis.html#backup-incumbent-settings-object-stack
|
306
|
+
*/
|
307
|
+
class V8_EXPORT V8_NODISCARD BackupIncumbentScope final {
|
308
|
+
public:
|
309
|
+
/**
|
310
|
+
* |backup_incumbent_context| is pushed onto the backup incumbent settings
|
311
|
+
* object stack.
|
312
|
+
*/
|
313
|
+
explicit BackupIncumbentScope(Local<Context> backup_incumbent_context);
|
314
|
+
~BackupIncumbentScope();
|
315
|
+
|
316
|
+
/**
|
317
|
+
* Returns address that is comparable with JS stack address. Note that JS
|
318
|
+
* stack may be allocated separately from the native stack. See also
|
319
|
+
* |TryCatch::JSStackComparableAddressPrivate| for details.
|
320
|
+
*/
|
321
|
+
V8_DEPRECATE_SOON(
|
322
|
+
"This is private V8 information that should not be exposed in the API.")
|
323
|
+
uintptr_t JSStackComparableAddress() const {
|
324
|
+
return JSStackComparableAddressPrivate();
|
325
|
+
}
|
326
|
+
|
327
|
+
private:
|
328
|
+
friend class internal::Isolate;
|
329
|
+
|
330
|
+
uintptr_t JSStackComparableAddressPrivate() const {
|
331
|
+
return js_stack_comparable_address_;
|
332
|
+
}
|
333
|
+
|
334
|
+
Local<Context> backup_incumbent_context_;
|
335
|
+
uintptr_t js_stack_comparable_address_ = 0;
|
336
|
+
const BackupIncumbentScope* prev_ = nullptr;
|
337
|
+
};
|
338
|
+
|
339
|
+
V8_INLINE static Context* Cast(Data* data);
|
340
|
+
|
341
|
+
private:
|
342
|
+
friend class Value;
|
343
|
+
friend class Script;
|
344
|
+
friend class Object;
|
345
|
+
friend class Function;
|
346
|
+
|
347
|
+
static void CheckCast(Data* obj);
|
348
|
+
|
349
|
+
internal::Address* GetDataFromSnapshotOnce(size_t index);
|
350
|
+
Local<Value> SlowGetEmbedderData(int index);
|
351
|
+
void* SlowGetAlignedPointerFromEmbedderData(int index);
|
352
|
+
};
|
353
|
+
|
354
|
+
// --- Implementation ---
|
355
|
+
|
356
|
+
Local<Value> Context::GetEmbedderData(int index) {
|
357
|
+
#ifndef V8_ENABLE_CHECKS
|
358
|
+
using A = internal::Address;
|
359
|
+
using I = internal::Internals;
|
360
|
+
A ctx = *reinterpret_cast<const A*>(this);
|
361
|
+
A embedder_data =
|
362
|
+
I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
|
363
|
+
int value_offset =
|
364
|
+
I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index);
|
365
|
+
A value = I::ReadRawField<A>(embedder_data, value_offset);
|
366
|
+
#ifdef V8_COMPRESS_POINTERS
|
367
|
+
// We read the full pointer value and then decompress it in order to avoid
|
368
|
+
// dealing with potential endiannes issues.
|
369
|
+
value =
|
370
|
+
I::DecompressTaggedAnyField(embedder_data, static_cast<uint32_t>(value));
|
371
|
+
#endif
|
372
|
+
internal::Isolate* isolate = internal::IsolateFromNeverReadOnlySpaceObject(
|
373
|
+
*reinterpret_cast<A*>(this));
|
374
|
+
A* result = HandleScope::CreateHandle(isolate, value);
|
375
|
+
return Local<Value>(reinterpret_cast<Value*>(result));
|
376
|
+
#else
|
377
|
+
return SlowGetEmbedderData(index);
|
378
|
+
#endif
|
379
|
+
}
|
380
|
+
|
381
|
+
void* Context::GetAlignedPointerFromEmbedderData(int index) {
|
382
|
+
#ifndef V8_ENABLE_CHECKS
|
383
|
+
using A = internal::Address;
|
384
|
+
using I = internal::Internals;
|
385
|
+
A ctx = *reinterpret_cast<const A*>(this);
|
386
|
+
A embedder_data =
|
387
|
+
I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
|
388
|
+
int value_offset =
|
389
|
+
I::kEmbedderDataArrayHeaderSize + (I::kEmbedderDataSlotSize * index);
|
390
|
+
#ifdef V8_HEAP_SANDBOX
|
391
|
+
value_offset += I::kEmbedderDataSlotRawPayloadOffset;
|
392
|
+
#endif
|
393
|
+
internal::Isolate* isolate = I::GetIsolateForHeapSandbox(ctx);
|
394
|
+
return reinterpret_cast<void*>(
|
395
|
+
I::ReadExternalPointerField(isolate, embedder_data, value_offset,
|
396
|
+
internal::kEmbedderDataSlotPayloadTag));
|
397
|
+
#else
|
398
|
+
return SlowGetAlignedPointerFromEmbedderData(index);
|
399
|
+
#endif
|
400
|
+
}
|
401
|
+
|
402
|
+
template <class T>
|
403
|
+
MaybeLocal<T> Context::GetDataFromSnapshotOnce(size_t index) {
|
404
|
+
T* data = reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
|
405
|
+
if (data) internal::PerformCastCheck(data);
|
406
|
+
return Local<T>(data);
|
407
|
+
}
|
408
|
+
|
409
|
+
Context* Context::Cast(v8::Data* data) {
|
410
|
+
#ifdef V8_ENABLE_CHECKS
|
411
|
+
CheckCast(data);
|
412
|
+
#endif
|
413
|
+
return static_cast<Context*>(data);
|
414
|
+
}
|
415
|
+
|
416
|
+
} // namespace v8
|
417
|
+
|
418
|
+
#endif // INCLUDE_V8_CONTEXT_H_
|
@@ -14,8 +14,9 @@
|
|
14
14
|
#include "cppgc/heap-statistics.h"
|
15
15
|
#include "cppgc/internal/write-barrier.h"
|
16
16
|
#include "cppgc/visitor.h"
|
17
|
-
#include "v8-internal.h"
|
18
|
-
#include "v8.h"
|
17
|
+
#include "v8-internal.h" // NOLINT(build/include_directory)
|
18
|
+
#include "v8-platform.h" // NOLINT(build/include_directory)
|
19
|
+
#include "v8-traced-handle.h" // NOLINT(build/include_directory)
|
19
20
|
|
20
21
|
namespace cppgc {
|
21
22
|
class AllocationHandle;
|
@@ -24,6 +25,8 @@ class HeapHandle;
|
|
24
25
|
|
25
26
|
namespace v8 {
|
26
27
|
|
28
|
+
class Object;
|
29
|
+
|
27
30
|
namespace internal {
|
28
31
|
class CppHeap;
|
29
32
|
} // namespace internal
|
@@ -0,0 +1,65 @@
|
|
1
|
+
// Copyright 2021 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_V8_DATA_H_
|
6
|
+
#define INCLUDE_V8_DATA_H_
|
7
|
+
|
8
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
9
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
10
|
+
|
11
|
+
namespace v8 {
|
12
|
+
|
13
|
+
class Context;
|
14
|
+
|
15
|
+
/**
|
16
|
+
* The superclass of objects that can reside on V8's heap.
|
17
|
+
*/
|
18
|
+
class V8_EXPORT Data {
|
19
|
+
public:
|
20
|
+
/**
|
21
|
+
* Returns true if this data is a |v8::Value|.
|
22
|
+
*/
|
23
|
+
bool IsValue() const;
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Returns true if this data is a |v8::Module|.
|
27
|
+
*/
|
28
|
+
bool IsModule() const;
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Returns true if this data is a |v8::Private|.
|
32
|
+
*/
|
33
|
+
bool IsPrivate() const;
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Returns true if this data is a |v8::ObjectTemplate|.
|
37
|
+
*/
|
38
|
+
bool IsObjectTemplate() const;
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Returns true if this data is a |v8::FunctionTemplate|.
|
42
|
+
*/
|
43
|
+
bool IsFunctionTemplate() const;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Returns true if this data is a |v8::Context|.
|
47
|
+
*/
|
48
|
+
bool IsContext() const;
|
49
|
+
|
50
|
+
private:
|
51
|
+
Data();
|
52
|
+
};
|
53
|
+
|
54
|
+
/**
|
55
|
+
* A fixed-sized array with elements of type Data.
|
56
|
+
*/
|
57
|
+
class V8_EXPORT FixedArray : public Data {
|
58
|
+
public:
|
59
|
+
int Length() const;
|
60
|
+
Local<Data> Get(Local<Context> context, int i) const;
|
61
|
+
};
|
62
|
+
|
63
|
+
} // namespace v8
|
64
|
+
|
65
|
+
#endif // INCLUDE_V8_DATA_H_
|
@@ -0,0 +1,43 @@
|
|
1
|
+
// Copyright 2021 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_V8_DATE_H_
|
6
|
+
#define INCLUDE_V8_DATE_H_
|
7
|
+
|
8
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
9
|
+
#include "v8-object.h" // NOLINT(build/include_directory)
|
10
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
11
|
+
|
12
|
+
namespace v8 {
|
13
|
+
|
14
|
+
class Context;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* An instance of the built-in Date constructor (ECMA-262, 15.9).
|
18
|
+
*/
|
19
|
+
class V8_EXPORT Date : public Object {
|
20
|
+
public:
|
21
|
+
static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context,
|
22
|
+
double time);
|
23
|
+
|
24
|
+
/**
|
25
|
+
* A specialization of Value::NumberValue that is more efficient
|
26
|
+
* because we know the structure of this object.
|
27
|
+
*/
|
28
|
+
double ValueOf() const;
|
29
|
+
|
30
|
+
V8_INLINE static Date* Cast(Value* value) {
|
31
|
+
#ifdef V8_ENABLE_CHECKS
|
32
|
+
CheckCast(value);
|
33
|
+
#endif
|
34
|
+
return static_cast<Date*>(value);
|
35
|
+
}
|
36
|
+
|
37
|
+
private:
|
38
|
+
static void CheckCast(Value* obj);
|
39
|
+
};
|
40
|
+
|
41
|
+
} // namespace v8
|
42
|
+
|
43
|
+
#endif // INCLUDE_V8_DATE_H_
|
@@ -0,0 +1,151 @@
|
|
1
|
+
// Copyright 2021 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_V8_DEBUG_H_
|
6
|
+
#define INCLUDE_V8_DEBUG_H_
|
7
|
+
|
8
|
+
#include <stdint.h>
|
9
|
+
|
10
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
11
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
12
|
+
|
13
|
+
namespace v8 {
|
14
|
+
|
15
|
+
class Isolate;
|
16
|
+
class String;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* A single JavaScript stack frame.
|
20
|
+
*/
|
21
|
+
class V8_EXPORT StackFrame {
|
22
|
+
public:
|
23
|
+
/**
|
24
|
+
* Returns the number, 1-based, of the line for the associate function call.
|
25
|
+
* This method will return Message::kNoLineNumberInfo if it is unable to
|
26
|
+
* retrieve the line number, or if kLineNumber was not passed as an option
|
27
|
+
* when capturing the StackTrace.
|
28
|
+
*/
|
29
|
+
int GetLineNumber() const;
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Returns the 1-based column offset on the line for the associated function
|
33
|
+
* call.
|
34
|
+
* This method will return Message::kNoColumnInfo if it is unable to retrieve
|
35
|
+
* the column number, or if kColumnOffset was not passed as an option when
|
36
|
+
* capturing the StackTrace.
|
37
|
+
*/
|
38
|
+
int GetColumn() const;
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Returns the id of the script for the function for this StackFrame.
|
42
|
+
* This method will return Message::kNoScriptIdInfo if it is unable to
|
43
|
+
* retrieve the script id, or if kScriptId was not passed as an option when
|
44
|
+
* capturing the StackTrace.
|
45
|
+
*/
|
46
|
+
int GetScriptId() const;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Returns the name of the resource that contains the script for the
|
50
|
+
* function for this StackFrame.
|
51
|
+
*/
|
52
|
+
Local<String> GetScriptName() const;
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Returns the name of the resource that contains the script for the
|
56
|
+
* function for this StackFrame or sourceURL value if the script name
|
57
|
+
* is undefined and its source ends with //# sourceURL=... string or
|
58
|
+
* deprecated //@ sourceURL=... string.
|
59
|
+
*/
|
60
|
+
Local<String> GetScriptNameOrSourceURL() const;
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Returns the source of the script for the function for this StackFrame.
|
64
|
+
*/
|
65
|
+
Local<String> GetScriptSource() const;
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Returns the source mapping URL (if one is present) of the script for
|
69
|
+
* the function for this StackFrame.
|
70
|
+
*/
|
71
|
+
Local<String> GetScriptSourceMappingURL() const;
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Returns the name of the function associated with this stack frame.
|
75
|
+
*/
|
76
|
+
Local<String> GetFunctionName() const;
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Returns whether or not the associated function is compiled via a call to
|
80
|
+
* eval().
|
81
|
+
*/
|
82
|
+
bool IsEval() const;
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Returns whether or not the associated function is called as a
|
86
|
+
* constructor via "new".
|
87
|
+
*/
|
88
|
+
bool IsConstructor() const;
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Returns whether or not the associated functions is defined in wasm.
|
92
|
+
*/
|
93
|
+
bool IsWasm() const;
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Returns whether or not the associated function is defined by the user.
|
97
|
+
*/
|
98
|
+
bool IsUserJavaScript() const;
|
99
|
+
};
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Representation of a JavaScript stack trace. The information collected is a
|
103
|
+
* snapshot of the execution stack and the information remains valid after
|
104
|
+
* execution continues.
|
105
|
+
*/
|
106
|
+
class V8_EXPORT StackTrace {
|
107
|
+
public:
|
108
|
+
/**
|
109
|
+
* Flags that determine what information is placed captured for each
|
110
|
+
* StackFrame when grabbing the current stack trace.
|
111
|
+
* Note: these options are deprecated and we always collect all available
|
112
|
+
* information (kDetailed).
|
113
|
+
*/
|
114
|
+
enum StackTraceOptions {
|
115
|
+
kLineNumber = 1,
|
116
|
+
kColumnOffset = 1 << 1 | kLineNumber,
|
117
|
+
kScriptName = 1 << 2,
|
118
|
+
kFunctionName = 1 << 3,
|
119
|
+
kIsEval = 1 << 4,
|
120
|
+
kIsConstructor = 1 << 5,
|
121
|
+
kScriptNameOrSourceURL = 1 << 6,
|
122
|
+
kScriptId = 1 << 7,
|
123
|
+
kExposeFramesAcrossSecurityOrigins = 1 << 8,
|
124
|
+
kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
|
125
|
+
kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
|
126
|
+
};
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Returns a StackFrame at a particular index.
|
130
|
+
*/
|
131
|
+
Local<StackFrame> GetFrame(Isolate* isolate, uint32_t index) const;
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Returns the number of StackFrames.
|
135
|
+
*/
|
136
|
+
int GetFrameCount() const;
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Grab a snapshot of the current JavaScript execution stack.
|
140
|
+
*
|
141
|
+
* \param frame_limit The maximum number of stack frames we want to capture.
|
142
|
+
* \param options Enumerates the set of things we will capture for each
|
143
|
+
* StackFrame.
|
144
|
+
*/
|
145
|
+
static Local<StackTrace> CurrentStackTrace(
|
146
|
+
Isolate* isolate, int frame_limit, StackTraceOptions options = kDetailed);
|
147
|
+
};
|
148
|
+
|
149
|
+
} // namespace v8
|
150
|
+
|
151
|
+
#endif // INCLUDE_V8_DEBUG_H_
|