@@ -1574,9 +1574,17 @@ class V8_EXPORT Module : public Data {
1574
1574
/* *
1575
1575
* Set this module's exported value for the name export_name to the specified
1576
1576
* export_value. This method must be called only on Modules created via
1577
- * CreateSyntheticModule. export_name must be one of the export_names that
1578
- * were passed in that CreateSyntheticModule call.
1579
- */
1577
+ * CreateSyntheticModule. An error will be thrown if export_name is not one
1578
+ * of the export_names that were passed in that CreateSyntheticModule call.
1579
+ * Returns Just(true) on success, Nothing<bool>() if an error was thrown.
1580
+ */
1581
+ V8_WARN_UNUSED_RESULT Maybe<bool > SetSyntheticModuleExport (
1582
+ Isolate* isolate, Local<String> export_name, Local<Value> export_value);
1583
+ V8_DEPRECATE_SOON (
1584
+ " Use the preceding SetSyntheticModuleExport with an Isolate parameter, "
1585
+ " instead of the one that follows. The former will throw a runtime "
1586
+ " error if called for an export that doesn't exist (as per spec); "
1587
+ " the latter will crash with a failed CHECK()." )
1580
1588
void SetSyntheticModuleExport (Local<String> export_name,
1581
1589
Local<Value> export_value);
1582
1590
};
@@ -2206,6 +2214,8 @@ struct UnwindState {
2206
2214
MemoryRange code_range;
2207
2215
MemoryRange embedded_code_range;
2208
2216
JSEntryStub js_entry_stub;
2217
+ JSEntryStub js_construct_entry_stub;
2218
+ JSEntryStub js_run_microtasks_entry_stub;
2209
2219
};
2210
2220
2211
2221
/* *
@@ -4841,6 +4851,10 @@ enum class ArrayBufferCreationMode { kInternalized, kExternalized };
4841
4851
* V8. Clients should always use standard C++ memory ownership types (i.e.
4842
4852
* std::unique_ptr and std::shared_ptr) to manage lifetimes of backing stores
4843
4853
* properly, since V8 internal objects may alias backing stores.
4854
+ *
4855
+ * This object does not keep the underlying |ArrayBuffer::Allocator| alive by
4856
+ * default. Use Isolate::CreateParams::array_buffer_allocator_shared when
4857
+ * creating the Isolate to make it hold a reference to the allocator itself.
4844
4858
*/
4845
4859
class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase {
4846
4860
public:
@@ -4858,10 +4872,24 @@ class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase {
4858
4872
*/
4859
4873
size_t ByteLength () const ;
4860
4874
4875
+ /* *
4876
+ * Indicates whether the backing store was created for an ArrayBuffer or
4877
+ * a SharedArrayBuffer.
4878
+ */
4879
+ bool IsShared () const ;
4880
+
4861
4881
private:
4862
4882
BackingStore ();
4863
4883
};
4864
4884
4885
+ /* *
4886
+ * This callback is used only if the memory block for this backing store cannot
4887
+ * be allocated with an ArrayBuffer::Allocator. In such cases the destructor
4888
+ * of this backing store object invokes the callback to free the memory block.
4889
+ */
4890
+ using BackingStoreDeleterCallback = void (*)(void * data, size_t length,
4891
+ void * deleter_data);
4892
+
4865
4893
/* *
4866
4894
* An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5).
4867
4895
*/
@@ -5012,6 +5040,29 @@ class V8_EXPORT ArrayBuffer : public Object {
5012
5040
static Local<ArrayBuffer> New (Isolate* isolate,
5013
5041
std::shared_ptr<BackingStore> backing_store);
5014
5042
5043
+ /* *
5044
+ * Returns a new standalone BackingStore that is allocated using the array
5045
+ * buffer allocator of the isolate. The result can be later passed to
5046
+ * ArrayBuffer::New.
5047
+ *
5048
+ * If the allocator returns nullptr, then the function may cause GCs in the
5049
+ * given isolate and re-try the allocation. If GCs do not help, then the
5050
+ * function will crash with an out-of-memory error.
5051
+ */
5052
+ static std::unique_ptr<BackingStore> NewBackingStore (Isolate* isolate,
5053
+ size_t byte_length);
5054
+ /* *
5055
+ * Returns a new standalone BackingStore that takes over the ownership of
5056
+ * the given buffer. The destructor of the BackingStore invokes the given
5057
+ * deleter callback.
5058
+ *
5059
+ * The result can be later passed to ArrayBuffer::New. The raw pointer
5060
+ * to the buffer must not be passed again to any V8 API function.
5061
+ */
5062
+ static std::unique_ptr<BackingStore> NewBackingStore (
5063
+ void * data, size_t byte_length, BackingStoreDeleterCallback deleter,
5064
+ void * deleter_data);
5065
+
5015
5066
/* *
5016
5067
* Returns true if ArrayBuffer is externalized, that is, does not
5017
5068
* own its memory block.
@@ -5462,6 +5513,29 @@ class V8_EXPORT SharedArrayBuffer : public Object {
5462
5513
static Local<SharedArrayBuffer> New (
5463
5514
Isolate* isolate, std::shared_ptr<BackingStore> backing_store);
5464
5515
5516
+ /* *
5517
+ * Returns a new standalone BackingStore that is allocated using the array
5518
+ * buffer allocator of the isolate. The result can be later passed to
5519
+ * SharedArrayBuffer::New.
5520
+ *
5521
+ * If the allocator returns nullptr, then the function may cause GCs in the
5522
+ * given isolate and re-try the allocation. If GCs do not help, then the
5523
+ * function will crash with an out-of-memory error.
5524
+ */
5525
+ static std::unique_ptr<BackingStore> NewBackingStore (Isolate* isolate,
5526
+ size_t byte_length);
5527
+ /* *
5528
+ * Returns a new standalone BackingStore that takes over the ownership of
5529
+ * the given buffer. The destructor of the BackingStore invokes the given
5530
+ * deleter callback.
5531
+ *
5532
+ * The result can be later passed to SharedArrayBuffer::New. The raw pointer
5533
+ * to the buffer must not be passed again to any V8 functions.
5534
+ */
5535
+ static std::unique_ptr<BackingStore> NewBackingStore (
5536
+ void * data, size_t byte_length, BackingStoreDeleterCallback deleter,
5537
+ void * deleter_data);
5538
+
5465
5539
/* *
5466
5540
* Create a new SharedArrayBuffer over an existing memory block. Propagate
5467
5541
* flags to indicate whether the underlying buffer can be grown.
@@ -5669,6 +5743,29 @@ class V8_EXPORT RegExp : public Object {
5669
5743
Local<String> pattern,
5670
5744
Flags flags);
5671
5745
5746
+ /* *
5747
+ * Like New, but additionally specifies a backtrack limit. If the number of
5748
+ * backtracks done in one Exec call hits the limit, a match failure is
5749
+ * immediately returned.
5750
+ */
5751
+ static V8_WARN_UNUSED_RESULT MaybeLocal<RegExp> NewWithBacktrackLimit (
5752
+ Local<Context> context, Local<String> pattern, Flags flags,
5753
+ uint32_t backtrack_limit);
5754
+
5755
+ /* *
5756
+ * Executes the current RegExp instance on the given subject string.
5757
+ * Equivalent to RegExp.prototype.exec as described in
5758
+ *
5759
+ * https://tc39.es/ecma262/#sec-regexp.prototype.exec
5760
+ *
5761
+ * On success, an Array containing the matched strings is returned. On
5762
+ * failure, returns Null.
5763
+ *
5764
+ * Note: modifies global context state, accessible e.g. through RegExp.input.
5765
+ */
5766
+ V8_WARN_UNUSED_RESULT MaybeLocal<Object> Exec (Local<Context> context,
5767
+ Local<String> subject);
5768
+
5672
5769
/* *
5673
5770
* Returns the value of the source property: a string representing
5674
5771
* the regular expression.
@@ -7809,6 +7906,7 @@ class V8_EXPORT Isolate {
7809
7906
create_histogram_callback(nullptr ),
7810
7907
add_histogram_sample_callback(nullptr ),
7811
7908
array_buffer_allocator(nullptr ),
7909
+ array_buffer_allocator_shared(),
7812
7910
external_references(nullptr ),
7813
7911
allow_atomics_wait(true ),
7814
7912
only_terminate_in_safe_scope(false ) {}
@@ -7848,8 +7946,14 @@ class V8_EXPORT Isolate {
7848
7946
/* *
7849
7947
* The ArrayBuffer::Allocator to use for allocating and freeing the backing
7850
7948
* store of ArrayBuffers.
7949
+ *
7950
+ * If the shared_ptr version is used, the Isolate instance and every
7951
+ * |BackingStore| allocated using this allocator hold a std::shared_ptr
7952
+ * to the allocator, in order to facilitate lifetime
7953
+ * management for the allocator instance.
7851
7954
*/
7852
7955
ArrayBuffer::Allocator* array_buffer_allocator;
7956
+ std::shared_ptr<ArrayBuffer::Allocator> array_buffer_allocator_shared;
7853
7957
7854
7958
/* *
7855
7959
* Specifies an optional nullptr-terminated array of raw addresses in the
@@ -8071,6 +8175,8 @@ class V8_EXPORT Isolate {
8071
8175
kCallSiteAPIGetFunctionSloppyCall = 76 ,
8072
8176
kCallSiteAPIGetThisSloppyCall = 77 ,
8073
8177
kRegExpMatchAllWithNonGlobalRegExp = 78 ,
8178
+ kRegExpExecCalledOnSlowRegExp = 79 ,
8179
+ kRegExpReplaceCalledOnSlowRegExp = 80 ,
8074
8180
8075
8181
// If you add new values here, you'll also need to update Chromium's:
8076
8182
// web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
@@ -9132,8 +9238,6 @@ class V8_EXPORT V8 {
9132
9238
* handled entirely on the embedders' side.
9133
9239
* - The call will abort if the data is invalid.
9134
9240
*/
9135
- V8_DEPRECATED (" The natives blob is deprecated (https://crbug.com/v8/7624)." )
9136
- static void SetNativesDataBlob (StartupData* startup_blob);
9137
9241
static void SetSnapshotDataBlob (StartupData* startup_blob);
9138
9242
9139
9243
/* * Set the callback to invoke in case of Dcheck failures. */
@@ -9218,18 +9322,14 @@ class V8_EXPORT V8 {
9218
9322
* V8 needs to be given those external files during startup. There are
9219
9323
* three ways to do this:
9220
9324
* - InitializeExternalStartupData(const char*)
9221
- * This will look in the given directory for files "natives_blob.bin"
9222
- * and "snapshot_blob.bin" - which is what the default build calls them.
9223
- * - InitializeExternalStartupData(const char*, const char*)
9224
- * As above, but will directly use the two given file names.
9225
- * - Call SetNativesDataBlob, SetNativesDataBlob.
9226
- * This will read the blobs from the given data structures and will
9325
+ * This will look in the given directory for the file "snapshot_blob.bin".
9326
+ * - InitializeExternalStartupDataFromFile(const char*)
9327
+ * As above, but will directly use the given file name.
9328
+ * - Call SetSnapshotDataBlob.
9329
+ * This will read the blobs from the given data structure and will
9227
9330
* not perform any file IO.
9228
9331
*/
9229
9332
static void InitializeExternalStartupData (const char * directory_path);
9230
- V8_DEPRECATED (" The natives blob is deprecated (https://crbug.com/v8/7624)." )
9231
- static void InitializeExternalStartupData (const char * natives_blob,
9232
- const char * snapshot_blob);
9233
9333
static void InitializeExternalStartupDataFromFile (const char * snapshot_blob);
9234
9334
9235
9335
/* *
0 commit comments