diff --git a/common.gypi b/common.gypi index 2a06e7d1401..ccfd1bccb16 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.14', + 'v8_embedder_string': '-node.15', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/include/v8-script.h b/deps/v8/include/v8-script.h index dbd98ed55b4..e2ba845268d 100644 --- a/deps/v8/include/v8-script.h +++ b/deps/v8/include/v8-script.h @@ -92,7 +92,15 @@ class V8_EXPORT UnboundScript { * A compiled JavaScript module, not yet tied to a Context. */ class V8_EXPORT UnboundModuleScript : public Data { - // Only used as a container for code caching. + public: + /** + * Data read from magic sourceURL comments. + */ + Local GetSourceURL(); + /** + * Data read from magic sourceMappingURL comments. + */ + Local GetSourceMappingURL(); }; /** diff --git a/deps/v8/src/api/api.cc b/deps/v8/src/api/api.cc index 608da3369fa..cf755cafc2c 100644 --- a/deps/v8/src/api/api.cc +++ b/deps/v8/src/api/api.cc @@ -1936,8 +1936,32 @@ void ObjectTemplate::SetCodeLike() { // --- S c r i p t s --- -// Internally, UnboundScript is a SharedFunctionInfo, and Script is a -// JSFunction. +// Internally, UnboundScript and UnboundModuleScript are SharedFunctionInfos, +// and Script is a JSFunction. + +namespace { +inline Local GetSharedFunctionInfoSourceMappingURL( + i::Isolate* isolate, i::Handle obj) { + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); + if (obj->script().IsScript()) { + i::Object url = i::Script::cast(obj->script()).source_mapping_url(); + return Utils::ToLocal(i::Handle(url, isolate)); + } else { + return Local(); + } +} + +inline Local GetSharedFunctionInfoSourceURL( + i::Isolate* isolate, i::Handle obj) { + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); + if (obj->script().IsScript()) { + i::Object url = i::Script::cast(obj->script()).source_url(); + return Utils::ToLocal(i::Handle(url, isolate)); + } else { + return Local(); + } +} +} // namespace ScriptCompiler::CachedData::CachedData(const uint8_t* data_, int length_, BufferPolicy buffer_policy_) @@ -2022,14 +2046,8 @@ Local UnboundScript::GetSourceURL() { i::Handle obj = i::Handle::cast(Utils::OpenHandle(this)); i::Isolate* i_isolate = obj->GetIsolate(); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); API_RCS_SCOPE(i_isolate, UnboundScript, GetSourceURL); - if (obj->script().IsScript()) { - i::Object url = i::Script::cast(obj->script()).source_url(); - return Utils::ToLocal(i::Handle(url, i_isolate)); - } else { - return Local(); - } + return GetSharedFunctionInfoSourceURL(i_isolate, obj); } Local UnboundScript::GetSourceMappingURL() { @@ -2037,13 +2055,23 @@ Local UnboundScript::GetSourceMappingURL() { i::Handle::cast(Utils::OpenHandle(this)); i::Isolate* i_isolate = obj->GetIsolate(); API_RCS_SCOPE(i_isolate, UnboundScript, GetSourceMappingURL); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); - if (obj->script().IsScript()) { - i::Object url = i::Script::cast(obj->script()).source_mapping_url(); - return Utils::ToLocal(i::Handle(url, i_isolate)); - } else { - return Local(); - } + return GetSharedFunctionInfoSourceMappingURL(i_isolate, obj); +} + +Local UnboundModuleScript::GetSourceURL() { + i::Handle obj = + i::Handle::cast(Utils::OpenHandle(this)); + i::Isolate* i_isolate = obj->GetIsolate(); + API_RCS_SCOPE(i_isolate, UnboundModuleScript, GetSourceURL); + return GetSharedFunctionInfoSourceURL(i_isolate, obj); +} + +Local UnboundModuleScript::GetSourceMappingURL() { + i::Handle obj = + i::Handle::cast(Utils::OpenHandle(this)); + i::Isolate* i_isolate = obj->GetIsolate(); + API_RCS_SCOPE(i_isolate, UnboundModuleScript, GetSourceMappingURL); + return GetSharedFunctionInfoSourceMappingURL(i_isolate, obj); } MaybeLocal Script::Run(Local context) { diff --git a/deps/v8/src/logging/runtime-call-stats.h b/deps/v8/src/logging/runtime-call-stats.h index e6998d4bfb1..4c02309b749 100644 --- a/deps/v8/src/logging/runtime-call-stats.h +++ b/deps/v8/src/logging/runtime-call-stats.h @@ -278,6 +278,8 @@ class RuntimeCallTimer final { V(Uint32Array_New) \ V(Uint8Array_New) \ V(Uint8ClampedArray_New) \ + V(UnboundModuleScript_GetSourceMappingURL) \ + V(UnboundModuleScript_GetSourceURL) \ V(UnboundScript_GetColumnNumber) \ V(UnboundScript_GetId) \ V(UnboundScript_GetLineNumber) \ diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 759851f6997..51294fccc8d 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -22920,33 +22920,58 @@ TEST(ScriptPositionInfo) { } } -void CheckMagicComments(v8::Isolate* isolate, Local