Skip to content

Commit c03634c

Browse files
committed
feat: Updated V8 to latest version (6d1c9afc11490b4557d275a9ad69be3adfed8a62)
1 parent 8381fa8 commit c03634c

24 files changed

+159
-184
lines changed

NativeScript/include/v8-platform.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class Platform {
368368
* scheduling. The definition of "foreground" is opaque to V8.
369369
*/
370370
V8_DEPRECATED("Use a taskrunner acquired by GetForegroundTaskRunner instead.")
371-
virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0;
371+
virtual void CallOnForegroundThread(Isolate* isolate, Task* task) { abort(); }
372372

373373
/**
374374
* Schedules a task to be invoked on a foreground thread wrt a specific
@@ -378,7 +378,9 @@ class Platform {
378378
*/
379379
V8_DEPRECATED("Use a taskrunner acquired by GetForegroundTaskRunner instead.")
380380
virtual void CallDelayedOnForegroundThread(Isolate* isolate, Task* task,
381-
double delay_in_seconds) = 0;
381+
double delay_in_seconds) {
382+
abort();
383+
}
382384

383385
/**
384386
* Schedules a task to be invoked on a foreground thread wrt a specific
@@ -390,16 +392,13 @@ class Platform {
390392
*/
391393
V8_DEPRECATED("Use a taskrunner acquired by GetForegroundTaskRunner instead.")
392394
virtual void CallIdleOnForegroundThread(Isolate* isolate, IdleTask* task) {
393-
// This must be overriden if |IdleTasksEnabled()|.
394395
abort();
395396
}
396397

397398
/**
398399
* Returns true if idle tasks are enabled for the given |isolate|.
399400
*/
400-
virtual bool IdleTasksEnabled(Isolate* isolate) {
401-
return false;
402-
}
401+
virtual bool IdleTasksEnabled(Isolate* isolate) { return false; }
403402

