libv8-node 16.19.0.1-x86_64-darwin → 17.9.1.1-x86_64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/include/cppgc/allocation.h +11 -5
  4. data/vendor/v8/include/cppgc/cross-thread-persistent.h +78 -26
  5. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +2 -2
  6. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +2 -0
  7. data/vendor/v8/include/cppgc/internal/gc-info.h +90 -10
  8. data/vendor/v8/include/cppgc/internal/name-trait.h +11 -0
  9. data/vendor/v8/include/cppgc/internal/persistent-node.h +44 -12
  10. data/vendor/v8/include/cppgc/internal/pointer-policies.h +22 -11
  11. data/vendor/v8/include/cppgc/internal/write-barrier.h +9 -1
  12. data/vendor/v8/include/cppgc/persistent.h +1 -1
  13. data/vendor/v8/include/cppgc/prefinalizer.h +1 -1
  14. data/vendor/v8/include/v8-array-buffer.h +433 -0
  15. data/vendor/v8/include/v8-callbacks.h +377 -0
  16. data/vendor/v8/include/v8-container.h +129 -0
  17. data/vendor/v8/include/v8-context.h +418 -0
  18. data/vendor/v8/include/v8-cppgc.h +5 -2
  19. data/vendor/v8/include/v8-data.h +65 -0
  20. data/vendor/v8/include/v8-date.h +43 -0
  21. data/vendor/v8/include/v8-debug.h +151 -0
  22. data/vendor/v8/include/v8-embedder-heap.h +238 -0
  23. data/vendor/v8/include/v8-exception.h +224 -0
  24. data/vendor/v8/include/v8-extension.h +62 -0
  25. data/vendor/v8/include/v8-external.h +37 -0
  26. data/vendor/v8/include/v8-fast-api-calls.h +63 -11
  27. data/vendor/v8/include/v8-forward.h +81 -0
  28. data/vendor/v8/include/v8-function-callback.h +475 -0
  29. data/vendor/v8/include/v8-function.h +122 -0
  30. data/vendor/v8/include/v8-initialization.h +282 -0
  31. data/vendor/v8/include/v8-inspector.h +11 -21
  32. data/vendor/v8/include/v8-internal.h +85 -22
  33. data/vendor/v8/include/v8-isolate.h +1662 -0
  34. data/vendor/v8/include/v8-json.h +47 -0
  35. data/vendor/v8/include/v8-local-handle.h +459 -0
  36. data/vendor/v8/include/v8-locker.h +148 -0
  37. data/vendor/v8/include/v8-maybe.h +137 -0
  38. data/vendor/v8/include/v8-memory-span.h +43 -0
  39. data/vendor/v8/include/v8-message.h +241 -0
  40. data/vendor/v8/include/v8-metrics.h +37 -1
  41. data/vendor/v8/include/v8-microtask-queue.h +152 -0
  42. data/vendor/v8/include/v8-microtask.h +28 -0
  43. data/vendor/v8/include/v8-object.h +770 -0
  44. data/vendor/v8/include/v8-persistent-handle.h +590 -0
  45. data/vendor/v8/include/v8-platform.h +41 -17
  46. data/vendor/v8/include/v8-primitive-object.h +118 -0
  47. data/vendor/v8/include/v8-primitive.h +858 -0
  48. data/vendor/v8/include/v8-profiler.h +10 -11
  49. data/vendor/v8/include/v8-promise.h +174 -0
  50. data/vendor/v8/include/v8-proxy.h +50 -0
  51. data/vendor/v8/include/v8-regexp.h +105 -0
  52. data/vendor/v8/include/v8-script.h +771 -0
  53. data/vendor/v8/include/v8-snapshot.h +198 -0
  54. data/vendor/v8/include/v8-statistics.h +215 -0
  55. data/vendor/v8/include/v8-template.h +1052 -0
  56. data/vendor/v8/include/v8-traced-handle.h +605 -0
  57. data/vendor/v8/include/v8-typed-array.h +282 -0
  58. data/vendor/v8/include/v8-unwinder-state.h +4 -3
  59. data/vendor/v8/include/v8-unwinder.h +129 -0
  60. data/vendor/v8/include/v8-util.h +7 -1
  61. data/vendor/v8/include/v8-value-serializer.h +249 -0
  62. data/vendor/v8/include/v8-value.h +526 -0
  63. data/vendor/v8/include/v8-version.h +3 -3
  64. data/vendor/v8/include/v8-wasm.h +245 -0
  65. data/vendor/v8/include/v8-weak-callback-info.h +73 -0
  66. data/vendor/v8/include/v8.h +41 -12604
  67. data/vendor/v8/x86_64-darwin/libv8/obj/libv8_monolith.a +0 -0
  68. metadata +43 -1
