libv8-node 15.14.0.1-x86_64-linux → 17.9.1.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libv8-node/location.rb +1 -1
  3. data/ext/libv8-node/paths.rb +5 -1
  4. data/lib/libv8/node/version.rb +3 -3
  5. data/vendor/v8/include/cppgc/allocation.h +110 -44
  6. data/vendor/v8/include/cppgc/common.h +9 -6
  7. data/vendor/v8/include/cppgc/cross-thread-persistent.h +465 -0
  8. data/vendor/v8/include/cppgc/custom-space.h +37 -2
  9. data/vendor/v8/include/cppgc/default-platform.h +47 -48
  10. data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
  11. data/vendor/v8/include/cppgc/explicit-management.h +82 -0
  12. data/vendor/v8/include/cppgc/garbage-collected.h +4 -3
  13. data/vendor/v8/include/cppgc/heap-consistency.h +253 -0
  14. data/vendor/v8/include/cppgc/heap-state.h +70 -0
  15. data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
  16. data/vendor/v8/include/cppgc/heap.h +68 -6
  17. data/vendor/v8/include/cppgc/internal/api-constants.h +3 -3
  18. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +4 -3
  19. data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
  20. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +2 -0
  21. data/vendor/v8/include/cppgc/internal/gc-info.h +124 -13
  22. data/vendor/v8/include/cppgc/internal/name-trait.h +122 -0
  23. data/vendor/v8/include/cppgc/internal/persistent-node.h +94 -6
  24. data/vendor/v8/include/cppgc/internal/pointer-policies.h +81 -29
  25. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +1 -1
  26. data/vendor/v8/include/cppgc/internal/write-barrier.h +398 -35
  27. data/vendor/v8/include/cppgc/liveness-broker.h +11 -2
  28. data/vendor/v8/include/cppgc/macros.h +2 -0
  29. data/vendor/v8/include/cppgc/member.h +87 -25
  30. data/vendor/v8/include/cppgc/name-provider.h +65 -0
  31. data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
  32. data/vendor/v8/include/cppgc/persistent.h +41 -11
  33. data/vendor/v8/include/cppgc/platform.h +49 -25
  34. data/vendor/v8/include/cppgc/prefinalizer.h +2 -2
  35. data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
  36. data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
  37. data/vendor/v8/include/cppgc/source-location.h +2 -1
  38. data/vendor/v8/include/cppgc/testing.h +99 -0
  39. data/vendor/v8/include/cppgc/trace-trait.h +8 -3
  40. data/vendor/v8/include/cppgc/type-traits.h +157 -19
  41. data/vendor/v8/include/cppgc/visitor.h +194 -28
  42. data/vendor/v8/include/libplatform/libplatform.h +11 -0
  43. data/vendor/v8/include/libplatform/v8-tracing.h +2 -0
  44. data/vendor/v8/include/v8-array-buffer.h +433 -0
  45. data/vendor/v8/include/v8-callbacks.h +377 -0
  46. data/vendor/v8/include/v8-container.h +129 -0
  47. data/vendor/v8/include/v8-context.h +418 -0
  48. data/vendor/v8/include/v8-cppgc.h +261 -159
  49. data/vendor/v8/include/v8-data.h +65 -0
  50. data/vendor/v8/include/v8-date.h +43 -0
  51. data/vendor/v8/include/v8-debug.h +151 -0
  52. data/vendor/v8/include/v8-embedder-heap.h +238 -0
  53. data/vendor/v8/include/v8-exception.h +224 -0
  54. data/vendor/v8/include/v8-extension.h +62 -0
  55. data/vendor/v8/include/v8-external.h +37 -0
  56. data/vendor/v8/include/v8-fast-api-calls.h +652 -152
  57. data/vendor/v8/include/v8-forward.h +81 -0
  58. data/vendor/v8/include/v8-function-callback.h +475 -0
  59. data/vendor/v8/include/v8-function.h +122 -0
  60. data/vendor/v8/include/v8-initialization.h +282 -0
  61. data/vendor/v8/include/v8-inspector.h +33 -25
  62. data/vendor/v8/include/v8-internal.h +178 -31
  63. data/vendor/v8/include/v8-isolate.h +1662 -0
  64. data/vendor/v8/include/v8-json.h +47 -0
  65. data/vendor/v8/include/v8-local-handle.h +459 -0
  66. data/vendor/v8/include/v8-locker.h +148 -0
  67. data/vendor/v8/include/v8-maybe.h +137 -0
  68. data/vendor/v8/include/v8-memory-span.h +43 -0
  69. data/vendor/v8/include/v8-message.h +241 -0
  70. data/vendor/v8/include/v8-metrics.h +114 -9
  71. data/vendor/v8/include/v8-microtask-queue.h +152 -0
  72. data/vendor/v8/include/v8-microtask.h +28 -0
  73. data/vendor/v8/include/v8-object.h +770 -0
  74. data/vendor/v8/include/v8-persistent-handle.h +590 -0
  75. data/vendor/v8/include/v8-platform.h +74 -25
  76. data/vendor/v8/include/v8-primitive-object.h +118 -0
  77. data/vendor/v8/include/v8-primitive.h +858 -0
  78. data/vendor/v8/include/v8-profiler.h +72 -9
  79. data/vendor/v8/include/v8-promise.h +174 -0
  80. data/vendor/v8/include/v8-proxy.h +50 -0
  81. data/vendor/v8/include/v8-regexp.h +105 -0
  82. data/vendor/v8/include/v8-script.h +771 -0
  83. data/vendor/v8/include/v8-snapshot.h +198 -0
  84. data/vendor/v8/include/v8-statistics.h +215 -0
  85. data/vendor/v8/include/v8-template.h +1052 -0
  86. data/vendor/v8/include/v8-traced-handle.h +605 -0
  87. data/vendor/v8/include/v8-typed-array.h +282 -0
  88. data/vendor/v8/include/v8-unwinder-state.h +31 -0
  89. data/vendor/v8/include/v8-unwinder.h +129 -0
  90. data/vendor/v8/include/v8-util.h +8 -2
  91. data/vendor/v8/include/v8-value-serializer.h +249 -0
  92. data/vendor/v8/include/v8-value.h +526 -0
  93. data/vendor/v8/include/v8-version.h +3 -3
  94. data/vendor/v8/include/v8-wasm.h +245 -0
  95. data/vendor/v8/include/v8-weak-callback-info.h +73 -0
  96. data/vendor/v8/include/v8.h +41 -12050
  97. data/vendor/v8/include/v8config.h +87 -11
  98. data/vendor/v8/{out.gn → x86_64-linux}/libv8/obj/libv8_monolith.a +0 -0
  99. metadata +60 -6
  100. data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -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_