diff --git a/deps/include/libplatform/v8-tracing.h b/deps/include/libplatform/v8-tracing.h index ccdca0a8..e7cd8bfc 100644 --- a/deps/include/libplatform/v8-tracing.h +++ b/deps/include/libplatform/v8-tracing.h @@ -14,6 +14,10 @@ #include "libplatform/libplatform-export.h" #include "v8-platform.h" // NOLINT(build/include) +namespace perfetto { +class TracingSession; +} + namespace v8 { namespace base { @@ -23,8 +27,8 @@ class Mutex; namespace platform { namespace tracing { -class PerfettoTracingController; class TraceEventListener; +class JSONTraceEventListener; const int kTraceMaxNumArgs = 2; @@ -292,11 +296,10 @@ class V8_PLATFORM_EXPORT TracingController std::unordered_set observers_; std::atomic_bool recording_{false}; #ifdef V8_USE_PERFETTO - std::atomic_bool perfetto_recording_{false}; - std::unique_ptr perfetto_tracing_controller_; std::ostream* output_stream_ = nullptr; - std::unique_ptr json_listener_; + std::unique_ptr json_listener_; TraceEventListener* listener_for_testing_ = nullptr; + std::unique_ptr tracing_session_; #endif // Disallow copy and assign diff --git a/deps/include/v8-inspector.h b/deps/include/v8-inspector.h index b96a6e29..cfa2aaba 100644 --- a/deps/include/v8-inspector.h +++ b/deps/include/v8-inspector.h @@ -109,6 +109,8 @@ class V8_EXPORT V8StackTrace { virtual ~V8StackTrace() = default; virtual std::unique_ptr buildInspectorObject() const = 0; + virtual std::unique_ptr + buildInspectorObject(int maxAsyncDepth) const = 0; virtual std::unique_ptr toString() const = 0; // Safe to pass between threads, drops async chain. @@ -130,10 +132,6 @@ class V8_EXPORT V8InspectorSession { // Dispatching protocol messages. static bool canDispatchMethod(const StringView& method); virtual void dispatchProtocolMessage(const StringView& message) = 0; - virtual V8_DEPRECATED("Use state() instead", - std::unique_ptr stateJSON()) { - return nullptr; - } virtual std::vector state() = 0; virtual std::vector> supportedDomains() = 0; diff --git a/deps/include/v8-platform.h b/deps/include/v8-platform.h index b707fafc..7e43b0d9 100644 --- a/deps/include/v8-platform.h +++ b/deps/include/v8-platform.h @@ -439,6 +439,14 @@ class Platform { */ virtual void DumpWithoutCrashing() {} + /** + * Lets the embedder to add crash keys. + */ + virtual void AddCrashKey(int id, const char* name, uintptr_t value) { + // "noop" is a valid implementation if the embedder doesn't care to log + // additional data for crashes. + } + protected: /** * Default implementation of current wall-clock time in milliseconds diff --git a/deps/include/v8-version.h b/deps/include/v8-version.h index 853a322c..8c9365ad 100644 --- a/deps/include/v8-version.h +++ b/deps/include/v8-version.h @@ -9,9 +9,9 @@ // NOTE these macros are used by some of the tool scripts and the build // system so their names cannot be changed without changing the scripts. #define V8_MAJOR_VERSION 7 -#define V8_MINOR_VERSION 6 -#define V8_BUILD_NUMBER 303 -#define V8_PATCH_LEVEL 0 +#define V8_MINOR_VERSION 7 +#define V8_BUILD_NUMBER 299 +#define V8_PATCH_LEVEL 9 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/include/v8.h b/deps/include/v8.h index c54b0884..ca96c320 100644 --- a/deps/include/v8.h +++ b/deps/include/v8.h @@ -1326,6 +1326,37 @@ class V8_EXPORT Module { * kEvaluated or kErrored. */ Local GetUnboundModuleScript(); + + /* + * Callback defined in the embedder. This is responsible for setting + * the module's exported values with calls to SetSyntheticModuleExport(). + * The callback must return a Value to indicate success (where no + * exception was thrown) and return an empy MaybeLocal to indicate falure + * (where an exception was thrown). + */ + typedef MaybeLocal (*SyntheticModuleEvaluationSteps)( + Local context, Local module); + + /** + * Creates a new SyntheticModule with the specified export names, where + * evaluation_steps will be executed upon module evaluation. + * export_names must not contain duplicates. + * module_name is used solely for logging/debugging and doesn't affect module + * behavior. + */ + static Local CreateSyntheticModule( + Isolate* isolate, Local module_name, + const std::vector>& export_names, + SyntheticModuleEvaluationSteps evaluation_steps); + + /** + * Set this module's exported value for the name export_name to the specified + * export_value. This method must be called only on Modules created via + * CreateSyntheticModule. export_name must be one of the export_names that + * were passed in that CreateSyntheticModule call. + */ + void SetSyntheticModuleExport(Local export_name, + Local export_value); }; /** @@ -1668,7 +1699,8 @@ class V8_EXPORT ScriptCompiler { Local arguments[], size_t context_extension_count, Local context_extensions[], CompileOptions options = kNoCompileOptions, - NoCacheReason no_cache_reason = kNoCacheNoReason); + NoCacheReason no_cache_reason = kNoCacheNoReason, + Local* script_or_module_out = nullptr); /** * Creates and returns code cache for the specified unbound_script. @@ -3288,8 +3320,6 @@ enum class IntegrityLevel { kFrozen, kSealed }; */ class V8_EXPORT Object : public Value { public: - V8_DEPRECATED("Use maybe version", - bool Set(Local key, Local value)); /** * Set only return Just(true) or Empty(), so if it should never fail, use * result.Check(). @@ -3297,8 +3327,6 @@ class V8_EXPORT Object : public Value { V8_WARN_UNUSED_RESULT Maybe Set(Local context, Local key, Local value); - V8_DEPRECATED("Use maybe version", - bool Set(uint32_t index, Local value)); V8_WARN_UNUSED_RESULT Maybe Set(Local context, uint32_t index, Local value); @@ -3340,13 +3368,12 @@ class V8_EXPORT Object : public Value { // // Returns true on success. V8_WARN_UNUSED_RESULT Maybe DefineProperty( - Local context, Local key, PropertyDescriptor& descriptor); + Local context, Local key, + PropertyDescriptor& descriptor); // NOLINT(runtime/references) - V8_DEPRECATED("Use maybe version", Local Get(Local key)); V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context, Local key); - V8_DEPRECATED("Use maybe version", Local Get(uint32_t index)); V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context, uint32_t index); @@ -5319,6 +5346,8 @@ class V8_EXPORT RegExp : public Object { kDotAll = 1 << 5, }; + static constexpr int kFlagCount = 6; + /** * Creates a regular expression from the given pattern string and * the flags bit field. May throw a JavaScript exception as @@ -6405,7 +6434,19 @@ V8_INLINE Local False(Isolate* isolate); */ class V8_EXPORT ResourceConstraints { public: - ResourceConstraints(); + /** + * Configures the constraints with reasonable default values based on the + * provided heap size limit. The heap size includes both the young and + * the old generation. + * + * \param maximum_heap_size_in_bytes The hard limit for the heap size. + * When the heap size approaches this limit, V8 will perform series of + * garbage collections and invoke the NearHeapLimitCallback. + * If the garbage collections do not help and the callback does not + * increase the limit, then V8 will crash with V8::FatalProcessOutOfMemory. + */ + void ConfigureDefaultsFromHeapSize(size_t initial_heap_size_in_bytes, + size_t maximum_heap_size_in_bytes); /** * Configures the constraints with reasonable default values based on the @@ -6419,26 +6460,81 @@ class V8_EXPORT ResourceConstraints { void ConfigureDefaults(uint64_t physical_memory, uint64_t virtual_memory_limit); - // Returns the max semi-space size in KB. - size_t max_semi_space_size_in_kb() const { - return max_semi_space_size_in_kb_; + /** + * The address beyond which the VM's stack may not grow. + */ + uint32_t* stack_limit() const { return stack_limit_; } + void set_stack_limit(uint32_t* value) { stack_limit_ = value; } + + /** + * The amount of virtual memory reserved for generated code. This is relevant + * for 64-bit architectures that rely on code range for calls in code. + */ + size_t code_range_size_in_bytes() const { return code_range_size_; } + void set_code_range_size_in_bytes(size_t limit) { code_range_size_ = limit; } + + /** + * The maximum size of the old generation. + * When the old generation approaches this limit, V8 will perform series of + * garbage collections and invoke the NearHeapLimitCallback. + * If the garbage collections do not help and the callback does not + * increase the limit, then V8 will crash with V8::FatalProcessOutOfMemory. + */ + size_t max_old_generation_size_in_bytes() const { + return max_old_generation_size_; + } + void set_max_old_generation_size_in_bytes(size_t limit) { + max_old_generation_size_ = limit; } - // Sets the max semi-space size in KB. - void set_max_semi_space_size_in_kb(size_t limit_in_kb) { - max_semi_space_size_in_kb_ = limit_in_kb; + /** + * The maximum size of the young generation, which consists of two semi-spaces + * and a large object space. This affects frequency of Scavenge garbage + * collections and should be typically much smaller that the old generation. + */ + size_t max_young_generation_size_in_bytes() const { + return max_young_generation_size_; + } + void set_max_young_generation_size_in_bytes(size_t limit) { + max_young_generation_size_ = limit; } - size_t max_old_space_size() const { return max_old_space_size_; } - void set_max_old_space_size(size_t limit_in_mb) { - max_old_space_size_ = limit_in_mb; + size_t initial_old_generation_size_in_bytes() const { + return initial_old_generation_size_; } - uint32_t* stack_limit() const { return stack_limit_; } - // Sets an address beyond which the VM's stack may not grow. - void set_stack_limit(uint32_t* value) { stack_limit_ = value; } - size_t code_range_size() const { return code_range_size_; } - void set_code_range_size(size_t limit_in_mb) { - code_range_size_ = limit_in_mb; + void set_initial_old_generation_size_in_bytes(size_t initial_size) { + initial_old_generation_size_ = initial_size; + } + + size_t initial_young_generation_size_in_bytes() const { + return initial_young_generation_size_; + } + void set_initial_young_generation_size_in_bytes(size_t initial_size) { + initial_young_generation_size_ = initial_size; + } + + /** + * Deprecated functions. Do not use in new code. + */ + V8_DEPRECATE_SOON("Use code_range_size_in_bytes.", + size_t code_range_size() const) { + return code_range_size_ / kMB; + } + V8_DEPRECATE_SOON("Use set_code_range_size_in_bytes.", + void set_code_range_size(size_t limit_in_mb)) { + code_range_size_ = limit_in_mb * kMB; + } + V8_DEPRECATE_SOON("Use max_young_generation_size_in_bytes.", + size_t max_semi_space_size_in_kb() const); + V8_DEPRECATE_SOON("Use set_max_young_generation_size_in_bytes.", + void set_max_semi_space_size_in_kb(size_t limit_in_kb)); + V8_DEPRECATE_SOON("Use max_old_generation_size_in_bytes.", + size_t max_old_space_size() const) { + return max_old_generation_size_ / kMB; + } + V8_DEPRECATE_SOON("Use set_max_old_generation_size_in_bytes.", + void set_max_old_space_size(size_t limit_in_mb)) { + max_old_generation_size_ = limit_in_mb * kMB; } V8_DEPRECATE_SOON("Zone does not pool memory any more.", size_t max_zone_pool_size() const) { @@ -6450,14 +6546,14 @@ class V8_EXPORT ResourceConstraints { } private: - // max_semi_space_size_ is in KB - size_t max_semi_space_size_in_kb_; - - // The remaining limits are in MB - size_t max_old_space_size_; - uint32_t* stack_limit_; - size_t code_range_size_; - size_t max_zone_pool_size_; + static constexpr size_t kMB = 1048576u; + size_t code_range_size_ = 0; + size_t max_old_generation_size_ = 0; + size_t max_young_generation_size_ = 0; + size_t max_zone_pool_size_ = 0; + size_t initial_old_generation_size_ = 0; + size_t initial_young_generation_size_ = 0; + uint32_t* stack_limit_ = nullptr; }; @@ -6770,6 +6866,8 @@ typedef void (*FailedAccessCheckCallback)(Local target, */ typedef bool (*AllowCodeGenerationFromStringsCallback)(Local context, Local source); +typedef MaybeLocal (*ModifyCodeGenerationFromStringsCallback)( + Local context, Local source); // --- WebAssembly compilation callbacks --- typedef bool (*ExtensionCallback)(const FunctionCallbackInfo&); @@ -7230,12 +7328,13 @@ class V8_EXPORT EmbedderHeapTracer { void GarbageCollectionForTesting(EmbedderStackState stack_state); /* - * Called by the embedder to signal newly allocated memory. Not bound to - * tracing phases. Embedders should trade off when increments are reported as - * V8 may consult global heuristics on whether to trigger garbage collection - * on this change. + * Called by the embedder to signal newly allocated or freed memory. Not bound + * to tracing phases. Embedders should trade off when increments are reported + * as V8 may consult global heuristics on whether to trigger garbage + * collection on this change. */ void IncreaseAllocatedSize(size_t bytes); + void DecreaseAllocatedSize(size_t bytes); /* * Returns the v8::Isolate this tracer is attached too and |nullptr| if it @@ -7563,6 +7662,8 @@ class V8_EXPORT Isolate { kRegExpMatchIsFalseishOnJSRegExp = 73, kDateGetTimezoneOffset = 74, kStringNormalize = 75, + kCallSiteAPIGetFunctionSloppyCall = 76, + kCallSiteAPIGetThisSloppyCall = 77, // If you add new values here, you'll also need to update Chromium's: // web_feature.mojom, UseCounterCallback.cpp, and enums.xml. V8 changes to @@ -8367,6 +8468,8 @@ class V8_EXPORT Isolate { */ void SetAllowCodeGenerationFromStringsCallback( AllowCodeGenerationFromStringsCallback callback); + void SetModifyCodeGenerationFromStringsCallback( + ModifyCodeGenerationFromStringsCallback callback); /** * Set the callback to invoke to check if wasm code generation should @@ -9401,6 +9504,15 @@ class V8_EXPORT Context { template V8_INLINE MaybeLocal GetDataFromSnapshotOnce(size_t index); + /** + * If callback is set, abort any attempt to execute JavaScript in this + * context, call the specified callback, and throw an exception. + * To unset abort, pass nullptr as callback. + */ + typedef void (*AbortScriptExecutionCallback)(Isolate* isolate, + Local context); + void SetAbortScriptExecution(AbortScriptExecutionCallback callback); + /** * Stack-allocated class which sets the execution context for all * operations executed within a local scope. diff --git a/deps/include/v8config.h b/deps/include/v8config.h index 5ec0480c..7bd29382 100644 --- a/deps/include/v8config.h +++ b/deps/include/v8config.h @@ -353,6 +353,12 @@ #define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ #endif +#if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED) +#error Inconsistent build configuration: To build the V8 shared library \ +set BUILDING_V8_SHARED, to include its headers for linking against the \ +V8 shared library set USING_V8_SHARED. +#endif + #ifdef V8_OS_WIN // Setup for Windows DLL export/import. When building the V8 DLL the