@@ -0,0 +1,245 @@
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_WASM_H_
6
+ #define INCLUDE_V8_WASM_H_
7
+
8
+ #include <memory>
9
+ #include <string>
10
+
11
+ #include "v8-local-handle.h" // NOLINT(build/include_directory)
12
+ #include "v8-memory-span.h" // NOLINT(build/include_directory)
13
+ #include "v8-object.h" // NOLINT(build/include_directory)
14
+ #include "v8config.h" // NOLINT(build/include_directory)
15
+
16
+ namespace v8 {
17
+
18
+ class ArrayBuffer;
19
+ class Promise;
20
+
21
+ namespace internal {
22
+ namespace wasm {
23
+ class NativeModule;
24
+ class StreamingDecoder;
25
+ } // namespace wasm
26
+ } // namespace internal
27
+
28
+ /**
29
+ * An owned byte buffer with associated size.
30
+ */
31
+ struct OwnedBuffer {
32
+ std::unique_ptr<const uint8_t[]> buffer;
33
+ size_t size = 0;
34
+ OwnedBuffer(std::unique_ptr<const uint8_t[]> buffer, size_t size)
35
+ : buffer(std::move(buffer)), size(size) {}
36
+ OwnedBuffer() = default;
37
+ };
38
+
39
+ // Wrapper around a compiled WebAssembly module, which is potentially shared by
40
+ // different WasmModuleObjects.
41
+ class V8_EXPORT CompiledWasmModule {
42
+ public:
43
+ /**
44
+ * Serialize the compiled module. The serialized data does not include the
45
+ * wire bytes.
46
+ */
47
+ OwnedBuffer Serialize();
48
+
49
+ /**
50
+ * Get the (wasm-encoded) wire bytes that were used to compile this module.
51
+ */
52
+ MemorySpan<const uint8_t> GetWireBytesRef();
53
+
54
+ const std::string& source_url() const { return source_url_; }
55
+
56
+ private:
57
+ friend class WasmModuleObject;
58
+ friend class WasmStreaming;
59
+
60
+ explicit CompiledWasmModule(std::shared_ptr<internal::wasm::NativeModule>,
61
+ const char* source_url, size_t url_length);
62
+
63
+ const std::shared_ptr<internal::wasm::NativeModule> native_module_;
64
+ const std::string source_url_;
65
+ };
66
+
67
+ // An instance of WebAssembly.Memory.
68
+ class V8_EXPORT WasmMemoryObject : public Object {
69
+ public:
70
+ WasmMemoryObject() = delete;
71
+
72
+ /**
73
+ * Returns underlying ArrayBuffer.
74
+ */
75
+ Local<ArrayBuffer> Buffer();
76
+
77
+ V8_INLINE static WasmMemoryObject* Cast(Value* value) {
78
+ #ifdef V8_ENABLE_CHECKS
79
+ CheckCast(value);
80
+ #endif
81
+ return static_cast<WasmMemoryObject*>(value);
82
+ }
83
+
84
+ private:
85
+ static void CheckCast(Value* object);
86
+ };
87
+
88
+ // An instance of WebAssembly.Module.
89
+ class V8_EXPORT WasmModuleObject : public Object {
90
+ public:
91
+ WasmModuleObject() = delete;
92
+
93
+ /**
94
+ * Efficiently re-create a WasmModuleObject, without recompiling, from
95
+ * a CompiledWasmModule.
96
+ */
97
+ static MaybeLocal<WasmModuleObject> FromCompiledModule(
98
+ Isolate* isolate, const CompiledWasmModule&);
99
+
100
+ /**
101
+ * Get the compiled module for this module object. The compiled module can be
102
+ * shared by several module objects.
103
+ */
104
+ CompiledWasmModule GetCompiledModule();
105
+
106
+ V8_INLINE static WasmModuleObject* Cast(Value* value) {
107
+ #ifdef V8_ENABLE_CHECKS
108
+ CheckCast(value);
109
+ #endif
110
+ return static_cast<WasmModuleObject*>(value);
111
+ }
112
+
113
+ private:
114
+ static void CheckCast(Value* obj);
115
+ };
116
+
117
+ /**
118
+ * The V8 interface for WebAssembly streaming compilation. When streaming
119
+ * compilation is initiated, V8 passes a {WasmStreaming} object to the embedder
120
+ * such that the embedder can pass the input bytes for streaming compilation to
121
+ * V8.
122
+ */
123
+ class V8_EXPORT WasmStreaming final {
124
+ public:
125
+ class WasmStreamingImpl;
126
+
127
+ /**
128
+ * Client to receive streaming event notifications.
129
+ */
130
+ class Client {
131
+ public:
132
+ virtual ~Client() = default;
133
+ /**
134
+ * Passes the fully compiled module to the client. This can be used to
135
+ * implement code caching.
136
+ */
137
+ virtual void OnModuleCompiled(CompiledWasmModule compiled_module) = 0;
138
+ };
139
+
140
+ explicit WasmStreaming(std::unique_ptr<WasmStreamingImpl> impl);
141
+
142
+ ~WasmStreaming();
143
+
144
+ /**
145
+ * Pass a new chunk of bytes to WebAssembly streaming compilation.
146
+ * The buffer passed into {OnBytesReceived} is owned by the caller.
147
+ */
148
+ void OnBytesReceived(const uint8_t* bytes, size_t size);
149
+
150
+ /**
151
+ * {Finish} should be called after all received bytes where passed to
152
+ * {OnBytesReceived} to tell V8 that there will be no more bytes. {Finish}
153
+ * does not have to be called after {Abort} has been called already.
154
+ */
155
+ void Finish();
156
+
157
+ /**
158
+ * Abort streaming compilation. If {exception} has a value, then the promise
159
+ * associated with streaming compilation is rejected with that value. If
160
+ * {exception} does not have value, the promise does not get rejected.
161
+ */
162
+ void Abort(MaybeLocal<Value> exception);
163
+
164
+ /**
165
+ * Passes previously compiled module bytes. This must be called before
166
+ * {OnBytesReceived}, {Finish}, or {Abort}. Returns true if the module bytes
167
+ * can be used, false otherwise. The buffer passed via {bytes} and {size}
168
+ * is owned by the caller. If {SetCompiledModuleBytes} returns true, the
169
+ * buffer must remain valid until either {Finish} or {Abort} completes.
170
+ */
171
+ bool SetCompiledModuleBytes(const uint8_t* bytes, size_t size);
172
+
173
+ /**
174
+ * Sets the client object that will receive streaming event notifications.
175
+ * This must be called before {OnBytesReceived}, {Finish}, or {Abort}.
176
+ */
177
+ void SetClient(std::shared_ptr<Client> client);
178
+
179
+ /*
180
+ * Sets the UTF-8 encoded source URL for the {Script} object. This must be
181
+ * called before {Finish}.
182
+ */
183
+ void SetUrl(const char* url, size_t length);
184
+
185
+ /**
186
+ * Unpacks a {WasmStreaming} object wrapped in a {Managed} for the embedder.
187
+ * Since the embedder is on the other side of the API, it cannot unpack the
188
+ * {Managed} itself.
189
+ */
190
+ static std::shared_ptr<WasmStreaming> Unpack(Isolate* isolate,
191
+ Local<Value> value);
192
+
193
+ private:
194
+ std::unique_ptr<WasmStreamingImpl> impl_;
195
+ };
196
+
197
+ // TODO(mtrofin): when streaming compilation is done, we can rename this
198
+ // to simply WasmModuleObjectBuilder
199
+ class V8_EXPORT WasmModuleObjectBuilderStreaming final {
200
+ public:
201
+ explicit WasmModuleObjectBuilderStreaming(Isolate* isolate);
202
+ /**
203
+ * The buffer passed into OnBytesReceived is owned by the caller.
204
+ */
205
+ void OnBytesReceived(const uint8_t*, size_t size);
206
+ void Finish();
207
+ /**
208
+ * Abort streaming compilation. If {exception} has a value, then the promise
209
+ * associated with streaming compilation is rejected with that value. If
210
+ * {exception} does not have value, the promise does not get rejected.
211
+ */
212
+ void Abort(MaybeLocal<Value> exception);
213
+ Local<Promise> GetPromise();
214
+
215
+ ~WasmModuleObjectBuilderStreaming() = default;
216
+
217
+ private:
218
+ WasmModuleObjectBuilderStreaming(const WasmModuleObjectBuilderStreaming&) =
219
+ delete;
220
+ WasmModuleObjectBuilderStreaming(WasmModuleObjectBuilderStreaming&&) =
221
+ default;
222
+ WasmModuleObjectBuilderStreaming& operator=(
223
+ const WasmModuleObjectBuilderStreaming&) = delete;
224
+ WasmModuleObjectBuilderStreaming& operator=(
225
+ WasmModuleObjectBuilderStreaming&&) = default;
226
+ Isolate* isolate_ = nullptr;
227
+
228
+ #if V8_CC_MSVC
229
+ /**
230
+ * We don't need the static Copy API, so the default
231
+ * NonCopyablePersistentTraits would be sufficient, however,
232
+ * MSVC eagerly instantiates the Copy.
233
+ * We ensure we don't use Copy, however, by compiling with the
234
+ * defaults everywhere else.
235
+ */
236
+ Persistent<Promise, CopyablePersistentTraits<Promise>> promise_;
237
+ #else
238
+ Persistent<Promise> promise_;
239
+ #endif
240
+ std::shared_ptr<internal::wasm::StreamingDecoder> streaming_decoder_;
241
+ };
242
+
243
+ } // namespace v8
244
+
245
+ #endif // INCLUDE_V8_WASM_H_
@@ -0,0 +1,73 @@
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_WEAK_CALLBACK_INFO_H_
6
+ #define INCLUDE_V8_WEAK_CALLBACK_INFO_H_
7
+
8
+ #include "v8config.h" // NOLINT(build/include_directory)
9
+
10
+ namespace v8 {
11
+
12
+ class Isolate;
13
+
14
+ namespace api_internal {
15
+ V8_EXPORT void InternalFieldOutOfBounds(int index);
16
+ } // namespace api_internal
17
+
18
+ static const int kInternalFieldsInWeakCallback = 2;
19
+ static const int kEmbedderFieldsInWeakCallback = 2;
20
+
21
+ template <typename T>
22
+ class WeakCallbackInfo {
23
+ public:
24
+ using Callback = void (*)(const WeakCallbackInfo<T>& data);
25
+
26
+ WeakCallbackInfo(Isolate* isolate, T* parameter,
27
+ void* embedder_fields[kEmbedderFieldsInWeakCallback],
28
+ Callback* callback)
29
+ : isolate_(isolate), parameter_(parameter), callback_(callback) {
30
+ for (int i = 0; i < kEmbedderFieldsInWeakCallback; ++i) {
31
+ embedder_fields_[i] = embedder_fields[i];
32
+ }
33
+ }
34
+
35
+ V8_INLINE Isolate* GetIsolate() const { return isolate_; }
36
+ V8_INLINE T* GetParameter() const { return parameter_; }
37
+ V8_INLINE void* GetInternalField(int index) const;
38
+
39
+ // When first called, the embedder MUST Reset() the Global which triggered the
40
+ // callback. The Global itself is unusable for anything else. No v8 other api
41
+ // calls may be called in the first callback. Should additional work be
42
+ // required, the embedder must set a second pass callback, which will be
43
+ // called after all the initial callbacks are processed.
44
+ // Calling SetSecondPassCallback on the second pass will immediately crash.
45
+ void SetSecondPassCallback(Callback callback) const { *callback_ = callback; }
46
+
47
+ private:
48
+ Isolate* isolate_;
49
+ T* parameter_;
50
+ Callback* callback_;
51
+ void* embedder_fields_[kEmbedderFieldsInWeakCallback];
52
+ };
53
+
54
+ // kParameter will pass a void* parameter back to the callback, kInternalFields
55
+ // will pass the first two internal fields back to the callback, kFinalizer
56
+ // will pass a void* parameter back, but is invoked before the object is
57
+ // actually collected, so it can be resurrected. In the last case, it is not
58
+ // possible to request a second pass callback.
59
+ enum class WeakCallbackType { kParameter, kInternalFields, kFinalizer };
60
+
61
+ template <class T>
62
+ void* WeakCallbackInfo<T>::GetInternalField(int index) const {
63
+ #ifdef V8_ENABLE_CHECKS
64
+ if (index < 0 || index >= kEmbedderFieldsInWeakCallback) {
65
+ api_internal::InternalFieldOutOfBounds(index);
66
+ }
67
+ #endif
68
+ return embedder_fields_[index];
69
+ }
70
+
71
+ } // namespace v8
72
+
73
+ #endif // INCLUDE_V8_WEAK_CALLBACK_INFO_H_