GeezerVison is showing github.com — deps: V8: cherry-pick c3dffe6e2bda · nodejs/node@4884746
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: common.gypi +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 36 | 36 |
| 37 | 37 | # Reset this number to 0 on major V8 upgrades. | 38 | 38 | # Increment by one for each non-official patch applied to deps/v8. | 39 | | - 'v8_embedder_string': '-node.14', | | 39 | + 'v8_embedder_string': '-node.15', | 40 | 40 |
| 41 | 41 | ##### V8 defaults for Node.js ##### | 42 | 42 |
| |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/include/v8-script.h +9-1Lines changed: 9 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -92,7 +92,15 @@ class V8_EXPORT UnboundScript { | 92 | 92 | * A compiled JavaScript module, not yet tied to a Context. | 93 | 93 | */ | 94 | 94 | class V8_EXPORT UnboundModuleScript : public Data { | 95 | | - // Only used as a container for code caching. | | 95 | + public: | | 96 | + /** | | 97 | + * Data read from magic sourceURL comments. | | 98 | + */ | | 99 | + Local<Value> GetSourceURL(); | | 100 | + /** | | 101 | + * Data read from magic sourceMappingURL comments. | | 102 | + */ | | 103 | + Local<Value> GetSourceMappingURL(); | 96 | 104 | }; | 97 | 105 |
| 98 | 106 | /** | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/api/api.cc +44-16Lines changed: 44 additions & 16 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1936,8 +1936,32 @@ void ObjectTemplate::SetCodeLike() { | 1936 | 1936 |
| 1937 | 1937 | // --- S c r i p t s --- | 1938 | 1938 |
| 1939 | | -// Internally, UnboundScript is a SharedFunctionInfo, and Script is a | 1940 | | -// JSFunction. | | 1939 | +// Internally, UnboundScript and UnboundModuleScript are SharedFunctionInfos, | | 1940 | +// and Script is a JSFunction. | | 1941 | + | | 1942 | +namespace { | | 1943 | +inline Local<Value> GetSharedFunctionInfoSourceMappingURL( | | 1944 | + i::Isolate* isolate, i::Handle<i::SharedFunctionInfo> obj) { | | 1945 | + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); | | 1946 | + if (obj->script().IsScript()) { | | 1947 | + i::Object url = i::Script::cast(obj->script()).source_mapping_url(); | | 1948 | + return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); | | 1949 | + } else { | | 1950 | + return Local<String>(); | | 1951 | + } | | 1952 | +} | | 1953 | + | | 1954 | +inline Local<Value> GetSharedFunctionInfoSourceURL( | | 1955 | + i::Isolate* isolate, i::Handle<i::SharedFunctionInfo> obj) { | | 1956 | + ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); | | 1957 | + if (obj->script().IsScript()) { | | 1958 | + i::Object url = i::Script::cast(obj->script()).source_url(); | | 1959 | + return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); | | 1960 | + } else { | | 1961 | + return Local<String>(); | | 1962 | + } | | 1963 | +} | | 1964 | +} // namespace | 1941 | 1965 |
| 1942 | 1966 | ScriptCompiler::CachedData::CachedData(const uint8_t* data_, int length_, | 1943 | 1967 | BufferPolicy buffer_policy_) | @@ -2022,28 +2046,32 @@ Local<Value> UnboundScript::GetSourceURL() { | 2022 | 2046 | i::Handle<i::SharedFunctionInfo> obj = | 2023 | 2047 | i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 2024 | 2048 | i::Isolate* i_isolate = obj->GetIsolate(); | 2025 | | - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); | 2026 | 2049 | API_RCS_SCOPE(i_isolate, UnboundScript, GetSourceURL); | 2027 | | - if (obj->script().IsScript()) { | 2028 | | - i::Object url = i::Script::cast(obj->script()).source_url(); | 2029 | | - return Utils::ToLocal(i::Handle<i::Object>(url, i_isolate)); | 2030 | | - } else { | 2031 | | - return Local<String>(); | 2032 | | - } | | 2050 | + return GetSharedFunctionInfoSourceURL(i_isolate, obj); | 2033 | 2051 | } | 2034 | 2052 |
| 2035 | 2053 | Local<Value> UnboundScript::GetSourceMappingURL() { | 2036 | 2054 | i::Handle<i::SharedFunctionInfo> obj = | 2037 | 2055 | i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 2038 | 2056 | i::Isolate* i_isolate = obj->GetIsolate(); | 2039 | 2057 | API_RCS_SCOPE(i_isolate, UnboundScript, GetSourceMappingURL); | 2040 | | - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); | 2041 | | - if (obj->script().IsScript()) { | 2042 | | - i::Object url = i::Script::cast(obj->script()).source_mapping_url(); | 2043 | | - return Utils::ToLocal(i::Handle<i::Object>(url, i_isolate)); | 2044 | | - } else { | 2045 | | - return Local<String>(); | 2046 | | - } | | 2058 | + return GetSharedFunctionInfoSourceMappingURL(i_isolate, obj); | | 2059 | +} | | 2060 | + | | 2061 | +Local<Value> UnboundModuleScript::GetSourceURL() { | | 2062 | + i::Handle<i::SharedFunctionInfo> obj = | | 2063 | + i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | | 2064 | + i::Isolate* i_isolate = obj->GetIsolate(); | | 2065 | + API_RCS_SCOPE(i_isolate, UnboundModuleScript, GetSourceURL); | | 2066 | + return GetSharedFunctionInfoSourceURL(i_isolate, obj); | | 2067 | +} | | 2068 | + | | 2069 | +Local<Value> UnboundModuleScript::GetSourceMappingURL() { | | 2070 | + i::Handle<i::SharedFunctionInfo> obj = | | 2071 | + i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | | 2072 | + i::Isolate* i_isolate = obj->GetIsolate(); | | 2073 | + API_RCS_SCOPE(i_isolate, UnboundModuleScript, GetSourceMappingURL); | | 2074 | + return GetSharedFunctionInfoSourceMappingURL(i_isolate, obj); | 2047 | 2075 | } | 2048 | 2076 |
| 2049 | 2077 | MaybeLocal<Value> Script::Run(Local<Context> context) { | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/src/logging/runtime-call-stats.h +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -278,6 +278,8 @@ class RuntimeCallTimer final { | 278 | 278 | V(Uint32Array_New) \ | 279 | 279 | V(Uint8Array_New) \ | 280 | 280 | V(Uint8ClampedArray_New) \ | | 281 | + V(UnboundModuleScript_GetSourceMappingURL) \ | | 282 | + V(UnboundModuleScript_GetSourceURL) \ | 281 | 283 | V(UnboundScript_GetColumnNumber) \ | 282 | 284 | V(UnboundScript_GetId) \ | 283 | 285 | V(UnboundScript_GetLineNumber) \ | |
Collapse file Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-api.cc +39-14Lines changed: 39 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -22920,33 +22920,58 @@ TEST(ScriptPositionInfo) { | 22920 | 22920 | } | 22921 | 22921 | } | 22922 | 22922 |
| 22923 | | -void CheckMagicComments(v8::Isolate* isolate, Local<Script> script, | | 22923 | +template <typename T> | | 22924 | +void CheckMagicComments(v8::Isolate* isolate, Local<T> unbound_script, | 22924 | 22925 | const char* expected_source_url, | 22925 | 22926 | const char* expected_source_mapping_url) { | 22926 | 22927 | if (expected_source_url != nullptr) { | 22927 | | - v8::String::Utf8Value url(isolate, | 22928 | | - script->GetUnboundScript()->GetSourceURL()); | | 22928 | + v8::String::Utf8Value url(isolate, unbound_script->GetSourceURL()); | 22929 | 22929 | CHECK_EQ(0, strcmp(expected_source_url, *url)); | 22930 | 22930 | } else { | 22931 | | - CHECK(script->GetUnboundScript()->GetSourceURL()->IsUndefined()); | | 22931 | + CHECK(unbound_script->GetSourceURL()->IsUndefined()); | 22932 | 22932 | } | 22933 | 22933 | if (expected_source_mapping_url != nullptr) { | 22934 | | - v8::String::Utf8Value url( | 22935 | | - isolate, script->GetUnboundScript()->GetSourceMappingURL()); | | 22934 | + v8::String::Utf8Value url(isolate, unbound_script->GetSourceMappingURL()); | 22936 | 22935 | CHECK_EQ(0, strcmp(expected_source_mapping_url, *url)); | 22937 | 22936 | } else { | 22938 | | - CHECK(script->GetUnboundScript()->GetSourceMappingURL()->IsUndefined()); | | 22937 | + CHECK(unbound_script->GetSourceMappingURL()->IsUndefined()); | 22939 | 22938 | } | 22940 | 22939 | } | 22941 | 22940 |
| 22942 | | -void SourceURLHelper(v8::Isolate* isolate, const char* source, | | 22941 | +void SourceURLHelper(v8::Isolate* isolate, const char* source_text, | 22943 | 22942 | const char* expected_source_url, | 22944 | 22943 | const char* expected_source_mapping_url) { | 22945 | | - Local<Script> script = v8_compile(source); | 22946 | | - CheckMagicComments(isolate, script, expected_source_url, | 22947 | | - expected_source_mapping_url); | 22948 | | -} | | 22944 | + // Check scripts | | 22945 | + { | | 22946 | + Local<Script> script = v8_compile(source_text); | | 22947 | + CheckMagicComments(isolate, script->GetUnboundScript(), expected_source_url, | | 22948 | + expected_source_mapping_url); | | 22949 | + } | 22949 | 22950 |
| | 22951 | + // Check modules | | 22952 | + { | | 22953 | + Local<v8::String> source_str = v8_str(source_text); | | 22954 | + // Set a different resource name with the case above to invalidate the | | 22955 | + // cache. | | 22956 | + v8::ScriptOrigin origin(isolate, | | 22957 | + v8_str("module.js"), // resource name | | 22958 | + 0, // line offset | | 22959 | + 0, // column offset | | 22960 | + true, // is cross origin | | 22961 | + -1, // script id | | 22962 | + Local<Value>(), // source map URL | | 22963 | + false, // is opaque | | 22964 | + false, // is WASM | | 22965 | + true // is ES Module | | 22966 | + ); | | 22967 | + v8::ScriptCompiler::Source source(source_str, origin, nullptr); | | 22968 | + | | 22969 | + Local<v8::Module> module = | | 22970 | + v8::ScriptCompiler::CompileModule(isolate, &source).ToLocalChecked(); | | 22971 | + CheckMagicComments(isolate, module->GetUnboundModuleScript(), | | 22972 | + expected_source_url, expected_source_mapping_url); | | 22973 | + } | | 22974 | +} | 22950 | 22975 |
| 22951 | 22976 | TEST(ScriptSourceURLAndSourceMappingURL) { | 22952 | 22977 | LocalContext env; | @@ -23245,8 +23270,8 @@ void RunStreamingTest(const char** chunks, v8::ScriptType type, | 23245 | 23270 | script.ToLocalChecked()->Run(env.local()).ToLocalChecked()); | 23246 | 23271 | // All scripts are supposed to return the fixed value 13 when ran. | 23247 | 23272 | CHECK_EQ(13, result->Int32Value(env.local()).FromJust()); | 23248 | | - CheckMagicComments(isolate, script.ToLocalChecked(), expected_source_url, | 23249 | | - expected_source_mapping_url); | | 23273 | + CheckMagicComments(isolate, script.ToLocalChecked()->GetUnboundScript(), | | 23274 | + expected_source_url, expected_source_mapping_url); | 23250 | 23275 | } else { | 23251 | 23276 | CHECK(script.IsEmpty()); | 23252 | 23277 | } | |
|