404403
/**
405404
* Monotonically increasing time in seconds from an arbitrary fixed point in

NativeScript/include/v8.h

Lines changed: 114 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,9 +1574,17 @@ class V8_EXPORT Module : public Data {
15741574
/**
15751575
* Set this module's exported value for the name export_name to the specified
15761576
* 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().")
15801588
void SetSyntheticModuleExport(Local<String> export_name,
15811589
Local<Value> export_value);
15821590
};
@@ -2206,6 +2214,8 @@ struct UnwindState {
22062214
MemoryRange code_range;
22072215
MemoryRange embedded_code_range;
22082216
JSEntryStub js_entry_stub;
2217+
JSEntryStub js_construct_entry_stub;
2218+
JSEntryStub js_run_microtasks_entry_stub;
22092219
};
22102220

22112221
/**
@@ -4841,6 +4851,10 @@ enum class ArrayBufferCreationMode { kInternalized, kExternalized };
48414851
* V8. Clients should always use standard C++ memory ownership types (i.e.
48424852
* std::unique_ptr and std::shared_ptr) to manage lifetimes of backing stores
48434853
* 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.
48444858
*/
48454859
class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase {
48464860
public:
@@ -4858,10 +4872,24 @@ class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase {
48584872
*/
48594873
size_t ByteLength() const;
48604874

4875+
/**
4876+
* Indicates whether the backing store was created for an ArrayBuffer or
4877+
* a SharedArrayBuffer.
4878+
*/
4879+
bool IsShared() const;
4880+
48614881
private:
48624882
BackingStore();
48634883
};
48644884

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+
48654893
/**
48664894
* An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5).
48674895
*/
@@ -5012,6 +5040,29 @@ class V8_EXPORT ArrayBuffer : public Object {
50125040
static Local<ArrayBuffer> New(Isolate* isolate,
50135041
std::shared_ptr<BackingStore> backing_store);
50145042

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+
50155066
/**
50165067
* Returns true if ArrayBuffer is externalized, that is, does not
50175068
* own its memory block.
@@ -5462,6 +5513,29 @@ class V8_EXPORT SharedArrayBuffer : public Object {
54625513
static Local<SharedArrayBuffer> New(
54635514
Isolate* isolate, std::shared_ptr<BackingStore> backing_store);
54645515

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+
54655539
/**
54665540
* Create a new SharedArrayBuffer over an existing memory block. Propagate
54675541
* flags to indicate whether the underlying buffer can be grown.
@@ -5669,6 +5743,29 @@ class V8_EXPORT RegExp : public Object {
56695743
Local<String> pattern,
56705744
Flags flags);
56715745

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+
56725769
/**
56735770
* Returns the value of the source property: a string representing
56745771
* the regular expression.
@@ -7809,6 +7906,7 @@ class V8_EXPORT Isolate {
78097906
create_histogram_callback(nullptr),
78107907
add_histogram_sample_callback(nullptr),
78117908
array_buffer_allocator(nullptr),
7909+
array_buffer_allocator_shared(),
78127910
external_references(nullptr),
78137911
allow_atomics_wait(true),
78147912
only_terminate_in_safe_scope(false) {}
@@ -7848,8 +7946,14 @@ class V8_EXPORT Isolate {
78487946
/**
78497947
* The ArrayBuffer::Allocator to use for allocating and freeing the backing
78507948
* 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.
78517954
*/
78527955
ArrayBuffer::Allocator* array_buffer_allocator;
7956+
std::shared_ptr<ArrayBuffer::Allocator> array_buffer_allocator_shared;
78537957

78547958
/**
78557959
* Specifies an optional nullptr-terminated array of raw addresses in the
@@ -8071,6 +8175,8 @@ class V8_EXPORT Isolate {
80718175
kCallSiteAPIGetFunctionSloppyCall = 76,
80728176
kCallSiteAPIGetThisSloppyCall = 77,
80738177
kRegExpMatchAllWithNonGlobalRegExp = 78,
8178+
kRegExpExecCalledOnSlowRegExp = 79,
8179+
kRegExpReplaceCalledOnSlowRegExp = 80,
80748180

80758181
// If you add new values here, you'll also need to update Chromium's:
80768182
// web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
@@ -9132,8 +9238,6 @@ class V8_EXPORT V8 {
91329238
* handled entirely on the embedders' side.
91339239
* - The call will abort if the data is invalid.
91349240
*/
9135-
V8_DEPRECATED("The natives blob is deprecated (https://crbug.com/v8/7624).")
9136-
static void SetNativesDataBlob(StartupData* startup_blob);
91379241
static void SetSnapshotDataBlob(StartupData* startup_blob);
91389242

91399243
/** Set the callback to invoke in case of Dcheck failures. */
@@ -9218,18 +9322,14 @@ class V8_EXPORT V8 {
92189322
* V8 needs to be given those external files during startup. There are
92199323
* three ways to do this:
92209324
* - 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
92279330
* not perform any file IO.
92289331
*/
92299332
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);
92339333
static void InitializeExternalStartupDataFromFile(const char* snapshot_blob);
92349334

92359335
/**

NativeScript/include/v8config.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -311,22 +311,21 @@
311311
// always_inline is available in gcc 4.0 but not very reliable until 4.4.
312312
// Works around "sorry, unimplemented: inlining failed" build errors with
313313
// older compilers.
314-
# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0))
315-
# define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0))
316-
# define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0))
317-
# define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0))
318-
# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
319-
(!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0))
320-
321-
# define V8_HAS_BUILTIN_ASSUME_ALIGNED (V8_GNUC_PREREQ(4, 7, 0))
322-
# define V8_HAS_BUILTIN_CLZ (V8_GNUC_PREREQ(3, 4, 0))
323-
# define V8_HAS_BUILTIN_CTZ (V8_GNUC_PREREQ(3, 4, 0))
324-
# define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0))
325-
# define V8_HAS_BUILTIN_FRAME_ADDRESS (V8_GNUC_PREREQ(2, 96, 0))
326-
# define V8_HAS_BUILTIN_POPCOUNT (V8_GNUC_PREREQ(3, 4, 0))
314+
# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE 1
315+
# define V8_HAS_ATTRIBUTE_NOINLINE 1
316+
# define V8_HAS_ATTRIBUTE_UNUSED 1
317+
# define V8_HAS_ATTRIBUTE_VISIBILITY 1
318+
# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT (!V8_CC_INTEL)
319+
320+
# define V8_HAS_BUILTIN_ASSUME_ALIGNED 1
321+
# define V8_HAS_BUILTIN_CLZ 1
322+
# define V8_HAS_BUILTIN_CTZ 1
323+
# define V8_HAS_BUILTIN_EXPECT 1
324+
# define V8_HAS_BUILTIN_FRAME_ADDRESS 1
325+
# define V8_HAS_BUILTIN_POPCOUNT 1
327326

328327
// GCC doc: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
329-
#define V8_HAS_COMPUTED_GOTO (V8_GNUC_PREREQ(2, 0, 0))
328+
#define V8_HAS_COMPUTED_GOTO 1
330329

331330
// Whether constexpr has full C++14 semantics, in particular that non-constexpr
332331
// code is allowed as long as it's not executed for any constexpr instantiation.

NativeScript/inspector/src/common/globals.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ enum TypeofMode : int { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
400400
// Enums used by CEntry.
401401
enum SaveFPRegsMode { kDontSaveFPRegs, kSaveFPRegs };
402402
enum ArgvMode { kArgvOnStack, kArgvInRegister };
403-
enum FunctionDescriptorMode { kNoFunctionDescriptor, kHasFunctionDescriptor };
404403

405404
// This constant is used as an undefined value when passing source positions.
406405
constexpr int kNoSourcePosition = -1;
@@ -599,7 +598,6 @@ class JSReceiver;
599598
class JSArray;
600599
class JSFunction;
601600
class JSObject;
602-
class LargeObjectSpace;
603601
class MacroAssembler;
604602
class Map;
605603
class MapSpace;
@@ -617,6 +615,7 @@ class NewSpace;
617615
class NewLargeObjectSpace;
618616
class NumberDictionary;
619617
class Object;
618+
class OldLargeObjectSpace;
620619
template <HeapObjectReferenceType kRefType, typename StorageType>
621620
class TaggedImpl;
622621
class StrongTaggedValue;
@@ -758,6 +757,17 @@ enum MinimumCapacity {
758757

759758
enum GarbageCollector { SCAVENGER, MARK_COMPACTOR, MINOR_MARK_COMPACTOR };
760759

760+
enum class LocalSpaceKind {
761+
kNone,
762+
kOffThreadSpace,
763+
kCompactionSpaceForScavenge,
764+
kCompactionSpaceForMarkCompact,
765+
kCompactionSpaceForMinorMarkCompact,
766+
767+
kFirstCompactionSpace = kCompactionSpaceForScavenge,
768+
kLastCompactionSpace = kCompactionSpaceForMinorMarkCompact,
769+
};
770+
761771
enum Executability { NOT_EXECUTABLE, EXECUTABLE };
762772

763773
enum VisitMode {
@@ -1036,6 +1046,8 @@ constexpr uint64_t kHoleNanInt64 =
10361046
// ES6 section 20.1.2.6 Number.MAX_SAFE_INTEGER
10371047
constexpr double kMaxSafeInteger = 9007199254740991.0; // 2^53-1
10381048

1049+
constexpr double kMaxUInt32Double = double{kMaxUInt32};
1050+
10391051
// The order of this enum has to be kept in sync with the predicates below.
10401052
enum class VariableMode : uint8_t {
10411053
// User declared variables:

NativeScript/inspector/src/init/v8.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class V8 : public AllStatic {
3636
// Should be used only for testing.
3737
V8_EXPORT_PRIVATE static void SetPlatformForTesting(v8::Platform* platform);
3838

39-
static void SetNativesBlob(StartupData* natives_blob);
4039
static void SetSnapshotBlob(StartupData* snapshot_blob);
4140

4241
private:

NativeScript/inspector/src/inspector/protocol/Runtime.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1789,14 +1789,20 @@ void DispatcherImpl::evaluate(int callId, const String& method, const ProtocolMe
17891789
errors->setName("disableBreaks");
17901790
in_disableBreaks = ValueConversions<bool>::fromValue(disableBreaksValue, errors);
17911791
}
1792+
protocol::Value* replModeValue = object ? object->get("replMode") : nullptr;
1793+
Maybe<bool> in_replMode;
1794+
if (replModeValue) {
1795+
errors->setName("replMode");
1796+
in_replMode = ValueConversions<bool>::fromValue(replModeValue, errors);
1797+
}
17921798
errors->pop();
17931799
if (errors->hasErrors()) {
17941800
reportProtocolError(callId, DispatchResponse::kInvalidParams, kInvalidParamsString, errors);
17951801
return;
17961802
}
17971803

17981804
std::unique_ptr<EvaluateCallbackImpl> callback(new EvaluateCallbackImpl(weakPtr(), callId, method, message));
1799-
m_backend->evaluate(in_expression, std::move(in_objectGroup), std::move(in_includeCommandLineAPI), std::move(in_silent), std::move(in_contextId), std::move(in_returnByValue), std::move(in_generatePreview), std::move(in_userGesture), std::move(in_awaitPromise), std::move(in_throwOnSideEffect), std::move(in_timeout), std::move(in_disableBreaks), std::move(callback));
1805+
m_backend->evaluate(in_expression, std::move(in_objectGroup), std::move(in_includeCommandLineAPI), std::move(in_silent), std::move(in_contextId), std::move(in_returnByValue), std::move(in_generatePreview), std::move(in_userGesture), std::move(in_awaitPromise), std::move(in_throwOnSideEffect), std::move(in_timeout), std::move(in_disableBreaks), std::move(in_replMode), std::move(callback));
18001806
return;
18011807
}
18021808

0 commit comments

Comments
 (0)