From a977ecf7e3c4b9e41905f54c2d769003872e215a Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Thu, 26 Nov 2020 22:08:59 +0100 Subject: [PATCH 01/90] Prevent player.setDateTime from setting month above 11 Former-commit-id: 14d6dd824d991ead955b6e356f382ca17fffe41d --- src/bindings/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index 4339fd6e..2b01ab4c 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -401,7 +401,7 @@ static void SetDateTime(const v8::FunctionCallbackInfo& info) v8::Local minute = info[4]->ToInteger(isolate); v8::Local second = info[5]->ToInteger(isolate); - player->SetDateTime(day->Value(), month->Value(), year->Value(), hour->Value(), minute->Value(), second->Value()); + player->SetDateTime(day->Value(), month->Value() > 11 ? 11 : month->Value(), year->Value(), hour->Value(), minute->Value(), second->Value()); } static void SetWeather(const v8::FunctionCallbackInfo& info) From 879fa1279f6b7abe939b3f4d3e37650e652da334 Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Fri, 27 Nov 2020 11:26:31 +0100 Subject: [PATCH 02/90] Added checks for other parameters Former-commit-id: d3a8da107364f1a518e31f651527e81aab30f6e3 --- src/bindings/Player.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index 2b01ab4c..df4459bc 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -401,7 +401,14 @@ static void SetDateTime(const v8::FunctionCallbackInfo& info) v8::Local minute = info[4]->ToInteger(isolate); v8::Local second = info[5]->ToInteger(isolate); - player->SetDateTime(day->Value(), month->Value() > 11 ? 11 : month->Value(), year->Value(), hour->Value(), minute->Value(), second->Value()); + player->SetDateTime( + day->Value() > 31 ? 31 : day->Value(), + month->Value() > 11 ? 11 : month->Value(), + year->Value(), + hour->Value() > 23 ? 23 : hour->Value(), + minute->Value() > 59 ? 59 : minute->Value(), + second->Value() > 59 ? 59 : minute->Value() + ); } static void SetWeather(const v8::FunctionCallbackInfo& info) From 87995c91d3f6e4bea9f8d1adbf0422902f69e44e Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Fri, 27 Nov 2020 16:02:24 +0100 Subject: [PATCH 03/90] Add clamp Former-commit-id: 0d4747625eb39ab8ef659bd2a58ed80bcab252c1 --- src/bindings/Player.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index df4459bc..cdac8d1c 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -394,21 +394,20 @@ static void SetDateTime(const v8::FunctionCallbackInfo& info) Ref player = _this->GetHandle().As(); - v8::Local day = info[0]->ToInteger(isolate); - v8::Local month = info[1]->ToInteger(isolate); - v8::Local year = info[2]->ToInteger(isolate); - v8::Local hour = info[3]->ToInteger(isolate); - v8::Local minute = info[4]->ToInteger(isolate); - v8::Local second = info[5]->ToInteger(isolate); - - player->SetDateTime( - day->Value() > 31 ? 31 : day->Value(), - month->Value() > 11 ? 11 : month->Value(), - year->Value(), - hour->Value() > 23 ? 23 : hour->Value(), - minute->Value() > 59 ? 59 : minute->Value(), - second->Value() > 59 ? 59 : minute->Value() - ); + auto day = info[0]->ToInteger(isolate)->Value(); + V8_CLAMP(day, 0, 30); + auto month = info[1]->ToInteger(isolate)->Value(); + V8_CLAMP(day, 0, 11); + auto year = info[2]->ToInteger(isolate)->Value(); + V8_CLAMP(day, 0, 9999); + auto hour = info[3]->ToInteger(isolate)->Value(); + V8_CLAMP(day, 0, 23); + auto minute = info[4]->ToInteger(isolate)->Value(); + V8_CLAMP(day, 0, 59); + auto second = info[5]->ToInteger(isolate)->Value(); + V8_CLAMP(second, 0, 59); + + player->SetDateTime(day, month, year, hour, minute, second); } static void SetWeather(const v8::FunctionCallbackInfo& info) From 11e618964e79f76faf934df53d4aa6e9b448a73a Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Fri, 27 Nov 2020 16:12:25 +0100 Subject: [PATCH 04/90] Reworked clamp Former-commit-id: 2b4eac6f193f48edb15e7d3f94202585a55a840d --- src/bindings/Player.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index cdac8d1c..defa1818 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -2,6 +2,7 @@ #include "helpers/V8Helpers.h" #include "helpers/V8ResourceImpl.h" +#include using namespace alt; @@ -394,18 +395,12 @@ static void SetDateTime(const v8::FunctionCallbackInfo& info) Ref player = _this->GetHandle().As(); - auto day = info[0]->ToInteger(isolate)->Value(); - V8_CLAMP(day, 0, 30); - auto month = info[1]->ToInteger(isolate)->Value(); - V8_CLAMP(day, 0, 11); - auto year = info[2]->ToInteger(isolate)->Value(); - V8_CLAMP(day, 0, 9999); - auto hour = info[3]->ToInteger(isolate)->Value(); - V8_CLAMP(day, 0, 23); - auto minute = info[4]->ToInteger(isolate)->Value(); - V8_CLAMP(day, 0, 59); - auto second = info[5]->ToInteger(isolate)->Value(); - V8_CLAMP(second, 0, 59); + int day = std::clamp(static_cast(info[0]->ToInteger(isolate)->Value()), 0, 30); + int month = std::clamp(static_cast(info[1]->ToInteger(isolate)->Value()), 0, 11); + int year = std::clamp(static_cast(info[2]->ToInteger(isolate)->Value()), 0, 9999); + int hour = std::clamp(static_cast(info[3]->ToInteger(isolate)->Value()), 0, 23); + int minute = std::clamp(static_cast(info[4]->ToInteger(isolate)->Value()), 0, 59); + int second = std::clamp(static_cast(info[5]->ToInteger(isolate)->Value()), 0, 59); player->SetDateTime(day, month, year, hour, minute, second); } From 51d27e08d00c301c0d9113876308dd31c92ba4e9 Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Sat, 19 Dec 2020 11:28:54 +0100 Subject: [PATCH 05/90] Add player.emit and alt.emitAllClients Former-commit-id: cea9789120c4b0cded4175313fd6adb5c7417ce5 --- src/bindings/Main.cpp | 16 ++++++++++++++++ src/bindings/Player.cpp | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/bindings/Main.cpp b/src/bindings/Main.cpp index 51f0b4b9..58c2758e 100644 --- a/src/bindings/Main.cpp +++ b/src/bindings/Main.cpp @@ -81,6 +81,21 @@ static void EmitClient(const v8::FunctionCallbackInfo& info) ICore::Instance().TriggerClientEvent(player, *evName, mvArgs); } +static void EmitAllClients(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN_MIN(1); + V8_ARG_TO_STRING(1, eventName); + + Ref player; + MValueArgs args; + + for (int i = 1; i < info.Length(); ++i) + args.Push(V8Helpers::V8ToMValue(info[i])); + + ICore::Instance().TriggerClientEvent(player, eventName, args); +} + static void SetSyncedMeta(const v8::FunctionCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); @@ -316,6 +331,7 @@ extern V8Module v8Alt("alt", V8Helpers::RegisterFunc(exports, "onceClient", &OnceClient); V8Helpers::RegisterFunc(exports, "offClient", &OffClient); V8Helpers::RegisterFunc(exports, "emitClient", &EmitClient); + V8Helpers::RegisterFunc(exports, "emitAllClients", &EmitAllClients); V8Helpers::RegisterFunc(exports, "setSyncedMeta", &SetSyncedMeta); V8Helpers::RegisterFunc(exports, "deleteSyncedMeta", &DeleteSyncedMeta); diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index e1b83666..ea66e9e9 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -353,6 +353,21 @@ static void AuthTokenGetter(v8::Local name, const v8::PropertyCallba info.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, player->GetAuthToken().CStr())); } +static void Emit(const v8::FunctionCallbackInfo& info) +{ + V8_GET_ISOLATE_CONTEXT(); + V8_CHECK_ARGS_LEN_MIN(1); + V8_ARG_TO_STRING(1, eventName); + V8_GET_THIS_BASE_OBJECT(player, IPlayer); + + MValueArgs args; + + for (int i = 1; i < info.Length(); ++i) + args.Push(V8Helpers::V8ToMValue(info[i])); + + ICore::Instance().TriggerClientEvent(player, eventName, args); +} + static void Spawn(const v8::FunctionCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); @@ -638,6 +653,7 @@ extern V8Class v8Player("Player", v8Entity, nullptr, [](v8::LocalSetAccessor(v8::String::NewFromUtf8(isolate, "flashlightActive"), &FlashlightActiveGetter); + proto->Set(v8::String::NewFromUtf8(isolate, "emit"), v8::FunctionTemplate::New(isolate, &Emit)); proto->Set(v8::String::NewFromUtf8(isolate, "spawn"), v8::FunctionTemplate::New(isolate, &Spawn)); proto->Set(v8::String::NewFromUtf8(isolate, "setDateTime"), v8::FunctionTemplate::New(isolate, &SetDateTime)); proto->Set(v8::String::NewFromUtf8(isolate, "setWeather"), v8::FunctionTemplate::New(isolate, &SetWeather)); From 30d56bf80827a52e061e95fbad3e7c8613624e89 Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Sat, 19 Dec 2020 11:29:22 +0100 Subject: [PATCH 06/90] Add deprecation warning to alt.emitClient Former-commit-id: dcad174e78167e000070eb80696f7ba109d191ff --- src/bindings/Main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bindings/Main.cpp b/src/bindings/Main.cpp index 58c2758e..13af4b7c 100644 --- a/src/bindings/Main.cpp +++ b/src/bindings/Main.cpp @@ -52,6 +52,7 @@ static void OffClient(const v8::FunctionCallbackInfo& info) static void EmitClient(const v8::FunctionCallbackInfo& info) { + Log::Warning << "alt.emitClient is deprecated. Consider using player.emit instead" << Log::Endl; v8::Isolate* isolate = info.GetIsolate(); V8_CHECK(info.Length() >= 2, "at least 2 args expected"); From e23a89d75fd992f689816e63abb948055832cbe1 Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Sat, 19 Dec 2020 11:40:43 +0100 Subject: [PATCH 07/90] Remove deprecation warning from alt.emitClient Former-commit-id: b164f400c63848911e1688f3b40de3ad54981c92 --- src/bindings/Main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bindings/Main.cpp b/src/bindings/Main.cpp index 13af4b7c..58c2758e 100644 --- a/src/bindings/Main.cpp +++ b/src/bindings/Main.cpp @@ -52,7 +52,6 @@ static void OffClient(const v8::FunctionCallbackInfo& info) static void EmitClient(const v8::FunctionCallbackInfo& info) { - Log::Warning << "alt.emitClient is deprecated. Consider using player.emit instead" << Log::Endl; v8::Isolate* isolate = info.GetIsolate(); V8_CHECK(info.Length() >= 2, "at least 2 args expected"); From a35bc509d4a69285d553bd025a47af2249cf2abb Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Sat, 19 Dec 2020 15:02:29 +0100 Subject: [PATCH 08/90] Remove player.emit Former-commit-id: 6f47ae3ee52c488c37250da7f0a275a4608a3ac4 --- src/bindings/Player.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index ea66e9e9..e1b83666 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -353,21 +353,6 @@ static void AuthTokenGetter(v8::Local name, const v8::PropertyCallba info.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, player->GetAuthToken().CStr())); } -static void Emit(const v8::FunctionCallbackInfo& info) -{ - V8_GET_ISOLATE_CONTEXT(); - V8_CHECK_ARGS_LEN_MIN(1); - V8_ARG_TO_STRING(1, eventName); - V8_GET_THIS_BASE_OBJECT(player, IPlayer); - - MValueArgs args; - - for (int i = 1; i < info.Length(); ++i) - args.Push(V8Helpers::V8ToMValue(info[i])); - - ICore::Instance().TriggerClientEvent(player, eventName, args); -} - static void Spawn(const v8::FunctionCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); @@ -653,7 +638,6 @@ extern V8Class v8Player("Player", v8Entity, nullptr, [](v8::LocalSetAccessor(v8::String::NewFromUtf8(isolate, "flashlightActive"), &FlashlightActiveGetter); - proto->Set(v8::String::NewFromUtf8(isolate, "emit"), v8::FunctionTemplate::New(isolate, &Emit)); proto->Set(v8::String::NewFromUtf8(isolate, "spawn"), v8::FunctionTemplate::New(isolate, &Spawn)); proto->Set(v8::String::NewFromUtf8(isolate, "setDateTime"), v8::FunctionTemplate::New(isolate, &SetDateTime)); proto->Set(v8::String::NewFromUtf8(isolate, "setWeather"), v8::FunctionTemplate::New(isolate, &SetWeather)); From fa0f0e03cea6eeb0bc0d6d01e39538e15bc1f91f Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Sun, 27 Dec 2020 16:22:41 +0100 Subject: [PATCH 09/90] Add constructor check to Vehicle and VoiceChannel Former-commit-id: 46f45ef23958c6b96dd728d120d6aa709e5edc84 --- src/bindings/Vehicle.cpp | 1 + src/bindings/VoiceChannel.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/bindings/Vehicle.cpp b/src/bindings/Vehicle.cpp index 3d8b732e..3e028f91 100644 --- a/src/bindings/Vehicle.cpp +++ b/src/bindings/Vehicle.cpp @@ -44,6 +44,7 @@ static void DestroyedGetter(v8::Local name, const v8::PropertyCallba static void Constructor(const v8::FunctionCallbackInfo& info) { v8::Isolate* isolate = info.GetIsolate(); + V8_CHECK_CONSTRUCTOR(); V8_CHECK(info.Length() == 7, "7 args expected"); V8_CHECK(info[0]->IsString() || info[0]->IsNumber(), "string or number expected"); diff --git a/src/bindings/VoiceChannel.cpp b/src/bindings/VoiceChannel.cpp index 11ef5077..6ac2b42b 100644 --- a/src/bindings/VoiceChannel.cpp +++ b/src/bindings/VoiceChannel.cpp @@ -140,6 +140,7 @@ static void IsPlayerMuted(const v8::FunctionCallbackInfo& info) static void Constructor(const v8::FunctionCallbackInfo& info) { V8_GET_ISOLATE_CONTEXT_RESOURCE(); + V8_CHECK_CONSTRUCTOR(); V8_CHECK_ARGS_LEN(2); V8_ARG_TO_BOOLEAN(1, isSpatial); V8_ARG_TO_NUMBER(2, maxDistance); From 4059ff93c23b7fc86dee9a00b2f7d4d588ca635b Mon Sep 17 00:00:00 2001 From: LeonMrBonnie Date: Tue, 29 Dec 2020 21:39:26 +0100 Subject: [PATCH 10/90] Add socialID getter and deprecate socialId getter Former-commit-id: 6ec417dd7ab8eb4e950c5534d078f247adffc6c6 --- src/bindings/Player.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/bindings/Player.cpp b/src/bindings/Player.cpp index 0385ecd3..fed224fa 100644 --- a/src/bindings/Player.cpp +++ b/src/bindings/Player.cpp @@ -306,6 +306,23 @@ static void SocialIdGetter(v8::Local name, const v8::PropertyCallbac Ref player = _this->GetHandle().As(); + Log::Warning << "player.socialId is deprecated and will be removed in the future. Consider using player.socialID" << Log::Endl; + + info.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, std::to_string(player->GetSocialID()).c_str())); +} + +static void SocialIDGetter(v8::Local name, const v8::PropertyCallbackInfo& info) +{ + v8::Isolate* isolate = info.GetIsolate(); + + V8ResourceImpl* resource = V8ResourceImpl::Get(isolate->GetEnteredContext()); + V8_CHECK(resource, "invalid resource"); + + V8Entity* _this = V8Entity::Get(info.This()); + V8_CHECK(_this, "entity is invalid"); + + Ref player = _this->GetHandle().As(); + info.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, std::to_string(player->GetSocialID()).c_str())); } @@ -633,6 +650,7 @@ extern V8Class v8Player("Player", v8Entity, nullptr, [](v8::LocalSetAccessor(v8::String::NewFromUtf8(isolate, "currentWeaponTintIndex"), &CurrentWeaponTintIndexGetter); proto->SetAccessor(v8::String::NewFromUtf8(isolate, "socialId"), &SocialIdGetter); + proto->SetAccessor(v8::String::NewFromUtf8(isolate, "socialID"), &SocialIDGetter); proto->SetAccessor(v8::String::NewFromUtf8(isolate, "hwidHash"), &HwidHashGetter); proto->SetAccessor(v8::String::NewFromUtf8(isolate, "hwidExHash"), &HwidExHashGetter); proto->SetAccessor(v8::String::NewFromUtf8(isolate, "authToken"), &AuthTokenGetter); From d2a82fd6e72a8a9be95cc80a917fa7b36b24b26e Mon Sep 17 00:00:00 2001 From: Vadim Zubkov Date: Sat, 9 Jan 2021 03:02:30 +0300 Subject: [PATCH 11/90] Updated nodejs to 14.15.2 Former-commit-id: f0a77476a16f55d5dbb22466548a489b8fa54017 --- CMakeLists.txt | 2 +- deps/nodejs/deps/uv/include/uv.h | 155 +- deps/nodejs/deps/uv/include/uv/errno.h | 7 +- deps/nodejs/deps/uv/include/uv/unix.h | 26 +- deps/nodejs/deps/uv/include/uv/version.h | 6 +- deps/nodejs/deps/uv/include/uv/win.h | 3 +- deps/nodejs/deps/v8/include/APIDesign.md | 3 + deps/nodejs/deps/v8/include/DEPS | 1 + deps/nodejs/deps/v8/include/OWNERS | 9 +- deps/nodejs/deps/v8/include/cppgc/DEPS | 7 + deps/nodejs/deps/v8/include/cppgc/README.md | 5 + .../nodejs/deps/v8/include/cppgc/allocation.h | 161 ++ deps/nodejs/deps/v8/include/cppgc/common.h | 26 + .../deps/v8/include/cppgc/custom-space.h | 62 + .../deps/v8/include/cppgc/garbage-collected.h | 192 ++ deps/nodejs/deps/v8/include/cppgc/heap.h | 63 + .../v8/include/cppgc/internal/accessors.h | 26 + .../v8/include/cppgc/internal/api-constants.h | 44 + .../cppgc/internal/compiler-specific.h | 26 + .../include/cppgc/internal/finalizer-trait.h | 90 + .../deps/v8/include/cppgc/internal/gc-info.h | 43 + .../deps/v8/include/cppgc/internal/logging.h | 50 + .../include/cppgc/internal/persistent-node.h | 109 + .../include/cppgc/internal/pointer-policies.h | 133 + .../cppgc/internal/prefinalizer-handler.h | 31 + .../deps/v8/include/cppgc/liveness-broker.h | 50 + deps/nodejs/deps/v8/include/cppgc/macros.h | 26 + deps/nodejs/deps/v8/include/cppgc/member.h | 206 ++ .../nodejs/deps/v8/include/cppgc/persistent.h | 304 +++ deps/nodejs/deps/v8/include/cppgc/platform.h | 31 + .../deps/v8/include/cppgc/prefinalizer.h | 54 + .../deps/v8/include/cppgc/source-location.h | 59 + .../deps/v8/include/cppgc/trace-trait.h | 67 + .../deps/v8/include/cppgc/type-traits.h | 109 + deps/nodejs/deps/v8/include/cppgc/visitor.h | 138 + .../deps/v8/include/js_protocol-1.2.json | 997 ++++++++ .../deps/v8/include/js_protocol-1.3.json | 1205 +++++++++ deps/nodejs/deps/v8/include/js_protocol.pdl | 1616 ++++++++++++ .../deps/v8/include/libplatform/libplatform.h | 23 +- .../deps/v8/include/libplatform/v8-tracing.h | 27 +- .../deps/v8/include/v8-fast-api-calls.h | 412 +++ .../deps/v8/include/v8-inspector-protocol.h | 8 +- deps/nodejs/deps/v8/include/v8-inspector.h | 89 +- deps/nodejs/deps/v8/include/v8-internal.h | 160 +- deps/nodejs/deps/v8/include/v8-platform.h | 204 +- deps/nodejs/deps/v8/include/v8-profiler.h | 267 +- deps/nodejs/deps/v8/include/v8-util.h | 20 +- .../deps/v8/include/v8-version-string.h | 2 +- deps/nodejs/deps/v8/include/v8-version.h | 6 +- .../v8/include/v8-wasm-trap-handler-posix.h | 2 +- .../v8/include/v8-wasm-trap-handler-win.h | 2 +- deps/nodejs/deps/v8/include/v8.h | 2274 ++++++++++++----- deps/nodejs/deps/v8/include/v8config.h | 186 +- deps/nodejs/include/aliased_buffer.h | 9 +- deps/nodejs/include/aliased_struct-inl.h | 54 + deps/nodejs/include/aliased_struct.h | 63 + deps/nodejs/include/allocated_buffer-inl.h | 110 + deps/nodejs/include/allocated_buffer.h | 73 + deps/nodejs/include/async_wrap-inl.h | 19 +- deps/nodejs/include/async_wrap.h | 43 +- deps/nodejs/include/base64-inl.h | 98 + deps/nodejs/include/base64.h | 144 +- deps/nodejs/include/base_object-inl.h | 261 +- deps/nodejs/include/base_object.h | 189 +- deps/nodejs/include/callback_queue-inl.h | 97 + deps/nodejs/include/callback_queue.h | 78 + deps/nodejs/include/connect_wrap.h | 2 - deps/nodejs/include/connection_wrap.h | 4 +- deps/nodejs/include/debug_utils-inl.h | 223 ++ deps/nodejs/include/debug_utils.h | 117 +- deps/nodejs/include/diagnosticfilename-inl.h | 4 +- deps/nodejs/include/env-inl.h | 550 ++-- deps/nodejs/include/env.h | 560 ++-- deps/nodejs/include/handle_wrap.h | 5 +- deps/nodejs/include/histogram-inl.h | 70 +- deps/nodejs/include/histogram.h | 70 +- deps/nodejs/include/http_parser_adaptor.h | 24 - .../include/inspector/main_thread_interface.h | 9 +- deps/nodejs/include/inspector/runtime_agent.h | 2 +- .../include/inspector/worker_inspector.h | 13 + deps/nodejs/include/inspector_agent.h | 29 +- deps/nodejs/include/inspector_io.h | 31 +- deps/nodejs/include/inspector_profiler.h | 9 +- deps/nodejs/include/inspector_socket_server.h | 6 + deps/nodejs/include/js_native_api.h | 82 +- deps/nodejs/include/js_native_api_types.h | 48 + deps/nodejs/include/js_native_api_v8.h | 186 +- deps/nodejs/include/js_stream.h | 4 +- deps/nodejs/include/json_utils.h | 161 ++ .../include/large_pages/node_large_page.h | 3 +- deps/nodejs/include/memory_tracker-inl.h | 41 +- deps/nodejs/include/memory_tracker.h | 31 +- deps/nodejs/include/module_wrap.h | 36 +- deps/nodejs/include/node.h | 343 ++- deps/nodejs/include/node_api.h | 47 +- deps/nodejs/include/node_api_types.h | 6 + deps/nodejs/include/node_binding.h | 2 - deps/nodejs/include/node_buffer.h | 8 +- deps/nodejs/include/node_constants.h | 6 +- deps/nodejs/include/node_context_data.h | 5 + deps/nodejs/include/node_contextify.h | 52 +- deps/nodejs/include/node_crypto.h | 296 ++- deps/nodejs/include/node_crypto_bio.h | 20 +- deps/nodejs/include/node_crypto_common.h | 138 + deps/nodejs/include/node_crypto_groups.h | 21 +- deps/nodejs/include/node_dir.h | 52 + deps/nodejs/include/node_dtrace.h | 3 +- deps/nodejs/include/node_errors.h | 146 +- deps/nodejs/include/node_file-inl.h | 306 +++ deps/nodejs/include/node_file.h | 473 ++-- deps/nodejs/include/node_http2.h | 1126 ++++---- deps/nodejs/include/node_http2_state.h | 91 +- deps/nodejs/include/node_http_common-inl.h | 194 ++ deps/nodejs/include/node_http_common.h | 529 ++++ deps/nodejs/include/node_http_parser_impl.h | 970 ------- deps/nodejs/include/node_i18n.h | 78 +- deps/nodejs/include/node_internals.h | 106 +- deps/nodejs/include/node_main_instance.h | 21 +- deps/nodejs/include/node_mem-inl.h | 112 + deps/nodejs/include/node_mem.h | 45 + deps/nodejs/include/node_messaging.h | 120 +- deps/nodejs/include/node_metadata.h | 3 - deps/nodejs/include/node_mutex.h | 48 + deps/nodejs/include/node_native_module.h | 5 +- deps/nodejs/include/node_native_module_env.h | 14 +- deps/nodejs/include/node_object_wrap.h | 2 + deps/nodejs/include/node_options-inl.h | 64 +- deps/nodejs/include/node_options.h | 111 +- deps/nodejs/include/node_perf.h | 59 +- deps/nodejs/include/node_perf_common.h | 8 +- deps/nodejs/include/node_platform.h | 44 +- deps/nodejs/include/node_process.h | 19 +- deps/nodejs/include/node_report.h | 132 +- deps/nodejs/include/node_revert.h | 2 +- deps/nodejs/include/node_root_certs.h | 313 +-- deps/nodejs/include/node_sockaddr-inl.h | 170 ++ deps/nodejs/include/node_sockaddr.h | 123 + deps/nodejs/include/node_stat_watcher.h | 9 +- deps/nodejs/include/node_union_bytes.h | 23 +- deps/nodejs/include/node_url.h | 5 +- deps/nodejs/include/node_v8_platform-inl.h | 21 +- deps/nodejs/include/node_version.h | 20 +- deps/nodejs/include/node_wasi.h | 108 + deps/nodejs/include/node_watchdog.h | 59 +- deps/nodejs/include/node_worker.h | 64 +- deps/nodejs/include/pipe_wrap.h | 3 +- deps/nodejs/include/req_wrap-inl.h | 3 +- deps/nodejs/include/req_wrap.h | 8 +- .../include/sharedarraybuffer_metadata.h | 66 - deps/nodejs/include/stream_base-inl.h | 183 +- deps/nodejs/include/stream_base.h | 128 +- deps/nodejs/include/stream_pipe.h | 10 +- deps/nodejs/include/stream_wrap.h | 5 +- deps/nodejs/include/string_bytes.h | 33 +- deps/nodejs/include/string_decoder-inl.h | 1 - deps/nodejs/include/string_search.h | 35 +- deps/nodejs/include/tcp_wrap.h | 3 +- deps/nodejs/include/tls_wrap.h | 24 +- deps/nodejs/include/tracing/agent.h | 6 +- deps/nodejs/include/tracing/trace_event.h | 32 +- deps/nodejs/include/tracing/traced_value.h | 2 +- deps/nodejs/include/tty_wrap.h | 3 +- deps/nodejs/include/udp_wrap.h | 130 +- deps/nodejs/include/util-inl.h | 64 +- deps/nodejs/include/util.h | 137 +- deps/nodejs/include/v8abbr.h | 3 +- src/CNodeResourceImpl.cpp | 65 +- src/CNodeResourceImpl.h | 2 + src/CNodeScriptRuntime.cpp | 10 +- src/CNodeScriptRuntime.h | 5 +- src/bindings/Blip.cpp | 19 +- src/bindings/Checkpoint.cpp | 39 +- src/bindings/ColShape.cpp | 121 +- src/bindings/Main.cpp | 50 +- src/bindings/Player.cpp | 619 +---- src/bindings/Vehicle.cpp | 295 ++- src/bindings/vehicle/Appearance.h | 732 +----- src/bindings/vehicle/Damage.h | 15 - src/bindings/vehicle/GameState.h | 270 -- src/bindings/vehicle/Health.h | 150 -- src/bindings/vehicle/ScriptGameState.h | 30 - src/cpp-sdk | 2 +- src/events/Main.cpp | 294 +-- src/events/Player.cpp | 2 +- src/helpers | 2 +- src/node-module.cpp | 2 +- src/stdafx.h | 1 + 187 files changed, 16685 insertions(+), 7043 deletions(-) create mode 100644 deps/nodejs/deps/v8/include/cppgc/DEPS create mode 100644 deps/nodejs/deps/v8/include/cppgc/README.md create mode 100644 deps/nodejs/deps/v8/include/cppgc/allocation.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/common.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/custom-space.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/garbage-collected.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/heap.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/internal/accessors.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/internal/api-constants.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/internal/compiler-specific.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/internal/finalizer-trait.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/internal/gc-info.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/internal/logging.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/internal/persistent-node.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/internal/pointer-policies.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/internal/prefinalizer-handler.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/liveness-broker.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/macros.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/member.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/persistent.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/platform.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/prefinalizer.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/source-location.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/trace-trait.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/type-traits.h create mode 100644 deps/nodejs/deps/v8/include/cppgc/visitor.h create mode 100644 deps/nodejs/deps/v8/include/js_protocol-1.2.json create mode 100644 deps/nodejs/deps/v8/include/js_protocol-1.3.json create mode 100644 deps/nodejs/deps/v8/include/js_protocol.pdl create mode 100644 deps/nodejs/deps/v8/include/v8-fast-api-calls.h create mode 100644 deps/nodejs/include/aliased_struct-inl.h create mode 100644 deps/nodejs/include/aliased_struct.h create mode 100644 deps/nodejs/include/allocated_buffer-inl.h create mode 100644 deps/nodejs/include/allocated_buffer.h create mode 100644 deps/nodejs/include/base64-inl.h create mode 100644 deps/nodejs/include/callback_queue-inl.h create mode 100644 deps/nodejs/include/callback_queue.h create mode 100644 deps/nodejs/include/debug_utils-inl.h delete mode 100644 deps/nodejs/include/http_parser_adaptor.h create mode 100644 deps/nodejs/include/json_utils.h create mode 100644 deps/nodejs/include/node_crypto_common.h create mode 100644 deps/nodejs/include/node_dir.h create mode 100644 deps/nodejs/include/node_file-inl.h create mode 100644 deps/nodejs/include/node_http_common-inl.h create mode 100644 deps/nodejs/include/node_http_common.h delete mode 100644 deps/nodejs/include/node_http_parser_impl.h create mode 100644 deps/nodejs/include/node_mem-inl.h create mode 100644 deps/nodejs/include/node_mem.h create mode 100644 deps/nodejs/include/node_sockaddr-inl.h create mode 100644 deps/nodejs/include/node_sockaddr.h create mode 100644 deps/nodejs/include/node_wasi.h delete mode 100644 deps/nodejs/include/sharedarraybuffer_metadata.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f381be3..6a9d8fc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,7 +124,7 @@ add_library( ) if (WIN32) - target_link_libraries(${PROJECT_NAME} libnode.lib v8_libplatform.lib v8_libbase.lib dbghelp.lib winmm.lib shlwapi.lib) + target_link_libraries(${PROJECT_NAME} libnode.lib dbghelp.lib winmm.lib shlwapi.lib) endif (WIN32) if (UNIX) diff --git a/deps/nodejs/deps/uv/include/uv.h b/deps/nodejs/deps/uv/include/uv.h index da648b3e..72fe36fd 100644 --- a/deps/nodejs/deps/uv/include/uv.h +++ b/deps/nodejs/deps/uv/include/uv.h @@ -27,6 +27,10 @@ extern "C" { #endif +#if defined(BUILDING_UV_SHARED) && defined(USING_UV_SHARED) +#error "Define either BUILDING_UV_SHARED or USING_UV_SHARED, not both." +#endif + #ifdef _WIN32 /* Windows - set up dll import/export decorators. */ # if defined(BUILDING_UV_SHARED) @@ -143,6 +147,7 @@ extern "C" { XX(EREMOTEIO, "remote I/O error") \ XX(ENOTTY, "inappropriate ioctl for device") \ XX(EFTYPE, "inappropriate file type or format") \ + XX(EILSEQ, "illegal byte sequence") \ #define UV_HANDLE_TYPE_MAP(XX) \ XX(ASYNC, async) \ @@ -172,6 +177,7 @@ extern "C" { XX(WORK, work) \ XX(GETADDRINFO, getaddrinfo) \ XX(GETNAMEINFO, getnameinfo) \ + XX(RANDOM, random) \ typedef enum { #define XX(code, _) UV_ ## code = UV__ ## code, @@ -229,16 +235,20 @@ typedef struct uv_connect_s uv_connect_t; typedef struct uv_udp_send_s uv_udp_send_t; typedef struct uv_fs_s uv_fs_t; typedef struct uv_work_s uv_work_t; +typedef struct uv_random_s uv_random_t; /* None of the above. */ +typedef struct uv_env_item_s uv_env_item_t; typedef struct uv_cpu_info_s uv_cpu_info_t; typedef struct uv_interface_address_s uv_interface_address_t; typedef struct uv_dirent_s uv_dirent_t; typedef struct uv_passwd_s uv_passwd_t; typedef struct uv_utsname_s uv_utsname_t; +typedef struct uv_statfs_s uv_statfs_t; typedef enum { - UV_LOOP_BLOCK_SIGNAL + UV_LOOP_BLOCK_SIGNAL = 0, + UV_METRICS_IDLE_TIME } uv_loop_option; typedef enum { @@ -256,6 +266,8 @@ typedef void* (*uv_realloc_func)(void* ptr, size_t size); typedef void* (*uv_calloc_func)(size_t count, size_t size); typedef void (*uv_free_func)(void* ptr); +UV_EXTERN void uv_library_shutdown(void); + UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, uv_realloc_func realloc_func, uv_calloc_func calloc_func, @@ -323,6 +335,10 @@ typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, int status, const char* hostname, const char* service); +typedef void (*uv_random_cb)(uv_random_t* req, + int status, + void* buf, + size_t buflen); typedef struct { long tv_sec; @@ -557,6 +573,7 @@ UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle, UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle, struct sockaddr* name, int* namelen); +UV_EXTERN int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb); UV_EXTERN int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle, const struct sockaddr* addr, @@ -591,7 +608,23 @@ enum uv_udp_flags { * (provided they all set the flag) but only the last one to bind will receive * any traffic, in effect "stealing" the port from the previous listener. */ - UV_UDP_REUSEADDR = 4 + UV_UDP_REUSEADDR = 4, + /* + * Indicates that the message was received by recvmmsg, so the buffer provided + * must not be freed by the recv_cb callback. + */ + UV_UDP_MMSG_CHUNK = 8, + /* + * Indicates that the buffer provided has been fully utilized by recvmmsg and + * that it should now be freed by the recv_cb callback. When this flag is set + * in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL. + */ + UV_UDP_MMSG_FREE = 16, + + /* + * Indicates that recvmmsg should be used, if available. + */ + UV_UDP_RECVMMSG = 256 }; typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); @@ -643,6 +676,11 @@ UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr, const char* interface_addr, uv_membership membership); +UV_EXTERN int uv_udp_set_source_membership(uv_udp_t* handle, + const char* multicast_addr, + const char* interface_addr, + const char* source_addr, + uv_membership membership); UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on); UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle, @@ -662,6 +700,7 @@ UV_EXTERN int uv_udp_try_send(uv_udp_t* handle, UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, uv_udp_recv_cb recv_cb); +UV_EXTERN int uv_udp_using_recvmmsg(const uv_udp_t* handle); UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle); UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle); @@ -687,10 +726,25 @@ typedef enum { UV_TTY_MODE_IO } uv_tty_mode_t; +typedef enum { + /* + * The console supports handling of virtual terminal sequences + * (Windows10 new console, ConEmu) + */ + UV_TTY_SUPPORTED, + /* The console cannot process the virtual terminal sequence. (Legacy + * console) + */ + UV_TTY_UNSUPPORTED +} uv_tty_vtermstate_t; + + UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode); UV_EXTERN int uv_tty_reset_mode(void); UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); +UV_EXTERN void uv_tty_set_vterm_state(uv_tty_vtermstate_t state); +UV_EXTERN int uv_tty_get_vterm_state(uv_tty_vtermstate_t* state); #ifdef __cplusplus extern "C++" { @@ -817,6 +871,7 @@ UV_EXTERN int uv_timer_stop(uv_timer_t* handle); UV_EXTERN int uv_timer_again(uv_timer_t* handle); UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); +UV_EXTERN uint64_t uv_timer_get_due_in(const uv_timer_t* handle); /* @@ -1025,11 +1080,11 @@ UV_EXTERN int uv_cancel(uv_req_t* req); struct uv_cpu_times_s { - uint64_t user; - uint64_t nice; - uint64_t sys; - uint64_t idle; - uint64_t irq; + uint64_t user; /* milliseconds */ + uint64_t nice; /* milliseconds */ + uint64_t sys; /* milliseconds */ + uint64_t idle; /* milliseconds */ + uint64_t irq; /* milliseconds */ }; struct uv_cpu_info_s { @@ -1070,6 +1125,17 @@ struct uv_utsname_s { to as meaningless in the docs. */ }; +struct uv_statfs_s { + uint64_t f_type; + uint64_t f_bsize; + uint64_t f_blocks; + uint64_t f_bfree; + uint64_t f_bavail; + uint64_t f_files; + uint64_t f_ffree; + uint64_t f_spare[4]; +}; + typedef enum { UV_DIRENT_UNKNOWN, UV_DIRENT_FILE, @@ -1132,12 +1198,22 @@ UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); UV_EXTERN uv_pid_t uv_os_getpid(void); UV_EXTERN uv_pid_t uv_os_getppid(void); -#define UV_PRIORITY_LOW 19 -#define UV_PRIORITY_BELOW_NORMAL 10 -#define UV_PRIORITY_NORMAL 0 -#define UV_PRIORITY_ABOVE_NORMAL -7 -#define UV_PRIORITY_HIGH -14 -#define UV_PRIORITY_HIGHEST -20 +#if defined(__PASE__) +/* On IBM i PASE, the highest process priority is -10 */ +# define UV_PRIORITY_LOW 39 /* RUNPTY(99) */ +# define UV_PRIORITY_BELOW_NORMAL 15 /* RUNPTY(50) */ +# define UV_PRIORITY_NORMAL 0 /* RUNPTY(20) */ +# define UV_PRIORITY_ABOVE_NORMAL -4 /* RUNTY(12) */ +# define UV_PRIORITY_HIGH -7 /* RUNPTY(6) */ +# define UV_PRIORITY_HIGHEST -10 /* RUNPTY(1) */ +#else +# define UV_PRIORITY_LOW 19 +# define UV_PRIORITY_BELOW_NORMAL 10 +# define UV_PRIORITY_NORMAL 0 +# define UV_PRIORITY_ABOVE_NORMAL -7 +# define UV_PRIORITY_HIGH -14 +# define UV_PRIORITY_HIGHEST -20 +#endif UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority); UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority); @@ -1150,6 +1226,13 @@ UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses, int count); +struct uv_env_item_s { + char* name; + char* value; +}; + +UV_EXTERN int uv_os_environ(uv_env_item_t** envitems, int* count); +UV_EXTERN void uv_os_free_environ(uv_env_item_t* envitems, int count); UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size); UV_EXTERN int uv_os_setenv(const char* name, const char* value); UV_EXTERN int uv_os_unsetenv(const char* name); @@ -1169,6 +1252,7 @@ UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); UV_EXTERN int uv_os_uname(uv_utsname_t* buffer); +UV_EXTERN uint64_t uv_metrics_idle_time(uv_loop_t* loop); typedef enum { UV_FS_UNKNOWN = -1, @@ -1205,7 +1289,10 @@ typedef enum { UV_FS_LCHOWN, UV_FS_OPENDIR, UV_FS_READDIR, - UV_FS_CLOSEDIR + UV_FS_CLOSEDIR, + UV_FS_STATFS, + UV_FS_MKSTEMP, + UV_FS_LUTIME } uv_fs_type; struct uv_dir_s { @@ -1230,6 +1317,7 @@ struct uv_fs_s { UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*); UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*); +UV_EXTERN int uv_fs_get_system_error(const uv_fs_t*); UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*); UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*); UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*); @@ -1296,6 +1384,10 @@ UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, uv_fs_cb cb); +UV_EXTERN int uv_fs_mkstemp(uv_loop_t* loop, + uv_fs_t* req, + const char* tpl, + uv_fs_cb cb); UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, @@ -1374,6 +1466,12 @@ UV_EXTERN int uv_fs_futime(uv_loop_t* loop, double atime, double mtime, uv_fs_cb cb); +UV_EXTERN int uv_fs_lutime(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + double atime, + double mtime, + uv_fs_cb cb); UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, @@ -1433,6 +1531,10 @@ UV_EXTERN int uv_fs_lchown(uv_loop_t* loop, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb); +UV_EXTERN int uv_fs_statfs(uv_loop_t* loop, + uv_fs_t* req, + const char* path, + uv_fs_cb cb); enum uv_fs_event { @@ -1538,6 +1640,26 @@ UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); + +struct uv_random_s { + UV_REQ_FIELDS + /* read-only */ + uv_loop_t* loop; + /* private */ + int status; + void* buf; + size_t buflen; + uv_random_cb cb; + struct uv__work work_req; +}; + +UV_EXTERN int uv_random(uv_loop_t* loop, + uv_random_t* req, + void *buf, + size_t buflen, + unsigned flags, /* For future extension; must be 0. */ + uv_random_cb cb); + #if defined(IF_NAMESIZE) # define UV_IF_NAMESIZE (IF_NAMESIZE + 1) #elif defined(IFNAMSIZ) @@ -1564,6 +1686,7 @@ UV_EXTERN uint64_t uv_get_total_memory(void); UV_EXTERN uint64_t uv_get_constrained_memory(void); UV_EXTERN uint64_t uv_hrtime(void); +UV_EXTERN void uv_sleep(unsigned int msec); UV_EXTERN void uv_disable_stdio_inheritance(void); @@ -1663,9 +1786,11 @@ struct uv_loop_s { unsigned int active_handles; void* handle_queue[2]; union { - void* unused[2]; + void* unused; unsigned int count; } active_reqs; + /* Internal storage for future extensions. */ + void* internal_fields; /* Internal flag to signal loop stop. */ unsigned int stop_flag; UV_LOOP_PRIVATE_FIELDS diff --git a/deps/nodejs/deps/uv/include/uv/errno.h b/deps/nodejs/deps/uv/include/uv/errno.h index 8eeb95de..aadce9c1 100644 --- a/deps/nodejs/deps/uv/include/uv/errno.h +++ b/deps/nodejs/deps/uv/include/uv/errno.h @@ -317,7 +317,7 @@ #if defined(EPROTO) && !defined(_WIN32) # define UV__EPROTO UV__ERR(EPROTO) #else -# define UV__EPROTO UV__ERR(4046) +# define UV__EPROTO (-4046) #endif #if defined(EPROTONOSUPPORT) && !defined(_WIN32) @@ -439,5 +439,10 @@ # define UV__EFTYPE (-4028) #endif +#if defined(EILSEQ) && !defined(_WIN32) +# define UV__EILSEQ UV__ERR(EILSEQ) +#else +# define UV__EILSEQ (-4027) +#endif #endif /* UV_ERRNO_H_ */ diff --git a/deps/nodejs/deps/uv/include/uv/unix.h b/deps/nodejs/deps/uv/include/uv/unix.h index f73b7b04..e3cf7bdd 100644 --- a/deps/nodejs/deps/uv/include/uv/unix.h +++ b/deps/nodejs/deps/uv/include/uv/unix.h @@ -49,6 +49,8 @@ # include "uv/linux.h" #elif defined (__MVS__) # include "uv/os390.h" +#elif defined(__PASE__) /* __PASE__ and _AIX are both defined on IBM i */ +# include "uv/posix.h" /* IBM i needs uv/posix.h, not uv/aix.h */ #elif defined(_AIX) # include "uv/aix.h" #elif defined(__sun) @@ -61,11 +63,14 @@ defined(__OpenBSD__) || \ defined(__NetBSD__) # include "uv/bsd.h" -#elif defined(__PASE__) || \ - defined(__CYGWIN__) || \ +#elif defined(__CYGWIN__) || \ defined(__MSYS__) || \ defined(__GNU__) # include "uv/posix.h" +#elif defined(__HAIKU__) +# include "uv/posix.h" +#elif defined(__QNX__) +# include "uv/posix.h" #endif #ifndef NI_MAXHOST @@ -402,11 +407,25 @@ typedef struct { #else # define UV_FS_O_CREAT 0 #endif -#if defined(O_DIRECT) + +#if defined(__linux__) && defined(__arm__) +# define UV_FS_O_DIRECT 0x10000 +#elif defined(__linux__) && defined(__m68k__) +# define UV_FS_O_DIRECT 0x10000 +#elif defined(__linux__) && defined(__mips__) +# define UV_FS_O_DIRECT 0x08000 +#elif defined(__linux__) && defined(__powerpc__) +# define UV_FS_O_DIRECT 0x20000 +#elif defined(__linux__) && defined(__s390x__) +# define UV_FS_O_DIRECT 0x04000 +#elif defined(__linux__) && defined(__x86_64__) +# define UV_FS_O_DIRECT 0x04000 +#elif defined(O_DIRECT) # define UV_FS_O_DIRECT O_DIRECT #else # define UV_FS_O_DIRECT 0 #endif + #if defined(O_DIRECTORY) # define UV_FS_O_DIRECTORY O_DIRECTORY #else @@ -479,6 +498,7 @@ typedef struct { #endif /* fs open() flags supported on other platforms: */ +#define UV_FS_O_FILEMAP 0 #define UV_FS_O_RANDOM 0 #define UV_FS_O_SHORT_LIVED 0 #define UV_FS_O_SEQUENTIAL 0 diff --git a/deps/nodejs/deps/uv/include/uv/version.h b/deps/nodejs/deps/uv/include/uv/version.h index 6d3072c7..5272008a 100644 --- a/deps/nodejs/deps/uv/include/uv/version.h +++ b/deps/nodejs/deps/uv/include/uv/version.h @@ -26,13 +26,13 @@ * Versions with the same major number are ABI stable. API is allowed to * evolve between minor releases, but only in a backwards compatible way. * Make sure you update the -soname directives in configure.ac - * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but + * whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but * not UV_VERSION_PATCH.) */ #define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 29 -#define UV_VERSION_PATCH 1 +#define UV_VERSION_MINOR 40 +#define UV_VERSION_PATCH 0 #define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_SUFFIX "" diff --git a/deps/nodejs/deps/uv/include/uv/win.h b/deps/nodejs/deps/uv/include/uv/win.h index acbd958b..f5f1d3a3 100644 --- a/deps/nodejs/deps/uv/include/uv/win.h +++ b/deps/nodejs/deps/uv/include/uv/win.h @@ -517,7 +517,7 @@ typedef struct { /* eol conversion state */ \ unsigned char previous_eol; \ /* ansi parser state */ \ - unsigned char ansi_parser_state; \ + unsigned short ansi_parser_state; \ unsigned char ansi_csi_argc; \ unsigned short ansi_csi_argv[4]; \ COORD saved_position; \ @@ -668,6 +668,7 @@ typedef struct { #define UV_FS_O_APPEND _O_APPEND #define UV_FS_O_CREAT _O_CREAT #define UV_FS_O_EXCL _O_EXCL +#define UV_FS_O_FILEMAP 0x20000000 #define UV_FS_O_RANDOM _O_RANDOM #define UV_FS_O_RDONLY _O_RDONLY #define UV_FS_O_RDWR _O_RDWR diff --git a/deps/nodejs/deps/v8/include/APIDesign.md b/deps/nodejs/deps/v8/include/APIDesign.md index 8830fff7..fe42c8ed 100644 --- a/deps/nodejs/deps/v8/include/APIDesign.md +++ b/deps/nodejs/deps/v8/include/APIDesign.md @@ -67,3 +67,6 @@ which in turn guarantees long-term stability of the API. # The V8 inspector All debugging capabilities of V8 should be exposed via the inspector protocol. +The exception to this are profiling features exposed via v8-profiler.h. +Changes to the inspector protocol need to ensure backwards compatibility and +commitment to maintain. diff --git a/deps/nodejs/deps/v8/include/DEPS b/deps/nodejs/deps/v8/include/DEPS index ca60f841..7305ff51 100644 --- a/deps/nodejs/deps/v8/include/DEPS +++ b/deps/nodejs/deps/v8/include/DEPS @@ -1,4 +1,5 @@ include_rules = [ # v8-inspector-protocol.h depends on generated files under include/inspector. "+inspector", + "+cppgc/common.h", ] diff --git a/deps/nodejs/deps/v8/include/OWNERS b/deps/nodejs/deps/v8/include/OWNERS index 7953cfe1..4f90a5c8 100644 --- a/deps/nodejs/deps/v8/include/OWNERS +++ b/deps/nodejs/deps/v8/include/OWNERS @@ -1,16 +1,19 @@ -set noparent - adamk@chromium.org danno@chromium.org +mlippautz@chromium.org ulan@chromium.org +verwaest@chromium.org yangguo@chromium.org -per-file v8-internal.h=file://OWNERS +per-file *DEPS=file:../COMMON_OWNERS +per-file v8-internal.h=file:../COMMON_OWNERS per-file v8-inspector.h=dgozman@chromium.org per-file v8-inspector.h=pfeldman@chromium.org per-file v8-inspector.h=kozyatinskiy@chromium.org per-file v8-inspector-protocol.h=dgozman@chromium.org per-file v8-inspector-protocol.h=pfeldman@chromium.org per-file v8-inspector-protocol.h=kozyatinskiy@chromium.org +per-file js_protocol.pdl=dgozman@chromium.org +per-file js_protocol.pdl=pfeldman@chromium.org # COMPONENT: Blink>JavaScript>API diff --git a/deps/nodejs/deps/v8/include/cppgc/DEPS b/deps/nodejs/deps/v8/include/cppgc/DEPS new file mode 100644 index 00000000..04c343de --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/DEPS @@ -0,0 +1,7 @@ +include_rules = [ + "-include", + "+v8config.h", + "+v8-platform.h", + "+cppgc", + "-src", +] diff --git a/deps/nodejs/deps/v8/include/cppgc/README.md b/deps/nodejs/deps/v8/include/cppgc/README.md new file mode 100644 index 00000000..3a2db6df --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/README.md @@ -0,0 +1,5 @@ +# C++ Garbage Collection + +This directory provides an open-source garbage collection library for C++. + +The library is under construction, meaning that *all APIs in this directory are incomplete and considered unstable and should not be used*. \ No newline at end of file diff --git a/deps/nodejs/deps/v8/include/cppgc/allocation.h b/deps/nodejs/deps/v8/include/cppgc/allocation.h new file mode 100644 index 00000000..49ad49c3 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/allocation.h @@ -0,0 +1,161 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_ALLOCATION_H_ +#define INCLUDE_CPPGC_ALLOCATION_H_ + +#include + +#include + +#include "cppgc/custom-space.h" +#include "cppgc/garbage-collected.h" +#include "cppgc/heap.h" +#include "cppgc/internal/api-constants.h" +#include "cppgc/internal/gc-info.h" + +namespace cppgc { + +template +class MakeGarbageCollectedTraitBase; + +namespace internal { + +class V8_EXPORT MakeGarbageCollectedTraitInternal { + protected: + static inline void MarkObjectAsFullyConstructed(const void* payload) { + // See api_constants for an explanation of the constants. + std::atomic* atomic_mutable_bitfield = + reinterpret_cast*>( + const_cast(reinterpret_cast( + reinterpret_cast(payload) - + api_constants::kFullyConstructedBitFieldOffsetFromPayload))); + uint16_t value = atomic_mutable_bitfield->load(std::memory_order_relaxed); + value = value | api_constants::kFullyConstructedBitMask; + atomic_mutable_bitfield->store(value, std::memory_order_release); + } + + static void* Allocate(cppgc::Heap* heap, size_t size, GCInfoIndex index); + static void* Allocate(cppgc::Heap* heapx, size_t size, GCInfoIndex index, + CustomSpaceIndex space_inde); + + friend class HeapObjectHeader; +}; + +} // namespace internal + +/** + * Base trait that provides utilities for advancers users that have custom + * allocation needs (e.g., overriding size). It's expected that users override + * MakeGarbageCollectedTrait (see below) and inherit from + * MakeGarbageCollectedTraitBase and make use of the low-level primitives + * offered to allocate and construct an object. + */ +template +class MakeGarbageCollectedTraitBase + : private internal::MakeGarbageCollectedTraitInternal { + private: + template + struct SpacePolicy { + static void* Allocate(Heap* heap, size_t size) { + // Custom space. + static_assert(std::is_base_of::value, + "Custom space must inherit from CustomSpaceBase."); + return internal::MakeGarbageCollectedTraitInternal::Allocate( + heap, size, internal::GCInfoTrait::Index(), + CustomSpace::kSpaceIndex); + } + }; + + template + struct SpacePolicy { + static void* Allocate(Heap* heap, size_t size) { + // Default space. + return internal::MakeGarbageCollectedTraitInternal::Allocate( + heap, size, internal::GCInfoTrait::Index()); + } + }; + + protected: + /** + * Allocates memory for an object of type T. + * + * \param heap The heap to allocate this object on. + * \param size The size that should be reserved for the object. + * \returns the memory to construct an object of type T on. + */ + static void* Allocate(Heap* heap, size_t size) { + return SpacePolicy::Space>::Allocate(heap, size); + } + + /** + * Marks an object as fully constructed, resulting in precise handling by the + * garbage collector. + * + * \param payload The base pointer the object is allocated at. + */ + static void MarkObjectAsFullyConstructed(const void* payload) { + internal::MakeGarbageCollectedTraitInternal::MarkObjectAsFullyConstructed( + payload); + } +}; + +/** + * Default trait class that specifies how to construct an object of type T. + * Advanced users may override how an object is constructed using the utilities + * that are provided through MakeGarbageCollectedTraitBase. + * + * Any trait overriding construction must + * - allocate through MakeGarbageCollectedTraitBase::Allocate; + * - mark the object as fully constructed using + * MakeGarbageCollectedTraitBase::MarkObjectAsFullyConstructed; + */ +template +class MakeGarbageCollectedTrait : public MakeGarbageCollectedTraitBase { + public: + template + static T* Call(Heap* heap, Args&&... args) { + static_assert(internal::IsGarbageCollectedType::value, + "T needs to be a garbage collected object"); + static_assert( + !internal::IsGarbageCollectedMixinType::value || + sizeof(T) <= internal::api_constants::kLargeObjectSizeThreshold, + "GarbageCollectedMixin may not be a large object"); + void* memory = MakeGarbageCollectedTraitBase::Allocate(heap, sizeof(T)); + T* object = ::new (memory) T(std::forward(args)...); + MakeGarbageCollectedTraitBase::MarkObjectAsFullyConstructed(object); + return object; + } +}; + +/** + * Allows users to specify a post-construction callback for specific types. The + * callback is invoked on the instance of type T right after it has been + * constructed. This can be useful when the callback requires a + * fully-constructed object to be able to dispatch to virtual methods. + */ +template +struct PostConstructionCallbackTrait { + static void Call(T*) {} +}; + +/** + * Constructs a managed object of type T where T transitively inherits from + * GarbageCollected. + * + * \param args List of arguments with which an instance of T will be + * constructed. + * \returns an instance of type T. + */ +template +T* MakeGarbageCollected(Heap* heap, Args&&... args) { + T* object = + MakeGarbageCollectedTrait::Call(heap, std::forward(args)...); + PostConstructionCallbackTrait::Call(object); + return object; +} + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_ALLOCATION_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/common.h b/deps/nodejs/deps/v8/include/cppgc/common.h new file mode 100644 index 00000000..228b9abb --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/common.h @@ -0,0 +1,26 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_COMMON_H_ +#define INCLUDE_CPPGC_COMMON_H_ + +// TODO(chromium:1056170): Remove dependency on v8. +#include "v8config.h" // NOLINT(build/include_directory) + +namespace cppgc { + +// Indicator for the stack state of the embedder. +enum class EmbedderStackState { + kMayContainHeapPointers, + kNoHeapPointers, + kUnknown V8_ENUM_DEPRECATE_SOON("Use kMayContainHeapPointers") = + kMayContainHeapPointers, + kNonEmpty V8_ENUM_DEPRECATE_SOON("Use kMayContainHeapPointers") = + kMayContainHeapPointers, + kEmpty V8_ENUM_DEPRECATE_SOON("Use kNoHeapPointers") = kNoHeapPointers, +}; + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_COMMON_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/custom-space.h b/deps/nodejs/deps/v8/include/cppgc/custom-space.h new file mode 100644 index 00000000..2597a5bd --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/custom-space.h @@ -0,0 +1,62 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_CUSTOM_SPACE_H_ +#define INCLUDE_CPPGC_CUSTOM_SPACE_H_ + +#include + +namespace cppgc { + +struct CustomSpaceIndex { + CustomSpaceIndex(size_t value) : value(value) {} // NOLINT + size_t value; +}; + +/** + * Top-level base class for custom spaces. Users must inherit from CustomSpace + * below. + */ +class CustomSpaceBase { + public: + virtual ~CustomSpaceBase() = default; + virtual CustomSpaceIndex GetCustomSpaceIndex() const = 0; +}; + +/** + * Base class custom spaces should directly inherit from. The class inheriting + * from CustomSpace must define kSpaceIndex as unique space index. These + * indices need for form a sequence starting at 0. + * + * Example: + * \code + * class CustomSpace1 : public CustomSpace { + * public: + * static constexpr CustomSpaceIndex kSpaceIndex = 0; + * }; + * class CustomSpace2 : public CustomSpace { + * public: + * static constexpr CustomSpaceIndex kSpaceIndex = 1; + * }; + * \endcode + */ +template +class CustomSpace : public CustomSpaceBase { + public: + CustomSpaceIndex GetCustomSpaceIndex() const final { + return ConcreteCustomSpace::kSpaceIndex; + } +}; + +/** + * User-overridable trait that allows pinning types to custom spaces. + */ +template +struct SpaceTrait { + using Space = void; +}; + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_CUSTOM_SPACE_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/garbage-collected.h b/deps/nodejs/deps/v8/include/cppgc/garbage-collected.h new file mode 100644 index 00000000..c263a9fe --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/garbage-collected.h @@ -0,0 +1,192 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_GARBAGE_COLLECTED_H_ +#define INCLUDE_CPPGC_GARBAGE_COLLECTED_H_ + +#include + +#include "cppgc/internal/api-constants.h" +#include "cppgc/macros.h" +#include "cppgc/platform.h" +#include "cppgc/trace-trait.h" +#include "cppgc/type-traits.h" + +namespace cppgc { + +class Visitor; + +namespace internal { + +class GarbageCollectedBase { + public: + // Must use MakeGarbageCollected. + void* operator new(size_t) = delete; + void* operator new[](size_t) = delete; + // The garbage collector is taking care of reclaiming the object. Also, + // virtual destructor requires an unambiguous, accessible 'operator delete'. + void operator delete(void*) { +#ifdef V8_ENABLE_CHECKS + internal::Abort(); +#endif // V8_ENABLE_CHECKS + } + void operator delete[](void*) = delete; + + protected: + GarbageCollectedBase() = default; +}; + +} // namespace internal + +/** + * Base class for managed objects. Only descendent types of GarbageCollected + * can be constructed using MakeGarbageCollected. Must be inherited from as + * left-most base class. + * + * Types inheriting from GarbageCollected must provide a method of + * signature `void Trace(cppgc::Visitor*) const` that dispatchs all managed + * pointers to the visitor and delegates to garbage-collected base classes. + * The method must be virtual if the type is not directly a child of + * GarbageCollected and marked as final. + * + * \code + * // Example using final class. + * class FinalType final : public GarbageCollected { + * public: + * void Trace(cppgc::Visitor* visitor) const { + * // Dispatch using visitor->Trace(...); + * } + * }; + * + * // Example using non-final base class. + * class NonFinalBase : public GarbageCollected { + * public: + * virtual void Trace(cppgc::Visitor*) const {} + * }; + * + * class FinalChild final : public NonFinalBase { + * public: + * void Trace(cppgc::Visitor* visitor) const final { + * // Dispatch using visitor->Trace(...); + * NonFinalBase::Trace(visitor); + * } + * }; + * \endcode + */ +template +class GarbageCollected : public internal::GarbageCollectedBase { + public: + using IsGarbageCollectedTypeMarker = void; + + protected: + GarbageCollected() = default; +}; + +/** + * Base class for managed mixin objects. Such objects cannot be constructed + * directly but must be mixed into the inheritance hierarchy of a + * GarbageCollected object. + * + * Types inheriting from GarbageCollectedMixin must override a virtual method + * of signature `void Trace(cppgc::Visitor*) const` that dispatchs all managed + * pointers to the visitor and delegates to base classes. + * + * \code + * class Mixin : public GarbageCollectedMixin { + * public: + * void Trace(cppgc::Visitor* visitor) const override { + * // Dispatch using visitor->Trace(...); + * } + * }; + * \endcode + */ +class GarbageCollectedMixin : public internal::GarbageCollectedBase { + public: + using IsGarbageCollectedMixinTypeMarker = void; + + // Sentinel used to mark not-fully-constructed mixins. + static constexpr void* kNotFullyConstructedObject = nullptr; + + // Provide default implementation that indicate that the vtable is not yet + // set up properly. This is used to to get GCInfo objects for mixins so that + // these objects can be processed later on. + virtual TraceDescriptor GetTraceDescriptor() const { + return {kNotFullyConstructedObject, nullptr}; + } + + /** + * This Trace method must be overriden by objects inheriting from + * GarbageCollectedMixin. + */ + virtual void Trace(cppgc::Visitor*) const {} +}; + +/** + * Macro defines all methods and markers needed for handling mixins. Must be + * used on the type that is inheriting from GarbageCollected *and* + * GarbageCollectedMixin. + * + * \code + * class Mixin : public GarbageCollectedMixin { + * public: + * void Trace(cppgc::Visitor* visitor) const override { + * // Dispatch using visitor->Trace(...); + * } + * }; + * + * class Foo : public GarbageCollected, public Mixin { + * USING_GARBAGE_COLLECTED_MIXIN(); + * public: + * void Trace(cppgc::Visitor* visitor) const override { + * // Dispatch using visitor->Trace(...); + * Mixin::Trace(visitor); + * } + * }; + * \endcode + */ +#define USING_GARBAGE_COLLECTED_MIXIN() \ + public: \ + /* Marker is used by clang to check for proper usages of the macro. */ \ + typedef int HasUsingGarbageCollectedMixinMacro; \ + \ + TraceDescriptor GetTraceDescriptor() const override { \ + static_assert( \ + internal::IsSubclassOfTemplate< \ + std::remove_const_t>, \ + cppgc::GarbageCollected>::value, \ + "Only garbage collected objects can have garbage collected mixins"); \ + return {this, TraceTrait>>::Trace}; \ + } \ + \ + private: \ + friend class internal::__thisIsHereToForceASemicolonAfterThisMacro + +/** + * Merge two or more Mixins into one. + * + * \code + * class A : public GarbageCollectedMixin {}; + * class B : public GarbageCollectedMixin {}; + * class C : public A, public B { + * MERGE_GARBAGE_COLLECTED_MIXINS(); + * public: + * }; + * \endcode + */ +#define MERGE_GARBAGE_COLLECTED_MIXINS() \ + public: \ + /* When using multiple mixins the methods become */ \ + /* ambigous. Providing additional implementations */ \ + /* disambiguate them again. */ \ + TraceDescriptor GetTraceDescriptor() const override { \ + return {kNotFullyConstructedObject, nullptr}; \ + } \ + \ + private: \ + friend class internal::__thisIsHereToForceASemicolonAfterThisMacro + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_GARBAGE_COLLECTED_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/heap.h b/deps/nodejs/deps/v8/include/cppgc/heap.h new file mode 100644 index 00000000..90046c35 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/heap.h @@ -0,0 +1,63 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_HEAP_H_ +#define INCLUDE_CPPGC_HEAP_H_ + +#include +#include + +#include "cppgc/common.h" +#include "cppgc/custom-space.h" +#include "v8config.h" // NOLINT(build/include_directory) + +namespace cppgc { +namespace internal { +class Heap; +} // namespace internal + +class V8_EXPORT Heap { + public: + /** + * Specifies the stack state the embedder is in. + */ + using StackState = EmbedderStackState; + + struct HeapOptions { + static HeapOptions Default() { return {}; } + + /** + * Custom spaces added to heap are required to have indices forming a + * numbered sequence starting at 0, i.e., their kSpaceIndex must correspond + * to the index they reside in the vector. + */ + std::vector> custom_spaces; + }; + + static std::unique_ptr Create(HeapOptions = HeapOptions::Default()); + + virtual ~Heap() = default; + + /** + * Forces garbage collection. + * + * \param source String specifying the source (or caller) triggering a + * forced garbage collection. + * \param reason String specifying the reason for the forced garbage + * collection. + * \param stack_state The embedder stack state, see StackState. + */ + void ForceGarbageCollectionSlow( + const char* source, const char* reason, + StackState stack_state = StackState::kMayContainHeapPointers); + + private: + Heap() = default; + + friend class internal::Heap; +}; + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_HEAP_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/internal/accessors.h b/deps/nodejs/deps/v8/include/cppgc/internal/accessors.h new file mode 100644 index 00000000..ee0a0042 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/internal/accessors.h @@ -0,0 +1,26 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_INTERNAL_ACCESSORS_H_ +#define INCLUDE_CPPGC_INTERNAL_ACCESSORS_H_ + +#include "cppgc/internal/api-constants.h" + +namespace cppgc { + +class Heap; + +namespace internal { + +inline cppgc::Heap* GetHeapFromPayload(const void* payload) { + return *reinterpret_cast( + ((reinterpret_cast(payload) & api_constants::kPageBaseMask) + + api_constants::kGuardPageSize) + + api_constants::kHeapOffset); +} + +} // namespace internal +} // namespace cppgc + +#endif // INCLUDE_CPPGC_INTERNAL_ACCESSORS_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/internal/api-constants.h b/deps/nodejs/deps/v8/include/cppgc/internal/api-constants.h new file mode 100644 index 00000000..ef910a48 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/internal/api-constants.h @@ -0,0 +1,44 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_ +#define INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_ + +#include +#include + +#include "v8config.h" // NOLINT(build/include_directory) + +namespace cppgc { +namespace internal { + +// Embedders should not rely on this code! + +// Internal constants to avoid exposing internal types on the API surface. +namespace api_constants { +// Offset of the uint16_t bitfield from the payload contaning the +// in-construction bit. This is subtracted from the payload pointer to get +// to the right bitfield. +static constexpr size_t kFullyConstructedBitFieldOffsetFromPayload = + 2 * sizeof(uint16_t); +// Mask for in-construction bit. +static constexpr size_t kFullyConstructedBitMask = size_t{1}; + +// Page constants used to align pointers to page begin. +static constexpr size_t kPageSize = size_t{1} << 17; +static constexpr size_t kPageAlignment = kPageSize; +static constexpr size_t kPageBaseMask = ~(kPageAlignment - 1); +static constexpr size_t kGuardPageSize = 4096; + +// Offset of the Heap backref. +static constexpr size_t kHeapOffset = 0; + +static constexpr size_t kLargeObjectSizeThreshold = kPageSize / 2; + +} // namespace api_constants + +} // namespace internal +} // namespace cppgc + +#endif // INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/internal/compiler-specific.h b/deps/nodejs/deps/v8/include/cppgc/internal/compiler-specific.h new file mode 100644 index 00000000..e1f5c1d5 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/internal/compiler-specific.h @@ -0,0 +1,26 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_ +#define INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_ + +namespace cppgc { + +#if defined(__has_cpp_attribute) +#define CPPGC_HAS_CPP_ATTRIBUTE(FEATURE) __has_cpp_attribute(FEATURE) +#else +#define CPPGC_HAS_CPP_ATTRIBUTE(FEATURE) 0 +#endif + +// [[no_unique_address]] comes in C++20 but supported in clang with -std >= +// c++11. +#if CPPGC_HAS_CPP_ATTRIBUTE(no_unique_address) // NOLINTNEXTLINE +#define CPPGC_NO_UNIQUE_ADDRESS [[no_unique_address]] +#else +#define CPPGC_NO_UNIQUE_ADDRESS +#endif + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/internal/finalizer-trait.h b/deps/nodejs/deps/v8/include/cppgc/internal/finalizer-trait.h new file mode 100644 index 00000000..a9512659 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/internal/finalizer-trait.h @@ -0,0 +1,90 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_ +#define INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_ + +#include + +#include "cppgc/type-traits.h" + +namespace cppgc { +namespace internal { + +using FinalizationCallback = void (*)(void*); + +template +struct HasFinalizeGarbageCollectedObject : std::false_type {}; + +template +struct HasFinalizeGarbageCollectedObject< + T, void_t().FinalizeGarbageCollectedObject())>> + : std::true_type {}; + +// The FinalizerTraitImpl specifies how to finalize objects. +template +struct FinalizerTraitImpl; + +template +struct FinalizerTraitImpl { + private: + // Dispatch to custom FinalizeGarbageCollectedObject(). + struct Custom { + static void Call(void* obj) { + static_cast(obj)->FinalizeGarbageCollectedObject(); + } + }; + + // Dispatch to regular destructor. + struct Destructor { + static void Call(void* obj) { static_cast(obj)->~T(); } + }; + + using FinalizeImpl = + std::conditional_t::value, Custom, + Destructor>; + + public: + static void Finalize(void* obj) { + static_assert(sizeof(T), "T must be fully defined"); + FinalizeImpl::Call(obj); + } +}; + +template +struct FinalizerTraitImpl { + static void Finalize(void* obj) { + static_assert(sizeof(T), "T must be fully defined"); + } +}; + +// The FinalizerTrait is used to determine if a type requires finalization and +// what finalization means. +template +struct FinalizerTrait { + private: + // Object has a finalizer if it has + // - a custom FinalizeGarbageCollectedObject method, or + // - a destructor. + static constexpr bool kNonTrivialFinalizer = + internal::HasFinalizeGarbageCollectedObject::value || + !std::is_trivially_destructible::type>::value; + + static void Finalize(void* obj) { + internal::FinalizerTraitImpl::Finalize(obj); + } + + public: + // The callback used to finalize an object of type T. + static constexpr FinalizationCallback kCallback = + kNonTrivialFinalizer ? Finalize : nullptr; +}; + +template +constexpr FinalizationCallback FinalizerTrait::kCallback; + +} // namespace internal +} // namespace cppgc + +#endif // INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/internal/gc-info.h b/deps/nodejs/deps/v8/include/cppgc/internal/gc-info.h new file mode 100644 index 00000000..9aac1361 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/internal/gc-info.h @@ -0,0 +1,43 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_INTERNAL_GC_INFO_H_ +#define INCLUDE_CPPGC_INTERNAL_GC_INFO_H_ + +#include + +#include "cppgc/internal/finalizer-trait.h" +#include "v8config.h" // NOLINT(build/include_directory) + +namespace cppgc { +namespace internal { + +using GCInfoIndex = uint16_t; + +class V8_EXPORT RegisteredGCInfoIndex final { + public: + RegisteredGCInfoIndex(FinalizationCallback finalization_callback, + bool has_v_table); + GCInfoIndex GetIndex() const { return index_; } + + private: + const GCInfoIndex index_; +}; + +// Trait determines how the garbage collector treats objects wrt. to traversing, +// finalization, and naming. +template +struct GCInfoTrait { + static GCInfoIndex Index() { + static_assert(sizeof(T), "T must be fully defined"); + static const RegisteredGCInfoIndex registered_index( + FinalizerTrait::kCallback, std::is_polymorphic::value); + return registered_index.GetIndex(); + } +}; + +} // namespace internal +} // namespace cppgc + +#endif // INCLUDE_CPPGC_INTERNAL_GC_INFO_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/internal/logging.h b/deps/nodejs/deps/v8/include/cppgc/internal/logging.h new file mode 100644 index 00000000..79beaef7 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/internal/logging.h @@ -0,0 +1,50 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_INTERNAL_LOGGING_H_ +#define INCLUDE_CPPGC_INTERNAL_LOGGING_H_ + +#include "cppgc/source-location.h" +#include "v8config.h" // NOLINT(build/include_directory) + +namespace cppgc { +namespace internal { + +void V8_EXPORT DCheckImpl(const char*, + const SourceLocation& = SourceLocation::Current()); +[[noreturn]] void V8_EXPORT +FatalImpl(const char*, const SourceLocation& = SourceLocation::Current()); + +// Used to ignore -Wunused-variable. +template +struct EatParams {}; + +#if DEBUG +#define CPPGC_DCHECK_MSG(condition, message) \ + do { \ + if (V8_UNLIKELY(!(condition))) { \ + ::cppgc::internal::DCheckImpl(message); \ + } \ + } while (false) +#else +#define CPPGC_DCHECK_MSG(condition, message) \ + (static_cast(::cppgc::internal::EatParams(condition), message)>{})) +#endif + +#define CPPGC_DCHECK(condition) CPPGC_DCHECK_MSG(condition, #condition) + +#define CPPGC_CHECK_MSG(condition, message) \ + do { \ + if (V8_UNLIKELY(!(condition))) { \ + ::cppgc::internal::FatalImpl(message); \ + } \ + } while (false) + +#define CPPGC_CHECK(condition) CPPGC_CHECK_MSG(condition, #condition) + +} // namespace internal +} // namespace cppgc + +#endif // INCLUDE_CPPGC_INTERNAL_LOGGING_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/internal/persistent-node.h b/deps/nodejs/deps/v8/include/cppgc/internal/persistent-node.h new file mode 100644 index 00000000..11cf6962 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/internal/persistent-node.h @@ -0,0 +1,109 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_ +#define INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_ + +#include +#include +#include + +#include "cppgc/internal/logging.h" +#include "cppgc/trace-trait.h" +#include "v8config.h" // NOLINT(build/include_directory) + +namespace cppgc { + +class Visitor; + +namespace internal { + +// PersistentNode represesents a variant of two states: +// 1) traceable node with a back pointer to the Persistent object; +// 2) freelist entry. +class PersistentNode final { + public: + PersistentNode() = default; + + PersistentNode(const PersistentNode&) = delete; + PersistentNode& operator=(const PersistentNode&) = delete; + + void InitializeAsUsedNode(void* owner, TraceCallback trace) { + owner_ = owner; + trace_ = trace; + } + + void InitializeAsFreeNode(PersistentNode* next) { + next_ = next; + trace_ = nullptr; + } + + void UpdateOwner(void* owner) { + CPPGC_DCHECK(IsUsed()); + owner_ = owner; + } + + PersistentNode* FreeListNext() const { + CPPGC_DCHECK(!IsUsed()); + return next_; + } + + void Trace(Visitor* visitor) const { + CPPGC_DCHECK(IsUsed()); + trace_(visitor, owner_); + } + + bool IsUsed() const { return trace_; } + + private: + // PersistentNode acts as a designated union: + // If trace_ != nullptr, owner_ points to the corresponding Persistent handle. + // Otherwise, next_ points to the next freed PersistentNode. + union { + void* owner_ = nullptr; + PersistentNode* next_; + }; + TraceCallback trace_ = nullptr; +}; + +class V8_EXPORT PersistentRegion { + using PersistentNodeSlots = std::array; + + public: + PersistentRegion() = default; + + PersistentRegion(const PersistentRegion&) = delete; + PersistentRegion& operator=(const PersistentRegion&) = delete; + + PersistentNode* AllocateNode(void* owner, TraceCallback trace) { + if (!free_list_head_) { + EnsureNodeSlots(); + } + PersistentNode* node = free_list_head_; + free_list_head_ = free_list_head_->FreeListNext(); + node->InitializeAsUsedNode(owner, trace); + return node; + } + + void FreeNode(PersistentNode* node) { + node->InitializeAsFreeNode(free_list_head_); + free_list_head_ = node; + } + + void Trace(Visitor*); + + size_t NodesInUse() const; + + private: + void EnsureNodeSlots(); + + std::vector> nodes_; + PersistentNode* free_list_head_ = nullptr; +}; + +} // namespace internal + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_INTERNAL_PERSISTENT_NODE_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/internal/pointer-policies.h b/deps/nodejs/deps/v8/include/cppgc/internal/pointer-policies.h new file mode 100644 index 00000000..fe8d94b5 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/internal/pointer-policies.h @@ -0,0 +1,133 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_INTERNAL_POINTER_POLICIES_H_ +#define INCLUDE_CPPGC_INTERNAL_POINTER_POLICIES_H_ + +#include +#include + +#include "cppgc/source-location.h" +#include "v8config.h" // NOLINT(build/include_directory) + +namespace cppgc { +namespace internal { + +class PersistentRegion; + +// Tags to distinguish between strong and weak member types. +class StrongMemberTag; +class WeakMemberTag; +class UntracedMemberTag; + +struct DijkstraWriteBarrierPolicy { + static void InitializingBarrier(const void*, const void*) { + // Since in initializing writes the source object is always white, having no + // barrier doesn't break the tri-color invariant. + } + static void AssigningBarrier(const void*, const void*) { + // TODO(chromium:1056170): Add actual implementation. + } +}; + +struct NoWriteBarrierPolicy { + static void InitializingBarrier(const void*, const void*) {} + static void AssigningBarrier(const void*, const void*) {} +}; + +class V8_EXPORT EnabledCheckingPolicy { + protected: + EnabledCheckingPolicy(); + void CheckPointer(const void* ptr); + + private: + void* impl_; +}; + +class DisabledCheckingPolicy { + protected: + void CheckPointer(const void* raw) {} +}; + +#if V8_ENABLE_CHECKS +using DefaultCheckingPolicy = EnabledCheckingPolicy; +#else +using DefaultCheckingPolicy = DisabledCheckingPolicy; +#endif + +class KeepLocationPolicy { + public: + constexpr const SourceLocation& Location() const { return location_; } + + protected: + constexpr explicit KeepLocationPolicy(const SourceLocation& location) + : location_(location) {} + + // KeepLocationPolicy must not copy underlying source locations. + KeepLocationPolicy(const KeepLocationPolicy&) = delete; + KeepLocationPolicy& operator=(const KeepLocationPolicy&) = delete; + + // Location of the original moved from object should be preserved. + KeepLocationPolicy(KeepLocationPolicy&&) = default; + KeepLocationPolicy& operator=(KeepLocationPolicy&&) = default; + + private: + SourceLocation location_; +}; + +class IgnoreLocationPolicy { + public: + constexpr SourceLocation Location() const { return {}; } + + protected: + constexpr explicit IgnoreLocationPolicy(const SourceLocation&) {} +}; + +#if CPPGC_SUPPORTS_OBJECT_NAMES +using DefaultLocationPolicy = KeepLocationPolicy; +#else +using DefaultLocationPolicy = IgnoreLocationPolicy; +#endif + +struct StrongPersistentPolicy { + using IsStrongPersistent = std::true_type; + + static V8_EXPORT PersistentRegion& GetPersistentRegion(void* object); +}; + +struct WeakPersistentPolicy { + using IsStrongPersistent = std::false_type; + + static V8_EXPORT PersistentRegion& GetPersistentRegion(void* object); +}; + +// Persistent/Member forward declarations. +template +class BasicPersistent; +template +class BasicMember; + +// Special tag type used to denote some sentinel member. The semantics of the +// sentinel is defined by the embedder. +struct SentinelPointer { + template + operator T*() const { // NOLINT + static constexpr intptr_t kSentinelValue = -1; + return reinterpret_cast(kSentinelValue); + } + // Hidden friends. + friend bool operator==(SentinelPointer, SentinelPointer) { return true; } + friend bool operator!=(SentinelPointer, SentinelPointer) { return false; } +}; + +} // namespace internal + +constexpr internal::SentinelPointer kSentinelPointer; + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_INTERNAL_POINTER_POLICIES_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/internal/prefinalizer-handler.h b/deps/nodejs/deps/v8/include/cppgc/internal/prefinalizer-handler.h new file mode 100644 index 00000000..939a9b8f --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/internal/prefinalizer-handler.h @@ -0,0 +1,31 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_INTERNAL_PREFINALIZER_HANDLER_H_ +#define INCLUDE_CPPGC_INTERNAL_PREFINALIZER_HANDLER_H_ + +#include "cppgc/heap.h" +#include "cppgc/liveness-broker.h" + +namespace cppgc { +namespace internal { + +class V8_EXPORT PreFinalizerRegistrationDispatcher final { + public: + using PreFinalizerCallback = bool (*)(const LivenessBroker&, void*); + struct PreFinalizer { + void* object_; + PreFinalizerCallback callback_; + + bool operator==(const PreFinalizer& other); + }; + + static void RegisterPrefinalizer(cppgc::Heap* heap, + PreFinalizer prefinalzier); +}; + +} // namespace internal +} // namespace cppgc + +#endif // INCLUDE_CPPGC_INTERNAL_PREFINALIZER_HANDLER_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/liveness-broker.h b/deps/nodejs/deps/v8/include/cppgc/liveness-broker.h new file mode 100644 index 00000000..69dbc11f --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/liveness-broker.h @@ -0,0 +1,50 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_LIVENESS_BROKER_H_ +#define INCLUDE_CPPGC_LIVENESS_BROKER_H_ + +#include "cppgc/heap.h" +#include "cppgc/member.h" +#include "cppgc/trace-trait.h" +#include "v8config.h" // NOLINT(build/include_directory) + +namespace cppgc { + +namespace internal { +class LivenessBrokerFactory; +} // namespace internal + +class V8_EXPORT LivenessBroker final { + public: + template + bool IsHeapObjectAlive(const T* object) const { + return object && + IsHeapObjectAliveImpl( + TraceTrait::GetTraceDescriptor(object).base_object_payload); + } + + template + bool IsHeapObjectAlive(const WeakMember& weak_member) const { + return (weak_member != kSentinelPointer) && + IsHeapObjectAlive(weak_member.Get()); + } + + template + bool IsHeapObjectAlive(const UntracedMember& untraced_member) const { + return (untraced_member != kSentinelPointer) && + IsHeapObjectAlive(untraced_member.Get()); + } + + private: + LivenessBroker() = default; + + bool IsHeapObjectAliveImpl(const void*) const; + + friend class internal::LivenessBrokerFactory; +}; + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_LIVENESS_BROKER_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/macros.h b/deps/nodejs/deps/v8/include/cppgc/macros.h new file mode 100644 index 00000000..7c7a10e4 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/macros.h @@ -0,0 +1,26 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_MACROS_H_ +#define INCLUDE_CPPGC_MACROS_H_ + +namespace cppgc { + +namespace internal { +class __thisIsHereToForceASemicolonAfterThisMacro {}; +} // namespace internal + +// Use if the object is only stack allocated. +#define CPPGC_STACK_ALLOCATED() \ + public: \ + using IsStackAllocatedTypeMarker = int; \ + \ + private: \ + void* operator new(size_t) = delete; \ + void* operator new(size_t, void*) = delete; \ + friend class internal::__thisIsHereToForceASemicolonAfterThisMacro + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_MACROS_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/member.h b/deps/nodejs/deps/v8/include/cppgc/member.h new file mode 100644 index 00000000..a183edb9 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/member.h @@ -0,0 +1,206 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_MEMBER_H_ +#define INCLUDE_CPPGC_MEMBER_H_ + +#include +#include +#include + +#include "cppgc/internal/pointer-policies.h" +#include "cppgc/type-traits.h" +#include "v8config.h" // NOLINT(build/include_directory) + +namespace cppgc { + +class Visitor; + +namespace internal { + +// The basic class from which all Member classes are 'generated'. +template +class BasicMember : private CheckingPolicy { + public: + using PointeeType = T; + + constexpr BasicMember() = default; + constexpr BasicMember(std::nullptr_t) {} // NOLINT + BasicMember(SentinelPointer s) : raw_(s) {} // NOLINT + BasicMember(T* raw) : raw_(raw) { // NOLINT + InitializingWriteBarrier(); + this->CheckPointer(raw_); + } + BasicMember(T& raw) : BasicMember(&raw) {} // NOLINT + BasicMember(const BasicMember& other) : BasicMember(other.Get()) {} + // Allow heterogeneous construction. + template ::value>> + BasicMember( // NOLINT + const BasicMember& other) + : BasicMember(other.Get()) {} + // Construction from Persistent. + template ::value>> + BasicMember( // NOLINT + const BasicPersistent& + p) + : BasicMember(p.Get()) {} + + BasicMember& operator=(const BasicMember& other) { + return operator=(other.Get()); + } + // Allow heterogeneous assignment. + template ::value>> + BasicMember& operator=( + const BasicMember& other) { + return operator=(other.Get()); + } + // Assignment from Persistent. + template ::value>> + BasicMember& operator=( + const BasicPersistent& + other) { + return operator=(other.Get()); + } + BasicMember& operator=(T* other) { + SetRawAtomic(other); + AssigningWriteBarrier(); + this->CheckPointer(Get()); + return *this; + } + BasicMember& operator=(std::nullptr_t) { + Clear(); + return *this; + } + BasicMember& operator=(SentinelPointer s) { + SetRawAtomic(s); + return *this; + } + + template + void Swap(BasicMember& other) { + T* tmp = Get(); + *this = other; + other = tmp; + } + + explicit operator bool() const { return Get(); } + operator T*() const { return Get(); } // NOLINT + T* operator->() const { return Get(); } + T& operator*() const { return *Get(); } + + T* Get() const { + // Executed by the mutator, hence non atomic load. + return raw_; + } + + void Clear() { SetRawAtomic(nullptr); } + + T* Release() { + T* result = Get(); + Clear(); + return result; + } + + private: + void SetRawAtomic(T* raw) { + reinterpret_cast*>(&raw_)->store(raw, + std::memory_order_relaxed); + } + T* GetRawAtomic() const { + return reinterpret_cast*>(&raw_)->load( + std::memory_order_relaxed); + } + + void InitializingWriteBarrier() const { + WriteBarrierPolicy::InitializingBarrier( + reinterpret_cast(&raw_), static_cast(raw_)); + } + void AssigningWriteBarrier() const { + WriteBarrierPolicy::AssigningBarrier(reinterpret_cast(&raw_), + static_cast(raw_)); + } + + T* raw_ = nullptr; + + friend class cppgc::Visitor; +}; + +template +bool operator==( + BasicMember member1, + BasicMember + member2) { + return member1.Get() == member2.Get(); +} + +template +bool operator!=( + BasicMember member1, + BasicMember + member2) { + return !(member1 == member2); +} + +template +struct IsWeak< + internal::BasicMember> + : std::true_type {}; + +} // namespace internal + +/** + * Members are used in classes to contain strong pointers to other garbage + * collected objects. All Member fields of a class must be traced in the class' + * trace method. + */ +template +using Member = internal::BasicMember; + +/** + * WeakMember is similar to Member in that it is used to point to other garbage + * collected objects. However instead of creating a strong pointer to the + * object, the WeakMember creates a weak pointer, which does not keep the + * pointee alive. Hence if all pointers to to a heap allocated object are weak + * the object will be garbage collected. At the time of GC the weak pointers + * will automatically be set to null. + */ +template +using WeakMember = internal::BasicMember; + +/** + * UntracedMember is a pointer to an on-heap object that is not traced for some + * reason. Do not use this unless you know what you are doing. Keeping raw + * pointers to on-heap objects is prohibited unless used from stack. Pointee + * must be kept alive through other means. + */ +template +using UntracedMember = internal::BasicMember; + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_MEMBER_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/persistent.h b/deps/nodejs/deps/v8/include/cppgc/persistent.h new file mode 100644 index 00000000..fc6b0b9d --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/persistent.h @@ -0,0 +1,304 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_PERSISTENT_H_ +#define INCLUDE_CPPGC_PERSISTENT_H_ + +#include + +#include "cppgc/internal/persistent-node.h" +#include "cppgc/internal/pointer-policies.h" +#include "cppgc/source-location.h" +#include "cppgc/type-traits.h" +#include "cppgc/visitor.h" +#include "v8config.h" // NOLINT(build/include_directory) + +namespace cppgc { +namespace internal { + +// The basic class from which all Persistent classes are generated. +template +class BasicPersistent : public LocationPolicy, + private WeaknessPolicy, + private CheckingPolicy { + public: + using typename WeaknessPolicy::IsStrongPersistent; + using PointeeType = T; + + // Null-state/sentinel constructors. + BasicPersistent( // NOLINT + const SourceLocation& loc = SourceLocation::Current()) + : LocationPolicy(loc) {} + + BasicPersistent(std::nullptr_t, // NOLINT + const SourceLocation& loc = SourceLocation::Current()) + : LocationPolicy(loc) {} + + BasicPersistent( // NOLINT + SentinelPointer s, const SourceLocation& loc = SourceLocation::Current()) + : LocationPolicy(loc), raw_(s) {} + + // Raw value contstructors. + BasicPersistent(T* raw, // NOLINT + const SourceLocation& loc = SourceLocation::Current()) + : LocationPolicy(loc), raw_(raw) { + if (!IsValid()) return; + node_ = WeaknessPolicy::GetPersistentRegion(raw_).AllocateNode( + this, &BasicPersistent::Trace); + this->CheckPointer(Get()); + } + + BasicPersistent(T& raw, // NOLINT + const SourceLocation& loc = SourceLocation::Current()) + : BasicPersistent(&raw, loc) {} + + // Copy ctor. + BasicPersistent(const BasicPersistent& other, + const SourceLocation& loc = SourceLocation::Current()) + : BasicPersistent(other.Get(), loc) {} + + // Heterogeneous ctor. + template ::value>> + BasicPersistent( // NOLINT + const BasicPersistent& other, + const SourceLocation& loc = SourceLocation::Current()) + : BasicPersistent(other.Get(), loc) {} + + // Move ctor. The heterogeneous move ctor is not supported since e.g. + // persistent can't reuse persistent node from weak persistent. + BasicPersistent( + BasicPersistent&& other, + const SourceLocation& loc = SourceLocation::Current()) noexcept + : LocationPolicy(std::move(other)), + raw_(std::move(other.raw_)), + node_(std::move(other.node_)) { + if (!IsValid()) return; + node_->UpdateOwner(this); + other.raw_ = nullptr; + other.node_ = nullptr; + this->CheckPointer(Get()); + } + + // Constructor from member. + template ::value>> + BasicPersistent(internal::BasicMember + member, + const SourceLocation& loc = SourceLocation::Current()) + : BasicPersistent(member.Get(), loc) {} + + ~BasicPersistent() { Clear(); } + + // Copy assignment. + BasicPersistent& operator=(const BasicPersistent& other) { + return operator=(other.Get()); + } + + template ::value>> + BasicPersistent& operator=( + const BasicPersistent& other) { + return operator=(other.Get()); + } + + // Move assignment. + BasicPersistent& operator=(BasicPersistent&& other) { + if (this == &other) return *this; + Clear(); + LocationPolicy::operator=(std::move(other)); + raw_ = std::move(other.raw_); + node_ = std::move(other.node_); + if (!IsValid()) return *this; + node_->UpdateOwner(this); + other.raw_ = nullptr; + other.node_ = nullptr; + this->CheckPointer(Get()); + return *this; + } + + // Assignment from member. + template ::value>> + BasicPersistent& operator=( + internal::BasicMember + member) { + return operator=(member.Get()); + } + + BasicPersistent& operator=(T* other) { + Assign(other); + return *this; + } + + BasicPersistent& operator=(std::nullptr_t) { + Clear(); + return *this; + } + + BasicPersistent& operator=(SentinelPointer s) { + Assign(s); + return *this; + } + + explicit operator bool() const { return Get(); } + operator T*() const { return Get(); } + T* operator->() const { return Get(); } + T& operator*() const { return *Get(); } + + T* Get() const { return raw_; } + + void Clear() { Assign(nullptr); } + + T* Release() { + T* result = Get(); + Clear(); + return result; + } + + private: + static void Trace(Visitor* v, const void* ptr) { + const auto* persistent = static_cast(ptr); + v->TraceRoot(*persistent, persistent->Location()); + } + + bool IsValid() const { + // Ideally, handling kSentinelPointer would be done by the embedder. On the + // other hand, having Persistent aware of it is beneficial since no node + // gets wasted. + return raw_ != nullptr && raw_ != kSentinelPointer; + } + + void Assign(T* ptr) { + if (IsValid()) { + if (ptr && ptr != kSentinelPointer) { + // Simply assign the pointer reusing the existing node. + raw_ = ptr; + this->CheckPointer(ptr); + return; + } + WeaknessPolicy::GetPersistentRegion(raw_).FreeNode(node_); + node_ = nullptr; + } + raw_ = ptr; + if (!IsValid()) return; + node_ = WeaknessPolicy::GetPersistentRegion(raw_).AllocateNode( + this, &BasicPersistent::Trace); + this->CheckPointer(Get()); + } + + T* raw_ = nullptr; + PersistentNode* node_ = nullptr; +}; + +template +bool operator==(const BasicPersistent& p1, + const BasicPersistent& p2) { + return p1.Get() == p2.Get(); +} + +template +bool operator!=(const BasicPersistent& p1, + const BasicPersistent& p2) { + return !(p1 == p2); +} + +template +bool operator==(const BasicPersistent& p, + BasicMember + m) { + return p.Get() == m.Get(); +} + +template +bool operator!=(const BasicPersistent& p, + BasicMember + m) { + return !(p == m); +} + +template +bool operator==(BasicMember + m, + const BasicPersistent& p) { + return m.Get() == p.Get(); +} + +template +bool operator!=(BasicMember + m, + const BasicPersistent& p) { + return !(m == p); +} + +template +struct IsWeak> : std::true_type {}; +} // namespace internal + +/** + * Persistent is a way to create a strong pointer from an off-heap object to + * another on-heap object. As long as the Persistent handle is alive the GC will + * keep the object pointed to alive. The Persistent handle is always a GC root + * from the point of view of the GC. Persistent must be constructed and + * destructed in the same thread. + */ +template +using Persistent = + internal::BasicPersistent; + +/** + * WeakPersistent is a way to create a weak pointer from an off-heap object to + * an on-heap object. The pointer is automatically cleared when the pointee gets + * collected. WeakPersistent must be constructed and destructed in the same + * thread. + */ +template +using WeakPersistent = + internal::BasicPersistent; + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_PERSISTENT_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/platform.h b/deps/nodejs/deps/v8/include/cppgc/platform.h new file mode 100644 index 00000000..8dc5e14a --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/platform.h @@ -0,0 +1,31 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_PLATFORM_H_ +#define INCLUDE_CPPGC_PLATFORM_H_ + +#include "v8-platform.h" // NOLINT(build/include_directory) +#include "v8config.h" // NOLINT(build/include_directory) + +namespace cppgc { + +// TODO(v8:10346): Put PageAllocator in a non-V8 include header to avoid +// depending on namespace v8. +using PageAllocator = v8::PageAllocator; + +// Initializes the garbage collector with the provided platform. Must be called +// before creating a Heap. +V8_EXPORT void InitializePlatform(PageAllocator* page_allocator); + +// Must be called after destroying the last used heap. +V8_EXPORT void ShutdownPlatform(); + +namespace internal { + +V8_EXPORT void Abort(); + +} // namespace internal +} // namespace cppgc + +#endif // INCLUDE_CPPGC_PLATFORM_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/prefinalizer.h b/deps/nodejs/deps/v8/include/cppgc/prefinalizer.h new file mode 100644 index 00000000..2f6d68a1 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/prefinalizer.h @@ -0,0 +1,54 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_PREFINALIZER_H_ +#define INCLUDE_CPPGC_PREFINALIZER_H_ + +#include "cppgc/internal/accessors.h" +#include "cppgc/internal/compiler-specific.h" +#include "cppgc/internal/prefinalizer-handler.h" +#include "cppgc/liveness-broker.h" +#include "cppgc/macros.h" + +namespace cppgc { + +namespace internal { + +template +class PrefinalizerRegistration final { + public: + explicit PrefinalizerRegistration(T* self) { + static_assert(sizeof(&T::InvokePreFinalizer) > 0, + "USING_PRE_FINALIZER(T) must be defined."); + + cppgc::internal::PreFinalizerRegistrationDispatcher::RegisterPrefinalizer( + internal::GetHeapFromPayload(self), {self, T::InvokePreFinalizer}); + } + + void* operator new(size_t, void* location) = delete; + void* operator new(size_t) = delete; +}; + +} // namespace internal + +#define CPPGC_USING_PRE_FINALIZER(Class, PreFinalizer) \ + public: \ + static bool InvokePreFinalizer(const LivenessBroker& liveness_broker, \ + void* object) { \ + static_assert(internal::IsGarbageCollectedTypeV, \ + "Only garbage collected objects can have prefinalizers"); \ + Class* self = static_cast(object); \ + if (liveness_broker.IsHeapObjectAlive(self)) return false; \ + self->Class::PreFinalizer(); \ + return true; \ + } \ + \ + private: \ + CPPGC_NO_UNIQUE_ADDRESS internal::PrefinalizerRegistration \ + prefinalizer_dummy_{this}; \ + friend class internal::__thisIsHereToForceASemicolonAfterThisMacro + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_PREFINALIZER_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/source-location.h b/deps/nodejs/deps/v8/include/cppgc/source-location.h new file mode 100644 index 00000000..8cc52d6a --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/source-location.h @@ -0,0 +1,59 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_SOURCE_LOCATION_H_ +#define INCLUDE_CPPGC_SOURCE_LOCATION_H_ + +#include + +#include "v8config.h" // NOLINT(build/include_directory) + +#if defined(__has_builtin) +#define CPPGC_SUPPORTS_SOURCE_LOCATION \ + (__has_builtin(__builtin_FUNCTION) && __has_builtin(__builtin_FILE) && \ + __has_builtin(__builtin_LINE)) // NOLINT +#elif defined(V8_CC_GNU) && __GNUC__ >= 7 +#define CPPGC_SUPPORTS_SOURCE_LOCATION 1 +#elif defined(V8_CC_INTEL) && __ICC >= 1800 +#define CPPGC_SUPPORTS_SOURCE_LOCATION 1 +#else +#define CPPGC_SUPPORTS_SOURCE_LOCATION 0 +#endif + +namespace cppgc { + +// Encapsulates source location information. Mimics C++20's +// std::source_location. +class V8_EXPORT SourceLocation final { + public: +#if CPPGC_SUPPORTS_SOURCE_LOCATION + static constexpr SourceLocation Current( + const char* function = __builtin_FUNCTION(), + const char* file = __builtin_FILE(), size_t line = __builtin_LINE()) { + return SourceLocation(function, file, line); + } +#else + static constexpr SourceLocation Current() { return SourceLocation(); } +#endif // CPPGC_SUPPORTS_SOURCE_LOCATION + + constexpr SourceLocation() = default; + + constexpr const char* Function() const { return function_; } + constexpr const char* FileName() const { return file_; } + constexpr size_t Line() const { return line_; } + + std::string ToString() const; + + private: + constexpr SourceLocation(const char* function, const char* file, size_t line) + : function_(function), file_(file), line_(line) {} + + const char* function_ = nullptr; + const char* file_ = nullptr; + size_t line_ = 0u; +}; + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_SOURCE_LOCATION_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/trace-trait.h b/deps/nodejs/deps/v8/include/cppgc/trace-trait.h new file mode 100644 index 00000000..e246bc53 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/trace-trait.h @@ -0,0 +1,67 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_TRACE_TRAIT_H_ +#define INCLUDE_CPPGC_TRACE_TRAIT_H_ + +#include +#include "cppgc/type-traits.h" + +namespace cppgc { + +class Visitor; + +namespace internal { + +template ::type>> +struct TraceTraitImpl; + +} // namespace internal + +using TraceCallback = void (*)(Visitor*, const void*); + +// TraceDescriptor is used to describe how to trace an object. +struct TraceDescriptor { + // The adjusted base pointer of the object that should be traced. + const void* base_object_payload; + // A callback for tracing the object. + TraceCallback callback; +}; + +template +struct TraceTrait { + static_assert(internal::IsTraceableV, "T must have a Trace() method"); + + static TraceDescriptor GetTraceDescriptor(const void* self) { + return internal::TraceTraitImpl::GetTraceDescriptor( + static_cast(self)); + } + + static void Trace(Visitor* visitor, const void* self) { + static_cast(self)->Trace(visitor); + } +}; + +namespace internal { + +template +struct TraceTraitImpl { + static TraceDescriptor GetTraceDescriptor(const void* self) { + return {self, TraceTrait::Trace}; + } +}; + +template +struct TraceTraitImpl { + static TraceDescriptor GetTraceDescriptor(const void* self) { + return static_cast(self)->GetTraceDescriptor(); + } +}; + +} // namespace internal +} // namespace cppgc + +#endif // INCLUDE_CPPGC_TRACE_TRAIT_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/type-traits.h b/deps/nodejs/deps/v8/include/cppgc/type-traits.h new file mode 100644 index 00000000..4d8ab809 --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/type-traits.h @@ -0,0 +1,109 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_TYPE_TRAITS_H_ +#define INCLUDE_CPPGC_TYPE_TRAITS_H_ + +#include + +namespace cppgc { + +class Visitor; + +namespace internal { + +// Pre-C++17 custom implementation of std::void_t. +template +struct make_void { + typedef void type; +}; +template +using void_t = typename make_void::type; + +// Not supposed to be specialized by the user. +template +struct IsWeak : std::false_type {}; + +template class U> +struct IsSubclassOfTemplate { + private: + template + static std::true_type SubclassCheck(U*); + static std::false_type SubclassCheck(...); + + public: + static constexpr bool value = + decltype(SubclassCheck(std::declval()))::value; +}; + +// IsTraceMethodConst is used to verify that all Trace methods are marked as +// const. It is equivalent to IsTraceable but for a non-const object. +template +struct IsTraceMethodConst : std::false_type {}; + +template +struct IsTraceMethodConst().Trace( + std::declval()))>> : std::true_type { +}; + +template +struct IsTraceable : std::false_type { + static_assert(sizeof(T), "T must be fully defined"); +}; + +template +struct IsTraceable< + T, void_t().Trace(std::declval()))>> + : std::true_type { + // All Trace methods should be marked as const. If an object of type + // 'T' is traceable then any object of type 'const T' should also + // be traceable. + static_assert(IsTraceMethodConst(), + "Trace methods should be marked as const."); +}; + +template +constexpr bool IsTraceableV = IsTraceable::value; + +template +struct IsGarbageCollectedMixinType : std::false_type { + static_assert(sizeof(T), "T must be fully defined"); +}; + +template +struct IsGarbageCollectedMixinType< + T, + void_t::IsGarbageCollectedMixinTypeMarker>> + : std::true_type { + static_assert(sizeof(T), "T must be fully defined"); +}; + +template +struct IsGarbageCollectedType : IsGarbageCollectedMixinType { + static_assert(sizeof(T), "T must be fully defined"); +}; + +template +struct IsGarbageCollectedType< + T, void_t::IsGarbageCollectedTypeMarker>> + : std::true_type { + static_assert(sizeof(T), "T must be fully defined"); +}; + +template +constexpr bool IsGarbageCollectedTypeV = + internal::IsGarbageCollectedType::value; + +template +constexpr bool IsGarbageCollectedMixinTypeV = + internal::IsGarbageCollectedMixinType::value; + +} // namespace internal + +template +constexpr bool IsWeakV = internal::IsWeak::value; + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_TYPE_TRAITS_H_ diff --git a/deps/nodejs/deps/v8/include/cppgc/visitor.h b/deps/nodejs/deps/v8/include/cppgc/visitor.h new file mode 100644 index 00000000..a73a4abb --- /dev/null +++ b/deps/nodejs/deps/v8/include/cppgc/visitor.h @@ -0,0 +1,138 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef INCLUDE_CPPGC_VISITOR_H_ +#define INCLUDE_CPPGC_VISITOR_H_ + +#include "cppgc/garbage-collected.h" +#include "cppgc/internal/logging.h" +#include "cppgc/internal/pointer-policies.h" +#include "cppgc/liveness-broker.h" +#include "cppgc/member.h" +#include "cppgc/source-location.h" +#include "cppgc/trace-trait.h" + +namespace cppgc { +namespace internal { +class VisitorBase; +} // namespace internal + +using WeakCallback = void (*)(const LivenessBroker&, const void*); + +/** + * Visitor passed to trace methods. All managed pointers must have called the + * visitor's trace method on them. + */ +class Visitor { + public: + template + void Trace(const Member& member) { + const T* value = member.GetRawAtomic(); + CPPGC_DCHECK(value != kSentinelPointer); + Trace(value); + } + + template + void Trace(const WeakMember& weak_member) { + static_assert(sizeof(T), "T must be fully defined"); + static_assert(internal::IsGarbageCollectedType::value, + "T must be GarabgeCollected or GarbageCollectedMixin type"); + + const T* value = weak_member.GetRawAtomic(); + + // Bailout assumes that WeakMember emits write barrier. + if (!value) { + return; + } + + // TODO(chromium:1056170): DCHECK (or similar) for deleted values as they + // should come in at a different path. + VisitWeak(value, TraceTrait::GetTraceDescriptor(value), + &HandleWeak>, &weak_member); + } + + template * = nullptr> + void TraceRoot(const Persistent& p, const SourceLocation& loc) { + using PointeeType = typename Persistent::PointeeType; + static_assert(sizeof(PointeeType), + "Persistent's pointee type must be fully defined"); + static_assert(internal::IsGarbageCollectedType::value, + "Persisent's pointee type must be GarabgeCollected or " + "GarbageCollectedMixin"); + if (!p.Get()) { + return; + } + VisitRoot(p.Get(), TraceTrait::GetTraceDescriptor(p.Get())); + } + + template < + typename WeakPersistent, + std::enable_if_t* = nullptr> + void TraceRoot(const WeakPersistent& p, const SourceLocation& loc) { + using PointeeType = typename WeakPersistent::PointeeType; + static_assert(sizeof(PointeeType), + "Persistent's pointee type must be fully defined"); + static_assert(internal::IsGarbageCollectedType::value, + "Persisent's pointee type must be GarabgeCollected or " + "GarbageCollectedMixin"); + VisitWeakRoot(p.Get(), TraceTrait::GetTraceDescriptor(p.Get()), + &HandleWeak, &p); + } + + template + void RegisterWeakCallbackMethod(const T* obj) { + RegisterWeakCallback(&WeakCallbackMethodDelegate, obj); + } + + virtual void RegisterWeakCallback(WeakCallback, const void*) {} + + protected: + virtual void Visit(const void* self, TraceDescriptor) {} + virtual void VisitWeak(const void* self, TraceDescriptor, WeakCallback, + const void* weak_member) {} + virtual void VisitRoot(const void*, TraceDescriptor) {} + virtual void VisitWeakRoot(const void* self, TraceDescriptor, WeakCallback, + const void* weak_root) {} + + private: + template + static void WeakCallbackMethodDelegate(const LivenessBroker& info, + const void* self) { + // Callback is registered through a potential const Trace method but needs + // to be able to modify fields. See HandleWeak. + (const_cast(static_cast(self))->*method)(info); + } + + template + static void HandleWeak(const LivenessBroker& info, const void* object) { + const PointerType* weak = static_cast(object); + const auto* raw = weak->Get(); + if (raw && !info.IsHeapObjectAlive(raw)) { + // Object is passed down through the marker as const. Alternatives are + // - non-const Trace method; + // - mutable pointer in MemberBase; + const_cast(weak)->Clear(); + } + } + + Visitor() = default; + + template + void Trace(const T* t) { + static_assert(sizeof(T), "T must be fully defined"); + static_assert(internal::IsGarbageCollectedType::value, + "T must be GarabgeCollected or GarbageCollectedMixin type"); + if (!t) { + return; + } + Visit(t, TraceTrait::GetTraceDescriptor(t)); + } + + friend class internal::VisitorBase; +}; + +} // namespace cppgc + +#endif // INCLUDE_CPPGC_VISITOR_H_ diff --git a/deps/nodejs/deps/v8/include/js_protocol-1.2.json b/deps/nodejs/deps/v8/include/js_protocol-1.2.json new file mode 100644 index 00000000..aff68062 --- /dev/null +++ b/deps/nodejs/deps/v8/include/js_protocol-1.2.json @@ -0,0 +1,997 @@ +{ + "version": { "major": "1", "minor": "2" }, + "domains": [ + { + "domain": "Schema", + "description": "Provides information about the protocol schema.", + "types": [ + { + "id": "Domain", + "type": "object", + "description": "Description of the protocol domain.", + "exported": true, + "properties": [ + { "name": "name", "type": "string", "description": "Domain name." }, + { "name": "version", "type": "string", "description": "Domain version." } + ] + } + ], + "commands": [ + { + "name": "getDomains", + "description": "Returns supported domains.", + "handlers": ["browser", "renderer"], + "returns": [ + { "name": "domains", "type": "array", "items": { "$ref": "Domain" }, "description": "List of supported domains." } + ] + } + ] + }, + { + "domain": "Runtime", + "description": "Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects. Evaluation results are returned as mirror object that expose object type, string representation and unique identifier that can be used for further object reference. Original objects are maintained in memory unless they are either explicitly released or are released along with the other objects in their object group.", + "types": [ + { + "id": "ScriptId", + "type": "string", + "description": "Unique script identifier." + }, + { + "id": "RemoteObjectId", + "type": "string", + "description": "Unique object identifier." + }, + { + "id": "UnserializableValue", + "type": "string", + "enum": ["Infinity", "NaN", "-Infinity", "-0"], + "description": "Primitive value which cannot be JSON-stringified." + }, + { + "id": "RemoteObject", + "type": "object", + "description": "Mirror object referencing original JavaScript object.", + "exported": true, + "properties": [ + { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." }, + { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "map", "set", "iterator", "generator", "error", "proxy", "promise", "typedarray"], "description": "Object subtype hint. Specified for object type values only." }, + { "name": "className", "type": "string", "optional": true, "description": "Object class (constructor) name. Specified for object type values only." }, + { "name": "value", "type": "any", "optional": true, "description": "Remote object value in case of primitive values or JSON values (if it was requested)." }, + { "name": "unserializableValue", "$ref": "UnserializableValue", "optional": true, "description": "Primitive value which can not be JSON-stringified does not have value, but gets this property." }, + { "name": "description", "type": "string", "optional": true, "description": "String representation of the object." }, + { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Unique object identifier (for non-primitive values)." }, + { "name": "preview", "$ref": "ObjectPreview", "optional": true, "description": "Preview containing abbreviated property values. Specified for object type values only.", "experimental": true }, + { "name": "customPreview", "$ref": "CustomPreview", "optional": true, "experimental": true} + ] + }, + { + "id": "CustomPreview", + "type": "object", + "experimental": true, + "properties": [ + { "name": "header", "type": "string"}, + { "name": "hasBody", "type": "boolean"}, + { "name": "formatterObjectId", "$ref": "RemoteObjectId"}, + { "name": "bindRemoteObjectFunctionId", "$ref": "RemoteObjectId" }, + { "name": "configObjectId", "$ref": "RemoteObjectId", "optional": true } + ] + }, + { + "id": "ObjectPreview", + "type": "object", + "experimental": true, + "description": "Object containing abbreviated remote object value.", + "properties": [ + { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." }, + { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "map", "set", "iterator", "generator", "error"], "description": "Object subtype hint. Specified for object type values only." }, + { "name": "description", "type": "string", "optional": true, "description": "String representation of the object." }, + { "name": "overflow", "type": "boolean", "description": "True iff some of the properties or entries of the original object did not fit." }, + { "name": "properties", "type": "array", "items": { "$ref": "PropertyPreview" }, "description": "List of the properties." }, + { "name": "entries", "type": "array", "items": { "$ref": "EntryPreview" }, "optional": true, "description": "List of the entries. Specified for map and set subtype values only." } + ] + }, + { + "id": "PropertyPreview", + "type": "object", + "experimental": true, + "properties": [ + { "name": "name", "type": "string", "description": "Property name." }, + { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol", "accessor"], "description": "Object type. Accessor means that the property itself is an accessor property." }, + { "name": "value", "type": "string", "optional": true, "description": "User-friendly property value string." }, + { "name": "valuePreview", "$ref": "ObjectPreview", "optional": true, "description": "Nested value preview." }, + { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "map", "set", "iterator", "generator", "error"], "description": "Object subtype hint. Specified for object type values only." } + ] + }, + { + "id": "EntryPreview", + "type": "object", + "experimental": true, + "properties": [ + { "name": "key", "$ref": "ObjectPreview", "optional": true, "description": "Preview of the key. Specified for map-like collection entries." }, + { "name": "value", "$ref": "ObjectPreview", "description": "Preview of the value." } + ] + }, + { + "id": "PropertyDescriptor", + "type": "object", + "description": "Object property descriptor.", + "properties": [ + { "name": "name", "type": "string", "description": "Property name or symbol description." }, + { "name": "value", "$ref": "RemoteObject", "optional": true, "description": "The value associated with the property." }, + { "name": "writable", "type": "boolean", "optional": true, "description": "True if the value associated with the property may be changed (data descriptors only)." }, + { "name": "get", "$ref": "RemoteObject", "optional": true, "description": "A function which serves as a getter for the property, or undefined if there is no getter (accessor descriptors only)." }, + { "name": "set", "$ref": "RemoteObject", "optional": true, "description": "A function which serves as a setter for the property, or undefined if there is no setter (accessor descriptors only)." }, + { "name": "configurable", "type": "boolean", "description": "True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object." }, + { "name": "enumerable", "type": "boolean", "description": "True if this property shows up during enumeration of the properties on the corresponding object." }, + { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." }, + { "name": "isOwn", "optional": true, "type": "boolean", "description": "True if the property is owned for the object." }, + { "name": "symbol", "$ref": "RemoteObject", "optional": true, "description": "Property symbol object, if the property is of the symbol type." } + ] + }, + { + "id": "InternalPropertyDescriptor", + "type": "object", + "description": "Object internal property descriptor. This property isn't normally visible in JavaScript code.", + "properties": [ + { "name": "name", "type": "string", "description": "Conventional property name." }, + { "name": "value", "$ref": "RemoteObject", "optional": true, "description": "The value associated with the property." } + ] + }, + { + "id": "CallArgument", + "type": "object", + "description": "Represents function call argument. Either remote object id objectId, primitive value, unserializable primitive value or neither of (for undefined) them should be specified.", + "properties": [ + { "name": "value", "type": "any", "optional": true, "description": "Primitive value." }, + { "name": "unserializableValue", "$ref": "UnserializableValue", "optional": true, "description": "Primitive value which can not be JSON-stringified." }, + { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Remote object handle." } + ] + }, + { + "id": "ExecutionContextId", + "type": "integer", + "description": "Id of an execution context." + }, + { + "id": "ExecutionContextDescription", + "type": "object", + "description": "Description of an isolated world.", + "properties": [ + { "name": "id", "$ref": "ExecutionContextId", "description": "Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed." }, + { "name": "origin", "type": "string", "description": "Execution context origin." }, + { "name": "name", "type": "string", "description": "Human readable name describing given context." }, + { "name": "auxData", "type": "object", "optional": true, "description": "Embedder-specific auxiliary data." } + ] + }, + { + "id": "ExceptionDetails", + "type": "object", + "description": "Detailed information about exception (or error) that was thrown during script compilation or execution.", + "properties": [ + { "name": "exceptionId", "type": "integer", "description": "Exception id." }, + { "name": "text", "type": "string", "description": "Exception text, which should be used together with exception object when available." }, + { "name": "lineNumber", "type": "integer", "description": "Line number of the exception location (0-based)." }, + { "name": "columnNumber", "type": "integer", "description": "Column number of the exception location (0-based)." }, + { "name": "scriptId", "$ref": "ScriptId", "optional": true, "description": "Script ID of the exception location." }, + { "name": "url", "type": "string", "optional": true, "description": "URL of the exception location, to be used when the script was not reported." }, + { "name": "stackTrace", "$ref": "StackTrace", "optional": true, "description": "JavaScript stack trace if available." }, + { "name": "exception", "$ref": "RemoteObject", "optional": true, "description": "Exception object if available." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Identifier of the context where exception happened." } + ] + }, + { + "id": "Timestamp", + "type": "number", + "description": "Number of milliseconds since epoch." + }, + { + "id": "CallFrame", + "type": "object", + "description": "Stack entry for runtime errors and assertions.", + "properties": [ + { "name": "functionName", "type": "string", "description": "JavaScript function name." }, + { "name": "scriptId", "$ref": "ScriptId", "description": "JavaScript script id." }, + { "name": "url", "type": "string", "description": "JavaScript script name or url." }, + { "name": "lineNumber", "type": "integer", "description": "JavaScript script line number (0-based)." }, + { "name": "columnNumber", "type": "integer", "description": "JavaScript script column number (0-based)." } + ] + }, + { + "id": "StackTrace", + "type": "object", + "description": "Call frames for assertions or error messages.", + "exported": true, + "properties": [ + { "name": "description", "type": "string", "optional": true, "description": "String label of this stack trace. For async traces this may be a name of the function that initiated the async call." }, + { "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "JavaScript function name." }, + { "name": "parent", "$ref": "StackTrace", "optional": true, "description": "Asynchronous JavaScript stack trace that preceded this stack, if available." } + ] + } + ], + "commands": [ + { + "name": "evaluate", + "async": true, + "parameters": [ + { "name": "expression", "type": "string", "description": "Expression to evaluate." }, + { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." }, + { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation." }, + { "name": "silent", "type": "boolean", "optional": true, "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state." }, + { "name": "contextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page." }, + { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." }, + { "name": "generatePreview", "type": "boolean", "optional": true, "experimental": true, "description": "Whether preview should be generated for the result." }, + { "name": "userGesture", "type": "boolean", "optional": true, "experimental": true, "description": "Whether execution should be treated as initiated by user in the UI." }, + { "name": "awaitPromise", "type": "boolean", "optional":true, "description": "Whether execution should wait for promise to be resolved. If the result of evaluation is not a Promise, it's considered to be an error." } + ], + "returns": [ + { "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."} + ], + "description": "Evaluates expression on global object." + }, + { + "name": "awaitPromise", + "async": true, + "parameters": [ + { "name": "promiseObjectId", "$ref": "RemoteObjectId", "description": "Identifier of the promise." }, + { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." }, + { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for the result." } + ], + "returns": [ + { "name": "result", "$ref": "RemoteObject", "description": "Promise result. Will contain rejected value if promise was rejected." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details if stack strace is available."} + ], + "description": "Add handler to promise with given promise object id." + }, + { + "name": "callFunctionOn", + "async": true, + "parameters": [ + { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to call function on." }, + { "name": "functionDeclaration", "type": "string", "description": "Declaration of the function to call." }, + { "name": "arguments", "type": "array", "items": { "$ref": "CallArgument", "description": "Call argument." }, "optional": true, "description": "Call arguments. All call arguments must belong to the same JavaScript world as the target object." }, + { "name": "silent", "type": "boolean", "optional": true, "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state." }, + { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object which should be sent by value." }, + { "name": "generatePreview", "type": "boolean", "optional": true, "experimental": true, "description": "Whether preview should be generated for the result." }, + { "name": "userGesture", "type": "boolean", "optional": true, "experimental": true, "description": "Whether execution should be treated as initiated by user in the UI." }, + { "name": "awaitPromise", "type": "boolean", "optional":true, "description": "Whether execution should wait for promise to be resolved. If the result of evaluation is not a Promise, it's considered to be an error." } + ], + "returns": [ + { "name": "result", "$ref": "RemoteObject", "description": "Call result." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."} + ], + "description": "Calls function with given declaration on the given object. Object group of the result is inherited from the target object." + }, + { + "name": "getProperties", + "parameters": [ + { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to return properties for." }, + { "name": "ownProperties", "optional": true, "type": "boolean", "description": "If true, returns properties belonging only to the element itself, not to its prototype chain." }, + { "name": "accessorPropertiesOnly", "optional": true, "type": "boolean", "description": "If true, returns accessor properties (with getter/setter) only; internal properties are not returned either.", "experimental": true }, + { "name": "generatePreview", "type": "boolean", "optional": true, "experimental": true, "description": "Whether preview should be generated for the results." } + ], + "returns": [ + { "name": "result", "type": "array", "items": { "$ref": "PropertyDescriptor" }, "description": "Object properties." }, + { "name": "internalProperties", "optional": true, "type": "array", "items": { "$ref": "InternalPropertyDescriptor" }, "description": "Internal object properties (only of the element itself)." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."} + ], + "description": "Returns properties of a given object. Object group of the result is inherited from the target object." + }, + { + "name": "releaseObject", + "parameters": [ + { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to release." } + ], + "description": "Releases remote object with given id." + }, + { + "name": "releaseObjectGroup", + "parameters": [ + { "name": "objectGroup", "type": "string", "description": "Symbolic object group name." } + ], + "description": "Releases all remote objects that belong to a given group." + }, + { + "name": "runIfWaitingForDebugger", + "description": "Tells inspected instance to run if it was waiting for debugger to attach." + }, + { + "name": "enable", + "description": "Enables reporting of execution contexts creation by means of executionContextCreated event. When the reporting gets enabled the event will be sent immediately for each existing execution context." + }, + { + "name": "disable", + "description": "Disables reporting of execution contexts creation." + }, + { + "name": "discardConsoleEntries", + "description": "Discards collected exceptions and console API calls." + }, + { + "name": "setCustomObjectFormatterEnabled", + "parameters": [ + { + "name": "enabled", + "type": "boolean" + } + ], + "experimental": true + }, + { + "name": "compileScript", + "parameters": [ + { "name": "expression", "type": "string", "description": "Expression to compile." }, + { "name": "sourceURL", "type": "string", "description": "Source url to be set for the script." }, + { "name": "persistScript", "type": "boolean", "description": "Specifies whether the compiled script should be persisted." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page." } + ], + "returns": [ + { "name": "scriptId", "$ref": "ScriptId", "optional": true, "description": "Id of the script." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."} + ], + "description": "Compiles expression." + }, + { + "name": "runScript", + "async": true, + "parameters": [ + { "name": "scriptId", "$ref": "ScriptId", "description": "Id of the script to run." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page." }, + { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." }, + { "name": "silent", "type": "boolean", "optional": true, "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state." }, + { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation." }, + { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object which should be sent by value." }, + { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for the result." }, + { "name": "awaitPromise", "type": "boolean", "optional": true, "description": "Whether execution should wait for promise to be resolved. If the result of evaluation is not a Promise, it's considered to be an error." } + ], + "returns": [ + { "name": "result", "$ref": "RemoteObject", "description": "Run result." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."} + ], + "description": "Runs script with given id in a given context." + } + ], + "events": [ + { + "name": "executionContextCreated", + "parameters": [ + { "name": "context", "$ref": "ExecutionContextDescription", "description": "A newly created execution contex." } + ], + "description": "Issued when new execution context is created." + }, + { + "name": "executionContextDestroyed", + "parameters": [ + { "name": "executionContextId", "$ref": "ExecutionContextId", "description": "Id of the destroyed context" } + ], + "description": "Issued when execution context is destroyed." + }, + { + "name": "executionContextsCleared", + "description": "Issued when all executionContexts were cleared in browser" + }, + { + "name": "exceptionThrown", + "description": "Issued when exception was thrown and unhandled.", + "parameters": [ + { "name": "timestamp", "$ref": "Timestamp", "description": "Timestamp of the exception." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails" } + ] + }, + { + "name": "exceptionRevoked", + "description": "Issued when unhandled exception was revoked.", + "parameters": [ + { "name": "reason", "type": "string", "description": "Reason describing why exception was revoked." }, + { "name": "exceptionId", "type": "integer", "description": "The id of revoked exception, as reported in exceptionUnhandled." } + ] + }, + { + "name": "consoleAPICalled", + "description": "Issued when console API was called.", + "parameters": [ + { "name": "type", "type": "string", "enum": ["log", "debug", "info", "error", "warning", "dir", "dirxml", "table", "trace", "clear", "startGroup", "startGroupCollapsed", "endGroup", "assert", "profile", "profileEnd"], "description": "Type of the call." }, + { "name": "args", "type": "array", "items": { "$ref": "RemoteObject" }, "description": "Call arguments." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "description": "Identifier of the context where the call was made." }, + { "name": "timestamp", "$ref": "Timestamp", "description": "Call timestamp." }, + { "name": "stackTrace", "$ref": "StackTrace", "optional": true, "description": "Stack trace captured when the call was made." } + ] + }, + { + "name": "inspectRequested", + "description": "Issued when object should be inspected (for example, as a result of inspect() command line API call).", + "parameters": [ + { "name": "object", "$ref": "RemoteObject" }, + { "name": "hints", "type": "object" } + ] + } + ] + }, + { + "domain": "Debugger", + "description": "Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.", + "dependencies": ["Runtime"], + "types": [ + { + "id": "BreakpointId", + "type": "string", + "description": "Breakpoint identifier." + }, + { + "id": "CallFrameId", + "type": "string", + "description": "Call frame identifier." + }, + { + "id": "Location", + "type": "object", + "properties": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier as reported in the Debugger.scriptParsed." }, + { "name": "lineNumber", "type": "integer", "description": "Line number in the script (0-based)." }, + { "name": "columnNumber", "type": "integer", "optional": true, "description": "Column number in the script (0-based)." } + ], + "description": "Location in the source code." + }, + { + "id": "ScriptPosition", + "experimental": true, + "type": "object", + "properties": [ + { "name": "lineNumber", "type": "integer" }, + { "name": "columnNumber", "type": "integer" } + ], + "description": "Location in the source code." + }, + { + "id": "CallFrame", + "type": "object", + "properties": [ + { "name": "callFrameId", "$ref": "CallFrameId", "description": "Call frame identifier. This identifier is only valid while the virtual machine is paused." }, + { "name": "functionName", "type": "string", "description": "Name of the JavaScript function called on this call frame." }, + { "name": "functionLocation", "$ref": "Location", "optional": true, "experimental": true, "description": "Location in the source code." }, + { "name": "location", "$ref": "Location", "description": "Location in the source code." }, + { "name": "scopeChain", "type": "array", "items": { "$ref": "Scope" }, "description": "Scope chain for this call frame." }, + { "name": "this", "$ref": "Runtime.RemoteObject", "description": "this object for this call frame." }, + { "name": "returnValue", "$ref": "Runtime.RemoteObject", "optional": true, "description": "The value being returned, if the function is at return point." } + ], + "description": "JavaScript call frame. Array of call frames form the call stack." + }, + { + "id": "Scope", + "type": "object", + "properties": [ + { "name": "type", "type": "string", "enum": ["global", "local", "with", "closure", "catch", "block", "script"], "description": "Scope type." }, + { "name": "object", "$ref": "Runtime.RemoteObject", "description": "Object representing the scope. For global and with scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties." }, + { "name": "name", "type": "string", "optional": true }, + { "name": "startLocation", "$ref": "Location", "optional": true, "description": "Location in the source code where scope starts" }, + { "name": "endLocation", "$ref": "Location", "optional": true, "description": "Location in the source code where scope ends" } + ], + "description": "Scope description." + }, + { + "id": "SearchMatch", + "type": "object", + "description": "Search match for resource.", + "exported": true, + "properties": [ + { "name": "lineNumber", "type": "number", "description": "Line number in resource content." }, + { "name": "lineContent", "type": "string", "description": "Line with match content." } + ], + "experimental": true + } + ], + "commands": [ + { + "name": "enable", + "description": "Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received." + }, + { + "name": "disable", + "description": "Disables debugger for given page." + }, + { + "name": "setBreakpointsActive", + "parameters": [ + { "name": "active", "type": "boolean", "description": "New value for breakpoints active state." } + ], + "description": "Activates / deactivates all breakpoints on the page." + }, + { + "name": "setSkipAllPauses", + "parameters": [ + { "name": "skip", "type": "boolean", "description": "New value for skip pauses state." } + ], + "description": "Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc)." + }, + { + "name": "setBreakpointByUrl", + "parameters": [ + { "name": "lineNumber", "type": "integer", "description": "Line number to set breakpoint at." }, + { "name": "url", "type": "string", "optional": true, "description": "URL of the resources to set breakpoint on." }, + { "name": "urlRegex", "type": "string", "optional": true, "description": "Regex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified." }, + { "name": "columnNumber", "type": "integer", "optional": true, "description": "Offset in the line to set breakpoint at." }, + { "name": "condition", "type": "string", "optional": true, "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true." } + ], + "returns": [ + { "name": "breakpointId", "$ref": "BreakpointId", "description": "Id of the created breakpoint for further reference." }, + { "name": "locations", "type": "array", "items": { "$ref": "Location" }, "description": "List of the locations this breakpoint resolved into upon addition." } + ], + "description": "Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this command is issued, all existing parsed scripts will have breakpoints resolved and returned in locations property. Further matching script parsing will result in subsequent breakpointResolved events issued. This logical breakpoint will survive page reloads." + }, + { + "name": "setBreakpoint", + "parameters": [ + { "name": "location", "$ref": "Location", "description": "Location to set breakpoint in." }, + { "name": "condition", "type": "string", "optional": true, "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true." } + ], + "returns": [ + { "name": "breakpointId", "$ref": "BreakpointId", "description": "Id of the created breakpoint for further reference." }, + { "name": "actualLocation", "$ref": "Location", "description": "Location this breakpoint resolved into." } + ], + "description": "Sets JavaScript breakpoint at a given location." + }, + { + "name": "removeBreakpoint", + "parameters": [ + { "name": "breakpointId", "$ref": "BreakpointId" } + ], + "description": "Removes JavaScript breakpoint." + }, + { + "name": "continueToLocation", + "parameters": [ + { "name": "location", "$ref": "Location", "description": "Location to continue to." } + ], + "description": "Continues execution until specific location is reached." + }, + { + "name": "stepOver", + "description": "Steps over the statement." + }, + { + "name": "stepInto", + "description": "Steps into the function call." + }, + { + "name": "stepOut", + "description": "Steps out of the function call." + }, + { + "name": "pause", + "description": "Stops on the next JavaScript statement." + }, + { + "name": "resume", + "description": "Resumes JavaScript execution." + }, + { + "name": "searchInContent", + "parameters": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to search in." }, + { "name": "query", "type": "string", "description": "String to search for." }, + { "name": "caseSensitive", "type": "boolean", "optional": true, "description": "If true, search is case sensitive." }, + { "name": "isRegex", "type": "boolean", "optional": true, "description": "If true, treats string parameter as regex." } + ], + "returns": [ + { "name": "result", "type": "array", "items": { "$ref": "SearchMatch" }, "description": "List of search matches." } + ], + "experimental": true, + "description": "Searches for given string in script content." + }, + { + "name": "setScriptSource", + "parameters": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to edit." }, + { "name": "scriptSource", "type": "string", "description": "New content of the script." }, + { "name": "dryRun", "type": "boolean", "optional": true, "description": " If true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code." } + ], + "returns": [ + { "name": "callFrames", "type": "array", "optional": true, "items": { "$ref": "CallFrame" }, "description": "New stack trace in case editing has happened while VM was stopped." }, + { "name": "stackChanged", "type": "boolean", "optional": true, "description": "Whether current call stack was modified after applying the changes." }, + { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any." }, + { "name": "exceptionDetails", "optional": true, "$ref": "Runtime.ExceptionDetails", "description": "Exception details if any." } + ], + "description": "Edits JavaScript source live." + }, + { + "name": "restartFrame", + "parameters": [ + { "name": "callFrameId", "$ref": "CallFrameId", "description": "Call frame identifier to evaluate on." } + ], + "returns": [ + { "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "New stack trace." }, + { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any." } + ], + "description": "Restarts particular call frame from the beginning." + }, + { + "name": "getScriptSource", + "parameters": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to get source for." } + ], + "returns": [ + { "name": "scriptSource", "type": "string", "description": "Script source." } + ], + "description": "Returns source for the script with given id." + }, + { + "name": "setPauseOnExceptions", + "parameters": [ + { "name": "state", "type": "string", "enum": ["none", "uncaught", "all"], "description": "Pause on exceptions mode." } + ], + "description": "Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is none." + }, + { + "name": "evaluateOnCallFrame", + "parameters": [ + { "name": "callFrameId", "$ref": "CallFrameId", "description": "Call frame identifier to evaluate on." }, + { "name": "expression", "type": "string", "description": "Expression to evaluate." }, + { "name": "objectGroup", "type": "string", "optional": true, "description": "String object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup)." }, + { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Specifies whether command line API should be available to the evaluated expression, defaults to false." }, + { "name": "silent", "type": "boolean", "optional": true, "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state." }, + { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." }, + { "name": "generatePreview", "type": "boolean", "optional": true, "experimental": true, "description": "Whether preview should be generated for the result." } + ], + "returns": [ + { "name": "result", "$ref": "Runtime.RemoteObject", "description": "Object wrapper for the evaluation result." }, + { "name": "exceptionDetails", "$ref": "Runtime.ExceptionDetails", "optional": true, "description": "Exception details."} + ], + "description": "Evaluates expression on a given call frame." + }, + { + "name": "setVariableValue", + "parameters": [ + { "name": "scopeNumber", "type": "integer", "description": "0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually." }, + { "name": "variableName", "type": "string", "description": "Variable name." }, + { "name": "newValue", "$ref": "Runtime.CallArgument", "description": "New variable value." }, + { "name": "callFrameId", "$ref": "CallFrameId", "description": "Id of callframe that holds variable." } + ], + "description": "Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually." + }, + { + "name": "setAsyncCallStackDepth", + "parameters": [ + { "name": "maxDepth", "type": "integer", "description": "Maximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default)." } + ], + "description": "Enables or disables async call stacks tracking." + }, + { + "name": "setBlackboxPatterns", + "parameters": [ + { "name": "patterns", "type": "array", "items": { "type": "string" }, "description": "Array of regexps that will be used to check script url for blackbox state." } + ], + "experimental": true, + "description": "Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful." + }, + { + "name": "setBlackboxedRanges", + "parameters": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script." }, + { "name": "positions", "type": "array", "items": { "$ref": "ScriptPosition" } } + ], + "experimental": true, + "description": "Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted." + } + ], + "events": [ + { + "name": "scriptParsed", + "parameters": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Identifier of the script parsed." }, + { "name": "url", "type": "string", "description": "URL or name of the script parsed (if any)." }, + { "name": "startLine", "type": "integer", "description": "Line offset of the script within the resource with given URL (for script tags)." }, + { "name": "startColumn", "type": "integer", "description": "Column offset of the script within the resource with given URL." }, + { "name": "endLine", "type": "integer", "description": "Last line of the script." }, + { "name": "endColumn", "type": "integer", "description": "Length of the last line of the script." }, + { "name": "executionContextId", "$ref": "Runtime.ExecutionContextId", "description": "Specifies script creation context." }, + { "name": "hash", "type": "string", "description": "Content hash of the script."}, + { "name": "executionContextAuxData", "type": "object", "optional": true, "description": "Embedder-specific auxiliary data." }, + { "name": "isLiveEdit", "type": "boolean", "optional": true, "description": "True, if this script is generated as a result of the live edit operation.", "experimental": true }, + { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with script (if any)." }, + { "name": "hasSourceURL", "type": "boolean", "optional": true, "description": "True, if this script has sourceURL.", "experimental": true } + ], + "description": "Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger." + }, + { + "name": "scriptFailedToParse", + "parameters": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Identifier of the script parsed." }, + { "name": "url", "type": "string", "description": "URL or name of the script parsed (if any)." }, + { "name": "startLine", "type": "integer", "description": "Line offset of the script within the resource with given URL (for script tags)." }, + { "name": "startColumn", "type": "integer", "description": "Column offset of the script within the resource with given URL." }, + { "name": "endLine", "type": "integer", "description": "Last line of the script." }, + { "name": "endColumn", "type": "integer", "description": "Length of the last line of the script." }, + { "name": "executionContextId", "$ref": "Runtime.ExecutionContextId", "description": "Specifies script creation context." }, + { "name": "hash", "type": "string", "description": "Content hash of the script."}, + { "name": "executionContextAuxData", "type": "object", "optional": true, "description": "Embedder-specific auxiliary data." }, + { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with script (if any)." }, + { "name": "hasSourceURL", "type": "boolean", "optional": true, "description": "True, if this script has sourceURL.", "experimental": true } + ], + "description": "Fired when virtual machine fails to parse the script." + }, + { + "name": "breakpointResolved", + "parameters": [ + { "name": "breakpointId", "$ref": "BreakpointId", "description": "Breakpoint unique identifier." }, + { "name": "location", "$ref": "Location", "description": "Actual breakpoint location." } + ], + "description": "Fired when breakpoint is resolved to an actual script and location." + }, + { + "name": "paused", + "parameters": [ + { "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "Call stack the virtual machine stopped on." }, + { "name": "reason", "type": "string", "enum": [ "XHR", "DOM", "EventListener", "exception", "assert", "debugCommand", "promiseRejection", "other" ], "description": "Pause reason.", "exported": true }, + { "name": "data", "type": "object", "optional": true, "description": "Object containing break-specific auxiliary properties." }, + { "name": "hitBreakpoints", "type": "array", "optional": true, "items": { "type": "string" }, "description": "Hit breakpoints IDs" }, + { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any." } + ], + "description": "Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria." + }, + { + "name": "resumed", + "description": "Fired when the virtual machine resumed execution." + } + ] + }, + { + "domain": "Console", + "description": "This domain is deprecated - use Runtime or Log instead.", + "dependencies": ["Runtime"], + "deprecated": true, + "types": [ + { + "id": "ConsoleMessage", + "type": "object", + "description": "Console message.", + "properties": [ + { "name": "source", "type": "string", "enum": ["xml", "javascript", "network", "console-api", "storage", "appcache", "rendering", "security", "other", "deprecation", "worker"], "description": "Message source." }, + { "name": "level", "type": "string", "enum": ["log", "warning", "error", "debug", "info"], "description": "Message severity." }, + { "name": "text", "type": "string", "description": "Message text." }, + { "name": "url", "type": "string", "optional": true, "description": "URL of the message origin." }, + { "name": "line", "type": "integer", "optional": true, "description": "Line number in the resource that generated this message (1-based)." }, + { "name": "column", "type": "integer", "optional": true, "description": "Column number in the resource that generated this message (1-based)." } + ] + } + ], + "commands": [ + { + "name": "enable", + "description": "Enables console domain, sends the messages collected so far to the client by means of the messageAdded notification." + }, + { + "name": "disable", + "description": "Disables console domain, prevents further console messages from being reported to the client." + }, + { + "name": "clearMessages", + "description": "Does nothing." + } + ], + "events": [ + { + "name": "messageAdded", + "parameters": [ + { "name": "message", "$ref": "ConsoleMessage", "description": "Console message that has been added." } + ], + "description": "Issued when new console message is added." + } + ] + }, + { + "domain": "Profiler", + "dependencies": ["Runtime", "Debugger"], + "types": [ + { + "id": "ProfileNode", + "type": "object", + "description": "Profile node. Holds callsite information, execution statistics and child nodes.", + "properties": [ + { "name": "id", "type": "integer", "description": "Unique id of the node." }, + { "name": "callFrame", "$ref": "Runtime.CallFrame", "description": "Function location." }, + { "name": "hitCount", "type": "integer", "optional": true, "experimental": true, "description": "Number of samples where this node was on top of the call stack." }, + { "name": "children", "type": "array", "items": { "type": "integer" }, "optional": true, "description": "Child node ids." }, + { "name": "deoptReason", "type": "string", "optional": true, "description": "The reason of being not optimized. The function may be deoptimized or marked as don't optimize."}, + { "name": "positionTicks", "type": "array", "items": { "$ref": "PositionTickInfo" }, "optional": true, "experimental": true, "description": "An array of source position ticks." } + ] + }, + { + "id": "Profile", + "type": "object", + "description": "Profile.", + "properties": [ + { "name": "nodes", "type": "array", "items": { "$ref": "ProfileNode" }, "description": "The list of profile nodes. First item is the root node." }, + { "name": "startTime", "type": "number", "description": "Profiling start timestamp in microseconds." }, + { "name": "endTime", "type": "number", "description": "Profiling end timestamp in microseconds." }, + { "name": "samples", "optional": true, "type": "array", "items": { "type": "integer" }, "description": "Ids of samples top nodes." }, + { "name": "timeDeltas", "optional": true, "type": "array", "items": { "type": "integer" }, "description": "Time intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime." } + ] + }, + { + "id": "PositionTickInfo", + "type": "object", + "experimental": true, + "description": "Specifies a number of samples attributed to a certain source position.", + "properties": [ + { "name": "line", "type": "integer", "description": "Source line number (1-based)." }, + { "name": "ticks", "type": "integer", "description": "Number of samples attributed to the source line." } + ] + } + ], + "commands": [ + { + "name": "enable" + }, + { + "name": "disable" + }, + { + "name": "setSamplingInterval", + "parameters": [ + { "name": "interval", "type": "integer", "description": "New sampling interval in microseconds." } + ], + "description": "Changes CPU profiler sampling interval. Must be called before CPU profiles recording started." + }, + { + "name": "start" + }, + { + "name": "stop", + "returns": [ + { "name": "profile", "$ref": "Profile", "description": "Recorded profile." } + ] + } + ], + "events": [ + { + "name": "consoleProfileStarted", + "parameters": [ + { "name": "id", "type": "string" }, + { "name": "location", "$ref": "Debugger.Location", "description": "Location of console.profile()." }, + { "name": "title", "type": "string", "optional": true, "description": "Profile title passed as an argument to console.profile()." } + ], + "description": "Sent when new profile recodring is started using console.profile() call." + }, + { + "name": "consoleProfileFinished", + "parameters": [ + { "name": "id", "type": "string" }, + { "name": "location", "$ref": "Debugger.Location", "description": "Location of console.profileEnd()." }, + { "name": "profile", "$ref": "Profile" }, + { "name": "title", "type": "string", "optional": true, "description": "Profile title passed as an argument to console.profile()." } + ] + } + ] + }, + { + "domain": "HeapProfiler", + "dependencies": ["Runtime"], + "experimental": true, + "types": [ + { + "id": "HeapSnapshotObjectId", + "type": "string", + "description": "Heap snapshot object id." + }, + { + "id": "SamplingHeapProfileNode", + "type": "object", + "description": "Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes.", + "properties": [ + { "name": "callFrame", "$ref": "Runtime.CallFrame", "description": "Function location." }, + { "name": "selfSize", "type": "number", "description": "Allocations size in bytes for the node excluding children." }, + { "name": "children", "type": "array", "items": { "$ref": "SamplingHeapProfileNode" }, "description": "Child nodes." } + ] + }, + { + "id": "SamplingHeapProfile", + "type": "object", + "description": "Profile.", + "properties": [ + { "name": "head", "$ref": "SamplingHeapProfileNode" } + ] + } + ], + "commands": [ + { + "name": "enable" + }, + { + "name": "disable" + }, + { + "name": "startTrackingHeapObjects", + "parameters": [ + { "name": "trackAllocations", "type": "boolean", "optional": true } + ] + }, + { + "name": "stopTrackingHeapObjects", + "parameters": [ + { "name": "reportProgress", "type": "boolean", "optional": true, "description": "If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped." } + ] + }, + { + "name": "takeHeapSnapshot", + "parameters": [ + { "name": "reportProgress", "type": "boolean", "optional": true, "description": "If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken." } + ] + }, + { + "name": "collectGarbage" + }, + { + "name": "getObjectByHeapObjectId", + "parameters": [ + { "name": "objectId", "$ref": "HeapSnapshotObjectId" }, + { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." } + ], + "returns": [ + { "name": "result", "$ref": "Runtime.RemoteObject", "description": "Evaluation result." } + ] + }, + { + "name": "addInspectedHeapObject", + "parameters": [ + { "name": "heapObjectId", "$ref": "HeapSnapshotObjectId", "description": "Heap snapshot object id to be accessible by means of $x command line API." } + ], + "description": "Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions)." + }, + { + "name": "getHeapObjectId", + "parameters": [ + { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "Identifier of the object to get heap object id for." } + ], + "returns": [ + { "name": "heapSnapshotObjectId", "$ref": "HeapSnapshotObjectId", "description": "Id of the heap snapshot object corresponding to the passed remote object id." } + ] + }, + { + "name": "startSampling", + "parameters": [ + { "name": "samplingInterval", "type": "number", "optional": true, "description": "Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes." } + ] + }, + { + "name": "stopSampling", + "returns": [ + { "name": "profile", "$ref": "SamplingHeapProfile", "description": "Recorded sampling heap profile." } + ] + } + ], + "events": [ + { + "name": "addHeapSnapshotChunk", + "parameters": [ + { "name": "chunk", "type": "string" } + ] + }, + { + "name": "resetProfiles" + }, + { + "name": "reportHeapSnapshotProgress", + "parameters": [ + { "name": "done", "type": "integer" }, + { "name": "total", "type": "integer" }, + { "name": "finished", "type": "boolean", "optional": true } + ] + }, + { + "name": "lastSeenObjectId", + "description": "If heap objects tracking has been started then backend regulary sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event.", + "parameters": [ + { "name": "lastSeenObjectId", "type": "integer" }, + { "name": "timestamp", "type": "number" } + ] + }, + { + "name": "heapStatsUpdate", + "description": "If heap objects tracking has been started then backend may send update for one or more fragments", + "parameters": [ + { "name": "statsUpdate", "type": "array", "items": { "type": "integer" }, "description": "An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment."} + ] + } + ] + }] +} diff --git a/deps/nodejs/deps/v8/include/js_protocol-1.3.json b/deps/nodejs/deps/v8/include/js_protocol-1.3.json new file mode 100644 index 00000000..ea573d11 --- /dev/null +++ b/deps/nodejs/deps/v8/include/js_protocol-1.3.json @@ -0,0 +1,1205 @@ +{ + "version": { "major": "1", "minor": "3" }, + "domains": [ + { + "domain": "Schema", + "description": "This domain is deprecated.", + "deprecated": true, + "types": [ + { + "id": "Domain", + "type": "object", + "description": "Description of the protocol domain.", + "properties": [ + { "name": "name", "type": "string", "description": "Domain name." }, + { "name": "version", "type": "string", "description": "Domain version." } + ] + } + ], + "commands": [ + { + "name": "getDomains", + "description": "Returns supported domains.", + "handlers": ["browser", "renderer"], + "returns": [ + { "name": "domains", "type": "array", "items": { "$ref": "Domain" }, "description": "List of supported domains." } + ] + } + ] + }, + { + "domain": "Runtime", + "description": "Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects. Evaluation results are returned as mirror object that expose object type, string representation and unique identifier that can be used for further object reference. Original objects are maintained in memory unless they are either explicitly released or are released along with the other objects in their object group.", + "types": [ + { + "id": "ScriptId", + "type": "string", + "description": "Unique script identifier." + }, + { + "id": "RemoteObjectId", + "type": "string", + "description": "Unique object identifier." + }, + { + "id": "UnserializableValue", + "type": "string", + "enum": ["Infinity", "NaN", "-Infinity", "-0"], + "description": "Primitive value which cannot be JSON-stringified." + }, + { + "id": "RemoteObject", + "type": "object", + "description": "Mirror object referencing original JavaScript object.", + "properties": [ + { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." }, + { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error", "proxy", "promise", "typedarray"], "description": "Object subtype hint. Specified for object type values only." }, + { "name": "className", "type": "string", "optional": true, "description": "Object class (constructor) name. Specified for object type values only." }, + { "name": "value", "type": "any", "optional": true, "description": "Remote object value in case of primitive values or JSON values (if it was requested)." }, + { "name": "unserializableValue", "$ref": "UnserializableValue", "optional": true, "description": "Primitive value which can not be JSON-stringified does not have value, but gets this property." }, + { "name": "description", "type": "string", "optional": true, "description": "String representation of the object." }, + { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Unique object identifier (for non-primitive values)." }, + { "name": "preview", "$ref": "ObjectPreview", "optional": true, "description": "Preview containing abbreviated property values. Specified for object type values only.", "experimental": true }, + { "name": "customPreview", "$ref": "CustomPreview", "optional": true, "experimental": true} + ] + }, + { + "id": "CustomPreview", + "type": "object", + "experimental": true, + "properties": [ + { "name": "header", "type": "string"}, + { "name": "hasBody", "type": "boolean"}, + { "name": "formatterObjectId", "$ref": "RemoteObjectId"}, + { "name": "bindRemoteObjectFunctionId", "$ref": "RemoteObjectId" }, + { "name": "configObjectId", "$ref": "RemoteObjectId", "optional": true } + ] + }, + { + "id": "ObjectPreview", + "type": "object", + "experimental": true, + "description": "Object containing abbreviated remote object value.", + "properties": [ + { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." }, + { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error"], "description": "Object subtype hint. Specified for object type values only." }, + { "name": "description", "type": "string", "optional": true, "description": "String representation of the object." }, + { "name": "overflow", "type": "boolean", "description": "True iff some of the properties or entries of the original object did not fit." }, + { "name": "properties", "type": "array", "items": { "$ref": "PropertyPreview" }, "description": "List of the properties." }, + { "name": "entries", "type": "array", "items": { "$ref": "EntryPreview" }, "optional": true, "description": "List of the entries. Specified for map and set subtype values only." } + ] + }, + { + "id": "PropertyPreview", + "type": "object", + "experimental": true, + "properties": [ + { "name": "name", "type": "string", "description": "Property name." }, + { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol", "accessor"], "description": "Object type. Accessor means that the property itself is an accessor property." }, + { "name": "value", "type": "string", "optional": true, "description": "User-friendly property value string." }, + { "name": "valuePreview", "$ref": "ObjectPreview", "optional": true, "description": "Nested value preview." }, + { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "map", "set", "weakmap", "weakset", "iterator", "generator", "error"], "description": "Object subtype hint. Specified for object type values only." } + ] + }, + { + "id": "EntryPreview", + "type": "object", + "experimental": true, + "properties": [ + { "name": "key", "$ref": "ObjectPreview", "optional": true, "description": "Preview of the key. Specified for map-like collection entries." }, + { "name": "value", "$ref": "ObjectPreview", "description": "Preview of the value." } + ] + }, + { + "id": "PropertyDescriptor", + "type": "object", + "description": "Object property descriptor.", + "properties": [ + { "name": "name", "type": "string", "description": "Property name or symbol description." }, + { "name": "value", "$ref": "RemoteObject", "optional": true, "description": "The value associated with the property." }, + { "name": "writable", "type": "boolean", "optional": true, "description": "True if the value associated with the property may be changed (data descriptors only)." }, + { "name": "get", "$ref": "RemoteObject", "optional": true, "description": "A function which serves as a getter for the property, or undefined if there is no getter (accessor descriptors only)." }, + { "name": "set", "$ref": "RemoteObject", "optional": true, "description": "A function which serves as a setter for the property, or undefined if there is no setter (accessor descriptors only)." }, + { "name": "configurable", "type": "boolean", "description": "True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object." }, + { "name": "enumerable", "type": "boolean", "description": "True if this property shows up during enumeration of the properties on the corresponding object." }, + { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if the result was thrown during the evaluation." }, + { "name": "isOwn", "optional": true, "type": "boolean", "description": "True if the property is owned for the object." }, + { "name": "symbol", "$ref": "RemoteObject", "optional": true, "description": "Property symbol object, if the property is of the symbol type." } + ] + }, + { + "id": "InternalPropertyDescriptor", + "type": "object", + "description": "Object internal property descriptor. This property isn't normally visible in JavaScript code.", + "properties": [ + { "name": "name", "type": "string", "description": "Conventional property name." }, + { "name": "value", "$ref": "RemoteObject", "optional": true, "description": "The value associated with the property." } + ] + }, + { + "id": "CallArgument", + "type": "object", + "description": "Represents function call argument. Either remote object id objectId, primitive value, unserializable primitive value or neither of (for undefined) them should be specified.", + "properties": [ + { "name": "value", "type": "any", "optional": true, "description": "Primitive value or serializable javascript object." }, + { "name": "unserializableValue", "$ref": "UnserializableValue", "optional": true, "description": "Primitive value which can not be JSON-stringified." }, + { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Remote object handle." } + ] + }, + { + "id": "ExecutionContextId", + "type": "integer", + "description": "Id of an execution context." + }, + { + "id": "ExecutionContextDescription", + "type": "object", + "description": "Description of an isolated world.", + "properties": [ + { "name": "id", "$ref": "ExecutionContextId", "description": "Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed." }, + { "name": "origin", "type": "string", "description": "Execution context origin." }, + { "name": "name", "type": "string", "description": "Human readable name describing given context." }, + { "name": "auxData", "type": "object", "optional": true, "description": "Embedder-specific auxiliary data." } + ] + }, + { + "id": "ExceptionDetails", + "type": "object", + "description": "Detailed information about exception (or error) that was thrown during script compilation or execution.", + "properties": [ + { "name": "exceptionId", "type": "integer", "description": "Exception id." }, + { "name": "text", "type": "string", "description": "Exception text, which should be used together with exception object when available." }, + { "name": "lineNumber", "type": "integer", "description": "Line number of the exception location (0-based)." }, + { "name": "columnNumber", "type": "integer", "description": "Column number of the exception location (0-based)." }, + { "name": "scriptId", "$ref": "ScriptId", "optional": true, "description": "Script ID of the exception location." }, + { "name": "url", "type": "string", "optional": true, "description": "URL of the exception location, to be used when the script was not reported." }, + { "name": "stackTrace", "$ref": "StackTrace", "optional": true, "description": "JavaScript stack trace if available." }, + { "name": "exception", "$ref": "RemoteObject", "optional": true, "description": "Exception object if available." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Identifier of the context where exception happened." } + ] + }, + { + "id": "Timestamp", + "type": "number", + "description": "Number of milliseconds since epoch." + }, + { + "id": "CallFrame", + "type": "object", + "description": "Stack entry for runtime errors and assertions.", + "properties": [ + { "name": "functionName", "type": "string", "description": "JavaScript function name." }, + { "name": "scriptId", "$ref": "ScriptId", "description": "JavaScript script id." }, + { "name": "url", "type": "string", "description": "JavaScript script name or url." }, + { "name": "lineNumber", "type": "integer", "description": "JavaScript script line number (0-based)." }, + { "name": "columnNumber", "type": "integer", "description": "JavaScript script column number (0-based)." } + ] + }, + { + "id": "StackTrace", + "type": "object", + "description": "Call frames for assertions or error messages.", + "properties": [ + { "name": "description", "type": "string", "optional": true, "description": "String label of this stack trace. For async traces this may be a name of the function that initiated the async call." }, + { "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "JavaScript function name." }, + { "name": "parent", "$ref": "StackTrace", "optional": true, "description": "Asynchronous JavaScript stack trace that preceded this stack, if available." }, + { "name": "parentId", "$ref": "StackTraceId", "optional": true, "experimental": true, "description": "Asynchronous JavaScript stack trace that preceded this stack, if available." } + ] + }, + { + "id": "UniqueDebuggerId", + "type": "string", + "description": "Unique identifier of current debugger.", + "experimental": true + }, + { + "id": "StackTraceId", + "type": "object", + "description": "If debuggerId is set stack trace comes from another debugger and can be resolved there. This allows to track cross-debugger calls. See Runtime.StackTrace and Debugger.paused for usages.", + "properties": [ + { "name": "id", "type": "string" }, + { "name": "debuggerId", "$ref": "UniqueDebuggerId", "optional": true } + ], + "experimental": true + } + ], + "commands": [ + { + "name": "evaluate", + "parameters": [ + { "name": "expression", "type": "string", "description": "Expression to evaluate." }, + { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." }, + { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation." }, + { "name": "silent", "type": "boolean", "optional": true, "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state." }, + { "name": "contextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which execution context to perform evaluation. If the parameter is omitted the evaluation will be performed in the context of the inspected page." }, + { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." }, + { "name": "generatePreview", "type": "boolean", "optional": true, "experimental": true, "description": "Whether preview should be generated for the result." }, + { "name": "userGesture", "type": "boolean", "optional": true, "description": "Whether execution should be treated as initiated by user in the UI." }, + { "name": "awaitPromise", "type": "boolean", "optional":true, "description": "Whether execution should await for resulting value and return once awaited promise is resolved." } + ], + "returns": [ + { "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."} + ], + "description": "Evaluates expression on global object." + }, + { + "name": "awaitPromise", + "parameters": [ + { "name": "promiseObjectId", "$ref": "RemoteObjectId", "description": "Identifier of the promise." }, + { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." }, + { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for the result." } + ], + "returns": [ + { "name": "result", "$ref": "RemoteObject", "description": "Promise result. Will contain rejected value if promise was rejected." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details if stack strace is available."} + ], + "description": "Add handler to promise with given promise object id." + }, + { + "name": "callFunctionOn", + "parameters": [ + { "name": "functionDeclaration", "type": "string", "description": "Declaration of the function to call." }, + { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Identifier of the object to call function on. Either objectId or executionContextId should be specified." }, + { "name": "arguments", "type": "array", "items": { "$ref": "CallArgument", "description": "Call argument." }, "optional": true, "description": "Call arguments. All call arguments must belong to the same JavaScript world as the target object." }, + { "name": "silent", "type": "boolean", "optional": true, "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state." }, + { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object which should be sent by value." }, + { "name": "generatePreview", "type": "boolean", "optional": true, "experimental": true, "description": "Whether preview should be generated for the result." }, + { "name": "userGesture", "type": "boolean", "optional": true, "description": "Whether execution should be treated as initiated by user in the UI." }, + { "name": "awaitPromise", "type": "boolean", "optional":true, "description": "Whether execution should await for resulting value and return once awaited promise is resolved." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies execution context which global object will be used to call function on. Either executionContextId or objectId should be specified." }, + { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects. If objectGroup is not specified and objectId is, objectGroup will be inherited from object." } + ], + "returns": [ + { "name": "result", "$ref": "RemoteObject", "description": "Call result." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."} + ], + "description": "Calls function with given declaration on the given object. Object group of the result is inherited from the target object." + }, + { + "name": "getProperties", + "parameters": [ + { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to return properties for." }, + { "name": "ownProperties", "optional": true, "type": "boolean", "description": "If true, returns properties belonging only to the element itself, not to its prototype chain." }, + { "name": "accessorPropertiesOnly", "optional": true, "type": "boolean", "description": "If true, returns accessor properties (with getter/setter) only; internal properties are not returned either.", "experimental": true }, + { "name": "generatePreview", "type": "boolean", "optional": true, "experimental": true, "description": "Whether preview should be generated for the results." } + ], + "returns": [ + { "name": "result", "type": "array", "items": { "$ref": "PropertyDescriptor" }, "description": "Object properties." }, + { "name": "internalProperties", "optional": true, "type": "array", "items": { "$ref": "InternalPropertyDescriptor" }, "description": "Internal object properties (only of the element itself)." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."} + ], + "description": "Returns properties of a given object. Object group of the result is inherited from the target object." + }, + { + "name": "releaseObject", + "parameters": [ + { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to release." } + ], + "description": "Releases remote object with given id." + }, + { + "name": "releaseObjectGroup", + "parameters": [ + { "name": "objectGroup", "type": "string", "description": "Symbolic object group name." } + ], + "description": "Releases all remote objects that belong to a given group." + }, + { + "name": "runIfWaitingForDebugger", + "description": "Tells inspected instance to run if it was waiting for debugger to attach." + }, + { + "name": "enable", + "description": "Enables reporting of execution contexts creation by means of executionContextCreated event. When the reporting gets enabled the event will be sent immediately for each existing execution context." + }, + { + "name": "disable", + "description": "Disables reporting of execution contexts creation." + }, + { + "name": "discardConsoleEntries", + "description": "Discards collected exceptions and console API calls." + }, + { + "name": "setCustomObjectFormatterEnabled", + "parameters": [ + { + "name": "enabled", + "type": "boolean" + } + ], + "experimental": true + }, + { + "name": "compileScript", + "parameters": [ + { "name": "expression", "type": "string", "description": "Expression to compile." }, + { "name": "sourceURL", "type": "string", "description": "Source url to be set for the script." }, + { "name": "persistScript", "type": "boolean", "description": "Specifies whether the compiled script should be persisted." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page." } + ], + "returns": [ + { "name": "scriptId", "$ref": "ScriptId", "optional": true, "description": "Id of the script." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."} + ], + "description": "Compiles expression." + }, + { + "name": "runScript", + "parameters": [ + { "name": "scriptId", "$ref": "ScriptId", "description": "Id of the script to run." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page." }, + { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." }, + { "name": "silent", "type": "boolean", "optional": true, "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state." }, + { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation." }, + { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object which should be sent by value." }, + { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for the result." }, + { "name": "awaitPromise", "type": "boolean", "optional": true, "description": "Whether execution should await for resulting value and return once awaited promise is resolved." } + ], + "returns": [ + { "name": "result", "$ref": "RemoteObject", "description": "Run result." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails", "optional": true, "description": "Exception details."} + ], + "description": "Runs script with given id in a given context." + }, + { + "name": "queryObjects", + "parameters": [ + { "name": "prototypeObjectId", "$ref": "RemoteObjectId", "description": "Identifier of the prototype to return objects for." } + ], + "returns": [ + { "name": "objects", "$ref": "RemoteObject", "description": "Array with objects." } + ] + }, + { + "name": "globalLexicalScopeNames", + "parameters": [ + { "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which execution context to lookup global scope variables." } + ], + "returns": [ + { "name": "names", "type": "array", "items": { "type": "string" } } + ], + "description": "Returns all let, const and class variables from global scope." + } + ], + "events": [ + { + "name": "executionContextCreated", + "parameters": [ + { "name": "context", "$ref": "ExecutionContextDescription", "description": "A newly created execution context." } + ], + "description": "Issued when new execution context is created." + }, + { + "name": "executionContextDestroyed", + "parameters": [ + { "name": "executionContextId", "$ref": "ExecutionContextId", "description": "Id of the destroyed context" } + ], + "description": "Issued when execution context is destroyed." + }, + { + "name": "executionContextsCleared", + "description": "Issued when all executionContexts were cleared in browser" + }, + { + "name": "exceptionThrown", + "description": "Issued when exception was thrown and unhandled.", + "parameters": [ + { "name": "timestamp", "$ref": "Timestamp", "description": "Timestamp of the exception." }, + { "name": "exceptionDetails", "$ref": "ExceptionDetails" } + ] + }, + { + "name": "exceptionRevoked", + "description": "Issued when unhandled exception was revoked.", + "parameters": [ + { "name": "reason", "type": "string", "description": "Reason describing why exception was revoked." }, + { "name": "exceptionId", "type": "integer", "description": "The id of revoked exception, as reported in exceptionThrown." } + ] + }, + { + "name": "consoleAPICalled", + "description": "Issued when console API was called.", + "parameters": [ + { "name": "type", "type": "string", "enum": ["log", "debug", "info", "error", "warning", "dir", "dirxml", "table", "trace", "clear", "startGroup", "startGroupCollapsed", "endGroup", "assert", "profile", "profileEnd", "count", "timeEnd"], "description": "Type of the call." }, + { "name": "args", "type": "array", "items": { "$ref": "RemoteObject" }, "description": "Call arguments." }, + { "name": "executionContextId", "$ref": "ExecutionContextId", "description": "Identifier of the context where the call was made." }, + { "name": "timestamp", "$ref": "Timestamp", "description": "Call timestamp." }, + { "name": "stackTrace", "$ref": "StackTrace", "optional": true, "description": "Stack trace captured when the call was made." }, + { "name": "context", "type": "string", "optional": true, "experimental": true, "description": "Console context descriptor for calls on non-default console context (not console.*): 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call on named context." } + ] + }, + { + "name": "inspectRequested", + "description": "Issued when object should be inspected (for example, as a result of inspect() command line API call).", + "parameters": [ + { "name": "object", "$ref": "RemoteObject" }, + { "name": "hints", "type": "object" } + ] + } + ] + }, + { + "domain": "Debugger", + "description": "Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.", + "dependencies": ["Runtime"], + "types": [ + { + "id": "BreakpointId", + "type": "string", + "description": "Breakpoint identifier." + }, + { + "id": "CallFrameId", + "type": "string", + "description": "Call frame identifier." + }, + { + "id": "Location", + "type": "object", + "properties": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier as reported in the Debugger.scriptParsed." }, + { "name": "lineNumber", "type": "integer", "description": "Line number in the script (0-based)." }, + { "name": "columnNumber", "type": "integer", "optional": true, "description": "Column number in the script (0-based)." } + ], + "description": "Location in the source code." + }, + { + "id": "ScriptPosition", + "experimental": true, + "type": "object", + "properties": [ + { "name": "lineNumber", "type": "integer" }, + { "name": "columnNumber", "type": "integer" } + ], + "description": "Location in the source code." + }, + { + "id": "CallFrame", + "type": "object", + "properties": [ + { "name": "callFrameId", "$ref": "CallFrameId", "description": "Call frame identifier. This identifier is only valid while the virtual machine is paused." }, + { "name": "functionName", "type": "string", "description": "Name of the JavaScript function called on this call frame." }, + { "name": "functionLocation", "$ref": "Location", "optional": true, "description": "Location in the source code." }, + { "name": "location", "$ref": "Location", "description": "Location in the source code." }, + { "name": "url", "type": "string", "description": "JavaScript script name or url." }, + { "name": "scopeChain", "type": "array", "items": { "$ref": "Scope" }, "description": "Scope chain for this call frame." }, + { "name": "this", "$ref": "Runtime.RemoteObject", "description": "this object for this call frame." }, + { "name": "returnValue", "$ref": "Runtime.RemoteObject", "optional": true, "description": "The value being returned, if the function is at return point." } + ], + "description": "JavaScript call frame. Array of call frames form the call stack." + }, + { + "id": "Scope", + "type": "object", + "properties": [ + { "name": "type", "type": "string", "enum": ["global", "local", "with", "closure", "catch", "block", "script", "eval", "module"], "description": "Scope type." }, + { "name": "object", "$ref": "Runtime.RemoteObject", "description": "Object representing the scope. For global and with scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties." }, + { "name": "name", "type": "string", "optional": true }, + { "name": "startLocation", "$ref": "Location", "optional": true, "description": "Location in the source code where scope starts" }, + { "name": "endLocation", "$ref": "Location", "optional": true, "description": "Location in the source code where scope ends" } + ], + "description": "Scope description." + }, + { + "id": "SearchMatch", + "type": "object", + "description": "Search match for resource.", + "properties": [ + { "name": "lineNumber", "type": "number", "description": "Line number in resource content." }, + { "name": "lineContent", "type": "string", "description": "Line with match content." } + ] + }, + { + "id": "BreakLocation", + "type": "object", + "properties": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Script identifier as reported in the Debugger.scriptParsed." }, + { "name": "lineNumber", "type": "integer", "description": "Line number in the script (0-based)." }, + { "name": "columnNumber", "type": "integer", "optional": true, "description": "Column number in the script (0-based)." }, + { "name": "type", "type": "string", "enum": [ "debuggerStatement", "call", "return" ], "optional": true } + ] + } + ], + "commands": [ + { + "name": "enable", + "returns": [ + { "name": "debuggerId", "$ref": "Runtime.UniqueDebuggerId", "experimental": true, "description": "Unique identifier of the debugger." } + ], + "description": "Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received." + }, + { + "name": "disable", + "description": "Disables debugger for given page." + }, + { + "name": "setBreakpointsActive", + "parameters": [ + { "name": "active", "type": "boolean", "description": "New value for breakpoints active state." } + ], + "description": "Activates / deactivates all breakpoints on the page." + }, + { + "name": "setSkipAllPauses", + "parameters": [ + { "name": "skip", "type": "boolean", "description": "New value for skip pauses state." } + ], + "description": "Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc)." + }, + { + "name": "setBreakpointByUrl", + "parameters": [ + { "name": "lineNumber", "type": "integer", "description": "Line number to set breakpoint at." }, + { "name": "url", "type": "string", "optional": true, "description": "URL of the resources to set breakpoint on." }, + { "name": "urlRegex", "type": "string", "optional": true, "description": "Regex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified." }, + { "name": "scriptHash", "type": "string", "optional": true, "description": "Script hash of the resources to set breakpoint on." }, + { "name": "columnNumber", "type": "integer", "optional": true, "description": "Offset in the line to set breakpoint at." }, + { "name": "condition", "type": "string", "optional": true, "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true." } + ], + "returns": [ + { "name": "breakpointId", "$ref": "BreakpointId", "description": "Id of the created breakpoint for further reference." }, + { "name": "locations", "type": "array", "items": { "$ref": "Location" }, "description": "List of the locations this breakpoint resolved into upon addition." } + ], + "description": "Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this command is issued, all existing parsed scripts will have breakpoints resolved and returned in locations property. Further matching script parsing will result in subsequent breakpointResolved events issued. This logical breakpoint will survive page reloads." + }, + { + "name": "setBreakpoint", + "parameters": [ + { "name": "location", "$ref": "Location", "description": "Location to set breakpoint in." }, + { "name": "condition", "type": "string", "optional": true, "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true." } + ], + "returns": [ + { "name": "breakpointId", "$ref": "BreakpointId", "description": "Id of the created breakpoint for further reference." }, + { "name": "actualLocation", "$ref": "Location", "description": "Location this breakpoint resolved into." } + ], + "description": "Sets JavaScript breakpoint at a given location." + }, + { + "name": "removeBreakpoint", + "parameters": [ + { "name": "breakpointId", "$ref": "BreakpointId" } + ], + "description": "Removes JavaScript breakpoint." + }, + { + "name": "getPossibleBreakpoints", + "parameters": [ + { "name": "start", "$ref": "Location", "description": "Start of range to search possible breakpoint locations in." }, + { "name": "end", "$ref": "Location", "optional": true, "description": "End of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range." }, + { "name": "restrictToFunction", "type": "boolean", "optional": true, "description": "Only consider locations which are in the same (non-nested) function as start." } + ], + "returns": [ + { "name": "locations", "type": "array", "items": { "$ref": "BreakLocation" }, "description": "List of the possible breakpoint locations." } + ], + "description": "Returns possible locations for breakpoint. scriptId in start and end range locations should be the same." + }, + { + "name": "continueToLocation", + "parameters": [ + { "name": "location", "$ref": "Location", "description": "Location to continue to." }, + { "name": "targetCallFrames", "type": "string", "enum": ["any", "current"], "optional": true } + ], + "description": "Continues execution until specific location is reached." + }, + { + "name": "pauseOnAsyncCall", + "parameters": [ + { "name": "parentStackTraceId", "$ref": "Runtime.StackTraceId", "description": "Debugger will pause when async call with given stack trace is started." } + ], + "experimental": true + }, + { + "name": "stepOver", + "description": "Steps over the statement." + }, + { + "name": "stepInto", + "parameters": [ + { "name": "breakOnAsyncCall", "type": "boolean", "optional": true, "experimental": true, "description": "Debugger will issue additional Debugger.paused notification if any async task is scheduled before next pause." } + ], + "description": "Steps into the function call." + }, + { + "name": "stepOut", + "description": "Steps out of the function call." + }, + { + "name": "pause", + "description": "Stops on the next JavaScript statement." + }, + { + "name": "scheduleStepIntoAsync", + "description": "This method is deprecated - use Debugger.stepInto with breakOnAsyncCall and Debugger.pauseOnAsyncTask instead. Steps into next scheduled async task if any is scheduled before next pause. Returns success when async task is actually scheduled, returns error if no task were scheduled or another scheduleStepIntoAsync was called.", + "experimental": true + }, + { + "name": "resume", + "description": "Resumes JavaScript execution." + }, + { + "name": "getStackTrace", + "parameters": [ + { "name": "stackTraceId", "$ref": "Runtime.StackTraceId" } + ], + "returns": [ + { "name": "stackTrace", "$ref": "Runtime.StackTrace" } + ], + "description": "Returns stack trace with given stackTraceId.", + "experimental": true + }, + { + "name": "searchInContent", + "parameters": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to search in." }, + { "name": "query", "type": "string", "description": "String to search for." }, + { "name": "caseSensitive", "type": "boolean", "optional": true, "description": "If true, search is case sensitive." }, + { "name": "isRegex", "type": "boolean", "optional": true, "description": "If true, treats string parameter as regex." } + ], + "returns": [ + { "name": "result", "type": "array", "items": { "$ref": "SearchMatch" }, "description": "List of search matches." } + ], + "description": "Searches for given string in script content." + }, + { + "name": "setScriptSource", + "parameters": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to edit." }, + { "name": "scriptSource", "type": "string", "description": "New content of the script." }, + { "name": "dryRun", "type": "boolean", "optional": true, "description": " If true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code." } + ], + "returns": [ + { "name": "callFrames", "type": "array", "optional": true, "items": { "$ref": "CallFrame" }, "description": "New stack trace in case editing has happened while VM was stopped." }, + { "name": "stackChanged", "type": "boolean", "optional": true, "description": "Whether current call stack was modified after applying the changes." }, + { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any." }, + { "name": "asyncStackTraceId", "$ref": "Runtime.StackTraceId", "optional": true, "experimental": true, "description": "Async stack trace, if any." }, + { "name": "exceptionDetails", "optional": true, "$ref": "Runtime.ExceptionDetails", "description": "Exception details if any." } + ], + "description": "Edits JavaScript source live." + }, + { + "name": "restartFrame", + "parameters": [ + { "name": "callFrameId", "$ref": "CallFrameId", "description": "Call frame identifier to evaluate on." } + ], + "returns": [ + { "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "New stack trace." }, + { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any." }, + { "name": "asyncStackTraceId", "$ref": "Runtime.StackTraceId", "optional": true, "experimental": true, "description": "Async stack trace, if any." } + ], + "description": "Restarts particular call frame from the beginning." + }, + { + "name": "getScriptSource", + "parameters": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script to get source for." } + ], + "returns": [ + { "name": "scriptSource", "type": "string", "description": "Script source." } + ], + "description": "Returns source for the script with given id." + }, + { + "name": "setPauseOnExceptions", + "parameters": [ + { "name": "state", "type": "string", "enum": ["none", "uncaught", "all"], "description": "Pause on exceptions mode." } + ], + "description": "Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is none." + }, + { + "name": "evaluateOnCallFrame", + "parameters": [ + { "name": "callFrameId", "$ref": "CallFrameId", "description": "Call frame identifier to evaluate on." }, + { "name": "expression", "type": "string", "description": "Expression to evaluate." }, + { "name": "objectGroup", "type": "string", "optional": true, "description": "String object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup)." }, + { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Specifies whether command line API should be available to the evaluated expression, defaults to false." }, + { "name": "silent", "type": "boolean", "optional": true, "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state." }, + { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." }, + { "name": "generatePreview", "type": "boolean", "optional": true, "experimental": true, "description": "Whether preview should be generated for the result." }, + { "name": "throwOnSideEffect", "type": "boolean", "optional": true, "description": "Whether to throw an exception if side effect cannot be ruled out during evaluation." } + ], + "returns": [ + { "name": "result", "$ref": "Runtime.RemoteObject", "description": "Object wrapper for the evaluation result." }, + { "name": "exceptionDetails", "$ref": "Runtime.ExceptionDetails", "optional": true, "description": "Exception details."} + ], + "description": "Evaluates expression on a given call frame." + }, + { + "name": "setVariableValue", + "parameters": [ + { "name": "scopeNumber", "type": "integer", "description": "0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually." }, + { "name": "variableName", "type": "string", "description": "Variable name." }, + { "name": "newValue", "$ref": "Runtime.CallArgument", "description": "New variable value." }, + { "name": "callFrameId", "$ref": "CallFrameId", "description": "Id of callframe that holds variable." } + ], + "description": "Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually." + }, + { + "name": "setReturnValue", + "parameters": [ + { "name": "newValue", "$ref": "Runtime.CallArgument", "description": "New return value." } + ], + "experimental": true, + "description": "Changes return value in top frame. Available only at return break position." + }, + { + "name": "setAsyncCallStackDepth", + "parameters": [ + { "name": "maxDepth", "type": "integer", "description": "Maximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default)." } + ], + "description": "Enables or disables async call stacks tracking." + }, + { + "name": "setBlackboxPatterns", + "parameters": [ + { "name": "patterns", "type": "array", "items": { "type": "string" }, "description": "Array of regexps that will be used to check script url for blackbox state." } + ], + "experimental": true, + "description": "Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful." + }, + { + "name": "setBlackboxedRanges", + "parameters": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Id of the script." }, + { "name": "positions", "type": "array", "items": { "$ref": "ScriptPosition" } } + ], + "experimental": true, + "description": "Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted." + } + ], + "events": [ + { + "name": "scriptParsed", + "parameters": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Identifier of the script parsed." }, + { "name": "url", "type": "string", "description": "URL or name of the script parsed (if any)." }, + { "name": "startLine", "type": "integer", "description": "Line offset of the script within the resource with given URL (for script tags)." }, + { "name": "startColumn", "type": "integer", "description": "Column offset of the script within the resource with given URL." }, + { "name": "endLine", "type": "integer", "description": "Last line of the script." }, + { "name": "endColumn", "type": "integer", "description": "Length of the last line of the script." }, + { "name": "executionContextId", "$ref": "Runtime.ExecutionContextId", "description": "Specifies script creation context." }, + { "name": "hash", "type": "string", "description": "Content hash of the script."}, + { "name": "executionContextAuxData", "type": "object", "optional": true, "description": "Embedder-specific auxiliary data." }, + { "name": "isLiveEdit", "type": "boolean", "optional": true, "description": "True, if this script is generated as a result of the live edit operation.", "experimental": true }, + { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with script (if any)." }, + { "name": "hasSourceURL", "type": "boolean", "optional": true, "description": "True, if this script has sourceURL." }, + { "name": "isModule", "type": "boolean", "optional": true, "description": "True, if this script is ES6 module." }, + { "name": "length", "type": "integer", "optional": true, "description": "This script length." }, + { "name": "stackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "JavaScript top stack frame of where the script parsed event was triggered if available.", "experimental": true } + ], + "description": "Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger." + }, + { + "name": "scriptFailedToParse", + "parameters": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "Identifier of the script parsed." }, + { "name": "url", "type": "string", "description": "URL or name of the script parsed (if any)." }, + { "name": "startLine", "type": "integer", "description": "Line offset of the script within the resource with given URL (for script tags)." }, + { "name": "startColumn", "type": "integer", "description": "Column offset of the script within the resource with given URL." }, + { "name": "endLine", "type": "integer", "description": "Last line of the script." }, + { "name": "endColumn", "type": "integer", "description": "Length of the last line of the script." }, + { "name": "executionContextId", "$ref": "Runtime.ExecutionContextId", "description": "Specifies script creation context." }, + { "name": "hash", "type": "string", "description": "Content hash of the script."}, + { "name": "executionContextAuxData", "type": "object", "optional": true, "description": "Embedder-specific auxiliary data." }, + { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with script (if any)." }, + { "name": "hasSourceURL", "type": "boolean", "optional": true, "description": "True, if this script has sourceURL." }, + { "name": "isModule", "type": "boolean", "optional": true, "description": "True, if this script is ES6 module." }, + { "name": "length", "type": "integer", "optional": true, "description": "This script length." }, + { "name": "stackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "JavaScript top stack frame of where the script parsed event was triggered if available.", "experimental": true } + ], + "description": "Fired when virtual machine fails to parse the script." + }, + { + "name": "breakpointResolved", + "parameters": [ + { "name": "breakpointId", "$ref": "BreakpointId", "description": "Breakpoint unique identifier." }, + { "name": "location", "$ref": "Location", "description": "Actual breakpoint location." } + ], + "description": "Fired when breakpoint is resolved to an actual script and location." + }, + { + "name": "paused", + "parameters": [ + { "name": "callFrames", "type": "array", "items": { "$ref": "CallFrame" }, "description": "Call stack the virtual machine stopped on." }, + { "name": "reason", "type": "string", "enum": [ "XHR", "DOM", "EventListener", "exception", "assert", "debugCommand", "promiseRejection", "OOM", "other", "ambiguous" ], "description": "Pause reason." }, + { "name": "data", "type": "object", "optional": true, "description": "Object containing break-specific auxiliary properties." }, + { "name": "hitBreakpoints", "type": "array", "optional": true, "items": { "type": "string" }, "description": "Hit breakpoints IDs" }, + { "name": "asyncStackTrace", "$ref": "Runtime.StackTrace", "optional": true, "description": "Async stack trace, if any." }, + { "name": "asyncStackTraceId", "$ref": "Runtime.StackTraceId", "optional": true, "experimental": true, "description": "Async stack trace, if any." }, + { "name": "asyncCallStackTraceId", "$ref": "Runtime.StackTraceId", "optional": true, "experimental": true, "description": "Just scheduled async call will have this stack trace as parent stack during async execution. This field is available only after Debugger.stepInto call with breakOnAsynCall flag." } + ], + "description": "Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria." + }, + { + "name": "resumed", + "description": "Fired when the virtual machine resumed execution." + } + ] + }, + { + "domain": "Console", + "description": "This domain is deprecated - use Runtime or Log instead.", + "dependencies": ["Runtime"], + "deprecated": true, + "types": [ + { + "id": "ConsoleMessage", + "type": "object", + "description": "Console message.", + "properties": [ + { "name": "source", "type": "string", "enum": ["xml", "javascript", "network", "console-api", "storage", "appcache", "rendering", "security", "other", "deprecation", "worker"], "description": "Message source." }, + { "name": "level", "type": "string", "enum": ["log", "warning", "error", "debug", "info"], "description": "Message severity." }, + { "name": "text", "type": "string", "description": "Message text." }, + { "name": "url", "type": "string", "optional": true, "description": "URL of the message origin." }, + { "name": "line", "type": "integer", "optional": true, "description": "Line number in the resource that generated this message (1-based)." }, + { "name": "column", "type": "integer", "optional": true, "description": "Column number in the resource that generated this message (1-based)." } + ] + } + ], + "commands": [ + { + "name": "enable", + "description": "Enables console domain, sends the messages collected so far to the client by means of the messageAdded notification." + }, + { + "name": "disable", + "description": "Disables console domain, prevents further console messages from being reported to the client." + }, + { + "name": "clearMessages", + "description": "Does nothing." + } + ], + "events": [ + { + "name": "messageAdded", + "parameters": [ + { "name": "message", "$ref": "ConsoleMessage", "description": "Console message that has been added." } + ], + "description": "Issued when new console message is added." + } + ] + }, + { + "domain": "Profiler", + "dependencies": ["Runtime", "Debugger"], + "types": [ + { + "id": "ProfileNode", + "type": "object", + "description": "Profile node. Holds callsite information, execution statistics and child nodes.", + "properties": [ + { "name": "id", "type": "integer", "description": "Unique id of the node." }, + { "name": "callFrame", "$ref": "Runtime.CallFrame", "description": "Function location." }, + { "name": "hitCount", "type": "integer", "optional": true, "description": "Number of samples where this node was on top of the call stack." }, + { "name": "children", "type": "array", "items": { "type": "integer" }, "optional": true, "description": "Child node ids." }, + { "name": "deoptReason", "type": "string", "optional": true, "description": "The reason of being not optimized. The function may be deoptimized or marked as don't optimize."}, + { "name": "positionTicks", "type": "array", "items": { "$ref": "PositionTickInfo" }, "optional": true, "description": "An array of source position ticks." } + ] + }, + { + "id": "Profile", + "type": "object", + "description": "Profile.", + "properties": [ + { "name": "nodes", "type": "array", "items": { "$ref": "ProfileNode" }, "description": "The list of profile nodes. First item is the root node." }, + { "name": "startTime", "type": "number", "description": "Profiling start timestamp in microseconds." }, + { "name": "endTime", "type": "number", "description": "Profiling end timestamp in microseconds." }, + { "name": "samples", "optional": true, "type": "array", "items": { "type": "integer" }, "description": "Ids of samples top nodes." }, + { "name": "timeDeltas", "optional": true, "type": "array", "items": { "type": "integer" }, "description": "Time intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime." } + ] + }, + { + "id": "PositionTickInfo", + "type": "object", + "description": "Specifies a number of samples attributed to a certain source position.", + "properties": [ + { "name": "line", "type": "integer", "description": "Source line number (1-based)." }, + { "name": "ticks", "type": "integer", "description": "Number of samples attributed to the source line." } + ] + }, + { "id": "CoverageRange", + "type": "object", + "description": "Coverage data for a source range.", + "properties": [ + { "name": "startOffset", "type": "integer", "description": "JavaScript script source offset for the range start." }, + { "name": "endOffset", "type": "integer", "description": "JavaScript script source offset for the range end." }, + { "name": "count", "type": "integer", "description": "Collected execution count of the source range." } + ] + }, + { "id": "FunctionCoverage", + "type": "object", + "description": "Coverage data for a JavaScript function.", + "properties": [ + { "name": "functionName", "type": "string", "description": "JavaScript function name." }, + { "name": "ranges", "type": "array", "items": { "$ref": "CoverageRange" }, "description": "Source ranges inside the function with coverage data." }, + { "name": "isBlockCoverage", "type": "boolean", "description": "Whether coverage data for this function has block granularity." } + ] + }, + { + "id": "ScriptCoverage", + "type": "object", + "description": "Coverage data for a JavaScript script.", + "properties": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "JavaScript script id." }, + { "name": "url", "type": "string", "description": "JavaScript script name or url." }, + { "name": "functions", "type": "array", "items": { "$ref": "FunctionCoverage" }, "description": "Functions contained in the script that has coverage data." } + ] + }, + { "id": "TypeObject", + "type": "object", + "description": "Describes a type collected during runtime.", + "properties": [ + { "name": "name", "type": "string", "description": "Name of a type collected with type profiling." } + ], + "experimental": true + }, + { "id": "TypeProfileEntry", + "type": "object", + "description": "Source offset and types for a parameter or return value.", + "properties": [ + { "name": "offset", "type": "integer", "description": "Source offset of the parameter or end of function for return values." }, + { "name": "types", "type": "array", "items": {"$ref": "TypeObject"}, "description": "The types for this parameter or return value."} + ], + "experimental": true + }, + { + "id": "ScriptTypeProfile", + "type": "object", + "description": "Type profile data collected during runtime for a JavaScript script.", + "properties": [ + { "name": "scriptId", "$ref": "Runtime.ScriptId", "description": "JavaScript script id." }, + { "name": "url", "type": "string", "description": "JavaScript script name or url." }, + { "name": "entries", "type": "array", "items": { "$ref": "TypeProfileEntry" }, "description": "Type profile entries for parameters and return values of the functions in the script." } + ], + "experimental": true + } + ], + "commands": [ + { + "name": "enable" + }, + { + "name": "disable" + }, + { + "name": "setSamplingInterval", + "parameters": [ + { "name": "interval", "type": "integer", "description": "New sampling interval in microseconds." } + ], + "description": "Changes CPU profiler sampling interval. Must be called before CPU profiles recording started." + }, + { + "name": "start" + }, + { + "name": "stop", + "returns": [ + { "name": "profile", "$ref": "Profile", "description": "Recorded profile." } + ] + }, + { + "name": "startPreciseCoverage", + "parameters": [ + { "name": "callCount", "type": "boolean", "optional": true, "description": "Collect accurate call counts beyond simple 'covered' or 'not covered'." }, + { "name": "detailed", "type": "boolean", "optional": true, "description": "Collect block-based coverage." } + ], + "description": "Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code coverage may be incomplete. Enabling prevents running optimized code and resets execution counters." + }, + { + "name": "stopPreciseCoverage", + "description": "Disable precise code coverage. Disabling releases unnecessary execution count records and allows executing optimized code." + }, + { + "name": "takePreciseCoverage", + "returns": [ + { "name": "result", "type": "array", "items": { "$ref": "ScriptCoverage" }, "description": "Coverage data for the current isolate." } + ], + "description": "Collect coverage data for the current isolate, and resets execution counters. Precise code coverage needs to have started." + }, + { + "name": "getBestEffortCoverage", + "returns": [ + { "name": "result", "type": "array", "items": { "$ref": "ScriptCoverage" }, "description": "Coverage data for the current isolate." } + ], + "description": "Collect coverage data for the current isolate. The coverage data may be incomplete due to garbage collection." + }, + { + "name": "startTypeProfile", + "description": "Enable type profile.", + "experimental": true + }, + { + "name": "stopTypeProfile", + "description": "Disable type profile. Disabling releases type profile data collected so far.", + "experimental": true + }, + { + "name": "takeTypeProfile", + "returns": [ + { "name": "result", "type": "array", "items": { "$ref": "ScriptTypeProfile" }, "description": "Type profile for all scripts since startTypeProfile() was turned on." } + ], + "description": "Collect type profile.", + "experimental": true + } + ], + "events": [ + { + "name": "consoleProfileStarted", + "parameters": [ + { "name": "id", "type": "string" }, + { "name": "location", "$ref": "Debugger.Location", "description": "Location of console.profile()." }, + { "name": "title", "type": "string", "optional": true, "description": "Profile title passed as an argument to console.profile()." } + ], + "description": "Sent when new profile recording is started using console.profile() call." + }, + { + "name": "consoleProfileFinished", + "parameters": [ + { "name": "id", "type": "string" }, + { "name": "location", "$ref": "Debugger.Location", "description": "Location of console.profileEnd()." }, + { "name": "profile", "$ref": "Profile" }, + { "name": "title", "type": "string", "optional": true, "description": "Profile title passed as an argument to console.profile()." } + ] + } + ] + }, + { + "domain": "HeapProfiler", + "dependencies": ["Runtime"], + "experimental": true, + "types": [ + { + "id": "HeapSnapshotObjectId", + "type": "string", + "description": "Heap snapshot object id." + }, + { + "id": "SamplingHeapProfileNode", + "type": "object", + "description": "Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes.", + "properties": [ + { "name": "callFrame", "$ref": "Runtime.CallFrame", "description": "Function location." }, + { "name": "selfSize", "type": "number", "description": "Allocations size in bytes for the node excluding children." }, + { "name": "children", "type": "array", "items": { "$ref": "SamplingHeapProfileNode" }, "description": "Child nodes." } + ] + }, + { + "id": "SamplingHeapProfile", + "type": "object", + "description": "Profile.", + "properties": [ + { "name": "head", "$ref": "SamplingHeapProfileNode" } + ] + } + ], + "commands": [ + { + "name": "enable" + }, + { + "name": "disable" + }, + { + "name": "startTrackingHeapObjects", + "parameters": [ + { "name": "trackAllocations", "type": "boolean", "optional": true } + ] + }, + { + "name": "stopTrackingHeapObjects", + "parameters": [ + { "name": "reportProgress", "type": "boolean", "optional": true, "description": "If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken when the tracking is stopped." } + ] + }, + { + "name": "takeHeapSnapshot", + "parameters": [ + { "name": "reportProgress", "type": "boolean", "optional": true, "description": "If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken." } + ] + }, + { + "name": "collectGarbage" + }, + { + "name": "getObjectByHeapObjectId", + "parameters": [ + { "name": "objectId", "$ref": "HeapSnapshotObjectId" }, + { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." } + ], + "returns": [ + { "name": "result", "$ref": "Runtime.RemoteObject", "description": "Evaluation result." } + ] + }, + { + "name": "addInspectedHeapObject", + "parameters": [ + { "name": "heapObjectId", "$ref": "HeapSnapshotObjectId", "description": "Heap snapshot object id to be accessible by means of $x command line API." } + ], + "description": "Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions)." + }, + { + "name": "getHeapObjectId", + "parameters": [ + { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "Identifier of the object to get heap object id for." } + ], + "returns": [ + { "name": "heapSnapshotObjectId", "$ref": "HeapSnapshotObjectId", "description": "Id of the heap snapshot object corresponding to the passed remote object id." } + ] + }, + { + "name": "startSampling", + "parameters": [ + { "name": "samplingInterval", "type": "number", "optional": true, "description": "Average sample interval in bytes. Poisson distribution is used for the intervals. The default value is 32768 bytes." } + ] + }, + { + "name": "stopSampling", + "returns": [ + { "name": "profile", "$ref": "SamplingHeapProfile", "description": "Recorded sampling heap profile." } + ] + }, + { + "name": "getSamplingProfile", + "returns": [ + { "name": "profile", "$ref": "SamplingHeapProfile", "description": "Return the sampling profile being collected." } + ] + } + ], + "events": [ + { + "name": "addHeapSnapshotChunk", + "parameters": [ + { "name": "chunk", "type": "string" } + ] + }, + { + "name": "resetProfiles" + }, + { + "name": "reportHeapSnapshotProgress", + "parameters": [ + { "name": "done", "type": "integer" }, + { "name": "total", "type": "integer" }, + { "name": "finished", "type": "boolean", "optional": true } + ] + }, + { + "name": "lastSeenObjectId", + "description": "If heap objects tracking has been started then backend regularly sends a current value for last seen object id and corresponding timestamp. If the were changes in the heap since last event then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event.", + "parameters": [ + { "name": "lastSeenObjectId", "type": "integer" }, + { "name": "timestamp", "type": "number" } + ] + }, + { + "name": "heapStatsUpdate", + "description": "If heap objects tracking has been started then backend may send update for one or more fragments", + "parameters": [ + { "name": "statsUpdate", "type": "array", "items": { "type": "integer" }, "description": "An array of triplets. Each triplet describes a fragment. The first integer is the fragment index, the second integer is a total count of objects for the fragment, the third integer is a total size of the objects for the fragment."} + ] + } + ] + }] +} diff --git a/deps/nodejs/deps/v8/include/js_protocol.pdl b/deps/nodejs/deps/v8/include/js_protocol.pdl new file mode 100644 index 00000000..706c37f9 --- /dev/null +++ b/deps/nodejs/deps/v8/include/js_protocol.pdl @@ -0,0 +1,1616 @@ +# Copyright 2017 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +version + major 1 + minor 3 + +# This domain is deprecated - use Runtime or Log instead. +deprecated domain Console + depends on Runtime + + # Console message. + type ConsoleMessage extends object + properties + # Message source. + enum source + xml + javascript + network + console-api + storage + appcache + rendering + security + other + deprecation + worker + # Message severity. + enum level + log + warning + error + debug + info + # Message text. + string text + # URL of the message origin. + optional string url + # Line number in the resource that generated this message (1-based). + optional integer line + # Column number in the resource that generated this message (1-based). + optional integer column + + # Does nothing. + command clearMessages + + # Disables console domain, prevents further console messages from being reported to the client. + command disable + + # Enables console domain, sends the messages collected so far to the client by means of the + # `messageAdded` notification. + command enable + + # Issued when new console message is added. + event messageAdded + parameters + # Console message that has been added. + ConsoleMessage message + +# Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing +# breakpoints, stepping through execution, exploring stack traces, etc. +domain Debugger + depends on Runtime + + # Breakpoint identifier. + type BreakpointId extends string + + # Call frame identifier. + type CallFrameId extends string + + # Location in the source code. + type Location extends object + properties + # Script identifier as reported in the `Debugger.scriptParsed`. + Runtime.ScriptId scriptId + # Line number in the script (0-based). + integer lineNumber + # Column number in the script (0-based). + optional integer columnNumber + + # Location in the source code. + experimental type ScriptPosition extends object + properties + integer lineNumber + integer columnNumber + + # JavaScript call frame. Array of call frames form the call stack. + type CallFrame extends object + properties + # Call frame identifier. This identifier is only valid while the virtual machine is paused. + CallFrameId callFrameId + # Name of the JavaScript function called on this call frame. + string functionName + # Location in the source code. + optional Location functionLocation + # Location in the source code. + Location location + # JavaScript script name or url. + string url + # Scope chain for this call frame. + array of Scope scopeChain + # `this` object for this call frame. + Runtime.RemoteObject this + # The value being returned, if the function is at return point. + optional Runtime.RemoteObject returnValue + + # Scope description. + type Scope extends object + properties + # Scope type. + enum type + global + local + with + closure + catch + block + script + eval + module + wasm-expression-stack + # Object representing the scope. For `global` and `with` scopes it represents the actual + # object; for the rest of the scopes, it is artificial transient object enumerating scope + # variables as its properties. + Runtime.RemoteObject object + optional string name + # Location in the source code where scope starts + optional Location startLocation + # Location in the source code where scope ends + optional Location endLocation + + # Search match for resource. + type SearchMatch extends object + properties + # Line number in resource content. + number lineNumber + # Line with match content. + string lineContent + + type BreakLocation extends object + properties + # Script identifier as reported in the `Debugger.scriptParsed`. + Runtime.ScriptId scriptId + # Line number in the script (0-based). + integer lineNumber + # Column number in the script (0-based). + optional integer columnNumber + optional enum type + debuggerStatement + call + return + + # Continues execution until specific location is reached. + command continueToLocation + parameters + # Location to continue to. + Location location + optional enum targetCallFrames + any + current + + # Disables debugger for given page. + command disable + + # Enables debugger for the given page. Clients should not assume that the debugging has been + # enabled until the result for this command is received. + command enable + parameters + # The maximum size in bytes of collected scripts (not referenced by other heap objects) + # the debugger can hold. Puts no limit if paramter is omitted. + experimental optional number maxScriptsCacheSize + returns + # Unique identifier of the debugger. + experimental Runtime.UniqueDebuggerId debuggerId + + # Evaluates expression on a given call frame. + command evaluateOnCallFrame + parameters + # Call frame identifier to evaluate on. + CallFrameId callFrameId + # Expression to evaluate. + string expression + # String object group name to put result into (allows rapid releasing resulting object handles + # using `releaseObjectGroup`). + optional string objectGroup + # Specifies whether command line API should be available to the evaluated expression, defaults + # to false. + optional boolean includeCommandLineAPI + # In silent mode exceptions thrown during evaluation are not reported and do not pause + # execution. Overrides `setPauseOnException` state. + optional boolean silent + # Whether the result is expected to be a JSON object that should be sent by value. + optional boolean returnByValue + # Whether preview should be generated for the result. + experimental optional boolean generatePreview + # Whether to throw an exception if side effect cannot be ruled out during evaluation. + optional boolean throwOnSideEffect + # Terminate execution after timing out (number of milliseconds). + experimental optional Runtime.TimeDelta timeout + returns + # Object wrapper for the evaluation result. + Runtime.RemoteObject result + # Exception details. + optional Runtime.ExceptionDetails exceptionDetails + + # Execute a Wasm Evaluator module on a given call frame. + experimental command executeWasmEvaluator + parameters + # WebAssembly call frame identifier to evaluate on. + CallFrameId callFrameId + # Code of the evaluator module. + binary evaluator + # Terminate execution after timing out (number of milliseconds). + experimental optional Runtime.TimeDelta timeout + returns + # Object wrapper for the evaluation result. + Runtime.RemoteObject result + # Exception details. + optional Runtime.ExceptionDetails exceptionDetails + + # Returns possible locations for breakpoint. scriptId in start and end range locations should be + # the same. + command getPossibleBreakpoints + parameters + # Start of range to search possible breakpoint locations in. + Location start + # End of range to search possible breakpoint locations in (excluding). When not specified, end + # of scripts is used as end of range. + optional Location end + # Only consider locations which are in the same (non-nested) function as start. + optional boolean restrictToFunction + returns + # List of the possible breakpoint locations. + array of BreakLocation locations + + # Returns source for the script with given id. + command getScriptSource + parameters + # Id of the script to get source for. + Runtime.ScriptId scriptId + returns + # Script source (empty in case of Wasm bytecode). + string scriptSource + # Wasm bytecode. + optional binary bytecode + + # This command is deprecated. Use getScriptSource instead. + deprecated command getWasmBytecode + parameters + # Id of the Wasm script to get source for. + Runtime.ScriptId scriptId + returns + # Script source. + binary bytecode + + # Returns stack trace with given `stackTraceId`. + experimental command getStackTrace + parameters + Runtime.StackTraceId stackTraceId + returns + Runtime.StackTrace stackTrace + + # Stops on the next JavaScript statement. + command pause + + experimental deprecated command pauseOnAsyncCall + parameters + # Debugger will pause when async call with given stack trace is started. + Runtime.StackTraceId parentStackTraceId + + # Removes JavaScript breakpoint. + command removeBreakpoint + parameters + BreakpointId breakpointId + + # Restarts particular call frame from the beginning. + command restartFrame + parameters + # Call frame identifier to evaluate on. + CallFrameId callFrameId + returns + # New stack trace. + array of CallFrame callFrames + # Async stack trace, if any. + optional Runtime.StackTrace asyncStackTrace + # Async stack trace, if any. + experimental optional Runtime.StackTraceId asyncStackTraceId + + # Resumes JavaScript execution. + command resume + parameters + # Set to true to terminate execution upon resuming execution. In contrast + # to Runtime.terminateExecution, this will allows to execute further + # JavaScript (i.e. via evaluation) until execution of the paused code + # is actually resumed, at which point termination is triggered. + # If execution is currently not paused, this parameter has no effect. + optional boolean terminateOnResume + + # Searches for given string in script content. + command searchInContent + parameters + # Id of the script to search in. + Runtime.ScriptId scriptId + # String to search for. + string query + # If true, search is case sensitive. + optional boolean caseSensitive + # If true, treats string parameter as regex. + optional boolean isRegex + returns + # List of search matches. + array of SearchMatch result + + # Enables or disables async call stacks tracking. + command setAsyncCallStackDepth + parameters + # Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async + # call stacks (default). + integer maxDepth + + # Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in + # scripts with url matching one of the patterns. VM will try to leave blackboxed script by + # performing 'step in' several times, finally resorting to 'step out' if unsuccessful. + experimental command setBlackboxPatterns + parameters + # Array of regexps that will be used to check script url for blackbox state. + array of string patterns + + # Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted + # scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. + # Positions array contains positions where blackbox state is changed. First interval isn't + # blackboxed. Array should be sorted. + experimental command setBlackboxedRanges + parameters + # Id of the script. + Runtime.ScriptId scriptId + array of ScriptPosition positions + + # Sets JavaScript breakpoint at a given location. + command setBreakpoint + parameters + # Location to set breakpoint in. + Location location + # Expression to use as a breakpoint condition. When specified, debugger will only stop on the + # breakpoint if this expression evaluates to true. + optional string condition + returns + # Id of the created breakpoint for further reference. + BreakpointId breakpointId + # Location this breakpoint resolved into. + Location actualLocation + + # Sets instrumentation breakpoint. + command setInstrumentationBreakpoint + parameters + # Instrumentation name. + enum instrumentation + beforeScriptExecution + beforeScriptWithSourceMapExecution + returns + # Id of the created breakpoint for further reference. + BreakpointId breakpointId + + # Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this + # command is issued, all existing parsed scripts will have breakpoints resolved and returned in + # `locations` property. Further matching script parsing will result in subsequent + # `breakpointResolved` events issued. This logical breakpoint will survive page reloads. + command setBreakpointByUrl + parameters + # Line number to set breakpoint at. + integer lineNumber + # URL of the resources to set breakpoint on. + optional string url + # Regex pattern for the URLs of the resources to set breakpoints on. Either `url` or + # `urlRegex` must be specified. + optional string urlRegex + # Script hash of the resources to set breakpoint on. + optional string scriptHash + # Offset in the line to set breakpoint at. + optional integer columnNumber + # Expression to use as a breakpoint condition. When specified, debugger will only stop on the + # breakpoint if this expression evaluates to true. + optional string condition + returns + # Id of the created breakpoint for further reference. + BreakpointId breakpointId + # List of the locations this breakpoint resolved into upon addition. + array of Location locations + + # Sets JavaScript breakpoint before each call to the given function. + # If another function was created from the same source as a given one, + # calling it will also trigger the breakpoint. + experimental command setBreakpointOnFunctionCall + parameters + # Function object id. + Runtime.RemoteObjectId objectId + # Expression to use as a breakpoint condition. When specified, debugger will + # stop on the breakpoint if this expression evaluates to true. + optional string condition + returns + # Id of the created breakpoint for further reference. + BreakpointId breakpointId + + # Activates / deactivates all breakpoints on the page. + command setBreakpointsActive + parameters + # New value for breakpoints active state. + boolean active + + # Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or + # no exceptions. Initial pause on exceptions state is `none`. + command setPauseOnExceptions + parameters + # Pause on exceptions mode. + enum state + none + uncaught + all + + # Changes return value in top frame. Available only at return break position. + experimental command setReturnValue + parameters + # New return value. + Runtime.CallArgument newValue + + # Edits JavaScript source live. + command setScriptSource + parameters + # Id of the script to edit. + Runtime.ScriptId scriptId + # New content of the script. + string scriptSource + # If true the change will not actually be applied. Dry run may be used to get result + # description without actually modifying the code. + optional boolean dryRun + returns + # New stack trace in case editing has happened while VM was stopped. + optional array of CallFrame callFrames + # Whether current call stack was modified after applying the changes. + optional boolean stackChanged + # Async stack trace, if any. + optional Runtime.StackTrace asyncStackTrace + # Async stack trace, if any. + experimental optional Runtime.StackTraceId asyncStackTraceId + # Exception details if any. + optional Runtime.ExceptionDetails exceptionDetails + + # Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc). + command setSkipAllPauses + parameters + # New value for skip pauses state. + boolean skip + + # Changes value of variable in a callframe. Object-based scopes are not supported and must be + # mutated manually. + command setVariableValue + parameters + # 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' + # scope types are allowed. Other scopes could be manipulated manually. + integer scopeNumber + # Variable name. + string variableName + # New variable value. + Runtime.CallArgument newValue + # Id of callframe that holds variable. + CallFrameId callFrameId + + # Steps into the function call. + command stepInto + parameters + # Debugger will pause on the execution of the first async task which was scheduled + # before next pause. + experimental optional boolean breakOnAsyncCall + + # Steps out of the function call. + command stepOut + + # Steps over the statement. + command stepOver + + # Fired when breakpoint is resolved to an actual script and location. + event breakpointResolved + parameters + # Breakpoint unique identifier. + BreakpointId breakpointId + # Actual breakpoint location. + Location location + + # Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria. + event paused + parameters + # Call stack the virtual machine stopped on. + array of CallFrame callFrames + # Pause reason. + enum reason + ambiguous + assert + debugCommand + DOM + EventListener + exception + instrumentation + OOM + other + promiseRejection + XHR + # Object containing break-specific auxiliary properties. + optional object data + # Hit breakpoints IDs + optional array of string hitBreakpoints + # Async stack trace, if any. + optional Runtime.StackTrace asyncStackTrace + # Async stack trace, if any. + experimental optional Runtime.StackTraceId asyncStackTraceId + # Never present, will be removed. + experimental deprecated optional Runtime.StackTraceId asyncCallStackTraceId + + # Fired when the virtual machine resumed execution. + event resumed + + # Enum of possible script languages. + type ScriptLanguage extends string + enum + JavaScript + WebAssembly + + # Debug symbols available for a wasm script. + type DebugSymbols extends object + properties + # Type of the debug symbols. + enum type + None + SourceMap + EmbeddedDWARF + ExternalDWARF + # URL of the external symbol source. + optional string externalURL + + # Fired when virtual machine fails to parse the script. + event scriptFailedToParse + parameters + # Identifier of the script parsed. + Runtime.ScriptId scriptId + # URL or name of the script parsed (if any). + string url + # Line offset of the script within the resource with given URL (for script tags). + integer startLine + # Column offset of the script within the resource with given URL. + integer startColumn + # Last line of the script. + integer endLine + # Length of the last line of the script. + integer endColumn + # Specifies script creation context. + Runtime.ExecutionContextId executionContextId + # Content hash of the script. + string hash + # Embedder-specific auxiliary data. + optional object executionContextAuxData + # URL of source map associated with script (if any). + optional string sourceMapURL + # True, if this script has sourceURL. + optional boolean hasSourceURL + # True, if this script is ES6 module. + optional boolean isModule + # This script length. + optional integer length + # JavaScript top stack frame of where the script parsed event was triggered if available. + experimental optional Runtime.StackTrace stackTrace + # If the scriptLanguage is WebAssembly, the code section offset in the module. + experimental optional integer codeOffset + # The language of the script. + experimental optional Debugger.ScriptLanguage scriptLanguage + + # Fired when virtual machine parses script. This event is also fired for all known and uncollected + # scripts upon enabling debugger. + event scriptParsed + parameters + # Identifier of the script parsed. + Runtime.ScriptId scriptId + # URL or name of the script parsed (if any). + string url + # Line offset of the script within the resource with given URL (for script tags). + integer startLine + # Column offset of the script within the resource with given URL. + integer startColumn + # Last line of the script. + integer endLine + # Length of the last line of the script. + integer endColumn + # Specifies script creation context. + Runtime.ExecutionContextId executionContextId + # Content hash of the script. + string hash + # Embedder-specific auxiliary data. + optional object executionContextAuxData + # True, if this script is generated as a result of the live edit operation. + experimental optional boolean isLiveEdit + # URL of source map associated with script (if any). + optional string sourceMapURL + # True, if this script has sourceURL. + optional boolean hasSourceURL + # True, if this script is ES6 module. + optional boolean isModule + # This script length. + optional integer length + # JavaScript top stack frame of where the script parsed event was triggered if available. + experimental optional Runtime.StackTrace stackTrace + # If the scriptLanguage is WebAssembly, the code section offset in the module. + experimental optional integer codeOffset + # The language of the script. + experimental optional Debugger.ScriptLanguage scriptLanguage + # If the scriptLanguage is WebASsembly, the source of debug symbols for the module. + experimental optional Debugger.DebugSymbols debugSymbols + +experimental domain HeapProfiler + depends on Runtime + + # Heap snapshot object id. + type HeapSnapshotObjectId extends string + + # Sampling Heap Profile node. Holds callsite information, allocation statistics and child nodes. + type SamplingHeapProfileNode extends object + properties + # Function location. + Runtime.CallFrame callFrame + # Allocations size in bytes for the node excluding children. + number selfSize + # Node id. Ids are unique across all profiles collected between startSampling and stopSampling. + integer id + # Child nodes. + array of SamplingHeapProfileNode children + + # A single sample from a sampling profile. + type SamplingHeapProfileSample extends object + properties + # Allocation size in bytes attributed to the sample. + number size + # Id of the corresponding profile tree node. + integer nodeId + # Time-ordered sample ordinal number. It is unique across all profiles retrieved + # between startSampling and stopSampling. + number ordinal + + # Sampling profile. + type SamplingHeapProfile extends object + properties + SamplingHeapProfileNode head + array of SamplingHeapProfileSample samples + + # Enables console to refer to the node with given id via $x (see Command Line API for more details + # $x functions). + command addInspectedHeapObject + parameters + # Heap snapshot object id to be accessible by means of $x command line API. + HeapSnapshotObjectId heapObjectId + + command collectGarbage + + command disable + + command enable + + command getHeapObjectId + parameters + # Identifier of the object to get heap object id for. + Runtime.RemoteObjectId objectId + returns + # Id of the heap snapshot object corresponding to the passed remote object id. + HeapSnapshotObjectId heapSnapshotObjectId + + command getObjectByHeapObjectId + parameters + HeapSnapshotObjectId objectId + # Symbolic group name that can be used to release multiple objects. + optional string objectGroup + returns + # Evaluation result. + Runtime.RemoteObject result + + command getSamplingProfile + returns + # Return the sampling profile being collected. + SamplingHeapProfile profile + + command startSampling + parameters + # Average sample interval in bytes. Poisson distribution is used for the intervals. The + # default value is 32768 bytes. + optional number samplingInterval + + command startTrackingHeapObjects + parameters + optional boolean trackAllocations + + command stopSampling + returns + # Recorded sampling heap profile. + SamplingHeapProfile profile + + command stopTrackingHeapObjects + parameters + # If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken + # when the tracking is stopped. + optional boolean reportProgress + optional boolean treatGlobalObjectsAsRoots + + command takeHeapSnapshot + parameters + # If true 'reportHeapSnapshotProgress' events will be generated while snapshot is being taken. + optional boolean reportProgress + # If true, a raw snapshot without artifical roots will be generated + optional boolean treatGlobalObjectsAsRoots + + event addHeapSnapshotChunk + parameters + string chunk + + # If heap objects tracking has been started then backend may send update for one or more fragments + event heapStatsUpdate + parameters + # An array of triplets. Each triplet describes a fragment. The first integer is the fragment + # index, the second integer is a total count of objects for the fragment, the third integer is + # a total size of the objects for the fragment. + array of integer statsUpdate + + # If heap objects tracking has been started then backend regularly sends a current value for last + # seen object id and corresponding timestamp. If the were changes in the heap since last event + # then one or more heapStatsUpdate events will be sent before a new lastSeenObjectId event. + event lastSeenObjectId + parameters + integer lastSeenObjectId + number timestamp + + event reportHeapSnapshotProgress + parameters + integer done + integer total + optional boolean finished + + event resetProfiles + +domain Profiler + depends on Runtime + depends on Debugger + + # Profile node. Holds callsite information, execution statistics and child nodes. + type ProfileNode extends object + properties + # Unique id of the node. + integer id + # Function location. + Runtime.CallFrame callFrame + # Number of samples where this node was on top of the call stack. + optional integer hitCount + # Child node ids. + optional array of integer children + # The reason of being not optimized. The function may be deoptimized or marked as don't + # optimize. + optional string deoptReason + # An array of source position ticks. + optional array of PositionTickInfo positionTicks + + # Profile. + type Profile extends object + properties + # The list of profile nodes. First item is the root node. + array of ProfileNode nodes + # Profiling start timestamp in microseconds. + number startTime + # Profiling end timestamp in microseconds. + number endTime + # Ids of samples top nodes. + optional array of integer samples + # Time intervals between adjacent samples in microseconds. The first delta is relative to the + # profile startTime. + optional array of integer timeDeltas + + # Specifies a number of samples attributed to a certain source position. + type PositionTickInfo extends object + properties + # Source line number (1-based). + integer line + # Number of samples attributed to the source line. + integer ticks + + # Coverage data for a source range. + type CoverageRange extends object + properties + # JavaScript script source offset for the range start. + integer startOffset + # JavaScript script source offset for the range end. + integer endOffset + # Collected execution count of the source range. + integer count + + # Coverage data for a JavaScript function. + type FunctionCoverage extends object + properties + # JavaScript function name. + string functionName + # Source ranges inside the function with coverage data. + array of CoverageRange ranges + # Whether coverage data for this function has block granularity. + boolean isBlockCoverage + + # Coverage data for a JavaScript script. + type ScriptCoverage extends object + properties + # JavaScript script id. + Runtime.ScriptId scriptId + # JavaScript script name or url. + string url + # Functions contained in the script that has coverage data. + array of FunctionCoverage functions + + # Describes a type collected during runtime. + experimental type TypeObject extends object + properties + # Name of a type collected with type profiling. + string name + + # Source offset and types for a parameter or return value. + experimental type TypeProfileEntry extends object + properties + # Source offset of the parameter or end of function for return values. + integer offset + # The types for this parameter or return value. + array of TypeObject types + + # Type profile data collected during runtime for a JavaScript script. + experimental type ScriptTypeProfile extends object + properties + # JavaScript script id. + Runtime.ScriptId scriptId + # JavaScript script name or url. + string url + # Type profile entries for parameters and return values of the functions in the script. + array of TypeProfileEntry entries + + # Collected counter information. + experimental type CounterInfo extends object + properties + # Counter name. + string name + # Counter value. + integer value + + command disable + + command enable + + # Collect coverage data for the current isolate. The coverage data may be incomplete due to + # garbage collection. + command getBestEffortCoverage + returns + # Coverage data for the current isolate. + array of ScriptCoverage result + + # Changes CPU profiler sampling interval. Must be called before CPU profiles recording started. + command setSamplingInterval + parameters + # New sampling interval in microseconds. + integer interval + + command start + + # Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code + # coverage may be incomplete. Enabling prevents running optimized code and resets execution + # counters. + command startPreciseCoverage + parameters + # Collect accurate call counts beyond simple 'covered' or 'not covered'. + optional boolean callCount + # Collect block-based coverage. + optional boolean detailed + # Allow the backend to send updates on its own initiative + optional boolean allowTriggeredUpdates + returns + # Monotonically increasing time (in seconds) when the coverage update was taken in the backend. + number timestamp + + # Enable type profile. + experimental command startTypeProfile + + command stop + returns + # Recorded profile. + Profile profile + + # Disable precise code coverage. Disabling releases unnecessary execution count records and allows + # executing optimized code. + command stopPreciseCoverage + + # Disable type profile. Disabling releases type profile data collected so far. + experimental command stopTypeProfile + + # Collect coverage data for the current isolate, and resets execution counters. Precise code + # coverage needs to have started. + command takePreciseCoverage + returns + # Coverage data for the current isolate. + array of ScriptCoverage result + # Monotonically increasing time (in seconds) when the coverage update was taken in the backend. + number timestamp + + # Collect type profile. + experimental command takeTypeProfile + returns + # Type profile for all scripts since startTypeProfile() was turned on. + array of ScriptTypeProfile result + + # Enable run time call stats collection. + experimental command enableRuntimeCallStats + + # Disable run time call stats collection. + experimental command disableRuntimeCallStats + + # Retrieve run time call stats. + experimental command getRuntimeCallStats + returns + # Collected counter information. + array of CounterInfo result + + event consoleProfileFinished + parameters + string id + # Location of console.profileEnd(). + Debugger.Location location + Profile profile + # Profile title passed as an argument to console.profile(). + optional string title + + # Sent when new profile recording is started using console.profile() call. + event consoleProfileStarted + parameters + string id + # Location of console.profile(). + Debugger.Location location + # Profile title passed as an argument to console.profile(). + optional string title + + # Reports coverage delta since the last poll (either from an event like this, or from + # `takePreciseCoverage` for the current isolate. May only be sent if precise code + # coverage has been started. This event can be trigged by the embedder to, for example, + # trigger collection of coverage data immediatelly at a certain point in time. + experimental event preciseCoverageDeltaUpdate + parameters + # Monotonically increasing time (in seconds) when the coverage update was taken in the backend. + number timestamp + # Identifier for distinguishing coverage events. + string occassion + # Coverage data for the current isolate. + array of ScriptCoverage result + +# Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects. +# Evaluation results are returned as mirror object that expose object type, string representation +# and unique identifier that can be used for further object reference. Original objects are +# maintained in memory unless they are either explicitly released or are released along with the +# other objects in their object group. +domain Runtime + + # Unique script identifier. + type ScriptId extends string + + # Unique object identifier. + type RemoteObjectId extends string + + # Primitive value which cannot be JSON-stringified. Includes values `-0`, `NaN`, `Infinity`, + # `-Infinity`, and bigint literals. + type UnserializableValue extends string + + # Mirror object referencing original JavaScript object. + type RemoteObject extends object + properties + # Object type. + enum type + object + function + undefined + string + number + boolean + symbol + bigint + wasm + # Object subtype hint. Specified for `object` or `wasm` type values only. + optional enum subtype + array + null + node + regexp + date + map + set + weakmap + weakset + iterator + generator + error + proxy + promise + typedarray + arraybuffer + dataview + i32 + i64 + f32 + f64 + v128 + anyref + # Object class (constructor) name. Specified for `object` type values only. + optional string className + # Remote object value in case of primitive values or JSON values (if it was requested). + optional any value + # Primitive value which can not be JSON-stringified does not have `value`, but gets this + # property. + optional UnserializableValue unserializableValue + # String representation of the object. + optional string description + # Unique object identifier (for non-primitive values). + optional RemoteObjectId objectId + # Preview containing abbreviated property values. Specified for `object` type values only. + experimental optional ObjectPreview preview + experimental optional CustomPreview customPreview + + experimental type CustomPreview extends object + properties + # The JSON-stringified result of formatter.header(object, config) call. + # It contains json ML array that represents RemoteObject. + string header + # If formatter returns true as a result of formatter.hasBody call then bodyGetterId will + # contain RemoteObjectId for the function that returns result of formatter.body(object, config) call. + # The result value is json ML array. + optional RemoteObjectId bodyGetterId + + # Object containing abbreviated remote object value. + experimental type ObjectPreview extends object + properties + # Object type. + enum type + object + function + undefined + string + number + boolean + symbol + bigint + # Object subtype hint. Specified for `object` type values only. + optional enum subtype + array + null + node + regexp + date + map + set + weakmap + weakset + iterator + generator + error + # String representation of the object. + optional string description + # True iff some of the properties or entries of the original object did not fit. + boolean overflow + # List of the properties. + array of PropertyPreview properties + # List of the entries. Specified for `map` and `set` subtype values only. + optional array of EntryPreview entries + + experimental type PropertyPreview extends object + properties + # Property name. + string name + # Object type. Accessor means that the property itself is an accessor property. + enum type + object + function + undefined + string + number + boolean + symbol + accessor + bigint + # User-friendly property value string. + optional string value + # Nested value preview. + optional ObjectPreview valuePreview + # Object subtype hint. Specified for `object` type values only. + optional enum subtype + array + null + node + regexp + date + map + set + weakmap + weakset + iterator + generator + error + + experimental type EntryPreview extends object + properties + # Preview of the key. Specified for map-like collection entries. + optional ObjectPreview key + # Preview of the value. + ObjectPreview value + + # Object property descriptor. + type PropertyDescriptor extends object + properties + # Property name or symbol description. + string name + # The value associated with the property. + optional RemoteObject value + # True if the value associated with the property may be changed (data descriptors only). + optional boolean writable + # A function which serves as a getter for the property, or `undefined` if there is no getter + # (accessor descriptors only). + optional RemoteObject get + # A function which serves as a setter for the property, or `undefined` if there is no setter + # (accessor descriptors only). + optional RemoteObject set + # True if the type of this property descriptor may be changed and if the property may be + # deleted from the corresponding object. + boolean configurable + # True if this property shows up during enumeration of the properties on the corresponding + # object. + boolean enumerable + # True if the result was thrown during the evaluation. + optional boolean wasThrown + # True if the property is owned for the object. + optional boolean isOwn + # Property symbol object, if the property is of the `symbol` type. + optional RemoteObject symbol + + # Object internal property descriptor. This property isn't normally visible in JavaScript code. + type InternalPropertyDescriptor extends object + properties + # Conventional property name. + string name + # The value associated with the property. + optional RemoteObject value + + # Object private field descriptor. + experimental type PrivatePropertyDescriptor extends object + properties + # Private property name. + string name + # The value associated with the private property. + optional RemoteObject value + # A function which serves as a getter for the private property, + # or `undefined` if there is no getter (accessor descriptors only). + optional RemoteObject get + # A function which serves as a setter for the private property, + # or `undefined` if there is no setter (accessor descriptors only). + optional RemoteObject set + + # Represents function call argument. Either remote object id `objectId`, primitive `value`, + # unserializable primitive value or neither of (for undefined) them should be specified. + type CallArgument extends object + properties + # Primitive value or serializable javascript object. + optional any value + # Primitive value which can not be JSON-stringified. + optional UnserializableValue unserializableValue + # Remote object handle. + optional RemoteObjectId objectId + + # Id of an execution context. + type ExecutionContextId extends integer + + # Description of an isolated world. + type ExecutionContextDescription extends object + properties + # Unique id of the execution context. It can be used to specify in which execution context + # script evaluation should be performed. + ExecutionContextId id + # Execution context origin. + string origin + # Human readable name describing given context. + string name + # Embedder-specific auxiliary data. + optional object auxData + + # Detailed information about exception (or error) that was thrown during script compilation or + # execution. + type ExceptionDetails extends object + properties + # Exception id. + integer exceptionId + # Exception text, which should be used together with exception object when available. + string text + # Line number of the exception location (0-based). + integer lineNumber + # Column number of the exception location (0-based). + integer columnNumber + # Script ID of the exception location. + optional ScriptId scriptId + # URL of the exception location, to be used when the script was not reported. + optional string url + # JavaScript stack trace if available. + optional StackTrace stackTrace + # Exception object if available. + optional RemoteObject exception + # Identifier of the context where exception happened. + optional ExecutionContextId executionContextId + + # Number of milliseconds since epoch. + type Timestamp extends number + + # Number of milliseconds. + type TimeDelta extends number + + # Stack entry for runtime errors and assertions. + type CallFrame extends object + properties + # JavaScript function name. + string functionName + # JavaScript script id. + ScriptId scriptId + # JavaScript script name or url. + string url + # JavaScript script line number (0-based). + integer lineNumber + # JavaScript script column number (0-based). + integer columnNumber + + # Call frames for assertions or error messages. + type StackTrace extends object + properties + # String label of this stack trace. For async traces this may be a name of the function that + # initiated the async call. + optional string description + # JavaScript function name. + array of CallFrame callFrames + # Asynchronous JavaScript stack trace that preceded this stack, if available. + optional StackTrace parent + # Asynchronous JavaScript stack trace that preceded this stack, if available. + experimental optional StackTraceId parentId + + # Unique identifier of current debugger. + experimental type UniqueDebuggerId extends string + + # If `debuggerId` is set stack trace comes from another debugger and can be resolved there. This + # allows to track cross-debugger calls. See `Runtime.StackTrace` and `Debugger.paused` for usages. + experimental type StackTraceId extends object + properties + string id + optional UniqueDebuggerId debuggerId + + # Add handler to promise with given promise object id. + command awaitPromise + parameters + # Identifier of the promise. + RemoteObjectId promiseObjectId + # Whether the result is expected to be a JSON object that should be sent by value. + optional boolean returnByValue + # Whether preview should be generated for the result. + optional boolean generatePreview + returns + # Promise result. Will contain rejected value if promise was rejected. + RemoteObject result + # Exception details if stack strace is available. + optional ExceptionDetails exceptionDetails + + # Calls function with given declaration on the given object. Object group of the result is + # inherited from the target object. + command callFunctionOn + parameters + # Declaration of the function to call. + string functionDeclaration + # Identifier of the object to call function on. Either objectId or executionContextId should + # be specified. + optional RemoteObjectId objectId + # Call arguments. All call arguments must belong to the same JavaScript world as the target + # object. + optional array of CallArgument arguments + # In silent mode exceptions thrown during evaluation are not reported and do not pause + # execution. Overrides `setPauseOnException` state. + optional boolean silent + # Whether the result is expected to be a JSON object which should be sent by value. + optional boolean returnByValue + # Whether preview should be generated for the result. + experimental optional boolean generatePreview + # Whether execution should be treated as initiated by user in the UI. + optional boolean userGesture + # Whether execution should `await` for resulting value and return once awaited promise is + # resolved. + optional boolean awaitPromise + # Specifies execution context which global object will be used to call function on. Either + # executionContextId or objectId should be specified. + optional ExecutionContextId executionContextId + # Symbolic group name that can be used to release multiple objects. If objectGroup is not + # specified and objectId is, objectGroup will be inherited from object. + optional string objectGroup + returns + # Call result. + RemoteObject result + # Exception details. + optional ExceptionDetails exceptionDetails + + # Compiles expression. + command compileScript + parameters + # Expression to compile. + string expression + # Source url to be set for the script. + string sourceURL + # Specifies whether the compiled script should be persisted. + boolean persistScript + # Specifies in which execution context to perform script run. If the parameter is omitted the + # evaluation will be performed in the context of the inspected page. + optional ExecutionContextId executionContextId + returns + # Id of the script. + optional ScriptId scriptId + # Exception details. + optional ExceptionDetails exceptionDetails + + # Disables reporting of execution contexts creation. + command disable + + # Discards collected exceptions and console API calls. + command discardConsoleEntries + + # Enables reporting of execution contexts creation by means of `executionContextCreated` event. + # When the reporting gets enabled the event will be sent immediately for each existing execution + # context. + command enable + + # Evaluates expression on global object. + command evaluate + parameters + # Expression to evaluate. + string expression + # Symbolic group name that can be used to release multiple objects. + optional string objectGroup + # Determines whether Command Line API should be available during the evaluation. + optional boolean includeCommandLineAPI + # In silent mode exceptions thrown during evaluation are not reported and do not pause + # execution. Overrides `setPauseOnException` state. + optional boolean silent + # Specifies in which execution context to perform evaluation. If the parameter is omitted the + # evaluation will be performed in the context of the inspected page. + optional ExecutionContextId contextId + # Whether the result is expected to be a JSON object that should be sent by value. + optional boolean returnByValue + # Whether preview should be generated for the result. + experimental optional boolean generatePreview + # Whether execution should be treated as initiated by user in the UI. + optional boolean userGesture + # Whether execution should `await` for resulting value and return once awaited promise is + # resolved. + optional boolean awaitPromise + # Whether to throw an exception if side effect cannot be ruled out during evaluation. + # This implies `disableBreaks` below. + experimental optional boolean throwOnSideEffect + # Terminate execution after timing out (number of milliseconds). + experimental optional TimeDelta timeout + # Disable breakpoints during execution. + experimental optional boolean disableBreaks + # Setting this flag to true enables `let` re-declaration and top-level `await`. + # Note that `let` variables can only be re-declared if they originate from + # `replMode` themselves. + experimental optional boolean replMode + returns + # Evaluation result. + RemoteObject result + # Exception details. + optional ExceptionDetails exceptionDetails + + # Returns the isolate id. + experimental command getIsolateId + returns + # The isolate id. + string id + + # Returns the JavaScript heap usage. + # It is the total usage of the corresponding isolate not scoped to a particular Runtime. + experimental command getHeapUsage + returns + # Used heap size in bytes. + number usedSize + # Allocated heap size in bytes. + number totalSize + + # Returns properties of a given object. Object group of the result is inherited from the target + # object. + command getProperties + parameters + # Identifier of the object to return properties for. + RemoteObjectId objectId + # If true, returns properties belonging only to the element itself, not to its prototype + # chain. + optional boolean ownProperties + # If true, returns accessor properties (with getter/setter) only; internal properties are not + # returned either. + experimental optional boolean accessorPropertiesOnly + # Whether preview should be generated for the results. + experimental optional boolean generatePreview + returns + # Object properties. + array of PropertyDescriptor result + # Internal object properties (only of the element itself). + optional array of InternalPropertyDescriptor internalProperties + # Object private properties. + experimental optional array of PrivatePropertyDescriptor privateProperties + # Exception details. + optional ExceptionDetails exceptionDetails + + # Returns all let, const and class variables from global scope. + command globalLexicalScopeNames + parameters + # Specifies in which execution context to lookup global scope variables. + optional ExecutionContextId executionContextId + returns + array of string names + + command queryObjects + parameters + # Identifier of the prototype to return objects for. + RemoteObjectId prototypeObjectId + # Symbolic group name that can be used to release the results. + optional string objectGroup + returns + # Array with objects. + RemoteObject objects + + # Releases remote object with given id. + command releaseObject + parameters + # Identifier of the object to release. + RemoteObjectId objectId + + # Releases all remote objects that belong to a given group. + command releaseObjectGroup + parameters + # Symbolic object group name. + string objectGroup + + # Tells inspected instance to run if it was waiting for debugger to attach. + command runIfWaitingForDebugger + + # Runs script with given id in a given context. + command runScript + parameters + # Id of the script to run. + ScriptId scriptId + # Specifies in which execution context to perform script run. If the parameter is omitted the + # evaluation will be performed in the context of the inspected page. + optional ExecutionContextId executionContextId + # Symbolic group name that can be used to release multiple objects. + optional string objectGroup + # In silent mode exceptions thrown during evaluation are not reported and do not pause + # execution. Overrides `setPauseOnException` state. + optional boolean silent + # Determines whether Command Line API should be available during the evaluation. + optional boolean includeCommandLineAPI + # Whether the result is expected to be a JSON object which should be sent by value. + optional boolean returnByValue + # Whether preview should be generated for the result. + optional boolean generatePreview + # Whether execution should `await` for resulting value and return once awaited promise is + # resolved. + optional boolean awaitPromise + returns + # Run result. + RemoteObject result + # Exception details. + optional ExceptionDetails exceptionDetails + + # Enables or disables async call stacks tracking. + command setAsyncCallStackDepth + redirect Debugger + parameters + # Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async + # call stacks (default). + integer maxDepth + + experimental command setCustomObjectFormatterEnabled + parameters + boolean enabled + + experimental command setMaxCallStackSizeToCapture + parameters + integer size + + # Terminate current or next JavaScript execution. + # Will cancel the termination when the outer-most script execution ends. + experimental command terminateExecution + + # If executionContextId is empty, adds binding with the given name on the + # global objects of all inspected contexts, including those created later, + # bindings survive reloads. + # If executionContextId is specified, adds binding only on global object of + # given execution context. + # Binding function takes exactly one argument, this argument should be string, + # in case of any other input, function throws an exception. + # Each binding function call produces Runtime.bindingCalled notification. + experimental command addBinding + parameters + string name + optional ExecutionContextId executionContextId + + # This method does not remove binding function from global object but + # unsubscribes current runtime agent from Runtime.bindingCalled notifications. + experimental command removeBinding + parameters + string name + + # Notification is issued every time when binding is called. + experimental event bindingCalled + parameters + string name + string payload + # Identifier of the context where the call was made. + ExecutionContextId executionContextId + + # Issued when console API was called. + event consoleAPICalled + parameters + # Type of the call. + enum type + log + debug + info + error + warning + dir + dirxml + table + trace + clear + startGroup + startGroupCollapsed + endGroup + assert + profile + profileEnd + count + timeEnd + # Call arguments. + array of RemoteObject args + # Identifier of the context where the call was made. + ExecutionContextId executionContextId + # Call timestamp. + Timestamp timestamp + # Stack trace captured when the call was made. The async stack chain is automatically reported for + # the following call types: `assert`, `error`, `trace`, `warning`. For other types the async call + # chain can be retrieved using `Debugger.getStackTrace` and `stackTrace.parentId` field. + optional StackTrace stackTrace + # Console context descriptor for calls on non-default console context (not console.*): + # 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call + # on named context. + experimental optional string context + + # Issued when unhandled exception was revoked. + event exceptionRevoked + parameters + # Reason describing why exception was revoked. + string reason + # The id of revoked exception, as reported in `exceptionThrown`. + integer exceptionId + + # Issued when exception was thrown and unhandled. + event exceptionThrown + parameters + # Timestamp of the exception. + Timestamp timestamp + ExceptionDetails exceptionDetails + + # Issued when new execution context is created. + event executionContextCreated + parameters + # A newly created execution context. + ExecutionContextDescription context + + # Issued when execution context is destroyed. + event executionContextDestroyed + parameters + # Id of the destroyed context + ExecutionContextId executionContextId + + # Issued when all executionContexts were cleared in browser + event executionContextsCleared + + # Issued when object should be inspected (for example, as a result of inspect() command line API + # call). + event inspectRequested + parameters + RemoteObject object + object hints + +# This domain is deprecated. +deprecated domain Schema + + # Description of the protocol domain. + type Domain extends object + properties + # Domain name. + string name + # Domain version. + string version + + # Returns supported domains. + command getDomains + returns + # List of supported domains. + array of Domain domains diff --git a/deps/nodejs/deps/v8/include/libplatform/libplatform.h b/deps/nodejs/deps/v8/include/libplatform/libplatform.h index 6908aeaa..c7ea4c2b 100644 --- a/deps/nodejs/deps/v8/include/libplatform/libplatform.h +++ b/deps/nodejs/deps/v8/include/libplatform/libplatform.h @@ -5,10 +5,12 @@ #ifndef V8_LIBPLATFORM_LIBPLATFORM_H_ #define V8_LIBPLATFORM_LIBPLATFORM_H_ +#include + #include "libplatform/libplatform-export.h" #include "libplatform/v8-tracing.h" -#include "v8-platform.h" // NOLINT(build/include) -#include "v8config.h" // NOLINT(build/include) +#include "v8-platform.h" // NOLINT(build/include_directory) +#include "v8config.h" // NOLINT(build/include_directory) namespace v8 { namespace platform { @@ -45,9 +47,11 @@ V8_PLATFORM_EXPORT std::unique_ptr NewDefaultPlatform( * Pumps the message loop for the given isolate. * * The caller has to make sure that this is called from the right thread. - * Returns true if a task was executed, and false otherwise. Unless requested - * through the |behavior| parameter, this call does not block if no task is - * pending. The |platform| has to be created using |NewDefaultPlatform|. + * Returns true if a task was executed, and false otherwise. If the call to + * PumpMessageLoop is nested within another call to PumpMessageLoop, only + * nestable tasks may run. Otherwise, any task may run. Unless requested through + * the |behavior| parameter, this call does not block if no task is pending. The + * |platform| has to be created using |NewDefaultPlatform|. */ V8_PLATFORM_EXPORT bool PumpMessageLoop( v8::Platform* platform, v8::Isolate* isolate, @@ -70,11 +74,10 @@ V8_PLATFORM_EXPORT void RunIdleTasks(v8::Platform* platform, * The |platform| has to be created using |NewDefaultPlatform|. * */ -V8_PLATFORM_EXPORT V8_DEPRECATE_SOON( - "Access the DefaultPlatform directly", - void SetTracingController( - v8::Platform* platform, - v8::platform::tracing::TracingController* tracing_controller)); +V8_DEPRECATE_SOON("Access the DefaultPlatform directly") +V8_PLATFORM_EXPORT void SetTracingController( + v8::Platform* platform, + v8::platform::tracing::TracingController* tracing_controller); } // namespace platform } // namespace v8 diff --git a/deps/nodejs/deps/v8/include/libplatform/v8-tracing.h b/deps/nodejs/deps/v8/include/libplatform/v8-tracing.h index bc249cb9..79c647e5 100644 --- a/deps/nodejs/deps/v8/include/libplatform/v8-tracing.h +++ b/deps/nodejs/deps/v8/include/libplatform/v8-tracing.h @@ -12,7 +12,11 @@ #include #include "libplatform/libplatform-export.h" -#include "v8-platform.h" // NOLINT(build/include) +#include "v8-platform.h" // NOLINT(build/include_directory) + +namespace perfetto { +class TracingSession; +} namespace v8 { @@ -23,12 +27,15 @@ class Mutex; namespace platform { namespace tracing { +class TraceEventListener; +class JSONTraceEventListener; + const int kTraceMaxNumArgs = 2; class V8_PLATFORM_EXPORT TraceObject { public: union ArgValue { - bool as_bool; + V8_DEPRECATED("use as_uint ? true : false") bool as_bool; uint64_t as_uint; int64_t as_int; double as_double; @@ -237,7 +244,17 @@ class V8_PLATFORM_EXPORT TracingController TracingController(); ~TracingController() override; + + // Takes ownership of |trace_buffer|. void Initialize(TraceBuffer* trace_buffer); +#ifdef V8_USE_PERFETTO + // Must be called before StartTracing() if V8_USE_PERFETTO is true. Provides + // the output stream for the JSON trace data. + void InitializeForPerfetto(std::ostream* output_stream); + // Provide an optional listener for testing that will receive trace events. + // Must be called before StartTracing(). + void SetTraceEventListenerForTesting(TraceEventListener* listener); +#endif // v8::TracingController implementation. const uint8_t* GetCategoryGroupEnabled(const char* category_group) override; @@ -280,6 +297,12 @@ class V8_PLATFORM_EXPORT TracingController std::unique_ptr mutex_; std::unordered_set observers_; std::atomic_bool recording_{false}; +#ifdef V8_USE_PERFETTO + std::ostream* output_stream_ = nullptr; + std::unique_ptr json_listener_; + TraceEventListener* listener_for_testing_ = nullptr; + std::unique_ptr tracing_session_; +#endif // Disallow copy and assign TracingController(const TracingController&) = delete; diff --git a/deps/nodejs/deps/v8/include/v8-fast-api-calls.h b/deps/nodejs/deps/v8/include/v8-fast-api-calls.h new file mode 100644 index 00000000..f7440649 --- /dev/null +++ b/deps/nodejs/deps/v8/include/v8-fast-api-calls.h @@ -0,0 +1,412 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/** + * This file provides additional API on top of the default one for making + * API calls, which come from embedder C++ functions. The functions are being + * called directly from optimized code, doing all the necessary typechecks + * in the compiler itself, instead of on the embedder side. Hence the "fast" + * in the name. Example usage might look like: + * + * \code + * void FastMethod(int param, bool another_param); + * + * v8::FunctionTemplate::New(isolate, SlowCallback, data, + * signature, length, constructor_behavior + * side_effect_type, + * &v8::CFunction::Make(FastMethod)); + * \endcode + * + * An example for custom embedder type support might employ a way to wrap/ + * unwrap various C++ types in JSObject instances, e.g: + * + * \code + * + * // Represents the way this type system maps C++ and JS values. + * struct WrapperTypeInfo { + * // Store e.g. a method to map from exposed C++ types to the already + * // created v8::FunctionTemplate's for instantiating them. + * }; + * + * // Helper method with a sanity check. + * template + * inline T* GetInternalField(v8::Local wrapper) { + * assert(offset < wrapper->InternalFieldCount()); + * return reinterpret_cast( + * wrapper->GetAlignedPointerFromInternalField(offset)); + * } + * + * // Returns the type info from a wrapper JS object. + * inline const WrapperTypeInfo* ToWrapperTypeInfo( + * v8::Local wrapper) { + * return GetInternalField(wrapper); + * } + * + * class CustomEmbedderType { + * public: + * static constexpr const WrapperTypeInfo* GetWrapperTypeInfo() { + * return &custom_type_wrapper_type_info; + * } + * // Returns the raw C object from a wrapper JS object. + * static CustomEmbedderType* Unwrap(v8::Local wrapper) { + * return GetInternalField(wrapper); + * } + * static void FastMethod(CustomEmbedderType* receiver, int param) { + * assert(receiver != nullptr); + * // Type checks are already done by the optimized code. + * // Then call some performance-critical method like: + * // receiver->Method(param); + * } + * + * static void SlowMethod( + * const v8::FunctionCallbackInfo& info) { + * v8::Local instance = + * v8::Local::Cast(info.Holder()); + * CustomEmbedderType* receiver = Unwrap(instance); + * // TODO: Do type checks and extract {param}. + * FastMethod(receiver, param); + * } + * + * private: + * static const WrapperTypeInfo custom_type_wrapper_type_info; + * }; + * + * // Support for custom embedder types via specialization of WrapperTraits. + * namespace v8 { + * template <> + * class WrapperTraits { + * public: + * static const void* GetTypeInfo() { + * // We use the already defined machinery for the custom type. + * return CustomEmbedderType::GetWrapperTypeInfo(); + * } + * }; + * } // namespace v8 + * + * // The constants kV8EmbedderWrapperTypeIndex and + * // kV8EmbedderWrapperObjectIndex describe the offsets for the type info + * // struct (the one returned by WrapperTraits::GetTypeInfo) and the + * // native object, when expressed as internal field indices within a + * // JSObject. The existance of this helper function assumes that all + * // embedder objects have their JSObject-side type info at the same + * // offset, but this is not a limitation of the API itself. For a detailed + * // use case, see the third example. + * static constexpr int kV8EmbedderWrapperTypeIndex = 0; + * static constexpr int kV8EmbedderWrapperObjectIndex = 1; + * + * // The following setup function can be templatized based on + * // the {embedder_object} argument. + * void SetupCustomEmbedderObject(v8::Isolate* isolate, + * v8::Local context, + * CustomEmbedderType* embedder_object) { + * isolate->set_embedder_wrapper_type_index( + * kV8EmbedderWrapperTypeIndex); + * isolate->set_embedder_wrapper_object_index( + * kV8EmbedderWrapperObjectIndex); + * + * v8::CFunction c_func = + * MakeV8CFunction(CustomEmbedderType::FastMethod); + * + * Local method_template = + * v8::FunctionTemplate::New( + * isolate, CustomEmbedderType::SlowMethod, v8::Local(), + * v8::Local(), 1, v8::ConstructorBehavior::kAllow, + * v8::SideEffectType::kHasSideEffect, &c_func); + * + * v8::Local object_template = + * v8::ObjectTemplate::New(isolate); + * object_template->SetInternalFieldCount( + * kV8EmbedderWrapperObjectIndex + 1); + * object_template->Set( + v8::String::NewFromUtf8Literal(isolate, "method"), method_template); + * + * // Instantiate the wrapper JS object. + * v8::Local object = + * object_template->NewInstance(context).ToLocalChecked(); + * object->SetAlignedPointerInInternalField( + * kV8EmbedderWrapperObjectIndex, + * reinterpret_cast(embedder_object)); + * + * // TODO: Expose {object} where it's necessary. + * } + * \endcode + * + * For instance if {object} is exposed via a global "obj" variable, + * one could write in JS: + * function hot_func() { + * obj.method(42); + * } + * and once {hot_func} gets optimized, CustomEmbedderType::FastMethod + * will be called instead of the slow version, with the following arguments: + * receiver := the {embedder_object} from above + * param := 42 + * + * Currently only void return types are supported. + * Currently supported argument types: + * - pointer to an embedder type + * - bool + * - int32_t + * - uint32_t + * To be supported types: + * - int64_t + * - uint64_t + * - float32_t + * - float64_t + * - arrays of C types + * - arrays of embedder types + */ + +#ifndef INCLUDE_V8_FAST_API_CALLS_H_ +#define INCLUDE_V8_FAST_API_CALLS_H_ + +#include +#include + +#include "v8config.h" // NOLINT(build/include_directory) + +namespace v8 { + +class CTypeInfo { + public: + enum class Type : char { + kVoid, + kBool, + kInt32, + kUint32, + kInt64, + kUint64, + kFloat32, + kFloat64, + kUnwrappedApiObject, + }; + + enum class ArgFlags : uint8_t { + kNone = 0, + kIsArrayBit = 1 << 0, // This argument is first in an array of values. + }; + + static CTypeInfo FromWrapperType(const void* wrapper_type_info, + ArgFlags flags = ArgFlags::kNone) { + uintptr_t wrapper_type_info_ptr = + reinterpret_cast(wrapper_type_info); + // Check that the lower kIsWrapperTypeBit bits are 0's. + CHECK_EQ( + wrapper_type_info_ptr & ~(static_cast(~0) + << static_cast(kIsWrapperTypeBit)), + 0u); + // TODO(mslekova): Refactor the manual bit manipulations to use + // PointerWithPayload instead. + return CTypeInfo(wrapper_type_info_ptr | static_cast(flags) | + kIsWrapperTypeBit); + } + + static constexpr CTypeInfo FromCType(Type ctype, + ArgFlags flags = ArgFlags::kNone) { + // ctype cannot be Type::kUnwrappedApiObject. + return CTypeInfo( + ((static_cast(ctype) << kTypeOffset) & kTypeMask) | + static_cast(flags)); + } + + const void* GetWrapperInfo() const; + + constexpr Type GetType() const { + if (payload_ & kIsWrapperTypeBit) { + return Type::kUnwrappedApiObject; + } + return static_cast((payload_ & kTypeMask) >> kTypeOffset); + } + + constexpr bool IsArray() const { + return payload_ & static_cast(ArgFlags::kIsArrayBit); + } + + private: + explicit constexpr CTypeInfo(uintptr_t payload) : payload_(payload) {} + + // That must be the last bit after ArgFlags. + static constexpr uintptr_t kIsWrapperTypeBit = 1 << 1; + static constexpr uintptr_t kWrapperTypeInfoMask = static_cast(~0) + << 2; + + static constexpr unsigned int kTypeOffset = kIsWrapperTypeBit; + static constexpr unsigned int kTypeSize = 8 - kTypeOffset; + static constexpr uintptr_t kTypeMask = + (~(static_cast(~0) << kTypeSize)) << kTypeOffset; + + const uintptr_t payload_; +}; + +class CFunctionInfo { + public: + virtual const CTypeInfo& ReturnInfo() const = 0; + virtual unsigned int ArgumentCount() const = 0; + virtual const CTypeInfo& ArgumentInfo(unsigned int index) const = 0; +}; + +template +class WrapperTraits { + public: + static const void* GetTypeInfo() { + static_assert(sizeof(T) != sizeof(T), + "WrapperTraits must be specialized for this type."); + return nullptr; + } +}; + +namespace internal { + +template +struct GetCType { + static_assert(sizeof(T) != sizeof(T), "Unsupported CType"); +}; + +#define SPECIALIZE_GET_C_TYPE_FOR(ctype, ctypeinfo) \ + template <> \ + struct GetCType { \ + static constexpr CTypeInfo Get() { \ + return CTypeInfo::FromCType(CTypeInfo::Type::ctypeinfo); \ + } \ + }; + +#define SUPPORTED_C_TYPES(V) \ + V(void, kVoid) \ + V(bool, kBool) \ + V(int32_t, kInt32) \ + V(uint32_t, kUint32) \ + V(int64_t, kInt64) \ + V(uint64_t, kUint64) \ + V(float, kFloat32) \ + V(double, kFloat64) + +SUPPORTED_C_TYPES(SPECIALIZE_GET_C_TYPE_FOR) + +template +struct EnableIfHasWrapperTypeInfo {}; + +template +struct EnableIfHasWrapperTypeInfo::GetTypeInfo(), + void())> { + typedef void type; +}; + +// T* where T is a primitive (array of primitives). +template +struct GetCTypePointerImpl { + static constexpr CTypeInfo Get() { + return CTypeInfo::FromCType(GetCType::Get().GetType(), + CTypeInfo::ArgFlags::kIsArrayBit); + } +}; + +// T* where T is an API object. +template +struct GetCTypePointerImpl::type> { + static constexpr CTypeInfo Get() { + return CTypeInfo::FromWrapperType(WrapperTraits::GetTypeInfo()); + } +}; + +// T** where T is a primitive. Not allowed. +template +struct GetCTypePointerPointerImpl { + static_assert(sizeof(T**) != sizeof(T**), "Unsupported type"); +}; + +// T** where T is an API object (array of API objects). +template +struct GetCTypePointerPointerImpl< + T, typename EnableIfHasWrapperTypeInfo::type> { + static constexpr CTypeInfo Get() { + return CTypeInfo::FromWrapperType(WrapperTraits::GetTypeInfo(), + CTypeInfo::ArgFlags::kIsArrayBit); + } +}; + +template +struct GetCType : public GetCTypePointerPointerImpl {}; + +template +struct GetCType : public GetCTypePointerImpl {}; + +template +class CFunctionInfoImpl : public CFunctionInfo { + public: + CFunctionInfoImpl() + : return_info_(internal::GetCType::Get()), + arg_count_(sizeof...(Args)), + arg_info_{internal::GetCType::Get()...} { + static_assert( + internal::GetCType::Get().GetType() == CTypeInfo::Type::kVoid, + "Only void return types are currently supported."); + } + + const CTypeInfo& ReturnInfo() const override { return return_info_; } + unsigned int ArgumentCount() const override { return arg_count_; } + const CTypeInfo& ArgumentInfo(unsigned int index) const override { + CHECK_LT(index, ArgumentCount()); + return arg_info_[index]; + } + + private: + CTypeInfo return_info_; + const unsigned int arg_count_; + CTypeInfo arg_info_[sizeof...(Args)]; +}; + +} // namespace internal + +class V8_EXPORT CFunction { + public: + constexpr CFunction() : address_(nullptr), type_info_(nullptr) {} + + const CTypeInfo& ReturnInfo() const { return type_info_->ReturnInfo(); } + + const CTypeInfo& ArgumentInfo(unsigned int index) const { + return type_info_->ArgumentInfo(index); + } + + unsigned int ArgumentCount() const { return type_info_->ArgumentCount(); } + + const void* GetAddress() const { return address_; } + const CFunctionInfo* GetTypeInfo() const { return type_info_; } + + template + static CFunction Make(F* func) { + return ArgUnwrap::Make(func); + } + + private: + const void* address_; + const CFunctionInfo* type_info_; + + CFunction(const void* address, const CFunctionInfo* type_info); + + template + static CFunctionInfo* GetCFunctionInfo() { + static internal::CFunctionInfoImpl instance; + return &instance; + } + + template + class ArgUnwrap { + static_assert(sizeof(F) != sizeof(F), + "CFunction must be created from a function pointer."); + }; + + template + class ArgUnwrap { + public: + static CFunction Make(R (*func)(Args...)) { + return CFunction(reinterpret_cast(func), + GetCFunctionInfo()); + } + }; +}; + +} // namespace v8 + +#endif // INCLUDE_V8_FAST_API_CALLS_H_ diff --git a/deps/nodejs/deps/v8/include/v8-inspector-protocol.h b/deps/nodejs/deps/v8/include/v8-inspector-protocol.h index 612a2ebc..a5ffb7d6 100644 --- a/deps/nodejs/deps/v8/include/v8-inspector-protocol.h +++ b/deps/nodejs/deps/v8/include/v8-inspector-protocol.h @@ -5,9 +5,9 @@ #ifndef V8_V8_INSPECTOR_PROTOCOL_H_ #define V8_V8_INSPECTOR_PROTOCOL_H_ -#include "inspector/Debugger.h" // NOLINT(build/include) -#include "inspector/Runtime.h" // NOLINT(build/include) -#include "inspector/Schema.h" // NOLINT(build/include) -#include "v8-inspector.h" // NOLINT(build/include) +#include "inspector/Debugger.h" // NOLINT(build/include_directory) +#include "inspector/Runtime.h" // NOLINT(build/include_directory) +#include "inspector/Schema.h" // NOLINT(build/include_directory) +#include "v8-inspector.h" // NOLINT(build/include_directory) #endif // V8_V8_INSPECTOR_PROTOCOL_H_ diff --git a/deps/nodejs/deps/v8/include/v8-inspector.h b/deps/nodejs/deps/v8/include/v8-inspector.h index 70201358..6573940e 100644 --- a/deps/nodejs/deps/v8/include/v8-inspector.h +++ b/deps/nodejs/deps/v8/include/v8-inspector.h @@ -9,8 +9,9 @@ #include #include +#include -#include "v8.h" // NOLINT(build/include) +#include "v8.h" // NOLINT(build/include_directory) namespace v8_inspector { @@ -24,6 +25,7 @@ namespace Runtime { namespace API { class RemoteObject; class StackTrace; +class StackTraceId; } } namespace Schema { @@ -63,15 +65,15 @@ class V8_EXPORT StringView { class V8_EXPORT StringBuffer { public: virtual ~StringBuffer() = default; - virtual const StringView& string() = 0; + virtual StringView string() const = 0; // This method copies contents. - static std::unique_ptr create(const StringView&); + static std::unique_ptr create(StringView); }; class V8_EXPORT V8ContextInfo { public: V8ContextInfo(v8::Local context, int contextGroupId, - const StringView& humanReadableName) + StringView humanReadableName) : context(context), contextGroupId(contextGroupId), humanReadableName(humanReadableName), @@ -87,7 +89,6 @@ class V8_EXPORT V8ContextInfo { static int executionContextId(v8::Local context); - private: // Disallow copying and allocating this one. enum NotNullTagEnum { NotNullLiteral }; void* operator new(size_t) = delete; @@ -110,6 +111,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. @@ -129,35 +132,36 @@ class V8_EXPORT V8InspectorSession { virtual void addInspectedObject(std::unique_ptr) = 0; // Dispatching protocol messages. - static bool canDispatchMethod(const StringView& method); - virtual void dispatchProtocolMessage(const StringView& message) = 0; - virtual std::unique_ptr stateJSON() = 0; + static bool canDispatchMethod(StringView method); + virtual void dispatchProtocolMessage(StringView message) = 0; + virtual std::vector state() = 0; virtual std::vector> supportedDomains() = 0; // Debugger actions. - virtual void schedulePauseOnNextStatement(const StringView& breakReason, - const StringView& breakDetails) = 0; + virtual void schedulePauseOnNextStatement(StringView breakReason, + StringView breakDetails) = 0; virtual void cancelPauseOnNextStatement() = 0; - virtual void breakProgram(const StringView& breakReason, - const StringView& breakDetails) = 0; + virtual void breakProgram(StringView breakReason, + StringView breakDetails) = 0; virtual void setSkipAllPauses(bool) = 0; - virtual void resume() = 0; + virtual void resume(bool setTerminateOnResume = false) = 0; virtual void stepOver() = 0; virtual std::vector> - searchInTextByLines(const StringView& text, const StringView& query, - bool caseSensitive, bool isRegex) = 0; + searchInTextByLines(StringView text, StringView query, bool caseSensitive, + bool isRegex) = 0; // Remote objects. virtual std::unique_ptr wrapObject( - v8::Local, v8::Local, const StringView& groupName, + v8::Local, v8::Local, StringView groupName, bool generatePreview) = 0; virtual bool unwrapObject(std::unique_ptr* error, - const StringView& objectId, v8::Local*, + StringView objectId, v8::Local*, v8::Local*, std::unique_ptr* objectGroup) = 0; - virtual void releaseObjectGroup(const StringView&) = 0; + virtual void releaseObjectGroup(StringView) = 0; + virtual void triggerPreciseCoverageDeltaUpdate(StringView occassion) = 0; }; class V8_EXPORT V8InspectorClient { @@ -228,12 +232,20 @@ class V8_EXPORT V8InspectorClient { struct V8_EXPORT V8StackTraceId { uintptr_t id; std::pair debugger_id; + bool should_pause = false; V8StackTraceId(); + V8StackTraceId(const V8StackTraceId&) = default; V8StackTraceId(uintptr_t id, const std::pair debugger_id); + V8StackTraceId(uintptr_t id, const std::pair debugger_id, + bool should_pause); + explicit V8StackTraceId(StringView); + V8StackTraceId& operator=(const V8StackTraceId&) = default; + V8StackTraceId& operator=(V8StackTraceId&&) noexcept = default; ~V8StackTraceId() = default; bool IsInvalid() const; + std::unique_ptr ToString(); }; class V8_EXPORT V8Inspector { @@ -252,26 +264,26 @@ class V8_EXPORT V8Inspector { virtual void idleFinished() = 0; // Async stack traces instrumentation. - virtual void asyncTaskScheduled(const StringView& taskName, void* task, + virtual void asyncTaskScheduled(StringView taskName, void* task, bool recurring) = 0; virtual void asyncTaskCanceled(void* task) = 0; virtual void asyncTaskStarted(void* task) = 0; virtual void asyncTaskFinished(void* task) = 0; virtual void allAsyncTasksCanceled() = 0; - virtual V8StackTraceId storeCurrentStackTrace( - const StringView& description) = 0; + virtual V8StackTraceId storeCurrentStackTrace(StringView description) = 0; virtual void externalAsyncTaskStarted(const V8StackTraceId& parent) = 0; virtual void externalAsyncTaskFinished(const V8StackTraceId& parent) = 0; // Exceptions instrumentation. - virtual unsigned exceptionThrown( - v8::Local, const StringView& message, - v8::Local exception, const StringView& detailedMessage, - const StringView& url, unsigned lineNumber, unsigned columnNumber, - std::unique_ptr, int scriptId) = 0; + virtual unsigned exceptionThrown(v8::Local, StringView message, + v8::Local exception, + StringView detailedMessage, StringView url, + unsigned lineNumber, unsigned columnNumber, + std::unique_ptr, + int scriptId) = 0; virtual void exceptionRevoked(v8::Local, unsigned exceptionId, - const StringView& message) = 0; + StringView message) = 0; // Connection. class V8_EXPORT Channel { @@ -282,13 +294,32 @@ class V8_EXPORT V8Inspector { virtual void sendNotification(std::unique_ptr message) = 0; virtual void flushProtocolNotifications() = 0; }; - virtual std::unique_ptr connect( - int contextGroupId, Channel*, const StringView& state) = 0; + virtual std::unique_ptr connect(int contextGroupId, + Channel*, + StringView state) = 0; // API methods. virtual std::unique_ptr createStackTrace( v8::Local) = 0; virtual std::unique_ptr captureStackTrace(bool fullStack) = 0; + + // Performance counters. + class V8_EXPORT Counters : public std::enable_shared_from_this { + public: + explicit Counters(v8::Isolate* isolate); + ~Counters(); + const std::unordered_map& getCountersMap() const { + return m_countersMap; + } + + private: + static int* getCounterPtr(const char* name); + + v8::Isolate* m_isolate; + std::unordered_map m_countersMap; + }; + + virtual std::shared_ptr enableCounters() = 0; }; } // namespace v8_inspector diff --git a/deps/nodejs/deps/v8/include/v8-internal.h b/deps/nodejs/deps/v8/include/v8-internal.h index 8e700a4d..127a77db 100644 --- a/deps/nodejs/deps/v8/include/v8-internal.h +++ b/deps/nodejs/deps/v8/include/v8-internal.h @@ -10,8 +10,8 @@ #include #include -#include "v8-version.h" // NOLINT(build/include) -#include "v8config.h" // NOLINT(build/include) +#include "v8-version.h" // NOLINT(build/include_directory) +#include "v8config.h" // NOLINT(build/include_directory) namespace v8 { @@ -48,28 +48,32 @@ const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; template struct SmiTagging; +constexpr intptr_t kIntptrAllBitsSet = intptr_t{-1}; +constexpr uintptr_t kUintptrAllBitsSet = + static_cast(kIntptrAllBitsSet); + // Smi constants for systems where tagged pointer is a 32-bit value. template <> struct SmiTagging<4> { enum { kSmiShiftSize = 0, kSmiValueSize = 31 }; + + static constexpr intptr_t kSmiMinValue = + static_cast(kUintptrAllBitsSet << (kSmiValueSize - 1)); + static constexpr intptr_t kSmiMaxValue = -(kSmiMinValue + 1); + V8_INLINE static int SmiToInt(const internal::Address value) { int shift_bits = kSmiTagSize + kSmiShiftSize; - // Shift down (requires >> to be sign extending). - return static_cast(static_cast(value)) >> shift_bits; + // Truncate and shift down (requires >> to be sign extending). + return static_cast(static_cast(value)) >> shift_bits; } V8_INLINE static constexpr bool IsValidSmi(intptr_t value) { - // To be representable as an tagged small integer, the two - // most-significant bits of 'value' must be either 00 or 11 due to - // sign-extension. To check this we add 01 to the two - // most-significant bits, and check if the most-significant bit is 0. - // - // CAUTION: The original code below: - // bool result = ((value + 0x40000000) & 0x80000000) == 0; - // may lead to incorrect results according to the C language spec, and - // in fact doesn't work correctly with gcc4.1.1 in some cases: The - // compiler may produce undefined results in case of signed integer - // overflow. The computation must be done w/ unsigned ints. - return static_cast(value) + 0x40000000U < 0x80000000U; + // Is value in range [kSmiMinValue, kSmiMaxValue]. + // Use unsigned operations in order to avoid undefined behaviour in case of + // signed integer overflow. + return (static_cast(value) - + static_cast(kSmiMinValue)) <= + (static_cast(kSmiMaxValue) - + static_cast(kSmiMinValue)); } }; @@ -77,6 +81,11 @@ struct SmiTagging<4> { template <> struct SmiTagging<8> { enum { kSmiShiftSize = 31, kSmiValueSize = 32 }; + + static constexpr intptr_t kSmiMinValue = + static_cast(kUintptrAllBitsSet << (kSmiValueSize - 1)); + static constexpr intptr_t kSmiMaxValue = -(kSmiMinValue + 1); + V8_INLINE static int SmiToInt(const internal::Address value) { int shift_bits = kSmiTagSize + kSmiShiftSize; // Shift down and throw away top 32 bits. @@ -97,16 +106,32 @@ const int kApiTaggedSize = kApiInt32Size; const int kApiTaggedSize = kApiSystemPointerSize; #endif +constexpr bool PointerCompressionIsEnabled() { + return kApiTaggedSize != kApiSystemPointerSize; +} + +constexpr bool HeapSandboxIsEnabled() { +#ifdef V8_HEAP_SANDBOX + return true; +#else + return false; +#endif +} + +using ExternalPointer_t = Address; + #ifdef V8_31BIT_SMIS_ON_64BIT_ARCH -typedef SmiTagging PlatformSmiTagging; +using PlatformSmiTagging = SmiTagging; #else -typedef SmiTagging PlatformSmiTagging; +using PlatformSmiTagging = SmiTagging; #endif +// TODO(ishell): Consinder adding kSmiShiftBits = kSmiShiftSize + kSmiTagSize +// since it's used much more often than the inividual constants. const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; -const int kSmiMinValue = (static_cast(-1)) << (kSmiValueSize - 1); -const int kSmiMaxValue = -(kSmiMinValue + 1); +const int kSmiMinValue = static_cast(PlatformSmiTagging::kSmiMinValue); +const int kSmiMaxValue = static_cast(PlatformSmiTagging::kSmiMaxValue); constexpr bool SmiValuesAre31Bits() { return kSmiValueSize == 31; } constexpr bool SmiValuesAre32Bits() { return kSmiValueSize == 32; } @@ -115,6 +140,15 @@ V8_INLINE static constexpr internal::Address IntToSmi(int value) { kSmiTag; } +// {obj} must be the raw tagged pointer representation of a HeapObject +// that's guaranteed to never be in ReadOnlySpace. +V8_EXPORT internal::Isolate* IsolateFromNeverReadOnlySpaceObject(Address obj); + +// Returns if we need to throw when an error occurs. This infers the language +// mode based on the current context and the closure. This returns true if the +// language mode is strict. +V8_EXPORT bool ShouldThrowOnError(v8::internal::Isolate* isolate); + /** * This class exports constants and functionality from within v8 that * is necessary to implement inline functions in the v8 api. Don't @@ -130,12 +164,11 @@ class Internals { 1 * kApiTaggedSize + 2 * kApiInt32Size; static const int kOddballKindOffset = 4 * kApiTaggedSize + kApiDoubleSize; - static const int kForeignAddressOffset = kApiTaggedSize; static const int kJSObjectHeaderSize = 3 * kApiTaggedSize; static const int kFixedArrayHeaderSize = 2 * kApiTaggedSize; static const int kEmbedderDataArrayHeaderSize = 2 * kApiTaggedSize; static const int kEmbedderDataSlotSize = kApiSystemPointerSize; - static const int kNativeContextEmbedderDataOffset = 7 * kApiTaggedSize; + static const int kNativeContextEmbedderDataOffset = 6 * kApiTaggedSize; static const int kFullStringRepresentationMask = 0x0f; static const int kStringEncodingMask = 0x8; static const int kExternalTwoByteRepresentationTag = 0x02; @@ -143,15 +176,22 @@ class Internals { static const uint32_t kNumIsolateDataSlots = 4; + // IsolateData layout guarantees. static const int kIsolateEmbedderDataOffset = 0; static const int kExternalMemoryOffset = kNumIsolateDataSlots * kApiSystemPointerSize; static const int kExternalMemoryLimitOffset = kExternalMemoryOffset + kApiInt64Size; - static const int kExternalMemoryAtLastMarkCompactOffset = + static const int kExternalMemoryLowSinceMarkCompactOffset = kExternalMemoryLimitOffset + kApiInt64Size; + static const int kIsolateFastCCallCallerFpOffset = + kExternalMemoryLowSinceMarkCompactOffset + kApiInt64Size; + static const int kIsolateFastCCallCallerPcOffset = + kIsolateFastCCallCallerFpOffset + kApiSystemPointerSize; + static const int kIsolateStackGuardOffset = + kIsolateFastCCallCallerPcOffset + kApiSystemPointerSize; static const int kIsolateRootsOffset = - kExternalMemoryAtLastMarkCompactOffset + kApiInt64Size; + kIsolateStackGuardOffset + 7 * kApiSystemPointerSize; static const int kUndefinedValueRootIndex = 4; static const int kTheHoleValueRootIndex = 5; @@ -165,12 +205,10 @@ class Internals { static const int kNodeStateMask = 0x7; static const int kNodeStateIsWeakValue = 2; static const int kNodeStateIsPendingValue = 3; - static const int kNodeIsIndependentShift = 3; - static const int kNodeIsActiveShift = 4; static const int kFirstNonstringType = 0x40; static const int kOddballType = 0x43; - static const int kForeignType = 0x47; + static const int kForeignType = 0x46; static const int kJSSpecialApiObjectType = 0x410; static const int kJSApiObjectType = 0x420; static const int kJSObjectType = 0x421; @@ -292,9 +330,9 @@ class Internals { V8_INLINE static internal::Address ReadTaggedPointerField( internal::Address heap_object_ptr, int offset) { #ifdef V8_COMPRESS_POINTERS - int32_t value = ReadRawField(heap_object_ptr, offset); + uint32_t value = ReadRawField(heap_object_ptr, offset); internal::Address root = GetRootFromOnHeapAddress(heap_object_ptr); - return root + static_cast(static_cast(value)); + return root + static_cast(static_cast(value)); #else return ReadRawField(heap_object_ptr, offset); #endif @@ -303,34 +341,61 @@ class Internals { V8_INLINE static internal::Address ReadTaggedSignedField( internal::Address heap_object_ptr, int offset) { #ifdef V8_COMPRESS_POINTERS - int32_t value = ReadRawField(heap_object_ptr, offset); - return static_cast(static_cast(value)); + uint32_t value = ReadRawField(heap_object_ptr, offset); + return static_cast(static_cast(value)); #else return ReadRawField(heap_object_ptr, offset); #endif } + V8_INLINE static internal::Isolate* GetIsolateForHeapSandbox( + internal::Address obj) { +#ifdef V8_HEAP_SANDBOX + return internal::IsolateFromNeverReadOnlySpaceObject(obj); +#else + // Not used in non-sandbox mode. + return nullptr; +#endif + } + + V8_INLINE static internal::Address ReadExternalPointerField( + internal::Isolate* isolate, internal::Address heap_object_ptr, + int offset) { + internal::Address value = ReadRawField
(heap_object_ptr, offset); +#ifdef V8_HEAP_SANDBOX + // We currently have to treat zero as nullptr in embedder slots. + if (value) value = DecodeExternalPointer(isolate, value); +#endif + return value; + } + #ifdef V8_COMPRESS_POINTERS // See v8:7703 or src/ptr-compr.* for details about pointer compression. static constexpr size_t kPtrComprHeapReservationSize = size_t{1} << 32; - static constexpr size_t kPtrComprIsolateRootBias = - kPtrComprHeapReservationSize / 2; static constexpr size_t kPtrComprIsolateRootAlignment = size_t{1} << 32; + // See v8:10391 for details about V8 heap sandbox. + static constexpr uint32_t kExternalPointerSalt = + 0x7fffffff & ~static_cast(kHeapObjectTagMask); + V8_INLINE static internal::Address GetRootFromOnHeapAddress( internal::Address addr) { - return (addr + kPtrComprIsolateRootBias) & - -static_cast(kPtrComprIsolateRootAlignment); + return addr & -static_cast(kPtrComprIsolateRootAlignment); } V8_INLINE static internal::Address DecompressTaggedAnyField( - internal::Address heap_object_ptr, int32_t value) { - internal::Address root_mask = static_cast( - -static_cast(value & kSmiTagMask)); - internal::Address root_or_zero = - root_mask & GetRootFromOnHeapAddress(heap_object_ptr); - return root_or_zero + - static_cast(static_cast(value)); + internal::Address heap_object_ptr, uint32_t value) { + internal::Address root = GetRootFromOnHeapAddress(heap_object_ptr); + return root + static_cast(static_cast(value)); + } + + V8_INLINE static Address DecodeExternalPointer( + const Isolate* isolate, ExternalPointer_t encoded_pointer) { +#ifndef V8_HEAP_SANDBOX + return encoded_pointer; +#else + return encoded_pointer ^ kExternalPointerSalt; +#endif } #endif // V8_COMPRESS_POINTERS }; @@ -358,14 +423,9 @@ V8_INLINE void PerformCastCheck(T* data) { CastCheck::value>::Perform(data); } -// {obj} must be the raw tagged pointer representation of a HeapObject -// that's guaranteed to never be in ReadOnlySpace. -V8_EXPORT internal::Isolate* IsolateFromNeverReadOnlySpaceObject(Address obj); - -// Returns if we need to throw when an error occurs. This infers the language -// mode based on the current context and the closure. This returns true if the -// language mode is strict. -V8_EXPORT bool ShouldThrowOnError(v8::internal::Isolate* isolate); +// A base class for backing stores, which is needed due to vagaries of +// how static casts work with std::shared_ptr. +class BackingStoreBase {}; } // namespace internal } // namespace v8 diff --git a/deps/nodejs/deps/v8/include/v8-platform.h b/deps/nodejs/deps/v8/include/v8-platform.h index 556407d8..bf474f26 100644 --- a/deps/nodejs/deps/v8/include/v8-platform.h +++ b/deps/nodejs/deps/v8/include/v8-platform.h @@ -11,12 +11,34 @@ #include #include -#include "v8config.h" // NOLINT(build/include) +#include "v8config.h" // NOLINT(build/include_directory) namespace v8 { class Isolate; +// Valid priorities supported by the task scheduling infrastructure. +enum class TaskPriority : uint8_t { + /** + * Best effort tasks are not critical for performance of the application. The + * platform implementation should preempt such tasks if higher priority tasks + * arrive. + */ + kBestEffort, + /** + * User visible tasks are long running background tasks that will + * improve performance and memory usage of the application upon completion. + * Example: background compilation and garbage collection. + */ + kUserVisible, + /** + * User blocking tasks are highest priority tasks that block the execution + * thread (e.g. major garbage collection). They must be finished as soon as + * possible. + */ + kUserBlocking, +}; + /** * A Task represents a unit of work. */ @@ -109,11 +131,86 @@ class TaskRunner { TaskRunner() = default; virtual ~TaskRunner() = default; - private: TaskRunner(const TaskRunner&) = delete; TaskRunner& operator=(const TaskRunner&) = delete; }; +/** + * Delegate that's passed to Job's worker task, providing an entry point to + * communicate with the scheduler. + */ +class JobDelegate { + public: + /** + * Returns true if this thread should return from the worker task on the + * current thread ASAP. Workers should periodically invoke ShouldYield (or + * YieldIfNeeded()) as often as is reasonable. + */ + virtual bool ShouldYield() = 0; + + /** + * Notifies the scheduler that max concurrency was increased, and the number + * of worker should be adjusted accordingly. See Platform::PostJob() for more + * details. + */ + virtual void NotifyConcurrencyIncrease() = 0; +}; + +/** + * Handle returned when posting a Job. Provides methods to control execution of + * the posted Job. + */ +class JobHandle { + public: + virtual ~JobHandle() = default; + + /** + * Notifies the scheduler that max concurrency was increased, and the number + * of worker should be adjusted accordingly. See Platform::PostJob() for more + * details. + */ + virtual void NotifyConcurrencyIncrease() = 0; + + /** + * Contributes to the job on this thread. Doesn't return until all tasks have + * completed and max concurrency becomes 0. When Join() is called and max + * concurrency reaches 0, it should not increase again. This also promotes + * this Job's priority to be at least as high as the calling thread's + * priority. + */ + virtual void Join() = 0; + + /** + * Forces all existing workers to yield ASAP. Waits until they have all + * returned from the Job's callback before returning. + */ + virtual void Cancel() = 0; + + /** + * Returns true if associated with a Job and other methods may be called. + * Returns false after Join() or Cancel() was called. + */ + virtual bool IsRunning() = 0; +}; + +/** + * A JobTask represents work to run in parallel from Platform::PostJob(). + */ +class JobTask { + public: + virtual ~JobTask() = default; + + virtual void Run(JobDelegate* delegate) = 0; + + /** + * Controls the maximum number of threads calling Run() concurrently. Run() is + * only invoked if the number of threads previously running Run() was less + * than the value returned. Since GetMaxConcurrency() is a leaf function, it + * must not call back any JobHandle methods. + */ + virtual size_t GetMaxConcurrency() const = 0; +}; + /** * The interface represents complex arguments to trace events. */ @@ -327,7 +424,8 @@ class Platform { /** * Returns a TaskRunner which can be used to post a task on the foreground. - * This function should only be called from a foreground thread. + * The TaskRunner's NonNestableTasksEnabled() must be true. This function + * should only be called from a foreground thread. */ virtual std::shared_ptr GetForegroundTaskRunner( Isolate* isolate) = 0; @@ -363,48 +461,70 @@ class Platform { virtual void CallDelayedOnWorkerThread(std::unique_ptr task, double delay_in_seconds) = 0; - /** - * Schedules a task to be invoked on a foreground thread wrt a specific - * |isolate|. Tasks posted for the same isolate should be execute in order of - * scheduling. The definition of "foreground" is opaque to V8. - */ - V8_DEPRECATE_SOON( - "Use a taskrunner acquired by GetForegroundTaskRunner instead.", - virtual void CallOnForegroundThread(Isolate* isolate, Task* task)) = 0; - - /** - * Schedules a task to be invoked on a foreground thread wrt a specific - * |isolate| after the given number of seconds |delay_in_seconds|. - * Tasks posted for the same isolate should be execute in order of - * scheduling. The definition of "foreground" is opaque to V8. - */ - V8_DEPRECATE_SOON( - "Use a taskrunner acquired by GetForegroundTaskRunner instead.", - virtual void CallDelayedOnForegroundThread(Isolate* isolate, Task* task, - double delay_in_seconds)) = 0; - - /** - * Schedules a task to be invoked on a foreground thread wrt a specific - * |isolate| when the embedder is idle. - * Requires that SupportsIdleTasks(isolate) is true. - * Idle tasks may be reordered relative to other task types and may be - * starved for an arbitrarily long time if no idle time is available. - * The definition of "foreground" is opaque to V8. - */ - V8_DEPRECATE_SOON( - "Use a taskrunner acquired by GetForegroundTaskRunner instead.", - virtual void CallIdleOnForegroundThread(Isolate* isolate, - IdleTask* task)) { - // This must be overriden if |IdleTasksEnabled()|. - abort(); - } - /** * Returns true if idle tasks are enabled for the given |isolate|. */ - virtual bool IdleTasksEnabled(Isolate* isolate) { - return false; - } + virtual bool IdleTasksEnabled(Isolate* isolate) { return false; } + + /** + * Posts |job_task| to run in parallel. Returns a JobHandle associated with + * the Job, which can be joined or canceled. + * This avoids degenerate cases: + * - Calling CallOnWorkerThread() for each work item, causing significant + * overhead. + * - Fixed number of CallOnWorkerThread() calls that split the work and might + * run for a long time. This is problematic when many components post + * "num cores" tasks and all expect to use all the cores. In these cases, + * the scheduler lacks context to be fair to multiple same-priority requests + * and/or ability to request lower priority work to yield when high priority + * work comes in. + * A canonical implementation of |job_task| looks like: + * class MyJobTask : public JobTask { + * public: + * MyJobTask(...) : worker_queue_(...) {} + * // JobTask: + * void Run(JobDelegate* delegate) override { + * while (!delegate->ShouldYield()) { + * // Smallest unit of work. + * auto work_item = worker_queue_.TakeWorkItem(); // Thread safe. + * if (!work_item) return; + * ProcessWork(work_item); + * } + * } + * + * size_t GetMaxConcurrency() const override { + * return worker_queue_.GetSize(); // Thread safe. + * } + * }; + * auto handle = PostJob(TaskPriority::kUserVisible, + * std::make_unique(...)); + * handle->Join(); + * + * PostJob() and methods of the returned JobHandle/JobDelegate, must never be + * called while holding a lock that could be acquired by JobTask::Run or + * JobTask::GetMaxConcurrency -- that could result in a deadlock. This is + * because [1] JobTask::GetMaxConcurrency may be invoked while holding + * internal lock (A), hence JobTask::GetMaxConcurrency can only use a lock (B) + * if that lock is *never* held while calling back into JobHandle from any + * thread (A=>B/B=>A deadlock) and [2] JobTask::Run or + * JobTask::GetMaxConcurrency may be invoked synchronously from JobHandle + * (B=>JobHandle::foo=>B deadlock). + * + * A sufficient PostJob() implementation that uses the default Job provided in + * libplatform looks like: + * std::unique_ptr PostJob( + * TaskPriority priority, std::unique_ptr job_task) override { + * return std::make_unique( + * std::make_shared( + * this, std::move(job_task), kNumThreads)); + * } + */ + /* This is not available on Node v14.x. + * virtual std::unique_ptr PostJob( + * TaskPriority priority, std::unique_ptr job_task) { + * return nullptr; + * } + */ /** * Monotonically increasing time in seconds from an arbitrary fixed point in diff --git a/deps/nodejs/deps/v8/include/v8-profiler.h b/deps/nodejs/deps/v8/include/v8-profiler.h index ada2dbbe..c3b25e8d 100644 --- a/deps/nodejs/deps/v8/include/v8-profiler.h +++ b/deps/nodejs/deps/v8/include/v8-profiler.h @@ -5,9 +5,12 @@ #ifndef V8_V8_PROFILER_H_ #define V8_V8_PROFILER_H_ +#include +#include #include #include -#include "v8.h" // NOLINT(build/include) + +#include "v8.h" // NOLINT(build/include_directory) /** * Profiler support for the V8 JavaScript engine. @@ -17,14 +20,18 @@ namespace v8 { class HeapGraphNode; struct HeapStatsUpdate; -typedef uint32_t SnapshotObjectId; - +using NativeObject = void*; +using SnapshotObjectId = uint32_t; struct CpuProfileDeoptFrame { int script_id; size_t position; }; +namespace internal { +class CpuProfile; +} // namespace internal + } // namespace v8 #ifdef V8_OS_WIN @@ -47,75 +54,6 @@ template class V8_EXPORT std::vector; namespace v8 { -// TickSample captures the information collected for each sample. -struct TickSample { - // Internal profiling (with --prof + tools/$OS-tick-processor) wants to - // include the runtime function we're calling. Externally exposed tick - // samples don't care. - enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame }; - - TickSample() - : state(OTHER), - pc(nullptr), - external_callback_entry(nullptr), - frames_count(0), - has_external_callback(false), - update_stats(true) {} - - /** - * Initialize a tick sample from the isolate. - * \param isolate The isolate. - * \param state Execution state. - * \param record_c_entry_frame Include or skip the runtime function. - * \param update_stats Whether update the sample to the aggregated stats. - * \param use_simulator_reg_state When set to true and V8 is running under a - * simulator, the method will use the simulator - * register state rather than the one provided - * with |state| argument. Otherwise the method - * will use provided register |state| as is. - */ - void Init(Isolate* isolate, const v8::RegisterState& state, - RecordCEntryFrame record_c_entry_frame, bool update_stats, - bool use_simulator_reg_state = true); - /** - * Get a call stack sample from the isolate. - * \param isolate The isolate. - * \param state Register state. - * \param record_c_entry_frame Include or skip the runtime function. - * \param frames Caller allocated buffer to store stack frames. - * \param frames_limit Maximum number of frames to capture. The buffer must - * be large enough to hold the number of frames. - * \param sample_info The sample info is filled up by the function - * provides number of actual captured stack frames and - * the current VM state. - * \param use_simulator_reg_state When set to true and V8 is running under a - * simulator, the method will use the simulator - * register state rather than the one provided - * with |state| argument. Otherwise the method - * will use provided register |state| as is. - * \note GetStackSample is thread and signal safe and should only be called - * when the JS thread is paused or interrupted. - * Otherwise the behavior is undefined. - */ - static bool GetStackSample(Isolate* isolate, v8::RegisterState* state, - RecordCEntryFrame record_c_entry_frame, - void** frames, size_t frames_limit, - v8::SampleInfo* sample_info, - bool use_simulator_reg_state = true); - StateTag state; // The state of the VM. - void* pc; // Instruction pointer. - union { - void* tos; // Top stack value (*sp). - void* external_callback_entry; - }; - static const unsigned kMaxFramesCountLog2 = 8; - static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; - void* stack[kMaxFramesCount]; // Call stack. - unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames. - bool has_external_callback : 1; - bool update_stats : 1; // Whether the sample should update aggregated stats. -}; - /** * CpuProfileNode represents a node in a call graph. */ @@ -129,6 +67,20 @@ class V8_EXPORT CpuProfileNode { unsigned int hit_count; }; + // An annotation hinting at the source of a CpuProfileNode. + enum SourceType { + // User-supplied script with associated resource information. + kScript = 0, + // Native scripts and provided builtins. + kBuiltin = 1, + // Callbacks into native code. + kCallback = 2, + // VM-internal functions or state. + kInternal = 3, + // A node that failed to symbolize. + kUnresolved = 4, + }; + /** Returns function name (empty string for anonymous functions.) */ Local GetFunctionName() const; @@ -152,6 +104,12 @@ class V8_EXPORT CpuProfileNode { */ const char* GetScriptResourceNameStr() const; + /** + * Return true if the script from where the function originates is flagged as + * being shared cross-origin. + */ + bool IsScriptSharedCrossOrigin() const; + /** * Returns the number, 1-based, of the line where the function originates. * kNoLineNumberInfo if no line number information is available. @@ -186,20 +144,23 @@ class V8_EXPORT CpuProfileNode { */ unsigned GetHitCount() const; - /** Returns function entry UID. */ - V8_DEPRECATE_SOON( - "Use GetScriptId, GetLineNumber, and GetColumnNumber instead.", - unsigned GetCallUid() const); - /** Returns id of the node. The id is unique within the tree */ unsigned GetNodeId() const; + /** + * Gets the type of the source which the node was captured from. + */ + SourceType GetSourceType() const; + /** Returns child nodes count of the node. */ int GetChildrenCount() const; /** Retrieves a child node by index. */ const CpuProfileNode* GetChild(int index) const; + /** Retrieves the ancestor node, or null if the root. */ + const CpuProfileNode* GetParent() const; + /** Retrieves deopt infos for the node. */ const std::vector& GetDeoptInfos() const; @@ -269,6 +230,66 @@ enum CpuProfilingMode { kCallerLineNumbers, }; +// Determines how names are derived for functions sampled. +enum CpuProfilingNamingMode { + // Use the immediate name of functions at compilation time. + kStandardNaming, + // Use more verbose naming for functions without names, inferred from scope + // where possible. + kDebugNaming, +}; + +enum CpuProfilingLoggingMode { + // Enables logging when a profile is active, and disables logging when all + // profiles are detached. + kLazyLogging, + // Enables logging for the lifetime of the CpuProfiler. Calls to + // StartRecording are faster, at the expense of runtime overhead. + kEagerLogging, +}; + +/** + * Optional profiling attributes. + */ +class V8_EXPORT CpuProfilingOptions { + public: + // Indicates that the sample buffer size should not be explicitly limited. + static const unsigned kNoSampleLimit = UINT_MAX; + + /** + * \param mode Type of computation of stack frame line numbers. + * \param max_samples The maximum number of samples that should be recorded by + * the profiler. Samples obtained after this limit will be + * discarded. + * \param sampling_interval_us controls the profile-specific target + * sampling interval. The provided sampling + * interval will be snapped to the next lowest + * non-zero multiple of the profiler's sampling + * interval, set via SetSamplingInterval(). If + * zero, the sampling interval will be equal to + * the profiler's sampling interval. + */ + CpuProfilingOptions( + CpuProfilingMode mode = kLeafNodeLineNumbers, + unsigned max_samples = kNoSampleLimit, int sampling_interval_us = 0, + MaybeLocal filter_context = MaybeLocal()); + + CpuProfilingMode mode() const { return mode_; } + unsigned max_samples() const { return max_samples_; } + int sampling_interval_us() const { return sampling_interval_us_; } + + private: + friend class internal::CpuProfile; + + bool has_filter_context() const { return !filter_context_.IsEmpty(); } + void* raw_filter_context() const; + + CpuProfilingMode mode_; + unsigned max_samples_; + int sampling_interval_us_; + CopyablePersistentTraits::CopyablePersistent filter_context_; +}; + /** * Interface for controlling CPU profiling. Instance of the * profiler can be created using v8::CpuProfiler::New method. @@ -280,7 +301,9 @@ class V8_EXPORT CpuProfiler { * initialized. The profiler object must be disposed after use by calling * |Dispose| method. */ - static CpuProfiler* New(Isolate* isolate); + static CpuProfiler* New(Isolate* isolate, + CpuProfilingNamingMode = kDebugNaming, + CpuProfilingLoggingMode = kLazyLogging); /** * Synchronously collect current stack sample in all profilers attached to @@ -302,18 +325,35 @@ class V8_EXPORT CpuProfiler { void SetSamplingInterval(int us); /** - * Starts collecting CPU profile. Title may be an empty string. It - * is allowed to have several profiles being collected at - * once. Attempts to start collecting several profiles with the same - * title are silently ignored. While collecting a profile, functions - * from all security contexts are included in it. The token-based - * filtering is only performed when querying for a profile. + * Sets whether or not the profiler should prioritize consistency of sample + * periodicity on Windows. Disabling this can greatly reduce CPU usage, but + * may result in greater variance in sample timings from the platform's + * scheduler. Defaults to enabled. This method must be called when there are + * no profiles being recorded. + */ + void SetUsePreciseSampling(bool); + + /** + * Starts collecting a CPU profile. Title may be an empty string. Several + * profiles may be collected at once. Attempts to start collecting several + * profiles with the same title are silently ignored. + */ + void StartProfiling(Local title, CpuProfilingOptions options); + + /** + * Starts profiling with the same semantics as above, except with expanded + * parameters. * * |record_samples| parameter controls whether individual samples should * be recorded in addition to the aggregated tree. + * + * |max_samples| controls the maximum number of samples that should be + * recorded by the profiler. Samples obtained after this limit will be + * discarded. */ - void StartProfiling(Local title, CpuProfilingMode mode, - bool record_samples = false); + void StartProfiling( + Local title, CpuProfilingMode mode, bool record_samples = false, + unsigned max_samples = CpuProfilingOptions::kNoSampleLimit); /** * The same as StartProfiling above, but the CpuProfilingMode defaults to * kLeafNodeLineNumbers mode, which was the previous default behavior of the @@ -327,20 +367,6 @@ class V8_EXPORT CpuProfiler { */ CpuProfile* StopProfiling(Local title); - /** - * Force collection of a sample. Must be called on the VM thread. - * Recording the forced sample does not contribute to the aggregated - * profile statistics. - */ - V8_DEPRECATED("Use static CollectSample(Isolate*) instead.", - void CollectSample()); - - /** - * Tells the profiler whether the embedder is idle. - */ - V8_DEPRECATED("Use Isolate::SetIdle(bool) instead.", - void SetIdle(bool is_idle)); - /** * Generate more detailed source positions to code objects. This results in * better results when mapping profiling samples to script source. @@ -354,7 +380,6 @@ class V8_EXPORT CpuProfiler { CpuProfiler& operator=(const CpuProfiler&); }; - /** * HeapSnapshotEdge represents a directed connection between heap * graph nodes: from retainers to retained nodes. @@ -705,7 +730,12 @@ class V8_EXPORT EmbedderGraph { */ virtual const char* NamePrefix() { return nullptr; } - private: + /** + * Returns the NativeObject that can be used for querying the + * |HeapSnapshot|. + */ + virtual NativeObject GetNativeObject() { return nullptr; } + Node(const Node&) = delete; Node& operator=(const Node&) = delete; }; @@ -768,6 +798,12 @@ class V8_EXPORT HeapProfiler { */ SnapshotObjectId GetObjectId(Local value); + /** + * Returns SnapshotObjectId for a native object referenced by |value| if it + * has been seen by the heap profiler, kUnknownObjectId otherwise. + */ + SnapshotObjectId GetObjectId(NativeObject value); + /** * Returns heap object with given SnapshotObjectId if the object is alive, * otherwise empty handle is returned. @@ -808,7 +844,8 @@ class V8_EXPORT HeapProfiler { */ const HeapSnapshot* TakeHeapSnapshot( ActivityControl* control = nullptr, - ObjectNameResolver* global_object_name_resolver = nullptr); + ObjectNameResolver* global_object_name_resolver = nullptr, + bool treat_global_objects_as_roots = true); /** * Starts tracking of heap objects population statistics. After calling @@ -936,7 +973,8 @@ struct HeapStatsUpdate { V(LazyCompile) \ V(RegExp) \ V(Script) \ - V(Stub) + V(Stub) \ + V(Relocation) /** * Note that this enum may be extended in the future. Please include a default @@ -969,10 +1007,12 @@ class V8_EXPORT CodeEvent { const char* GetComment(); static const char* GetCodeEventTypeName(CodeEventType code_event_type); + + uintptr_t GetPreviousCodeStartAddress(); }; /** - * Interface to listen to code creation events. + * Interface to listen to code creation and code relocation events. */ class V8_EXPORT CodeEventHandler { public: @@ -984,9 +1024,26 @@ class V8_EXPORT CodeEventHandler { explicit CodeEventHandler(Isolate* isolate); virtual ~CodeEventHandler(); + /** + * Handle is called every time a code object is created or moved. Information + * about each code event will be available through the `code_event` + * parameter. + * + * When the CodeEventType is kRelocationType, the code for this CodeEvent has + * moved from `GetPreviousCodeStartAddress()` to `GetCodeStartAddress()`. + */ virtual void Handle(CodeEvent* code_event) = 0; + /** + * Call `Enable()` to starts listening to code creation and code relocation + * events. These events will be handled by `Handle()`. + */ void Enable(); + + /** + * Call `Disable()` to stop listening to code creation and code relocation + * events. + */ void Disable(); private: diff --git a/deps/nodejs/deps/v8/include/v8-util.h b/deps/nodejs/deps/v8/include/v8-util.h index 24962607..89ec4f6a 100644 --- a/deps/nodejs/deps/v8/include/v8-util.h +++ b/deps/nodejs/deps/v8/include/v8-util.h @@ -5,7 +5,7 @@ #ifndef V8_UTIL_H_ #define V8_UTIL_H_ -#include "v8.h" // NOLINT(build/include) +#include "v8.h" // NOLINT(build/include_directory) #include #include #include @@ -194,14 +194,6 @@ class PersistentValueMapBase { return SetReturnValueFromVal(&returnValue, Traits::Get(&impl_, key)); } - /** - * Call V8::RegisterExternallyReferencedObject with the map value for given - * key. - */ - V8_DEPRECATED( - "Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference", - inline void RegisterExternallyReferencedObject(K& key)); - /** * Return value for key and remove it from the map. */ @@ -352,16 +344,6 @@ class PersistentValueMapBase { const char* label_; }; -template -inline void -PersistentValueMapBase::RegisterExternallyReferencedObject( - K& key) { - assert(Contains(key)); - V8::RegisterExternallyReferencedObject( - reinterpret_cast(FromVal(Traits::Get(&impl_, key))), - reinterpret_cast(GetIsolate())); -} - template class PersistentValueMap : public PersistentValueMapBase { public: diff --git a/deps/nodejs/deps/v8/include/v8-version-string.h b/deps/nodejs/deps/v8/include/v8-version-string.h index fb84144d..8faed2a7 100644 --- a/deps/nodejs/deps/v8/include/v8-version-string.h +++ b/deps/nodejs/deps/v8/include/v8-version-string.h @@ -5,7 +5,7 @@ #ifndef V8_VERSION_STRING_H_ #define V8_VERSION_STRING_H_ -#include "v8-version.h" // NOLINT(build/include) +#include "v8-version.h" // NOLINT(build/include_directory) // This is here rather than v8-version.h to keep that file simple and // machine-processable. diff --git a/deps/nodejs/deps/v8/include/v8-version.h b/deps/nodejs/deps/v8/include/v8-version.h index 4093306d..cee7990e 100644 --- a/deps/nodejs/deps/v8/include/v8-version.h +++ b/deps/nodejs/deps/v8/include/v8-version.h @@ -8,10 +8,10 @@ // These macros define the version number for the current version. // 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_MAJOR_VERSION 8 #define V8_MINOR_VERSION 4 -#define V8_BUILD_NUMBER 288 -#define V8_PATCH_LEVEL 27 +#define V8_BUILD_NUMBER 371 +#define V8_PATCH_LEVEL 19 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/nodejs/deps/v8/include/v8-wasm-trap-handler-posix.h b/deps/nodejs/deps/v8/include/v8-wasm-trap-handler-posix.h index 998d0a41..9b8e8a5b 100644 --- a/deps/nodejs/deps/v8/include/v8-wasm-trap-handler-posix.h +++ b/deps/nodejs/deps/v8/include/v8-wasm-trap-handler-posix.h @@ -7,7 +7,7 @@ #include -#include "v8config.h" // NOLINT(build/include) +#include "v8config.h" // NOLINT(build/include_directory) namespace v8 { /** diff --git a/deps/nodejs/deps/v8/include/v8-wasm-trap-handler-win.h b/deps/nodejs/deps/v8/include/v8-wasm-trap-handler-win.h index 0185df64..9d3cad58 100644 --- a/deps/nodejs/deps/v8/include/v8-wasm-trap-handler-win.h +++ b/deps/nodejs/deps/v8/include/v8-wasm-trap-handler-win.h @@ -7,7 +7,7 @@ #include -#include "v8config.h" // NOLINT(build/include) +#include "v8config.h" // NOLINT(build/include_directory) namespace v8 { /** diff --git a/deps/nodejs/deps/v8/include/v8.h b/deps/nodejs/deps/v8/include/v8.h index 7e48cd42..fe31e4ca 100644 --- a/deps/nodejs/deps/v8/include/v8.h +++ b/deps/nodejs/deps/v8/include/v8.h @@ -9,7 +9,7 @@ * This set of documents provides reference material generated from the * V8 header file, include/v8.h. * - * For other documentation see http://code.google.com/apis/v8/ + * For other documentation see https://v8.dev/. */ #ifndef INCLUDE_V8_H_ @@ -18,13 +18,17 @@ #include #include #include + #include +#include +#include #include #include -#include "v8-internal.h" // NOLINT(build/include) -#include "v8-version.h" // NOLINT(build/include) -#include "v8config.h" // NOLINT(build/include) +#include "cppgc/common.h" +#include "v8-internal.h" // NOLINT(build/include_directory) +#include "v8-version.h" // NOLINT(build/include_directory) +#include "v8config.h" // NOLINT(build/include_directory) // We reserve the V8_* prefix for macros defined in V8 public API and // assume there are no name conflicts with the embedder's code. @@ -95,6 +99,10 @@ template class Global; template class TracedGlobal; +template +class TracedReference; +template +class TracedReferenceBase; template class PersistentValueMap; template class PersistentValueMapBase; @@ -114,21 +122,25 @@ class EscapableHandleScope; template class ReturnValue; namespace internal { +enum class ArgumentsType; +template class Arguments; +template +class CustomArguments; class DeferredHandles; +class FunctionCallbackArguments; +class GlobalHandles; class Heap; class HeapObject; class ExternalString; class Isolate; class LocalEmbedderHeapTracer; class MicrotaskQueue; -class NeverReadOnlySpaceObject; -struct ScriptStreamingData; -template class CustomArguments; class PropertyCallbackArguments; -class FunctionCallbackArguments; -class GlobalHandles; +class ReadOnlyHeap; class ScopedExternalStringLock; +struct ScriptStreamingData; +class ThreadLocalTop; namespace wasm { class NativeModule; @@ -143,11 +155,6 @@ class ConsoleCallArguments; // --- Handles --- -#define TYPE_CHECK(T, S) \ - while (false) { \ - *(static_cast(0)) = static_cast(0); \ - } - /** * An object reference managed by the v8 garbage collector. * @@ -191,7 +198,7 @@ class Local { * handles. For example, converting from a Local to a * Local. */ - TYPE_CHECK(T, S); + static_assert(std::is_base_of::value, "type check"); } /** @@ -210,9 +217,13 @@ class Local { /** * Checks whether two handles are the same. - * Returns true if both are empty, or if the objects - * to which they refer are identical. - * The handles' references are not checked. + * Returns true if both are empty, or if the objects to which they refer + * are identical. + * + * If both handles refer to JS objects, this is the same as strict equality. + * For primitives, such as numbers or strings, a `false` return value does not + * indicate that the values aren't equal in the JavaScript sense. + * Use `Value::StrictEquals()` to check primitives for equality. */ template V8_INLINE bool operator==(const Local& that) const { @@ -236,7 +247,11 @@ class Local { * Checks whether two handles are different. * Returns true if only one of the handles is empty, or if * the objects to which they refer are different. - * The handles' references are not checked. + * + * If both handles refer to JS objects, this is the same as strict + * non-equality. For primitives, such as numbers or strings, a `true` return + * value does not indicate that the values aren't equal in the JavaScript + * sense. Use `Value::StrictEquals()` to check primitives for equality. */ template V8_INLINE bool operator!=(const Local& that) const { @@ -280,7 +295,8 @@ class Local { V8_INLINE static Local New(Isolate* isolate, Local that); V8_INLINE static Local New(Isolate* isolate, const PersistentBase& that); - V8_INLINE static Local New(Isolate* isolate, const TracedGlobal& that); + V8_INLINE static Local New(Isolate* isolate, + const TracedReferenceBase& that); private: friend class Utils; @@ -310,7 +326,13 @@ class Local { template friend class ReturnValue; template + friend class Traced; + template friend class TracedGlobal; + template + friend class TracedReferenceBase; + template + friend class TracedReference; explicit V8_INLINE Local(T* that) : val_(that) {} V8_INLINE static Local New(Isolate* isolate, T* that); @@ -342,7 +364,7 @@ class MaybeLocal { template V8_INLINE MaybeLocal(Local that) : val_(reinterpret_cast(*that)) { - TYPE_CHECK(T, S); + static_assert(std::is_base_of::value, "type check"); } V8_INLINE bool IsEmpty() const { return val_ == nullptr; } @@ -511,11 +533,16 @@ template class PersistentBase { } /** - * Install a finalization callback on this object. - * NOTE: There is no guarantee as to *when* or even *if* the callback is - * invoked. The invocation is performed solely on a best effort basis. - * As always, GC-based finalization should *not* be relied upon for any - * critical form of resource management! + * Install a finalization callback on this object. + * NOTE: There is no guarantee as to *when* or even *if* the callback is + * invoked. The invocation is performed solely on a best effort basis. + * As always, GC-based finalization should *not* be relied upon for any + * critical form of resource management! + * + * The callback is supposed to reset the handle. No further V8 API may be + * called in this callback. In case additional work involving V8 needs to be + * done, a second callback can be scheduled using + * WeakCallbackInfo::SetSecondPassCallback. */ template V8_INLINE void SetWeak(P* parameter, @@ -545,38 +572,6 @@ template class PersistentBase { */ V8_INLINE void AnnotateStrongRetainer(const char* label); - /** - * Allows the embedder to tell the v8 garbage collector that a certain object - * is alive. Only allowed when the embedder is asked to trace its heap by - * EmbedderHeapTracer. - */ - V8_DEPRECATED( - "Used TracedGlobal and EmbedderHeapTracer::RegisterEmbedderReference", - V8_INLINE void RegisterExternalReference(Isolate* isolate) const); - - /** - * Marks the reference to this object independent. Garbage collector is free - * to ignore any object groups containing this object. Weak callback for an - * independent handle should not assume that it will be preceded by a global - * GC prologue callback or followed by a global GC epilogue callback. - */ - V8_DEPRECATED( - "Weak objects are always considered independent. " - "Use TracedGlobal when trying to use EmbedderHeapTracer. " - "Use a strong handle when trying to keep an object alive.", - V8_INLINE void MarkIndependent()); - - /** - * Marks the reference to this object as active. The scavenge garbage - * collection should not reclaim the objects marked as active, even if the - * object held by the handle is otherwise unreachable. - * - * This bit is cleared after the each garbage collection pass. - */ - V8_DEPRECATED("Use TracedGlobal.", V8_INLINE void MarkActive()); - - V8_DEPRECATED("See MarkIndependent.", V8_INLINE bool IsIndependent() const); - /** Returns true if the handle's reference is weak. */ V8_INLINE bool IsWeak() const; @@ -629,11 +624,8 @@ class NonCopyablePersistentTraits { template V8_INLINE static void Copy(const Persistent& source, NonCopyablePersistent* dest) { - Uncompilable(); - } - // TODO(dcarney): come up with a good compile error here. - template V8_INLINE static void Uncompilable() { - TYPE_CHECK(O, Primitive); + static_assert(sizeof(S) < 0, + "NonCopyablePersistentTraits::Copy is not instantiable"); } }; @@ -676,7 +668,7 @@ template class Persistent : public PersistentBase { template V8_INLINE Persistent(Isolate* isolate, Local that) : PersistentBase(PersistentBase::New(isolate, *that)) { - TYPE_CHECK(T, S); + static_assert(std::is_base_of::value, "type check"); } /** * Construct a Persistent from a Persistent. @@ -686,7 +678,7 @@ template class Persistent : public PersistentBase { template V8_INLINE Persistent(Isolate* isolate, const Persistent& that) : PersistentBase(PersistentBase::New(isolate, *that)) { - TYPE_CHECK(T, S); + static_assert(std::is_base_of::value, "type check"); } /** * The copy constructors and assignment operator create a Persistent @@ -771,7 +763,7 @@ class Global : public PersistentBase { template V8_INLINE Global(Isolate* isolate, Local that) : PersistentBase(PersistentBase::New(isolate, *that)) { - TYPE_CHECK(T, S); + static_assert(std::is_base_of::value, "type check"); } /** @@ -782,7 +774,7 @@ class Global : public PersistentBase { template V8_INLINE Global(Isolate* isolate, const PersistentBase& that) : PersistentBase(PersistentBase::New(isolate, that.val_)) { - TYPE_CHECK(T, S); + static_assert(std::is_base_of::value, "type check"); } /** @@ -823,57 +815,32 @@ template using UniquePersistent = Global; /** - * A traced handle with move semantics, similar to std::unique_ptr. The handle - * is to be used together with |v8::EmbedderHeapTracer| and specifies edges from - * the embedder into V8's heap. + * Deprecated. Use |TracedReference| instead. + */ +template +struct TracedGlobalTrait {}; + +/** + * A traced handle with copy and move semantics. The handle is to be used + * together with |v8::EmbedderHeapTracer| and specifies edges from the embedder + * into V8's heap. * * The exact semantics are: * - Tracing garbage collections use |v8::EmbedderHeapTracer|. * - Non-tracing garbage collections refer to * |v8::EmbedderHeapTracer::IsRootForNonTracingGC()| whether the handle should * be treated as root or not. + * + * Note that the base class cannot be instantiated itself. Choose from + * - TracedGlobal + * - TracedReference */ template -class V8_EXPORT TracedGlobal { +class TracedReferenceBase { public: /** - * An empty TracedGlobal without storage cell. - */ - TracedGlobal() = default; - ~TracedGlobal() { Reset(); } - - /** - * Construct a TracedGlobal from a Local. - * - * When the Local is non-empty, a new storage cell is created - * pointing to the same object. - */ - template - TracedGlobal(Isolate* isolate, Local that) - : val_(New(isolate, *that, &val_)) { - TYPE_CHECK(T, S); - } - - /** - * Move constructor initializing TracedGlobal from an existing one. - */ - V8_INLINE TracedGlobal(TracedGlobal&& other); - - /** - * Move assignment operator initializing TracedGlobal from an existing one. - */ - template - V8_INLINE TracedGlobal& operator=(TracedGlobal&& rhs); - - /** - * TracedGlobal only supports move semantics and forbids copying. - */ - TracedGlobal(const TracedGlobal&) = delete; - void operator=(const TracedGlobal&) = delete; - - /** - * Returns true if this TracedGlobal is empty, i.e., has not been assigned an - * object. + * Returns true if this TracedReferenceBase is empty, i.e., has not been + * assigned an object. */ bool IsEmpty() const { return val_ == nullptr; } @@ -883,27 +850,14 @@ class V8_EXPORT TracedGlobal { */ V8_INLINE void Reset(); - /** - * If non-empty, destroy the underlying storage cell and create a new one with - * the contents of other if other is non empty - */ - template - V8_INLINE void Reset(Isolate* isolate, const Local& other); - /** * Construct a Local from this handle. */ Local Get(Isolate* isolate) const { return Local::New(isolate, *this); } template - V8_INLINE TracedGlobal& As() const { - return reinterpret_cast&>( - const_cast&>(*this)); - } - - template - V8_INLINE bool operator==(const TracedGlobal& that) const { - internal::Address* a = reinterpret_cast(this->val_); + V8_INLINE bool operator==(const TracedReferenceBase& that) const { + internal::Address* a = reinterpret_cast(val_); internal::Address* b = reinterpret_cast(that.val_); if (a == nullptr) return b == nullptr; if (b == nullptr) return false; @@ -912,7 +866,7 @@ class V8_EXPORT TracedGlobal { template V8_INLINE bool operator==(const Local& that) const { - internal::Address* a = reinterpret_cast(this->val_); + internal::Address* a = reinterpret_cast(val_); internal::Address* b = reinterpret_cast(that.val_); if (a == nullptr) return b == nullptr; if (b == nullptr) return false; @@ -920,7 +874,7 @@ class V8_EXPORT TracedGlobal { } template - V8_INLINE bool operator!=(const TracedGlobal& that) const { + V8_INLINE bool operator!=(const TracedReferenceBase& that) const { return !operator==(that); } @@ -940,6 +894,144 @@ class V8_EXPORT TracedGlobal { */ V8_INLINE uint16_t WrapperClassId() const; + template + V8_INLINE TracedReferenceBase& As() const { + return reinterpret_cast&>( + const_cast&>(*this)); + } + + private: + enum DestructionMode { kWithDestructor, kWithoutDestructor }; + + /** + * An empty TracedReferenceBase without storage cell. + */ + TracedReferenceBase() = default; + + V8_INLINE static T* New(Isolate* isolate, T* that, void* slot, + DestructionMode destruction_mode); + + T* val_ = nullptr; + + friend class EmbedderHeapTracer; + template + friend class Local; + friend class Object; + template + friend class TracedGlobal; + template + friend class TracedReference; + template + friend class ReturnValue; +}; + +/** + * A traced handle with destructor that clears the handle. For more details see + * TracedReferenceBase. + */ +template +class TracedGlobal : public TracedReferenceBase { + public: + using TracedReferenceBase::Reset; + + /** + * Destructor resetting the handle. + */ + ~TracedGlobal() { this->Reset(); } + + /** + * An empty TracedGlobal without storage cell. + */ + TracedGlobal() : TracedReferenceBase() {} + + /** + * Construct a TracedGlobal from a Local. + * + * When the Local is non-empty, a new storage cell is created + * pointing to the same object. + */ + template + TracedGlobal(Isolate* isolate, Local that) : TracedReferenceBase() { + this->val_ = this->New(isolate, that.val_, &this->val_, + TracedReferenceBase::kWithDestructor); + static_assert(std::is_base_of::value, "type check"); + } + + /** + * Move constructor initializing TracedGlobal from an existing one. + */ + V8_INLINE TracedGlobal(TracedGlobal&& other) { + // Forward to operator=. + *this = std::move(other); + } + + /** + * Move constructor initializing TracedGlobal from an existing one. + */ + template + V8_INLINE TracedGlobal(TracedGlobal&& other) { + // Forward to operator=. + *this = std::move(other); + } + + /** + * Copy constructor initializing TracedGlobal from an existing one. + */ + V8_INLINE TracedGlobal(const TracedGlobal& other) { + // Forward to operator=; + *this = other; + } + + /** + * Copy constructor initializing TracedGlobal from an existing one. + */ + template + V8_INLINE TracedGlobal(const TracedGlobal& other) { + // Forward to operator=; + *this = other; + } + + /** + * Move assignment operator initializing TracedGlobal from an existing one. + */ + V8_INLINE TracedGlobal& operator=(TracedGlobal&& rhs); + + /** + * Move assignment operator initializing TracedGlobal from an existing one. + */ + template + V8_INLINE TracedGlobal& operator=(TracedGlobal&& rhs); + + /** + * Copy assignment operator initializing TracedGlobal from an existing one. + * + * Note: Prohibited when |other| has a finalization callback set through + * |SetFinalizationCallback|. + */ + V8_INLINE TracedGlobal& operator=(const TracedGlobal& rhs); + + /** + * Copy assignment operator initializing TracedGlobal from an existing one. + * + * Note: Prohibited when |other| has a finalization callback set through + * |SetFinalizationCallback|. + */ + template + V8_INLINE TracedGlobal& operator=(const TracedGlobal& rhs); + + /** + * If non-empty, destroy the underlying storage cell and create a new one with + * the contents of other if other is non empty + */ + template + V8_INLINE void Reset(Isolate* isolate, const Local& other); + + template + V8_INLINE TracedGlobal& As() const { + return reinterpret_cast&>( + const_cast&>(*this)); + } + /** * Adds a finalization callback to the handle. The type of this callback is * similar to WeakCallbackType::kInternalFields, i.e., it will pass the @@ -952,20 +1044,114 @@ class V8_EXPORT TracedGlobal { */ V8_INLINE void SetFinalizationCallback( void* parameter, WeakCallbackInfo::Callback callback); +}; - private: - V8_INLINE static T* New(Isolate* isolate, T* that, T** slot); +/** + * A traced handle without destructor that clears the handle. The embedder needs + * to ensure that the handle is not accessed once the V8 object has been + * reclaimed. This can happen when the handle is not passed through the + * EmbedderHeapTracer. For more details see TracedReferenceBase. + * + * The reference assumes the embedder has precise knowledge about references at + * all times. In case V8 needs to separately handle on-stack references, the + * embedder is required to set the stack start through + * |EmbedderHeapTracer::SetStackStart|. + */ +template +class TracedReference : public TracedReferenceBase { + public: + using TracedReferenceBase::Reset; - T* operator*() const { return this->val_; } + /** + * An empty TracedReference without storage cell. + */ + TracedReference() : TracedReferenceBase() {} - T* val_ = nullptr; + /** + * Construct a TracedReference from a Local. + * + * When the Local is non-empty, a new storage cell is created + * pointing to the same object. + */ + template + TracedReference(Isolate* isolate, Local that) : TracedReferenceBase() { + this->val_ = this->New(isolate, that.val_, &this->val_, + TracedReferenceBase::kWithoutDestructor); + static_assert(std::is_base_of::value, "type check"); + } - friend class EmbedderHeapTracer; - template - friend class Local; - friend class Object; - template - friend class ReturnValue; + /** + * Move constructor initializing TracedReference from an + * existing one. + */ + V8_INLINE TracedReference(TracedReference&& other) { + // Forward to operator=. + *this = std::move(other); + } + + /** + * Move constructor initializing TracedReference from an + * existing one. + */ + template + V8_INLINE TracedReference(TracedReference&& other) { + // Forward to operator=. + *this = std::move(other); + } + + /** + * Copy constructor initializing TracedReference from an + * existing one. + */ + V8_INLINE TracedReference(const TracedReference& other) { + // Forward to operator=; + *this = other; + } + + /** + * Copy constructor initializing TracedReference from an + * existing one. + */ + template + V8_INLINE TracedReference(const TracedReference& other) { + // Forward to operator=; + *this = other; + } + + /** + * Move assignment operator initializing TracedGlobal from an existing one. + */ + V8_INLINE TracedReference& operator=(TracedReference&& rhs); + + /** + * Move assignment operator initializing TracedGlobal from an existing one. + */ + template + V8_INLINE TracedReference& operator=(TracedReference&& rhs); + + /** + * Copy assignment operator initializing TracedGlobal from an existing one. + */ + V8_INLINE TracedReference& operator=(const TracedReference& rhs); + + /** + * Copy assignment operator initializing TracedGlobal from an existing one. + */ + template + V8_INLINE TracedReference& operator=(const TracedReference& rhs); + + /** + * If non-empty, destroy the underlying storage cell and create a new one with + * the contents of other if other is non empty + */ + template + V8_INLINE void Reset(Isolate* isolate, const Local& other); + + template + V8_INLINE TracedReference& As() const { + return reinterpret_cast&>( + const_cast&>(*this)); + } }; /** @@ -1099,9 +1285,8 @@ class V8_EXPORT SealHandleScope { // --- Special objects --- - /** - * The superclass of values and API object templates. + * The superclass of objects that can reside on V8's heap. */ class V8_EXPORT Data { private: @@ -1248,7 +1433,7 @@ class V8_EXPORT UnboundScript { /** * A compiled JavaScript module, not yet tied to a Context. */ -class V8_EXPORT UnboundModuleScript { +class V8_EXPORT UnboundModuleScript : public Data { // Only used as a container for code caching. }; @@ -1271,7 +1456,7 @@ class V8_EXPORT Location { /** * A compiled JavaScript module. */ -class V8_EXPORT Module { +class V8_EXPORT Module : public Data { public: /** * The different states a module can be in. @@ -1359,6 +1544,45 @@ 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. An error will be thrown if export_name is not one + * of the export_names that were passed in that CreateSyntheticModule call. + * Returns Just(true) on success, Nothing() if an error was thrown. + */ + V8_WARN_UNUSED_RESULT Maybe SetSyntheticModuleExport( + Isolate* isolate, Local export_name, Local export_value); + V8_DEPRECATE_SOON( + "Use the preceding SetSyntheticModuleExport with an Isolate parameter, " + "instead of the one that follows. The former will throw a runtime " + "error if called for an export that doesn't exist (as per spec); " + "the latter will crash with a failed CHECK().") + void SetSyntheticModuleExport(Local export_name, + Local export_value); }; /** @@ -1532,10 +1756,12 @@ class V8_EXPORT ScriptCompiler { public: enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 }; +#if defined(_MSC_VER) && _MSC_VER >= 1910 /* Disable on VS2015 */ V8_DEPRECATE_SOON( "This class takes ownership of source_stream, so use the constructor " - "taking a unique_ptr to make these semantics clearer", - StreamedSource(ExternalSourceStream* source_stream, Encoding encoding)); + "taking a unique_ptr to make these semantics clearer") +#endif + StreamedSource(ExternalSourceStream* source_stream, Encoding encoding); StreamedSource(std::unique_ptr source_stream, Encoding encoding); ~StreamedSource(); @@ -1701,7 +1927,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. @@ -1784,6 +2011,12 @@ class V8_EXPORT Message { */ int GetEndPosition() const; + /** + * Returns the Wasm function index where the error occurred. Returns -1 if + * message is not from a Wasm script. + */ + int GetWasmFunctionIndex() const; + /** * Returns the error level of the message. */ @@ -1816,6 +2049,7 @@ class V8_EXPORT Message { static const int kNoLineNumberInfo = 0; static const int kNoColumnInfo = 0; static const int kNoScriptIdInfo = 0; + static const int kNoWasmFunctionIndexInfo = -1; }; @@ -1933,6 +2167,11 @@ class V8_EXPORT StackFrame { * Returns whether or not the associated functions is defined in wasm. */ bool IsWasm() const; + + /** + * Returns whether or not the associated function is defined by the user. + */ + bool IsUserJavaScript() const; }; @@ -1945,16 +2184,18 @@ enum StateTag { COMPILER, OTHER, EXTERNAL, + ATOMICS_WAIT, IDLE }; // A RegisterState represents the current state of registers used // by the sampling profiler API. struct RegisterState { - RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr) {} + RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr), lr(nullptr) {} void* pc; // Instruction pointer. void* sp; // Stack pointer. void* fp; // Frame pointer. + void* lr; // Link register (or nullptr on platforms without a link register). }; // The output structure filled up by GetStackSample API function. @@ -1963,6 +2204,7 @@ struct SampleInfo { StateTag vm_state; // Current VM state. void* external_callback_entry; // External callback address if VM is // executing an external callback. + void* top_context; // Incumbent native context address. }; struct MemoryRange { @@ -1978,6 +2220,14 @@ struct UnwindState { MemoryRange code_range; MemoryRange embedded_code_range; JSEntryStub js_entry_stub; + JSEntryStub js_construct_entry_stub; + JSEntryStub js_run_microtasks_entry_stub; +}; + +struct JSEntryStubs { + JSEntryStub js_entry_stub; + JSEntryStub js_construct_entry_stub; + JSEntryStub js_run_microtasks_entry_stub; }; /** @@ -2120,10 +2370,10 @@ class V8_EXPORT ValueSerializer { void WriteDouble(double value); void WriteRawBytes(const void* source, size_t length); - private: ValueSerializer(const ValueSerializer&) = delete; void operator=(const ValueSerializer&) = delete; + private: struct PrivateData; PrivateData* private_; }; @@ -2200,11 +2450,6 @@ class V8_EXPORT ValueDeserializer { */ void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format); - /** - * Expect inline wasm in the data stream (rather than in-memory transfer) - */ - void SetExpectInlineWasm(bool allow_inline_wasm); - /** * Reads the underlying wire format version. Likely mostly to be useful to * legacy code reading old wire format versions. Must be called after @@ -2222,10 +2467,10 @@ class V8_EXPORT ValueDeserializer { V8_WARN_UNUSED_RESULT bool ReadDouble(double* value); V8_WARN_UNUSED_RESULT bool ReadRawBytes(size_t length, const void** data); - private: ValueDeserializer(const ValueDeserializer&) = delete; void operator=(const ValueDeserializer&) = delete; + private: struct PrivateData; PrivateData* private_; }; @@ -2242,12 +2487,16 @@ class V8_EXPORT Value : public Data { /** * Returns true if this value is the undefined value. See ECMA-262 * 4.3.10. + * + * This is equivalent to `value === undefined` in JS. */ V8_INLINE bool IsUndefined() const; /** * Returns true if this value is the null value. See ECMA-262 * 4.3.11. + * + * This is equivalent to `value === null` in JS. */ V8_INLINE bool IsNull() const; @@ -2255,37 +2504,56 @@ class V8_EXPORT Value : public Data { * Returns true if this value is either the null or the undefined value. * See ECMA-262 * 4.3.11. and 4.3.12 + * + * This is equivalent to `value == null` in JS. */ V8_INLINE bool IsNullOrUndefined() const; /** - * Returns true if this value is true. - */ + * Returns true if this value is true. + * + * This is not the same as `BooleanValue()`. The latter performs a + * conversion to boolean, i.e. the result of `Boolean(value)` in JS, whereas + * this checks `value === true`. + */ bool IsTrue() const; /** * Returns true if this value is false. + * + * This is not the same as `!BooleanValue()`. The latter performs a + * conversion to boolean, i.e. the result of `!Boolean(value)` in JS, whereas + * this checks `value === false`. */ bool IsFalse() const; /** * Returns true if this value is a symbol or a string. + * + * This is equivalent to + * `typeof value === 'string' || typeof value === 'symbol'` in JS. */ bool IsName() const; /** * Returns true if this value is an instance of the String type. * See ECMA-262 8.4. + * + * This is equivalent to `typeof value === 'string'` in JS. */ V8_INLINE bool IsString() const; /** * Returns true if this value is a symbol. + * + * This is equivalent to `typeof value === 'symbol'` in JS. */ bool IsSymbol() const; /** * Returns true if this value is a function. + * + * This is equivalent to `typeof value === 'function'` in JS. */ bool IsFunction() const; @@ -2302,21 +2570,27 @@ class V8_EXPORT Value : public Data { /** * Returns true if this value is a bigint. + * + * This is equivalent to `typeof value === 'bigint'` in JS. */ bool IsBigInt() const; /** * Returns true if this value is boolean. + * + * This is equivalent to `typeof value === 'boolean'` in JS. */ bool IsBoolean() const; /** * Returns true if this value is a number. + * + * This is equivalent to `typeof value === 'number'` in JS. */ bool IsNumber() const; /** - * Returns true if this value is external. + * Returns true if this value is an `External` object. */ bool IsExternal() const; @@ -2502,7 +2776,6 @@ class V8_EXPORT Value : public Data { /** * Returns true if this value is a SharedArrayBuffer. - * This is an experimental feature. */ bool IsSharedArrayBuffer() const; @@ -2511,43 +2784,68 @@ class V8_EXPORT Value : public Data { */ bool IsProxy() const; - bool IsWebAssemblyCompiledModule() const; + /** + * Returns true if this value is a WasmModuleObject. + */ + bool IsWasmModuleObject() const; /** * Returns true if the value is a Module Namespace Object. */ bool IsModuleNamespaceObject() const; + /** + * Perform the equivalent of `BigInt(value)` in JS. + */ V8_WARN_UNUSED_RESULT MaybeLocal ToBigInt( Local context) const; - V8_DEPRECATE_SOON("ToBoolean can never throw. Use Local version.", - V8_WARN_UNUSED_RESULT MaybeLocal ToBoolean( - Local context) const); + /** + * Perform the equivalent of `Number(value)` in JS. + */ V8_WARN_UNUSED_RESULT MaybeLocal ToNumber( Local context) const; + /** + * Perform the equivalent of `String(value)` in JS. + */ V8_WARN_UNUSED_RESULT MaybeLocal ToString( Local context) const; + /** + * Provide a string representation of this value usable for debugging. + * This operation has no observable side effects and will succeed + * unless e.g. execution is being terminated. + */ V8_WARN_UNUSED_RESULT MaybeLocal ToDetailString( Local context) const; + /** + * Perform the equivalent of `Object(value)` in JS. + */ V8_WARN_UNUSED_RESULT MaybeLocal ToObject( Local context) const; + /** + * Perform the equivalent of `Number(value)` in JS and convert the result + * to an integer. Negative values are rounded up, positive values are rounded + * down. NaN is converted to 0. Infinite values yield undefined results. + */ V8_WARN_UNUSED_RESULT MaybeLocal ToInteger( Local context) const; + /** + * Perform the equivalent of `Number(value)` in JS and convert the result + * to an unsigned 32-bit integer by performing the steps in + * https://tc39.es/ecma262/#sec-touint32. + */ V8_WARN_UNUSED_RESULT MaybeLocal ToUint32( Local context) const; + /** + * Perform the equivalent of `Number(value)` in JS and convert the result + * to a signed 32-bit integer by performing the steps in + * https://tc39.es/ecma262/#sec-toint32. + */ V8_WARN_UNUSED_RESULT MaybeLocal ToInt32(Local context) const; + /** + * Perform the equivalent of `Boolean(value)` in JS. This can never fail. + */ Local ToBoolean(Isolate* isolate) const; - V8_DEPRECATE_SOON("Use maybe version", - Local ToNumber(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local ToString(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local ToObject(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local ToInteger(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local ToInt32(Isolate* isolate) const); /** * Attempts to convert a string to an array index. @@ -2556,16 +2854,18 @@ class V8_EXPORT Value : public Data { V8_WARN_UNUSED_RESULT MaybeLocal ToArrayIndex( Local context) const; + /** Returns the equivalent of `ToBoolean()->Value()`. */ bool BooleanValue(Isolate* isolate) const; - V8_DEPRECATED("BooleanValue can never throw. Use Isolate version.", - V8_WARN_UNUSED_RESULT Maybe BooleanValue( - Local context) const); + /** Returns the equivalent of `ToNumber()->Value()`. */ V8_WARN_UNUSED_RESULT Maybe NumberValue(Local context) const; + /** Returns the equivalent of `ToInteger()->Value()`. */ V8_WARN_UNUSED_RESULT Maybe IntegerValue( Local context) const; + /** Returns the equivalent of `ToUint32()->Value()`. */ V8_WARN_UNUSED_RESULT Maybe Uint32Value( Local context) const; + /** Returns the equivalent of `ToInt32()->Value()`. */ V8_WARN_UNUSED_RESULT Maybe Int32Value(Local context) const; /** JS == */ @@ -2657,9 +2957,8 @@ enum class NewStringType { */ class V8_EXPORT String : public Name { public: - static constexpr int kMaxLength = internal::kApiTaggedSize == 4 - ? (1 << 28) - 16 - : internal::kSmiMaxValue / 2 - 24; + static constexpr int kMaxLength = + internal::kApiSystemPointerSize == 4 ? (1 << 28) - 16 : (1 << 29) - 24; enum Encoding { UNKNOWN_ENCODING = 0x1, @@ -2764,6 +3063,10 @@ class V8_EXPORT String : public Name { */ virtual bool IsCacheable() const { return true; } + // Disallow copying and assigning. + ExternalStringResourceBase(const ExternalStringResourceBase&) = delete; + void operator=(const ExternalStringResourceBase&) = delete; + protected: ExternalStringResourceBase() = default; @@ -2793,10 +3096,6 @@ class V8_EXPORT String : public Name { */ virtual void Unlock() const {} - // Disallow copying and assigning. - ExternalStringResourceBase(const ExternalStringResourceBase&) = delete; - void operator=(const ExternalStringResourceBase&) = delete; - private: friend class internal::ExternalString; friend class v8::String; @@ -2880,43 +3179,40 @@ class V8_EXPORT String : public Name { V8_INLINE static String* Cast(v8::Value* obj); - // TODO(dcarney): remove with deprecation of New functions. - enum NewStringType { - kNormalString = static_cast(v8::NewStringType::kNormal), - kInternalizedString = static_cast(v8::NewStringType::kInternalized) - }; - - /** Allocates a new string from UTF-8 data.*/ - static V8_DEPRECATED( - "Use maybe version", - Local NewFromUtf8(Isolate* isolate, const char* data, - NewStringType type = kNormalString, - int length = -1)); + /** + * Allocates a new string from a UTF-8 literal. This is equivalent to calling + * String::NewFromUtf(isolate, "...").ToLocalChecked(), but without the check + * overhead. + * + * When called on a string literal containing '\0', the inferred length is the + * length of the input array minus 1 (for the final '\0') and not the value + * returned by strlen. + **/ + template + static V8_WARN_UNUSED_RESULT Local NewFromUtf8Literal( + Isolate* isolate, const char (&literal)[N], + NewStringType type = NewStringType::kNormal) { + static_assert(N <= kMaxLength, "String is too long"); + return NewFromUtf8Literal(isolate, literal, type, N - 1); + } /** Allocates a new string from UTF-8 data. Only returns an empty value when * length > kMaxLength. **/ static V8_WARN_UNUSED_RESULT MaybeLocal NewFromUtf8( - Isolate* isolate, const char* data, v8::NewStringType type, - int length = -1); + Isolate* isolate, const char* data, + NewStringType type = NewStringType::kNormal, int length = -1); /** Allocates a new string from Latin-1 data. Only returns an empty value * when length > kMaxLength. **/ static V8_WARN_UNUSED_RESULT MaybeLocal NewFromOneByte( - Isolate* isolate, const uint8_t* data, v8::NewStringType type, - int length = -1); - - /** Allocates a new string from UTF-16 data.*/ - static V8_DEPRECATE_SOON( - "Use maybe version", - Local NewFromTwoByte(Isolate* isolate, const uint16_t* data, - NewStringType type = kNormalString, - int length = -1)); + Isolate* isolate, const uint8_t* data, + NewStringType type = NewStringType::kNormal, int length = -1); /** Allocates a new string from UTF-16 data. Only returns an empty value when * length > kMaxLength. **/ static V8_WARN_UNUSED_RESULT MaybeLocal NewFromTwoByte( - Isolate* isolate, const uint16_t* data, v8::NewStringType type, - int length = -1); + Isolate* isolate, const uint16_t* data, + NewStringType type = NewStringType::kNormal, int length = -1); /** * Creates a new string by concatenating the left and the right strings @@ -2955,10 +3251,6 @@ class V8_EXPORT String : public Name { * should the underlying buffer be deallocated or modified except through the * destructor of the external string resource. */ - static V8_DEPRECATE_SOON( - "Use maybe version", - Local NewExternal(Isolate* isolate, - ExternalOneByteStringResource* resource)); static V8_WARN_UNUSED_RESULT MaybeLocal NewExternalOneByte( Isolate* isolate, ExternalOneByteStringResource* resource); @@ -3038,9 +3330,20 @@ class V8_EXPORT String : public Name { ExternalStringResourceBase* GetExternalStringResourceBaseSlow( String::Encoding* encoding_out) const; + static Local NewFromUtf8Literal(Isolate* isolate, + const char* literal, + NewStringType type, int length); + static void CheckCast(v8::Value* obj); }; +// Zero-length string specialization (templated string size includes +// terminator). +template <> +inline V8_WARN_UNUSED_RESULT Local String::NewFromUtf8Literal( + Isolate* isolate, const char (&literal)[1], NewStringType type) { + return String::Empty(isolate); +} /** * A JavaScript symbol (ECMA-262 edition 6) @@ -3048,30 +3351,35 @@ class V8_EXPORT String : public Name { class V8_EXPORT Symbol : public Name { public: /** - * Returns the print name string of the symbol, or undefined if none. + * Returns the description string of the symbol, or undefined if none. */ - Local Name() const; + Local Description() const; + + V8_DEPRECATE_SOON("Use Symbol::Description()") + Local Name() const { return Description(); } /** - * Create a symbol. If name is not empty, it will be used as the description. + * Create a symbol. If description is not empty, it will be used as the + * description. */ static Local New(Isolate* isolate, - Local name = Local()); + Local description = Local()); /** * Access global symbol registry. * Note that symbols created this way are never collected, so * they should only be used for statically fixed properties. - * Also, there is only one global name space for the names used as keys. + * Also, there is only one global name space for the descriptions used as + * keys. * To minimize the potential for clashes, use qualified names as keys. */ - static Local For(Isolate *isolate, Local name); + static Local For(Isolate* isolate, Local description); /** * Retrieve a global symbol. Similar to |For|, but using a separate * registry that is not accessible by (and cannot clash with) JavaScript code. */ - static Local ForApi(Isolate *isolate, Local name); + static Local ForApi(Isolate* isolate, Local description); // Well-known symbols static Local GetAsyncIterator(Isolate* isolate); @@ -3343,7 +3651,7 @@ enum class IndexFilter { kIncludeIndices, kSkipIndices }; * kConvertToString will convert integer indices to strings. * kKeepNumbers will return numbers for integer indices. */ -enum class KeyConversionMode { kConvertToString, kKeepNumbers }; +enum class KeyConversionMode { kConvertToString, kKeepNumbers, kNoNumbers }; /** * Integrity level for objects. @@ -3355,8 +3663,6 @@ enum class IntegrityLevel { kFrozen, kSealed }; */ class V8_EXPORT Object : public Value { public: - V8_DEPRECATE_SOON("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(). @@ -3364,8 +3670,6 @@ class V8_EXPORT Object : public Value { V8_WARN_UNUSED_RESULT Maybe Set(Local context, Local key, Local value); - V8_DEPRECATE_SOON("Use maybe version", - bool Set(uint32_t index, Local value)); V8_WARN_UNUSED_RESULT Maybe Set(Local context, uint32_t index, Local value); @@ -3407,13 +3711,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_DEPRECATE_SOON("Use maybe version", Local Get(Local key)); V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context, Local key); - V8_DEPRECATE_SOON("Use maybe version", Local Get(uint32_t index)); V8_WARN_UNUSED_RESULT MaybeLocal Get(Local context, uint32_t index); @@ -3592,8 +3895,9 @@ class V8_EXPORT Object : public Value { return object.val_->InternalFieldCount(); } - /** Same as above, but works for TracedGlobal. */ - V8_INLINE static int InternalFieldCount(const TracedGlobal& object) { + /** Same as above, but works for TracedReferenceBase. */ + V8_INLINE static int InternalFieldCount( + const TracedReferenceBase& object) { return object.val_->InternalFieldCount(); } @@ -3618,7 +3922,7 @@ class V8_EXPORT Object : public Value { /** Same as above, but works for TracedGlobal. */ V8_INLINE static void* GetAlignedPointerFromInternalField( - const TracedGlobal& object, int index) { + const TracedReferenceBase& object, int index) { return object.val_->GetAlignedPointerFromInternalField(index); } @@ -3737,6 +4041,22 @@ class V8_EXPORT Object : public Value { */ bool IsConstructor(); + /** + * True if this object can carry information relevant to the embedder in its + * embedder fields, false otherwise. This is generally true for objects + * constructed through function templates but also holds for other types where + * V8 automatically adds internal fields at compile time, such as e.g. + * v8::ArrayBuffer. + */ + bool IsApiWrapper(); + + /** + * True if this object was created from an object template which was marked + * as undetectable. See v8::ObjectTemplate::MarkAsUndetectable for more + * information. + */ + bool IsUndetectable(); + /** * Call an Object as a function if a callback is set by the * ObjectTemplate::SetCallAsFunctionHandler method. @@ -3893,16 +4213,13 @@ class ReturnValue { public: template V8_INLINE ReturnValue(const ReturnValue& that) : value_(that.value_) { - TYPE_CHECK(T, S); + static_assert(std::is_base_of::value, "type check"); } // Local setters template - V8_INLINE V8_DEPRECATED("Use Global<> instead", - void Set(const Persistent& handle)); - template V8_INLINE void Set(const Global& handle); template - V8_INLINE void Set(const TracedGlobal& handle); + V8_INLINE void Set(const TracedReferenceBase& handle); template V8_INLINE void Set(const Local handle); // Fast primitive setters @@ -3950,7 +4267,10 @@ class FunctionCallbackInfo { public: /** The number of available arguments. */ V8_INLINE int Length() const; - /** Accessor for the available arguments. */ + /** + * Accessor for the available arguments. Returns `undefined` if the index + * is out of bounds. + */ V8_INLINE Local operator[](int i) const; /** Returns the receiver. This corresponds to the "this" value. */ V8_INLINE Local This() const; @@ -4448,9 +4768,16 @@ class V8_EXPORT CompiledWasmModule { */ MemorySpan GetWireBytesRef(); + /* This is not available on Node v14.x. + * const std::string& source_url() const { return source_url_; } + */ + private: - explicit CompiledWasmModule(std::shared_ptr); - friend class Utils; + friend class WasmModuleObject; + friend class WasmStreaming; + + explicit CompiledWasmModule(std::shared_ptr, + const char* source_url, size_t url_length); const std::shared_ptr native_module_; }; @@ -4458,46 +4785,14 @@ class V8_EXPORT CompiledWasmModule { // An instance of WebAssembly.Module. class V8_EXPORT WasmModuleObject : public Object { public: - /** - * An opaque, native heap object for transferring wasm modules. It - * supports move semantics, and does not support copy semantics. - * TODO(wasm): Merge this with CompiledWasmModule once code sharing is always - * enabled. - */ - class TransferrableModule final { - public: - TransferrableModule(TransferrableModule&& src) = default; - TransferrableModule(const TransferrableModule& src) = delete; - - TransferrableModule& operator=(TransferrableModule&& src) = default; - TransferrableModule& operator=(const TransferrableModule& src) = delete; - - private: - typedef std::shared_ptr SharedModule; - friend class WasmModuleObject; - explicit TransferrableModule(SharedModule shared_module) - : shared_module_(std::move(shared_module)) {} - TransferrableModule(OwnedBuffer serialized, OwnedBuffer bytes) - : serialized_(std::move(serialized)), wire_bytes_(std::move(bytes)) {} - - SharedModule shared_module_; - OwnedBuffer serialized_ = {nullptr, 0}; - OwnedBuffer wire_bytes_ = {nullptr, 0}; - }; - - /** - * Get an in-memory, non-persistable, and context-independent (meaning, - * suitable for transfer to another Isolate and Context) representation - * of this wasm compiled module. - */ - TransferrableModule GetTransferrableModule(); + WasmModuleObject() = delete; /** * Efficiently re-create a WasmModuleObject, without recompiling, from - * a TransferrableModule. + * a CompiledWasmModule. */ - static MaybeLocal FromTransferrableModule( - Isolate* isolate, const TransferrableModule&); + static MaybeLocal FromCompiledModule( + Isolate* isolate, const CompiledWasmModule&); /** * Get the compiled module for this module object. The compiled module can be @@ -4505,27 +4800,9 @@ class V8_EXPORT WasmModuleObject : public Object { */ CompiledWasmModule GetCompiledModule(); - /** - * If possible, deserialize the module, otherwise compile it from the provided - * uncompiled bytes. - */ - static MaybeLocal DeserializeOrCompile( - Isolate* isolate, MemorySpan serialized_module, - MemorySpan wire_bytes); V8_INLINE static WasmModuleObject* Cast(Value* obj); private: - static MaybeLocal Deserialize( - Isolate* isolate, MemorySpan serialized_module, - MemorySpan wire_bytes); - static MaybeLocal Compile(Isolate* isolate, - const uint8_t* start, - size_t length); - static MemorySpan AsReference(const OwnedBuffer& buff) { - return {buff.buffer.get(), buff.size}; - } - - WasmModuleObject(); static void CheckCast(Value* obj); }; @@ -4591,6 +4868,12 @@ class V8_EXPORT WasmStreaming final { */ void SetClient(std::shared_ptr client); + /* + * Sets the UTF-8 encoded source URL for the {Script} object. This must be + * called before {Finish}. + */ + void SetUrl(const char* url, size_t length); + /** * Unpacks a {WasmStreaming} object wrapped in a {Managed} for the embedder. * Since the embedder is on the other side of the API, it cannot unpack the @@ -4657,6 +4940,90 @@ class V8_EXPORT WasmModuleObjectBuilderStreaming final { enum class ArrayBufferCreationMode { kInternalized, kExternalized }; +/** + * A wrapper around the backing store (i.e. the raw memory) of an array buffer. + * See a document linked in http://crbug.com/v8/9908 for more information. + * + * The allocation and destruction of backing stores is generally managed by + * V8. Clients should always use standard C++ memory ownership types (i.e. + * std::unique_ptr and std::shared_ptr) to manage lifetimes of backing stores + * properly, since V8 internal objects may alias backing stores. + * + * This object does not keep the underlying |ArrayBuffer::Allocator| alive by + * default. Use Isolate::CreateParams::array_buffer_allocator_shared when + * creating the Isolate to make it hold a reference to the allocator itself. + */ +class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase { + public: + ~BackingStore(); + + /** + * Return a pointer to the beginning of the memory block for this backing + * store. The pointer is only valid as long as this backing store object + * lives. + */ + void* Data() const; + + /** + * The length (in bytes) of this backing store. + */ + size_t ByteLength() const; + + /** + * Indicates whether the backing store was created for an ArrayBuffer or + * a SharedArrayBuffer. + */ + bool IsShared() const; + + /** + * Prevent implicit instantiation of operator delete with size_t argument. + * The size_t argument would be incorrect because ptr points to the + * internal BackingStore object. + */ + void operator delete(void* ptr) { ::operator delete(ptr); } + + /** + * Wrapper around ArrayBuffer::Allocator::Reallocate that preserves IsShared. + * Assumes that the backing_store was allocated by the ArrayBuffer allocator + * of the given isolate. + */ + static std::unique_ptr Reallocate( + v8::Isolate* isolate, std::unique_ptr backing_store, + size_t byte_length); + + /** + * This callback is used only if the memory block for a BackingStore cannot be + * allocated with an ArrayBuffer::Allocator. In such cases the destructor of + * the BackingStore invokes the callback to free the memory block. + */ + using DeleterCallback = void (*)(void* data, size_t length, + void* deleter_data); + + /** + * If the memory block of a BackingStore is static or is managed manually, + * then this empty deleter along with nullptr deleter_data can be passed to + * ArrayBuffer::NewBackingStore to indicate that. + * + * The manually managed case should be used with caution and only when it + * is guaranteed that the memory block freeing happens after detaching its + * ArrayBuffer. + */ + static void EmptyDeleter(void* data, size_t length, void* deleter_data); + + private: + /** + * See [Shared]ArrayBuffer::GetBackingStore and + * [Shared]ArrayBuffer::NewBackingStore. + */ + BackingStore(); +}; + +#if !defined(V8_IMMINENT_DEPRECATION_WARNINGS) +// Use v8::BackingStore::DeleterCallback instead. +using BackingStoreDeleterCallback = void (*)(void* data, size_t length, + void* deleter_data); + +#endif /** * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). @@ -4683,13 +5050,13 @@ class V8_EXPORT ArrayBuffer : public Object { virtual ~Allocator() = default; /** - * Allocate |length| bytes. Return NULL if allocation is not successful. + * Allocate |length| bytes. Return nullptr if allocation is not successful. * Memory should be initialized to zeroes. */ virtual void* Allocate(size_t length) = 0; /** - * Allocate |length| bytes. Return NULL if allocation is not successful. + * Allocate |length| bytes. Return nullptr if allocation is not successful. * Memory does not have to be initialized. */ virtual void* AllocateUninitialized(size_t length) = 0; @@ -4700,6 +5067,20 @@ class V8_EXPORT ArrayBuffer : public Object { */ virtual void Free(void* data, size_t length) = 0; + /** + * Reallocate the memory block of size |old_length| to a memory block of + * size |new_length| by expanding, contracting, or copying the existing + * memory block. If |new_length| > |old_length|, then the new part of + * the memory must be initialized to zeros. Return nullptr if reallocation + * is not successful. + * + * The caller guarantees that the memory block was previously allocated + * using Allocate or AllocateUninitialized. + * + * The default implementation allocates a new block and copies data. + */ + virtual void* Reallocate(void* data, size_t old_length, size_t new_length); + /** * ArrayBuffer allocation mode. kNormal is a malloc/free style allocation, * while kReservation is for larger allocations with the ability to set @@ -4789,14 +5170,58 @@ class V8_EXPORT ArrayBuffer : public Object { * |Allocator::Free| once all ArrayBuffers referencing it are collected by * the garbage collector. */ + V8_DEPRECATE_SOON( + "Use the version that takes a BackingStore. " + "See http://crbug.com/v8/9908.") static Local New( Isolate* isolate, void* data, size_t byte_length, ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); + /** + * Create a new ArrayBuffer with an existing backing store. + * The created array keeps a reference to the backing store until the array + * is garbage collected. Note that the IsExternal bit does not affect this + * reference from the array to the backing store. + * + * In future IsExternal bit will be removed. Until then the bit is set as + * follows. If the backing store does not own the underlying buffer, then + * the array is created in externalized state. Otherwise, the array is created + * in internalized state. In the latter case the array can be transitioned + * to the externalized state using Externalize(backing_store). + */ + static Local New(Isolate* isolate, + std::shared_ptr backing_store); + + /** + * Returns a new standalone BackingStore that is allocated using the array + * buffer allocator of the isolate. The result can be later passed to + * ArrayBuffer::New. + * + * If the allocator returns nullptr, then the function may cause GCs in the + * given isolate and re-try the allocation. If GCs do not help, then the + * function will crash with an out-of-memory error. + */ + static std::unique_ptr NewBackingStore(Isolate* isolate, + size_t byte_length); + /** + * Returns a new standalone BackingStore that takes over the ownership of + * the given buffer. The destructor of the BackingStore invokes the given + * deleter callback. + * + * The result can be later passed to ArrayBuffer::New. The raw pointer + * to the buffer must not be passed again to any V8 API function. + */ + static std::unique_ptr NewBackingStore( + void* data, size_t byte_length, v8::BackingStore::DeleterCallback deleter, + void* deleter_data); + /** * Returns true if ArrayBuffer is externalized, that is, does not * own its memory block. */ + V8_DEPRECATE_SOON( + "With v8::BackingStore externalized ArrayBuffers are " + "the same as ordinary ArrayBuffers. See http://crbug.com/v8/9908.") bool IsExternal() const; /** @@ -4804,12 +5229,6 @@ class V8_EXPORT ArrayBuffer : public Object { */ bool IsDetachable() const; - // TODO(913887): fix the use of 'neuter' in the API. - V8_DEPRECATE_SOON("Use IsDetachable() instead.", - inline bool IsNeuterable() const) { - return IsDetachable(); - } - /** * Detaches this ArrayBuffer and all its views (typed arrays). * Detaching sets the byte length of the buffer and all typed arrays to zero, @@ -4818,9 +5237,6 @@ class V8_EXPORT ArrayBuffer : public Object { */ void Detach(); - // TODO(913887): fix the use of 'neuter' in the API. - V8_DEPRECATE_SOON("Use Detach() instead.", inline void Neuter()) { Detach(); } - /** * Make this ArrayBuffer external. The pointer to underlying memory block * and byte length are returned as |Contents| structure. After ArrayBuffer @@ -4829,10 +5245,22 @@ class V8_EXPORT ArrayBuffer : public Object { * * The Data pointer of ArrayBuffer::Contents must be freed using the provided * deleter, which will call ArrayBuffer::Allocator::Free if the buffer - * was allocated with ArraryBuffer::Allocator::Allocate. + * was allocated with ArrayBuffer::Allocator::Allocate. */ + V8_DEPRECATE_SOON( + "Use GetBackingStore or Detach. See http://crbug.com/v8/9908.") Contents Externalize(); + /** + * Marks this ArrayBuffer external given a witness that the embedder + * has fetched the backing store using the new GetBackingStore() function. + * + * With the new lifetime management of backing stores there is no need for + * externalizing, so this function exists only to make the transition easier. + */ + V8_DEPRECATE_SOON("This will be removed together with IsExternal.") + void Externalize(const std::shared_ptr& backing_store); + /** * Get a pointer to the ArrayBuffer's underlying memory block without * externalizing it. If the ArrayBuffer is not externalized, this pointer @@ -4841,8 +5269,19 @@ class V8_EXPORT ArrayBuffer : public Object { * The embedder should make sure to hold a strong reference to the * ArrayBuffer while accessing this pointer. */ + V8_DEPRECATE_SOON("Use GetBackingStore. See http://crbug.com/v8/9908.") Contents GetContents(); + /** + * Get a shared pointer to the backing store of this array buffer. This + * pointer coordinates the lifetime management of the internal storage + * with any live ArrayBuffers on the heap, even across isolates. The embedder + * should not attempt to manage lifetime of the storage through other means. + * + * This function replaces both Externalize() and GetContents(). + */ + std::shared_ptr GetBackingStore(); + V8_INLINE static ArrayBuffer* Cast(Value* obj); static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; @@ -4851,6 +5290,7 @@ class V8_EXPORT ArrayBuffer : public Object { private: ArrayBuffer(); static void CheckCast(Value* obj); + Contents GetContents(bool externalize); }; @@ -4918,7 +5358,9 @@ class V8_EXPORT TypedArray : public ArrayBufferView { /* * The largest typed array size that can be constructed using New. */ - static constexpr size_t kMaxLength = internal::kSmiMaxValue; + static constexpr size_t kMaxLength = internal::kApiSystemPointerSize == 4 + ? internal::kSmiMaxValue + : 0xFFFFFFFF; /** * Number of elements in this typed array @@ -5137,7 +5579,6 @@ class V8_EXPORT DataView : public ArrayBufferView { /** * An instance of the built-in SharedArrayBuffer constructor. - * This API is experimental and may change significantly. */ class V8_EXPORT SharedArrayBuffer : public Object { public: @@ -5149,8 +5590,6 @@ class V8_EXPORT SharedArrayBuffer : public Object { * The Data pointer of ArrayBuffer::Contents must be freed using the provided * deleter, which will call ArrayBuffer::Allocator::Free if the buffer * was allocated with ArraryBuffer::Allocator::Allocate. - * - * This API is experimental and may change significantly. */ class V8_EXPORT Contents { // NOLINT public: @@ -5164,8 +5603,7 @@ class V8_EXPORT SharedArrayBuffer : public Object { allocation_length_(0), allocation_mode_(Allocator::AllocationMode::kNormal), deleter_(nullptr), - deleter_data_(nullptr), - is_growable_(false) {} + deleter_data_(nullptr) {} void* AllocationBase() const { return allocation_base_; } size_t AllocationLength() const { return allocation_length_; } @@ -5177,13 +5615,12 @@ class V8_EXPORT SharedArrayBuffer : public Object { size_t ByteLength() const { return byte_length_; } DeleterCallback Deleter() const { return deleter_; } void* DeleterData() const { return deleter_data_; } - bool IsGrowable() const { return is_growable_; } private: Contents(void* data, size_t byte_length, void* allocation_base, size_t allocation_length, Allocator::AllocationMode allocation_mode, DeleterCallback deleter, - void* deleter_data, bool is_growable); + void* deleter_data); void* data_; size_t byte_length_; @@ -5192,7 +5629,6 @@ class V8_EXPORT SharedArrayBuffer : public Object { Allocator::AllocationMode allocation_mode_; DeleterCallback deleter_; void* deleter_data_; - bool is_growable_; friend class SharedArrayBuffer; }; @@ -5216,14 +5652,58 @@ class V8_EXPORT SharedArrayBuffer : public Object { * specified. The memory block will not be reclaimed when a created * SharedArrayBuffer is garbage-collected. */ + V8_DEPRECATE_SOON( + "Use the version that takes a BackingStore. " + "See http://crbug.com/v8/9908.") static Local New( Isolate* isolate, void* data, size_t byte_length, ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); + /** + * Create a new SharedArrayBuffer with an existing backing store. + * The created array keeps a reference to the backing store until the array + * is garbage collected. Note that the IsExternal bit does not affect this + * reference from the array to the backing store. + * + * In future IsExternal bit will be removed. Until then the bit is set as + * follows. If the backing store does not own the underlying buffer, then + * the array is created in externalized state. Otherwise, the array is created + * in internalized state. In the latter case the array can be transitioned + * to the externalized state using Externalize(backing_store). + */ + static Local New( + Isolate* isolate, std::shared_ptr backing_store); + + /** + * Returns a new standalone BackingStore that is allocated using the array + * buffer allocator of the isolate. The result can be later passed to + * SharedArrayBuffer::New. + * + * If the allocator returns nullptr, then the function may cause GCs in the + * given isolate and re-try the allocation. If GCs do not help, then the + * function will crash with an out-of-memory error. + */ + static std::unique_ptr NewBackingStore(Isolate* isolate, + size_t byte_length); + /** + * Returns a new standalone BackingStore that takes over the ownership of + * the given buffer. The destructor of the BackingStore invokes the given + * deleter callback. + * + * The result can be later passed to SharedArrayBuffer::New. The raw pointer + * to the buffer must not be passed again to any V8 functions. + */ + static std::unique_ptr NewBackingStore( + void* data, size_t byte_length, v8::BackingStore::DeleterCallback deleter, + void* deleter_data); + /** * Create a new SharedArrayBuffer over an existing memory block. Propagate * flags to indicate whether the underlying buffer can be grown. */ + V8_DEPRECATED( + "Use the version that takes a BackingStore. " + "See http://crbug.com/v8/9908.") static Local New( Isolate* isolate, const SharedArrayBuffer::Contents&, ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); @@ -5232,6 +5712,9 @@ class V8_EXPORT SharedArrayBuffer : public Object { * Returns true if SharedArrayBuffer is externalized, that is, does not * own its memory block. */ + V8_DEPRECATE_SOON( + "With v8::BackingStore externalized SharedArrayBuffers are the same " + "as ordinary SharedArrayBuffers. See http://crbug.com/v8/9908.") bool IsExternal() const; /** @@ -5246,8 +5729,20 @@ class V8_EXPORT SharedArrayBuffer : public Object { * v8::Isolate::CreateParams::array_buffer_allocator. * */ + V8_DEPRECATE_SOON( + "Use GetBackingStore or Detach. See http://crbug.com/v8/9908.") Contents Externalize(); + /** + * Marks this SharedArrayBuffer external given a witness that the embedder + * has fetched the backing store using the new GetBackingStore() function. + * + * With the new lifetime management of backing stores there is no need for + * externalizing, so this function exists only to make the transition easier. + */ + V8_DEPRECATE_SOON("This will be removed together with IsExternal.") + void Externalize(const std::shared_ptr& backing_store); + /** * Get a pointer to the ArrayBuffer's underlying memory block without * externalizing it. If the ArrayBuffer is not externalized, this pointer @@ -5260,8 +5755,19 @@ class V8_EXPORT SharedArrayBuffer : public Object { * by the allocator specified in * v8::Isolate::CreateParams::array_buffer_allocator. */ + V8_DEPRECATE_SOON("Use GetBackingStore. See http://crbug.com/v8/9908.") Contents GetContents(); + /** + * Get a shared pointer to the backing store of this array buffer. This + * pointer coordinates the lifetime management of the internal storage + * with any live ArrayBuffers on the heap, even across isolates. The embedder + * should not attempt to manage lifetime of the storage through other means. + * + * This function replaces both Externalize() and GetContents(). + */ + std::shared_ptr GetBackingStore(); + V8_INLINE static SharedArrayBuffer* Cast(Value* obj); static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; @@ -5269,6 +5775,7 @@ class V8_EXPORT SharedArrayBuffer : public Object { private: SharedArrayBuffer(); static void CheckCast(Value* obj); + Contents GetContents(bool externalize); }; @@ -5288,39 +5795,6 @@ class V8_EXPORT Date : public Object { V8_INLINE static Date* Cast(Value* obj); - /** - * Time zone redetection indicator for - * DateTimeConfigurationChangeNotification. - * - * kSkip indicates V8 that the notification should not trigger redetecting - * host time zone. kRedetect indicates V8 that host time zone should be - * redetected, and used to set the default time zone. - * - * The host time zone detection may require file system access or similar - * operations unlikely to be available inside a sandbox. If v8 is run inside a - * sandbox, the host time zone has to be detected outside the sandbox before - * calling DateTimeConfigurationChangeNotification function. - */ - enum class TimeZoneDetection { kSkip, kRedetect }; - - /** - * Notification that the embedder has changed the time zone, - * daylight savings time, or other date / time configuration - * parameters. V8 keeps a cache of various values used for - * date / time computation. This notification will reset - * those cached values for the current context so that date / - * time configuration changes would be reflected in the Date - * object. - * - * This API should not be called more than needed as it will - * negatively impact the performance of date operations. - */ - V8_DEPRECATE_SOON( - "Use Isolate::DateTimeConfigurationChangeNotification", - static void DateTimeConfigurationChangeNotification( - Isolate* isolate, - TimeZoneDetection time_zone_detection = TimeZoneDetection::kSkip)); - private: static void CheckCast(Value* obj); }; @@ -5423,6 +5897,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 @@ -5437,6 +5913,29 @@ class V8_EXPORT RegExp : public Object { Local pattern, Flags flags); + /** + * Like New, but additionally specifies a backtrack limit. If the number of + * backtracks done in one Exec call hits the limit, a match failure is + * immediately returned. + */ + static V8_WARN_UNUSED_RESULT MaybeLocal NewWithBacktrackLimit( + Local context, Local pattern, Flags flags, + uint32_t backtrack_limit); + + /** + * Executes the current RegExp instance on the given subject string. + * Equivalent to RegExp.prototype.exec as described in + * + * https://tc39.es/ecma262/#sec-regexp.prototype.exec + * + * On success, an Array containing the matched strings is returned. On + * failure, returns Null. + * + * Note: modifies global context state, accessible e.g. through RegExp.input. + */ + V8_WARN_UNUSED_RESULT MaybeLocal Exec(Local context, + Local subject); + /** * Returns the value of the source property: a string representing * the regular expression. @@ -5454,6 +5953,36 @@ class V8_EXPORT RegExp : public Object { static void CheckCast(Value* obj); }; +/** + * An instance of the built-in FinalizationRegistry constructor. + * + * The C++ name is FinalizationGroup for backwards compatibility. This API is + * experimental and deprecated. + */ +class V8_EXPORT FinalizationGroup : public Object { + public: + /** + * Runs the cleanup callback of the given FinalizationRegistry. + * + * V8 will inform the embedder that there are finalizer callbacks be + * called through HostCleanupFinalizationGroupCallback. + * + * HostCleanupFinalizationGroupCallback should schedule a task to + * call FinalizationGroup::Cleanup() at some point in the + * future. It's the embedders responsiblity to make this call at a + * time which does not interrupt synchronous ECMAScript code + * execution. + * + * If the result is Nothing then an exception has + * occurred. Otherwise the result is |true| if the cleanup callback + * was called successfully. The result is never |false|. + */ + V8_DEPRECATED( + "FinalizationGroup cleanup is automatic if " + "HostCleanupFinalizationGroupCallback is not set") + static V8_WARN_UNUSED_RESULT Maybe Cleanup( + Local finalization_group); +}; /** * A JavaScript value that wraps a C++ void*. This type of value is mainly used @@ -5468,13 +5997,14 @@ class V8_EXPORT External : public Value { static void CheckCast(v8::Value* obj); }; -#define V8_INTRINSICS_LIST(F) \ - F(ArrayProto_entries, array_entries_iterator) \ - F(ArrayProto_forEach, array_for_each_iterator) \ - F(ArrayProto_keys, array_keys_iterator) \ - F(ArrayProto_values, array_values_iterator) \ - F(ErrorPrototype, initial_error_prototype) \ - F(IteratorPrototype, initial_iterator_prototype) +#define V8_INTRINSICS_LIST(F) \ + F(ArrayProto_entries, array_entries_iterator) \ + F(ArrayProto_forEach, array_for_each_iterator) \ + F(ArrayProto_keys, array_keys_iterator) \ + F(ArrayProto_values, array_values_iterator) \ + F(ErrorPrototype, initial_error_prototype) \ + F(IteratorPrototype, initial_iterator_prototype) \ + F(ObjProto_valueOf, object_value_of_function) enum Intrinsic { #define V8_DECL_INTRINSIC(name, iname) k##name, @@ -5820,6 +6350,7 @@ typedef bool (*AccessCheckCallback)(Local accessing_context, Local accessed_object, Local data); +class CFunction; /** * A FunctionTemplate is used to create functions at runtime. There * can only be one function created from a FunctionTemplate in a @@ -5855,11 +6386,12 @@ typedef bool (*AccessCheckCallback)(Local accessing_context, * proto_t->Set(isolate, "proto_const", v8::Number::New(isolate, 2)); * * v8::Local instance_t = t->InstanceTemplate(); - * instance_t->SetAccessor(String::NewFromUtf8(isolate, "instance_accessor"), - * InstanceAccessorCallback); + * instance_t->SetAccessor( + String::NewFromUtf8Literal(isolate, "instance_accessor"), + * InstanceAccessorCallback); * instance_t->SetHandler( * NamedPropertyHandlerConfiguration(PropertyHandlerCallback)); - * instance_t->Set(String::NewFromUtf8(isolate, "instance_property"), + * instance_t->Set(String::NewFromUtf8Literal(isolate, "instance_property"), * Number::New(isolate, 3)); * * v8::Local function = t->GetFunction(); @@ -5919,6 +6451,12 @@ typedef bool (*AccessCheckCallback)(Local accessing_context, * child_instance.instance_accessor calls 'InstanceAccessorCallback' * child_instance.instance_property == 3; * \endcode + * + * The additional 'c_function' parameter refers to a fast API call, which + * must not trigger GC or JavaScript execution, or call into V8 in other + * ways. For more information how to define them, see + * include/v8-fast-api-calls.h. Please note that this feature is still + * experimental. */ class V8_EXPORT FunctionTemplate : public Template { public: @@ -5928,11 +6466,8 @@ class V8_EXPORT FunctionTemplate : public Template { Local data = Local(), Local signature = Local(), int length = 0, ConstructorBehavior behavior = ConstructorBehavior::kAllow, - SideEffectType side_effect_type = SideEffectType::kHasSideEffect); - - /** Get a template included in the snapshot by index. */ - static MaybeLocal FromSnapshot(Isolate* isolate, - size_t index); + SideEffectType side_effect_type = SideEffectType::kHasSideEffect, + const CFunction* c_function = nullptr); /** * Creates a function template backed/cached by a private property. @@ -5959,11 +6494,13 @@ class V8_EXPORT FunctionTemplate : public Template { /** * Set the call-handler callback for a FunctionTemplate. This * callback is called whenever the function created from this - * FunctionTemplate is called. + * FunctionTemplate is called. The 'c_function' represents a fast + * API call, see the comment above the class declaration. */ void SetCallHandler( FunctionCallback callback, Local data = Local(), - SideEffectType side_effect_type = SideEffectType::kHasSideEffect); + SideEffectType side_effect_type = SideEffectType::kHasSideEffect, + const CFunction* c_function = nullptr); /** Set the predefined length property for the FunctionTemplate. */ void SetLength(int length); @@ -6006,21 +6543,6 @@ class V8_EXPORT FunctionTemplate : public Template { */ void SetAcceptAnyReceiver(bool value); - /** - * Determines whether the __proto__ accessor ignores instances of - * the function template. If instances of the function template are - * ignored, __proto__ skips all instances and instead returns the - * next object in the prototype chain. - * - * Call with a value of true to make the __proto__ accessor ignore - * instances of the function template. Call with a value of false - * to make the __proto__ accessor not ignore instances of the - * function template. By default, instances of a function template - * are not ignored. - */ - V8_DEPRECATED("This feature is incompatible with ES6+.", - void SetHiddenPrototype(bool value)); - /** * Sets the ReadOnly flag in the attributes of the 'prototype' property * of functions created from this FunctionTemplate to true. @@ -6236,10 +6758,6 @@ class V8_EXPORT ObjectTemplate : public Template { Isolate* isolate, Local constructor = Local()); - /** Get a template included in the snapshot by index. */ - static MaybeLocal FromSnapshot(Isolate* isolate, - size_t index); - /** Creates a new instance of this template.*/ V8_WARN_UNUSED_RESULT MaybeLocal NewInstance(Local context); @@ -6524,7 +7042,26 @@ 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 initial_heap_size_in_bytes The initial heap size or zero. + * By default V8 starts with a small heap and dynamically grows it to + * match the set of live objects. This may lead to ineffective + * garbage collections at startup if the live set is large. + * Setting the initial heap size avoids such garbage collections. + * Note that this does not affect young generation garbage collections. + * + * \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 @@ -6538,45 +7075,92 @@ 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; } - V8_DEPRECATE_SOON("Zone does not pool memory any more.", - size_t max_zone_pool_size() const) { - return max_zone_pool_size_; + + size_t initial_young_generation_size_in_bytes() const { + return initial_young_generation_size_; } - V8_DEPRECATE_SOON("Zone does not pool memory any more.", - void set_max_zone_pool_size(size_t bytes)) { - max_zone_pool_size_ = bytes; + void set_initial_young_generation_size_in_bytes(size_t initial_size) { + initial_young_generation_size_ = initial_size; } - private: - // max_semi_space_size_ is in KB - size_t max_semi_space_size_in_kb_; + /** + * 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 { return max_zone_pool_size_; } + V8_DEPRECATE_SOON("Zone does not pool memory any more.") + void set_max_zone_pool_size(size_t bytes) { max_zone_pool_size_ = bytes; } - // 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_; + private: + 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; }; @@ -6606,6 +7190,9 @@ class V8_EXPORT Exception { static Local ReferenceError(Local message); static Local SyntaxError(Local message); static Local TypeError(Local message); + static Local WasmCompileError(Local message); + static Local WasmLinkError(Local message); + static Local WasmRuntimeError(Local message); static Local Error(Local message); /** @@ -6634,10 +7221,35 @@ typedef void* (*CreateHistogramCallback)(const char* name, typedef void (*AddHistogramSampleCallback)(void* histogram, int sample); +// --- Crashkeys Callback --- +enum class CrashKeyId { + kIsolateAddress, + kReadonlySpaceFirstPageAddress, + kMapSpaceFirstPageAddress, + kCodeSpaceFirstPageAddress, + kDumpType, +}; + +typedef void (*AddCrashKeyCallback)(CrashKeyId id, const std::string& value); + // --- Enter/Leave Script Callback --- typedef void (*BeforeCallEnteredCallback)(Isolate*); typedef void (*CallCompletedCallback)(Isolate*); +/** + * HostCleanupFinalizationGroupCallback is called when we require the + * embedder to enqueue a task that would call + * FinalizationGroup::Cleanup(). + * + * The FinalizationGroup is the one for which the embedder needs to + * call FinalizationGroup::Cleanup() on. + * + * The context provided is the one in which the FinalizationGroup was + * created in. + */ +typedef void (*HostCleanupFinalizationGroupCallback)( + Local context, Local fg); + /** * HostImportModuleDynamicallyCallback is called when we require the * embedder to load a module. This is used as part of the dynamic @@ -6664,7 +7276,8 @@ typedef MaybeLocal (*HostImportModuleDynamicallyCallback)( /** * HostInitializeImportMetaObjectCallback is called the first time import.meta - * is accessed for a module. Subsequent access will reuse the same value. + * is accessed for a module. Subsequent access will reuse the same value. The + * callback must not throw. * * The method combines two implementation-defined abstract operations into one: * HostGetImportMetaProperties and HostFinalizeImportMeta. @@ -6681,7 +7294,7 @@ typedef void (*HostInitializeImportMetaObjectCallback)(Local context, * first accessed. The return value will be used as the stack value. If this * callback is registed, the |Error.prepareStackTrace| API will be disabled. * |sites| is an array of call sites, specified in - * https://github.com/v8/v8/wiki/Stack-Trace-API + * https://v8.dev/docs/stack-trace-api */ typedef MaybeLocal (*PrepareStackTraceCallback)(Local context, Local error, @@ -6739,10 +7352,10 @@ typedef void (*MicrotasksCompletedCallback)(Isolate*); typedef void (*MicrotasksCompletedCallbackWithData)(Isolate*, void*); typedef void (*MicrotaskCallback)(void* data); - /** * Policy for running microtasks: - * - explicit: microtasks are invoked with Isolate::RunMicrotasks() method; + * - explicit: microtasks are invoked with the + * Isolate::PerformMicrotaskCheckpoint() method; * - scoped: microtasks invocation is controlled by MicrotasksScope objects; * - auto: microtasks are invoked when the script call depth decrements * to zero. @@ -6769,7 +7382,8 @@ class V8_EXPORT MicrotaskQueue { /** * Creates an empty MicrotaskQueue instance. */ - static std::unique_ptr New(Isolate* isolate); + static std::unique_ptr New( + Isolate* isolate, MicrotasksPolicy policy = MicrotasksPolicy::kAuto); virtual ~MicrotaskQueue() = default; @@ -6817,15 +7431,22 @@ class V8_EXPORT MicrotaskQueue { */ virtual bool IsRunningMicrotasks() const = 0; + /** + * Returns the current depth of nested MicrotasksScope that has + * kRunMicrotasks. + */ + virtual int GetMicrotasksScopeDepth() const = 0; + + MicrotaskQueue(const MicrotaskQueue&) = delete; + MicrotaskQueue& operator=(const MicrotaskQueue&) = delete; + private: friend class internal::MicrotaskQueue; MicrotaskQueue() = default; - MicrotaskQueue(const MicrotaskQueue&) = delete; - MicrotaskQueue& operator=(const MicrotaskQueue&) = delete; }; /** - * This scope is used to control microtasks when kScopeMicrotasksInvocation + * This scope is used to control microtasks when MicrotasksPolicy::kScoped * is used on Isolate. In this mode every non-primitive call to V8 should be * done inside some MicrotasksScope. * Microtasks are executed when topmost MicrotasksScope marked as kRunMicrotasks @@ -6878,8 +7499,25 @@ typedef void (*FailedAccessCheckCallback)(Local target, * Callback to check if code generation from strings is allowed. See * Context::AllowCodeGenerationFromStrings. */ -typedef bool (*AllowCodeGenerationFromStringsCallback)(Local context, - Local source); +typedef bool (*AllowCodeGenerationFromStringsCallback)(Local context, + Local source); + +struct ModifyCodeGenerationFromStringsResult { + // If true, proceed with the codegen algorithm. Otherwise, block it. + bool codegen_allowed = false; + // Overwrite the original source with this string, if present. + // Use the original source if empty. + // This field is considered only if codegen_allowed is true. + MaybeLocal modified_source; +}; + +/** + * Callback to check if codegen is allowed from a source object, and convert + * the source to string if necessary.See ModifyCodeGenerationFromStrings. + */ +typedef ModifyCodeGenerationFromStringsResult ( + *ModifyCodeGenerationFromStringsCallback)(Local context, + Local source); // --- WebAssembly compilation callbacks --- typedef bool (*ExtensionCallback)(const FunctionCallbackInfo&); @@ -6897,6 +7535,13 @@ typedef void (*WasmStreamingCallback)(const FunctionCallbackInfo&); // --- Callback for checking if WebAssembly threads are enabled --- typedef bool (*WasmThreadsEnabledCallback)(Local context); +// --- Callback for loading source map file for Wasm profiling support +typedef Local (*WasmLoadSourceMapCallback)(Isolate* isolate, + const char* name); + +// --- Callback for checking if WebAssembly Simd is enabled --- +typedef bool (*WasmSimdEnabledCallback)(Local context); + // --- Garbage Collection Callbacks --- /** @@ -6953,10 +7598,34 @@ typedef void (*InterruptCallback)(Isolate* isolate, void* data); typedef size_t (*NearHeapLimitCallback)(void* data, size_t current_heap_limit, size_t initial_heap_limit); +/** + * Collection of shared per-process V8 memory information. + * + * Instances of this class can be passed to + * v8::V8::GetSharedMemoryStatistics to get shared memory statistics from V8. + */ +class V8_EXPORT SharedMemoryStatistics { + public: + SharedMemoryStatistics(); + size_t read_only_space_size() { return read_only_space_size_; } + size_t read_only_space_used_size() { return read_only_space_used_size_; } + size_t read_only_space_physical_size() { + return read_only_space_physical_size_; + } + + private: + size_t read_only_space_size_; + size_t read_only_space_used_size_; + size_t read_only_space_physical_size_; + + friend class V8; + friend class internal::ReadOnlyHeap; +}; + /** * Collection of V8 heap information. * - * Instances of this class can be passed to v8::V8::HeapStatistics to + * Instances of this class can be passed to v8::Isolate::GetHeapStatistics to * get heap statistics from V8. */ class V8_EXPORT HeapStatistics { @@ -6966,6 +7635,8 @@ class V8_EXPORT HeapStatistics { size_t total_heap_size_executable() { return total_heap_size_executable_; } size_t total_physical_size() { return total_physical_size_; } size_t total_available_size() { return total_available_size_; } + size_t total_global_handles_size() { return total_global_handles_size_; } + size_t used_global_handles_size() { return used_global_handles_size_; } size_t used_heap_size() { return used_heap_size_; } size_t heap_size_limit() { return heap_size_limit_; } size_t malloced_memory() { return malloced_memory_; } @@ -6993,6 +7664,8 @@ class V8_EXPORT HeapStatistics { bool does_zap_garbage_; size_t number_of_native_contexts_; size_t number_of_detached_contexts_; + size_t total_global_handles_size_; + size_t used_global_handles_size_; friend class V8; friend class Isolate; @@ -7112,6 +7785,20 @@ struct JitCodeEvent { PositionType position_type; }; + struct wasm_source_info_t { + // Source file name. + const char* filename; + // Length of filename. + size_t filename_size; + // Line number table, which maps offsets of JITted code to line numbers of + // source file. + const line_info_t* line_number_table; + // Number of entries in the line number table. + size_t line_number_table_size; + }; + + wasm_source_info_t* wasm_source_info; + union { // Only valid for CODE_ADDED. struct name_t name; @@ -7165,6 +7852,13 @@ enum JitCodeEventOptions { */ typedef void (*JitCodeEventHandler)(const JitCodeEvent* event); +/** + * Callback function passed to SetUnhandledExceptionCallback. + */ +#if defined(V8_OS_WIN) +typedef int (*UnhandledExceptionCallback)( + _EXCEPTION_POINTERS* exception_pointers); +#endif /** * Interface for iterating through all external resources in the heap. @@ -7205,11 +7899,12 @@ enum class MemoryPressureLevel { kNone, kModerate, kCritical }; */ class V8_EXPORT EmbedderHeapTracer { public: - // Indicator for the stack state of the embedder. - enum EmbedderStackState { - kUnknown, - kNonEmpty, - kEmpty, + using EmbedderStackState = cppgc::EmbedderStackState; + + enum TraceFlags : uint64_t { + kNoFlags = 0, + kReduceMemory = 1 << 0, + kForced = 1 << 2, }; /** @@ -7218,7 +7913,26 @@ class V8_EXPORT EmbedderHeapTracer { class V8_EXPORT TracedGlobalHandleVisitor { public: virtual ~TracedGlobalHandleVisitor() = default; - virtual void VisitTracedGlobalHandle(const TracedGlobal& value) = 0; + virtual void VisitTracedGlobalHandle(const TracedGlobal& handle) {} + virtual void VisitTracedReference(const TracedReference& handle) {} + }; + + /** + * Summary of a garbage collection cycle. See |TraceEpilogue| on how the + * summary is reported. + */ + struct TraceSummary { + /** + * Time spent managing the retained memory in milliseconds. This can e.g. + * include the time tracing through objects in the embedder. + */ + double time = 0.0; + + /** + * Memory retained by the embedder through the |EmbedderHeapTracer| + * mechanism in bytes. + */ + size_t allocated_size = 0; }; virtual ~EmbedderHeapTracer() = default; @@ -7229,6 +7943,17 @@ class V8_EXPORT EmbedderHeapTracer { */ void IterateTracedGlobalHandles(TracedGlobalHandleVisitor* visitor); + /** + * Called by the embedder to set the start of the stack which is e.g. used by + * V8 to determine whether handles are used from stack or heap. + */ + void SetStackStart(void* stack_start); + + /** + * Called by the embedder to notify V8 of an empty execution stack. + */ + void NotifyEmptyEmbedderStack(); + /** * Called by v8 to register internal fields of found wrappers. * @@ -7238,12 +7963,12 @@ class V8_EXPORT EmbedderHeapTracer { virtual void RegisterV8References( const std::vector >& embedder_fields) = 0; - void RegisterEmbedderReference(const TracedGlobal& ref); + void RegisterEmbedderReference(const TracedReferenceBase& ref); /** * Called at the beginning of a GC cycle. */ - virtual void TracePrologue() = 0; + virtual void TracePrologue(TraceFlags flags) {} /** * Called to advance tracing in the embedder. @@ -7266,9 +7991,11 @@ class V8_EXPORT EmbedderHeapTracer { /** * Called at the end of a GC cycle. * - * Note that allocation is *not* allowed within |TraceEpilogue|. + * Note that allocation is *not* allowed within |TraceEpilogue|. Can be + * overriden to fill a |TraceSummary| that is used by V8 to schedule future + * garbage collections. */ - virtual void TraceEpilogue() = 0; + virtual void TraceEpilogue(TraceSummary* trace_summary) {} /** * Called upon entering the final marking pause. No more incremental marking @@ -7290,13 +8017,35 @@ class V8_EXPORT EmbedderHeapTracer { /** * Returns true if the TracedGlobal handle should be considered as root for * the currently running non-tracing garbage collection and false otherwise. + * The default implementation will keep all TracedGlobal references as roots. * - * Default implementation will keep all TracedGlobal references as roots. + * If this returns false, then V8 may decide that the object referred to by + * such a handle is reclaimed. In that case: + * - No action is required if handles are used with destructors, i.e., by just + * using |TracedGlobal|. + * - When run without destructors, i.e., by using + * |TracedReference|, V8 calls |ResetHandleInNonTracingGC|. + * + * Note that the |handle| is different from the handle that the embedder holds + * for retaining the object. The embedder may use |WrapperClassId()| to + * distinguish cases where it wants handles to be treated as roots from not + * being treated as roots. */ virtual bool IsRootForNonTracingGC( - const v8::TracedGlobal& handle) { - return true; - } + const v8::TracedReference& handle); + virtual bool IsRootForNonTracingGC(const v8::TracedGlobal& handle); + + /** + * Used in combination with |IsRootForNonTracingGC|. Called by V8 when an + * object that is backed by a handle is reclaimed by a non-tracing garbage + * collection. It is up to the embedder to reset the original handle. + * + * Note that the |handle| is different from the handle that the embedder holds + * for retaining the object. It is up to the embedder to find the original + * handle via the object or class id. + */ + virtual void ResetHandleInNonTracingGC( + const v8::TracedReference& handle); /* * Called by the embedder to immediately perform a full garbage collection. @@ -7305,6 +8054,15 @@ class V8_EXPORT EmbedderHeapTracer { */ void GarbageCollectionForTesting(EmbedderStackState stack_state); + /* + * 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 * is not attached to any v8::Isolate. @@ -7354,6 +8112,66 @@ struct DeserializeInternalFieldsCallback { }; typedef DeserializeInternalFieldsCallback DeserializeEmbedderFieldsCallback; +/** + * Controls how the default MeasureMemoryDelegate reports the result of + * the memory measurement to JS. With kSummary only the total size is reported. + * With kDetailed the result includes the size of each native context. + */ +enum class MeasureMemoryMode { kSummary, kDetailed }; + +/** + * Controls how promptly a memory measurement request is executed. + * By default the measurement is folded with the next scheduled GC which may + * happen after a while. The kEager starts increment GC right away and + * is useful for testing. + */ +enum class MeasureMemoryExecution { kDefault, kEager }; + +/** + * The delegate is used in Isolate::MeasureMemory API. + * + * It specifies the contexts that need to be measured and gets called when + * the measurement is completed to report the results. + */ +class V8_EXPORT MeasureMemoryDelegate { + public: + virtual ~MeasureMemoryDelegate() = default; + + /** + * Returns true if the size of the given context needs to be measured. + */ + virtual bool ShouldMeasure(Local context) = 0; + + /** + * This function is called when memory measurement finishes. + * + * \param context_sizes_in_bytes a vector of (context, size) pairs that + * includes each context for which ShouldMeasure returned true and that + * was not garbage collected while the memory measurement was in progress. + * + * \param unattributed_size_in_bytes total size of objects that were not + * attributed to any context (i.e. are likely shared objects). + */ + virtual void MeasurementComplete( + const std::vector, size_t>>& + context_sizes_in_bytes, + size_t unattributed_size_in_bytes) = 0; + + /** + * Returns a default delegate that resolves the given promise when + * the memory measurement completes. + * + * \param isolate the current isolate + * \param context the current context + * \param promise_resolver the promise resolver that is given the + * result of the memory measurement. + * \param mode the detail level of the result. + */ + static std::unique_ptr Default( + Isolate* isolate, Local context, + Local promise_resolver, MeasureMemoryMode mode); +}; + /** * Isolate represents an isolated instance of the V8 engine. V8 isolates have * completely separate states. Objects from one isolate must not be used in @@ -7375,9 +8193,12 @@ class V8_EXPORT Isolate { create_histogram_callback(nullptr), add_histogram_sample_callback(nullptr), array_buffer_allocator(nullptr), + array_buffer_allocator_shared(), external_references(nullptr), allow_atomics_wait(true), - only_terminate_in_safe_scope(false) {} + only_terminate_in_safe_scope(false), + embedder_wrapper_type_index(-1), + embedder_wrapper_object_index(-1) {} /** * Allows the host application to provide the address of a function that is @@ -7414,8 +8235,14 @@ class V8_EXPORT Isolate { /** * The ArrayBuffer::Allocator to use for allocating and freeing the backing * store of ArrayBuffers. + * + * If the shared_ptr version is used, the Isolate instance and every + * |BackingStore| allocated using this allocator hold a std::shared_ptr + * to the allocator, in order to facilitate lifetime + * management for the allocator instance. */ ArrayBuffer::Allocator* array_buffer_allocator; + std::shared_ptr array_buffer_allocator_shared; /** * Specifies an optional nullptr-terminated array of raw addresses in the @@ -7435,6 +8262,14 @@ class V8_EXPORT Isolate { * Termination is postponed when there is no active SafeForTerminationScope. */ bool only_terminate_in_safe_scope; + + /** + * The following parameters describe the offsets for addressing type info + * for wrapped API objects and are used by the fast C API + * (for details see v8-fast-api-calls.h). + */ + int embedder_wrapper_type_index; + int embedder_wrapper_object_index; }; @@ -7507,8 +8342,8 @@ class V8_EXPORT Isolate { */ class V8_EXPORT SuppressMicrotaskExecutionScope { public: - explicit SuppressMicrotaskExecutionScope(Isolate* isolate); - explicit SuppressMicrotaskExecutionScope(MicrotaskQueue* microtask_queue); + explicit SuppressMicrotaskExecutionScope( + Isolate* isolate, MicrotaskQueue* microtask_queue = nullptr); ~SuppressMicrotaskExecutionScope(); // Prevent copying of Scope objects. @@ -7520,6 +8355,9 @@ class V8_EXPORT Isolate { private: internal::Isolate* const isolate_; internal::MicrotaskQueue* const microtask_queue_; + internal::Address previous_stack_height_; + + friend class internal::ThreadLocalTop; }; /** @@ -7629,11 +8467,43 @@ class V8_EXPORT Isolate { kOptimizedFunctionWithOneShotBytecode = 71, kRegExpMatchIsTrueishOnNonJSRegExp = 72, kRegExpMatchIsFalseishOnJSRegExp = 73, - kDateGetTimezoneOffset = 74, + kDateGetTimezoneOffset = 74, // Unused. kStringNormalize = 75, + kCallSiteAPIGetFunctionSloppyCall = 76, + kCallSiteAPIGetThisSloppyCall = 77, + kRegExpMatchAllWithNonGlobalRegExp = 78, + kRegExpExecCalledOnSlowRegExp = 79, + kRegExpReplaceCalledOnSlowRegExp = 80, + kDisplayNames = 81, + kSharedArrayBufferConstructed = 82, + kArrayPrototypeHasElements = 83, + kObjectPrototypeHasElements = 84, + kNumberFormatStyleUnit = 85, + kDateTimeFormatRange = 86, + kDateTimeFormatDateTimeStyle = 87, + kBreakIteratorTypeWord = 88, + kBreakIteratorTypeLine = 89, + kInvalidatedArrayBufferDetachingProtector = 90, + kInvalidatedArrayConstructorProtector = 91, + kInvalidatedArrayIteratorLookupChainProtector = 92, + kInvalidatedArraySpeciesLookupChainProtector = 93, + kInvalidatedIsConcatSpreadableLookupChainProtector = 94, + kInvalidatedMapIteratorLookupChainProtector = 95, + kInvalidatedNoElementsProtector = 96, + kInvalidatedPromiseHookProtector = 97, + kInvalidatedPromiseResolveLookupChainProtector = 98, + kInvalidatedPromiseSpeciesLookupChainProtector = 99, + kInvalidatedPromiseThenLookupChainProtector = 100, + kInvalidatedRegExpSpeciesLookupChainProtector = 101, + kInvalidatedSetIteratorLookupChainProtector = 102, + kInvalidatedStringIteratorLookupChainProtector = 103, + kInvalidatedStringLengthOverflowLookupChainProtector = 104, + kInvalidatedTypedArraySpeciesLookupChainProtector = 105, + kWasmSimdOpcodes = 106, + kVarRedeclaredCatchBinding = 107, // 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 + // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to // this list need to be landed first, then changes on the Chromium side. kUseCounterFeatureCount // This enum value must be last. }; @@ -7691,6 +8561,21 @@ class V8_EXPORT Isolate { */ static Isolate* GetCurrent(); + /** + * Clears the set of objects held strongly by the heap. This set of + * objects are originally built when a WeakRef is created or + * successfully dereferenced. + * + * This is invoked automatically after microtasks are run. See + * MicrotasksPolicy for when microtasks are run. + * + * This needs to be manually invoked only if the embedder is manually running + * microtasks via a custom MicrotaskQueue class's PerformCheckpoint. In that + * case, it is the embedder's responsibility to make this call at a time which + * does not interrupt synchronous ECMAScript code execution. + */ + void ClearKeptObjects(); + /** * Custom callback used by embedders to help V8 determine if it should abort * when it throws and no internal handler is predicted to catch the @@ -7704,6 +8589,17 @@ class V8_EXPORT Isolate { void SetAbortOnUncaughtExceptionCallback( AbortOnUncaughtExceptionCallback callback); + /** + * This specifies the callback to be called when FinalizationRegistries + * are ready to be cleaned up and require FinalizationGroup::Cleanup() + * to be called in a future task. + */ + V8_DEPRECATED( + "FinalizationRegistry cleanup is automatic if " + "HostCleanupFinalizationGroupCallback is not set") + void SetHostCleanupFinalizationGroupCallback( + HostCleanupFinalizationGroupCallback callback); + /** * This specifies the callback called by the upcoming dynamic * import() language feature to load modules. @@ -7848,6 +8744,26 @@ class V8_EXPORT Isolate { */ bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics* object_statistics); + /** + * This API is experimental and may change significantly. + * + * Enqueues a memory measurement request and invokes the delegate with the + * results. + * + * \param delegate the delegate that defines which contexts to measure and + * reports the results. + * + * \param execution promptness executing the memory measurement. + * The kEager value is expected to be used only in tests. + */ + bool MeasureMemory( + std::unique_ptr delegate, + MeasureMemoryExecution execution = MeasureMemoryExecution::kDefault); + + V8_DEPRECATE_SOON("Use the version with a delegate") + MaybeLocal MeasureMemory(Local context, + MeasureMemoryMode mode); + /** * Get a call stack sample from the isolate. * \param state Execution state. @@ -7909,8 +8825,8 @@ class V8_EXPORT Isolate { Local GetCurrentContext(); /** Returns the last context entered through V8's C++ API. */ - V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().", - Local GetEnteredContext()); + V8_DEPRECATED("Use GetEnteredOrMicrotaskContext().") + Local GetEnteredContext(); /** * Returns either the last context entered through V8's C++ API, or the @@ -8184,10 +9100,18 @@ class V8_EXPORT Isolate { void SetPromiseRejectCallback(PromiseRejectCallback callback); /** - * Runs the default MicrotaskQueue until it gets empty. - * Any exceptions thrown by microtask callbacks are swallowed. + * An alias for PerformMicrotaskCheckpoint. + */ + V8_DEPRECATE_SOON("Use PerformMicrotaskCheckpoint.") + void RunMicrotasks() { PerformMicrotaskCheckpoint(); } + + /** + * Runs the default MicrotaskQueue until it gets empty and perform other + * microtask checkpoint steps, such as calling ClearKeptObjects. Asserts that + * the MicrotasksPolicy is not kScoped. Any exceptions thrown by microtask + * callbacks are swallowed. */ - void RunMicrotasks(); + void PerformMicrotaskCheckpoint(); /** * Enqueues the callback to the default MicrotaskQueue @@ -8222,18 +9146,16 @@ class V8_EXPORT Isolate { * Executing scripts inside the callback will not re-trigger microtasks and * the callback. */ - V8_DEPRECATE_SOON("Use *WithData version.", - void AddMicrotasksCompletedCallback( - MicrotasksCompletedCallback callback)); + V8_DEPRECATE_SOON("Use *WithData version.") + void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback); void AddMicrotasksCompletedCallback( MicrotasksCompletedCallbackWithData callback, void* data = nullptr); /** * Removes callback that was installed by AddMicrotasksCompletedCallback. */ - V8_DEPRECATE_SOON("Use *WithData version.", - void RemoveMicrotasksCompletedCallback( - MicrotasksCompletedCallback callback)); + V8_DEPRECATE_SOON("Use *WithData version.") + void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback); void RemoveMicrotasksCompletedCallback( MicrotasksCompletedCallbackWithData callback, void* data = nullptr); @@ -8257,6 +9179,13 @@ class V8_EXPORT Isolate { void SetCreateHistogramFunction(CreateHistogramCallback); void SetAddHistogramSampleFunction(AddHistogramSampleCallback); + /** + * Enables the host application to provide a mechanism for recording a + * predefined set of data as crash keys to be used in postmortem debugging in + * case of a crash. + */ + void SetAddCrashKeyCallback(AddCrashKeyCallback); + /** * Optional notification that the embedder is idle. * V8 uses the notification to perform garbage collection. @@ -8280,10 +9209,10 @@ class V8_EXPORT Isolate { void LowMemoryNotification(); /** - * Optional notification that a context has been disposed. V8 uses - * these notifications to guide the GC heuristic. Returns the number - * of context disposals - including this one - since the last time - * V8 had a chance to clean up. + * Optional notification that a context has been disposed. V8 uses these + * notifications to guide the GC heuristic and cancel FinalizationRegistry + * cleanup tasks. Returns the number of context disposals - including this one + * - since the last time V8 had a chance to clean up. * * The optional parameter |dependant_context| specifies whether the disposed * context was depending on state from other contexts or not. @@ -8379,13 +9308,13 @@ class V8_EXPORT Isolate { /** * Returns a memory range that can potentially contain jitted code. Code for * V8's 'builtins' will not be in this range if embedded builtins is enabled. - * Instead, see GetEmbeddedCodeRange. * * On Win64, embedders are advised to install function table callbacks for * these ranges, as default SEH won't be able to unwind through jitted code. - * * The first page of the code range is reserved for the embedder and is - * committed, writable, and executable. + * committed, writable, and executable, to be used to store unwind data, as + * documented in + * https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64. * * Might be empty on other platforms. * @@ -8396,8 +9325,32 @@ class V8_EXPORT Isolate { /** * Returns the UnwindState necessary for use with the Unwinder API. */ + // TODO(petermarshall): Remove this API. + V8_DEPRECATED("Use entry_stubs + code_pages version.") UnwindState GetUnwindState(); + /** + * Returns the JSEntryStubs necessary for use with the Unwinder API. + */ + JSEntryStubs GetJSEntryStubs(); + + static constexpr size_t kMinCodePagesBufferSize = 32; + + /** + * Copies the code heap pages currently in use by V8 into |code_pages_out|. + * |code_pages_out| must have at least kMinCodePagesBufferSize capacity and + * must be empty. + * + * Signal-safe, does not allocate, does not access the V8 heap. + * No code on the stack can rely on pages that might be missing. + * + * Returns the number of pages available to be copied, which might be greater + * than |capacity|. In this case, only |capacity| pages will be copied into + * |code_pages_out|. The caller should provide a bigger buffer on the next + * call in order to get all available code pages, but this is not required. + */ + size_t CopyCodePages(size_t capacity, MemoryRange* code_pages_out); + /** Set the callback to invoke in case of fatal errors. */ void SetFatalErrorHandler(FatalErrorCallback that); @@ -8433,8 +9386,13 @@ class V8_EXPORT Isolate { * Set the callback to invoke to check if code generation from * strings should be allowed. */ + V8_DEPRECATED( + "Use Isolate::SetModifyCodeGenerationFromStringsCallback instead. " + "See http://crbug.com/v8/10096.") void SetAllowCodeGenerationFromStringsCallback( AllowCodeGenerationFromStringsCallback callback); + void SetModifyCodeGenerationFromStringsCallback( + ModifyCodeGenerationFromStringsCallback callback); /** * Set the callback to invoke to check if wasm code generation should @@ -8454,6 +9412,10 @@ class V8_EXPORT Isolate { void SetWasmThreadsEnabledCallback(WasmThreadsEnabledCallback callback); + void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback); + + void SetWasmSimdEnabledCallback(WasmSimdEnabledCallback callback); + /** * Check if V8 is dead and therefore unusable. This is the case after * fatal errors such as out-of-memory situations. @@ -8597,6 +9559,13 @@ class V8_EXPORT Isolate { class V8_EXPORT StartupData { public: + /** + * Whether the data created can be rehashed and and the hash seed can be + * recomputed when deserialized. + * Only valid for StartupData returned by SnapshotCreator::CreateBlob(). + */ + bool CanBeRehashed() const; + const char* data; int raw_size; }; @@ -8645,7 +9614,6 @@ class V8_EXPORT V8 { * handled entirely on the embedders' side. * - The call will abort if the data is invalid. */ - static void SetNativesDataBlob(StartupData* startup_blob); static void SetSnapshotDataBlob(StartupData* startup_blob); /** Set the callback to invoke in case of Dcheck failures. */ @@ -8655,7 +9623,8 @@ class V8_EXPORT V8 { /** * Sets V8 flags from a string. */ - static void SetFlagsFromString(const char* str, int length); + static void SetFlagsFromString(const char* str); + static void SetFlagsFromString(const char* str, size_t length); /** * Sets V8 flags from the command line. @@ -8671,7 +9640,13 @@ class V8_EXPORT V8 { * Initializes V8. This function needs to be called before the first Isolate * is created. It always returns true. */ - static bool Initialize(); + V8_INLINE static bool Initialize() { + const int kBuildConfiguration = + (internal::PointerCompressionIsEnabled() ? kPointerCompression : 0) | + (internal::SmiValuesAre31Bits() ? k31BitSmis : 0) | + (internal::HeapSandboxIsEnabled() ? kHeapSandbox : 0); + return Initialize(kBuildConfiguration); + } /** * Allows the host application to provide a callback which can be used @@ -8729,17 +9704,16 @@ class V8_EXPORT V8 { * V8 needs to be given those external files during startup. There are * three ways to do this: * - InitializeExternalStartupData(const char*) - * This will look in the given directory for files "natives_blob.bin" - * and "snapshot_blob.bin" - which is what the default build calls them. - * - InitializeExternalStartupData(const char*, const char*) - * As above, but will directly use the two given file names. - * - Call SetNativesDataBlob, SetNativesDataBlob. - * This will read the blobs from the given data structures and will + * This will look in the given directory for the file "snapshot_blob.bin". + * - InitializeExternalStartupDataFromFile(const char*) + * As above, but will directly use the given file name. + * - Call SetSnapshotDataBlob. + * This will read the blobs from the given data structure and will * not perform any file IO. */ static void InitializeExternalStartupData(const char* directory_path); - static void InitializeExternalStartupData(const char* natives_blob, - const char* snapshot_blob); + static void InitializeExternalStartupDataFromFile(const char* snapshot_blob); + /** * Sets the v8::Platform to use. This should be invoked before V8 is * initialized. @@ -8772,9 +9746,8 @@ class V8_EXPORT V8 { * \param context The third argument passed to the Linux signal handler, which * points to a ucontext_t structure. */ - V8_DEPRECATE_SOON("Use TryHandleWebAssemblyTrapPosix", - static bool TryHandleSignal(int signal_number, void* info, - void* context)); + V8_DEPRECATE_SOON("Use TryHandleWebAssemblyTrapPosix") + static bool TryHandleSignal(int signal_number, void* info, void* context); #endif // V8_OS_POSIX /** @@ -8785,18 +9758,52 @@ class V8_EXPORT V8 { */ static bool EnableWebAssemblyTrapHandler(bool use_v8_signal_handler); +#if defined(V8_OS_WIN) + /** + * On Win64, by default V8 does not emit unwinding data for jitted code, + * which means the OS cannot walk the stack frames and the system Structured + * Exception Handling (SEH) cannot unwind through V8-generated code: + * https://code.google.com/p/v8/issues/detail?id=3598. + * + * This function allows embedders to register a custom exception handler for + * exceptions in V8-generated code. + */ + static void SetUnhandledExceptionCallback( + UnhandledExceptionCallback unhandled_exception_callback); +#endif + + /** + * Get statistics about the shared memory usage. + */ + static void GetSharedMemoryStatistics(SharedMemoryStatistics* statistics); + private: V8(); + enum BuildConfigurationFeatures { + kPointerCompression = 1 << 0, + k31BitSmis = 1 << 1, + kHeapSandbox = 1 << 2, + }; + + /** + * Checks that the embedder build configuration is compatible with + * the V8 binary and if so initializes V8. + */ + static bool Initialize(int build_config); + static internal::Address* GlobalizeReference(internal::Isolate* isolate, internal::Address* handle); static internal::Address* GlobalizeTracedReference(internal::Isolate* isolate, internal::Address* handle, - internal::Address* slot); + internal::Address* slot, + bool has_destructor); static void MoveGlobalReference(internal::Address** from, internal::Address** to); static void MoveTracedGlobalReference(internal::Address** from, internal::Address** to); + static void CopyTracedGlobalReference(const internal::Address* const* from, + internal::Address** to); static internal::Address* CopyGlobalReference(internal::Address* from); static void DisposeGlobal(internal::Address* global_handle); static void DisposeTracedGlobal(internal::Address* global_handle); @@ -8812,9 +9819,6 @@ class V8_EXPORT V8 { const char* label); static Value* Eternalize(Isolate* isolate, Value* handle); - static void RegisterExternallyReferencedObject(internal::Address* location, - internal::Isolate* isolate); - template friend class PersistentValueMapBase; @@ -8829,8 +9833,12 @@ class V8_EXPORT V8 { template friend class Maybe; template + friend class TracedReferenceBase; + template friend class TracedGlobal; template + friend class TracedReference; + template friend class WeakCallbackInfo; template friend class Eternal; template friend class PersistentBase; @@ -8840,6 +9848,11 @@ class V8_EXPORT V8 { /** * Helper class to create a snapshot data blob. + * + * The Isolate used by a SnapshotCreator is owned by it, and will be entered + * and exited by the constructor and destructor, respectively; The destructor + * will also destroy the Isolate. Experimental language features, including + * those available by default, are not available while creating a snapshot. */ class V8_EXPORT SnapshotCreator { public: @@ -8868,6 +9881,10 @@ class V8_EXPORT SnapshotCreator { SnapshotCreator(const intptr_t* external_references = nullptr, StartupData* existing_blob = nullptr); + /** + * Destroy the snapshot creator, and exit and dispose of the Isolate + * associated with it. + */ ~SnapshotCreator(); /** @@ -8898,12 +9915,6 @@ class V8_EXPORT SnapshotCreator { SerializeInternalFieldsCallback callback = SerializeInternalFieldsCallback()); - /** - * Add a template to be included in the snapshot blob. - * \returns the index of the template in the snapshot blob. - */ - size_t AddTemplate(Local