diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-09-21 09:14:51 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-09-22 18:29:25 +0200 |
commit | 0e7ddbd3d7e9439c67573b854c49cf82c398ae82 (patch) | |
tree | 2afe372acde921cb57ddb3444ff00c5adef8848c /deps/v8/test/inspector | |
parent | 13245dc50da4cb7443c39ef6c68d419d5e6336d4 (diff) | |
download | node-new-0e7ddbd3d7e9439c67573b854c49cf82c398ae82.tar.gz |
deps: update V8 to 7.0.276.20
PR-URL: https://github.com/nodejs/node/pull/22754
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/test/inspector')
4 files changed, 110 insertions, 86 deletions
diff --git a/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt b/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt index 9173fe7e70..a24ba5c370 100644 --- a/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt +++ b/deps/v8/test/inspector/debugger/object-preview-internal-properties-expected.txt @@ -30,6 +30,11 @@ expression: Object(Symbol(42)) description : Symbol overflow : false properties : [ + [0] : { + name : description + type : string + value : 42 + } ] type : object } diff --git a/deps/v8/test/inspector/debugger/resource-name-to-url-expected.txt b/deps/v8/test/inspector/debugger/resource-name-to-url-expected.txt index 0ecd0b82ef..2e6e589b25 100644 --- a/deps/v8/test/inspector/debugger/resource-name-to-url-expected.txt +++ b/deps/v8/test/inspector/debugger/resource-name-to-url-expected.txt @@ -12,7 +12,7 @@ Check script with url: isModule : false length : 16 scriptId : <scriptId> - sourceMapURL : + sourceMapURL : startColumn : 0 startLine : 0 url : prefix://url @@ -31,7 +31,7 @@ Check script with sourceURL comment: isModule : false length : 37 scriptId : <scriptId> - sourceMapURL : + sourceMapURL : startColumn : 0 startLine : 0 url : foo.js @@ -49,7 +49,7 @@ Check script failed to parse: isModule : false length : 15 scriptId : <scriptId> - sourceMapURL : + sourceMapURL : startColumn : 0 startLine : 0 url : prefix://url @@ -67,7 +67,7 @@ Check script failed to parse with sourceURL comment: isModule : false length : 36 scriptId : <scriptId> - sourceMapURL : + sourceMapURL : startColumn : 0 startLine : 0 url : foo.js @@ -96,14 +96,14 @@ Test runtime stack trace: } [1] : { columnNumber : 0 - functionName : + functionName : lineNumber : 0 scriptId : <scriptId> url : boo.js } [2] : { columnNumber : 4 - functionName : + functionName : lineNumber : 4 scriptId : <scriptId> url : prefix://url diff --git a/deps/v8/test/inspector/inspector-test.cc b/deps/v8/test/inspector/inspector-test.cc index 93a8b1d3f2..dbb4493e66 100644 --- a/deps/v8/test/inspector/inspector-test.cc +++ b/deps/v8/test/inspector/inspector-test.cc @@ -7,6 +7,8 @@ #endif // !defined(_WIN32) && !defined(_WIN64) #include <locale.h> +#include <string> +#include <vector> #include "include/libplatform/libplatform.h" #include "include/v8.h" @@ -38,10 +40,10 @@ void Exit() { Terminate(); } -v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) { - v8::internal::Vector<uint16_t> buffer = - v8::internal::Vector<uint16_t>::New(str->Length()); - str->Write(buffer.start(), 0, str->Length()); +std::vector<uint16_t> ToVector(v8::Isolate* isolate, + v8::Local<v8::String> str) { + std::vector<uint16_t> buffer(str->Length()); + str->Write(isolate, buffer.data(), 0, str->Length()); return buffer; } @@ -50,24 +52,24 @@ v8::Local<v8::String> ToV8String(v8::Isolate* isolate, const char* str) { .ToLocalChecked(); } -v8::Local<v8::String> ToV8String(v8::Isolate* isolate, const char* str, - int length) { - return v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kNormal, - length) +v8::Local<v8::String> ToV8String(v8::Isolate* isolate, + const std::string& buffer) { + int length = static_cast<int>(buffer.size()); + return v8::String::NewFromUtf8(isolate, buffer.data(), + v8::NewStringType::kNormal, length) .ToLocalChecked(); } v8::Local<v8::String> ToV8String(v8::Isolate* isolate, - const v8::internal::Vector<uint16_t>& buffer) { - return v8::String::NewFromTwoByte(isolate, buffer.start(), - v8::NewStringType::kNormal, buffer.length()) + const std::vector<uint16_t>& buffer) { + int length = static_cast<int>(buffer.size()); + return v8::String::NewFromTwoByte(isolate, buffer.data(), + v8::NewStringType::kNormal, length) .ToLocalChecked(); } -v8::internal::Vector<uint16_t> ToVector( - const v8_inspector::StringView& string) { - v8::internal::Vector<uint16_t> buffer = - v8::internal::Vector<uint16_t>::New(static_cast<int>(string.length())); +std::vector<uint16_t> ToVector(const v8_inspector::StringView& string) { + std::vector<uint16_t> buffer(string.length()); for (size_t i = 0; i < string.length(); i++) { if (string.is8Bit()) buffer[i] = string.characters8()[i]; @@ -105,7 +107,7 @@ class FrontendChannelImpl : public v8_inspector::V8Inspector::Channel { class SendMessageTask : public TaskRunner::Task { public: SendMessageTask(FrontendChannelImpl* channel, - const v8::internal::Vector<uint16_t>& message) + const std::vector<uint16_t>& message) : channel_(channel), message_(message) {} virtual ~SendMessageTask() {} bool is_priority_task() final { return false; } @@ -124,7 +126,7 @@ class FrontendChannelImpl : public v8_inspector::V8Inspector::Channel { ->Call(context, context->Global(), 1, &message); } FrontendChannelImpl* channel_; - v8::internal::Vector<uint16_t> message_; + std::vector<uint16_t> message_; }; TaskRunner* task_runner_; @@ -160,19 +162,18 @@ void RunSyncTask(TaskRunner* task_runner, T callback) { class SendMessageToBackendTask : public TaskRunner::Task { public: - SendMessageToBackendTask(int session_id, - const v8::internal::Vector<uint16_t>& message) + SendMessageToBackendTask(int session_id, const std::vector<uint16_t>& message) : session_id_(session_id), message_(message) {} bool is_priority_task() final { return true; } private: void Run(IsolateData* data) override { - v8_inspector::StringView message_view(message_.start(), message_.length()); + v8_inspector::StringView message_view(message_.data(), message_.size()); data->SendMessage(session_id_, message_view); } int session_id_; - v8::internal::Vector<uint16_t> message_; + std::vector<uint16_t> message_; }; void RunAsyncTask(TaskRunner* task_runner, @@ -200,21 +201,23 @@ void RunAsyncTask(TaskRunner* task_runner, class ExecuteStringTask : public TaskRunner::Task { public: - ExecuteStringTask(int context_group_id, - const v8::internal::Vector<uint16_t>& expression, + ExecuteStringTask(v8::Isolate* isolate, int context_group_id, + const std::vector<uint16_t>& expression, v8::Local<v8::String> name, v8::Local<v8::Integer> line_offset, v8::Local<v8::Integer> column_offset, v8::Local<v8::Boolean> is_module) : expression_(expression), - name_(ToVector(name)), + name_(ToVector(isolate, name)), line_offset_(line_offset.As<v8::Int32>()->Value()), column_offset_(column_offset.As<v8::Int32>()->Value()), is_module_(is_module->Value()), context_group_id_(context_group_id) {} - ExecuteStringTask(const v8::internal::Vector<const char>& expression, - int context_group_id) + ExecuteStringTask(const std::string& expression, int context_group_id) : expression_utf8_(expression), context_group_id_(context_group_id) {} + + virtual ~ExecuteStringTask() { + } bool is_priority_task() override { return false; } void Run(IsolateData* data) override { v8::MicrotasksScope microtasks_scope(data->isolate(), @@ -233,11 +236,10 @@ class ExecuteStringTask : public TaskRunner::Task { /* is_wasm */ v8::Local<v8::Boolean>(), v8::Boolean::New(data->isolate(), is_module_)); v8::Local<v8::String> source; - if (expression_.length()) + if (expression_.size() != 0) source = ToV8String(data->isolate(), expression_); else - source = ToV8String(data->isolate(), expression_utf8_.start(), - expression_utf8_.length()); + source = ToV8String(data->isolate(), expression_utf8_); v8::ScriptCompiler::Source scriptSource(source, origin); v8::Isolate::SafeForTerminationScope allowTermination(data->isolate()); @@ -248,14 +250,19 @@ class ExecuteStringTask : public TaskRunner::Task { v8::MaybeLocal<v8::Value> result; result = script->Run(context); } else { - data->RegisterModule(context, name_, &scriptSource); + // Register Module takes ownership of {buffer}, so we need to make a copy. + int length = static_cast<int>(name_.size()); + v8::internal::Vector<uint16_t> buffer = + v8::internal::Vector<uint16_t>::New(length); + std::copy(name_.begin(), name_.end(), buffer.start()); + data->RegisterModule(context, buffer, &scriptSource); } } private: - v8::internal::Vector<uint16_t> expression_; - v8::internal::Vector<const char> expression_utf8_; - v8::internal::Vector<uint16_t> name_; + std::vector<uint16_t> expression_; + std::string expression_utf8_; + std::vector<uint16_t> name_; int32_t line_offset_ = 0; int32_t column_offset_ = 0; bool is_module_ = false; @@ -372,7 +379,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask { } static bool ReadFile(v8::Isolate* isolate, v8::Local<v8::Value> name, - v8::internal::Vector<const char>* chars) { + std::string* chars) { v8::String::Utf8Value str(isolate, name); bool exists = false; std::string filename(*str, str.length()); @@ -389,10 +396,11 @@ class UtilsExtension : public IsolateData::SetupGlobalTask { fprintf(stderr, "Internal error: read gets one string argument."); Exit(); } - v8::internal::Vector<const char> chars; + std::string chars; v8::Isolate* isolate = args.GetIsolate(); - if (ReadFile(isolate, args[0], &chars)) - args.GetReturnValue().Set(ToV8String(isolate, chars.start())); + if (ReadFile(isolate, args[0], &chars)) { + args.GetReturnValue().Set(ToV8String(isolate, chars)); + } } static void Load(const v8::FunctionCallbackInfo<v8::Value>& args) { @@ -400,7 +408,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask { fprintf(stderr, "Internal error: load gets one string argument."); Exit(); } - v8::internal::Vector<const char> chars; + std::string chars; v8::Isolate* isolate = args.GetIsolate(); v8::Local<v8::Context> context = isolate->GetCurrentContext(); IsolateData* data = IsolateData::FromContext(context); @@ -423,7 +431,8 @@ class UtilsExtension : public IsolateData::SetupGlobalTask { } backend_runner_->Append(new ExecuteStringTask( - args[0].As<v8::Int32>()->Value(), ToVector(args[1].As<v8::String>()), + args.GetIsolate(), args[0].As<v8::Int32>()->Value(), + ToVector(args.GetIsolate(), args[1].As<v8::String>()), args[2].As<v8::String>(), args[3].As<v8::Int32>(), args[4].As<v8::Int32>(), args[5].As<v8::Boolean>())); } @@ -456,16 +465,18 @@ class UtilsExtension : public IsolateData::SetupGlobalTask { "'reason', 'details')."); Exit(); } - v8::internal::Vector<uint16_t> reason = ToVector(args[1].As<v8::String>()); - v8::internal::Vector<uint16_t> details = ToVector(args[2].As<v8::String>()); + std::vector<uint16_t> reason = + ToVector(args.GetIsolate(), args[1].As<v8::String>()); + std::vector<uint16_t> details = + ToVector(args.GetIsolate(), args[2].As<v8::String>()); int context_group_id = args[0].As<v8::Int32>()->Value(); - RunSyncTask(backend_runner_, [&context_group_id, &reason, - &details](IsolateData* data) { - data->SchedulePauseOnNextStatement( - context_group_id, - v8_inspector::StringView(reason.start(), reason.length()), - v8_inspector::StringView(details.start(), details.length())); - }); + RunSyncTask(backend_runner_, + [&context_group_id, &reason, &details](IsolateData* data) { + data->SchedulePauseOnNextStatement( + context_group_id, + v8_inspector::StringView(reason.data(), reason.size()), + v8_inspector::StringView(details.data(), details.size())); + }); } static void CancelPauseOnNextStatement( @@ -530,14 +541,15 @@ class UtilsExtension : public IsolateData::SetupGlobalTask { IsolateData::FromContext(context)->GetContextGroupId(context), args.GetIsolate(), args[2].As<v8::Function>()); - v8::internal::Vector<uint16_t> state = ToVector(args[1].As<v8::String>()); + std::vector<uint16_t> state = + ToVector(args.GetIsolate(), args[1].As<v8::String>()); int context_group_id = args[0].As<v8::Int32>()->Value(); int session_id = 0; RunSyncTask(backend_runner_, [&context_group_id, &session_id, &channel, &state](IsolateData* data) { session_id = data->ConnectSession( context_group_id, - v8_inspector::StringView(state.start(), state.length()), channel); + v8_inspector::StringView(state.data(), state.size()), channel); channel->set_session_id(session_id); }); @@ -552,7 +564,7 @@ class UtilsExtension : public IsolateData::SetupGlobalTask { Exit(); } int session_id = args[0].As<v8::Int32>()->Value(); - v8::internal::Vector<uint16_t> state; + std::vector<uint16_t> state; RunSyncTask(backend_runner_, [&session_id, &state](IsolateData* data) { state = ToVector(data->DisconnectSession(session_id)->string()); }); @@ -568,7 +580,8 @@ class UtilsExtension : public IsolateData::SetupGlobalTask { Exit(); } backend_runner_->Append(new SendMessageToBackendTask( - args[0].As<v8::Int32>()->Value(), ToVector(args[1].As<v8::String>()))); + args[0].As<v8::Int32>()->Value(), + ToVector(args.GetIsolate(), args[1].As<v8::String>()))); } static std::map<int, std::unique_ptr<FrontendChannelImpl>> channels_; @@ -636,7 +649,8 @@ class SetTimeoutExtension : public IsolateData::SetupGlobalTask { RunAsyncTask( data->task_runner(), task_name_view, new ExecuteStringTask( - context_group_id, ToVector(args[0].As<v8::String>()), + isolate, context_group_id, + ToVector(isolate, args[0].As<v8::String>()), v8::String::Empty(isolate), v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0), v8::Boolean::New(isolate, false))); } @@ -778,10 +792,12 @@ class InspectorExtension : public IsolateData::SetupGlobalTask { } v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); IsolateData* data = IsolateData::FromContext(context); - v8::internal::Vector<uint16_t> reason = ToVector(args[0].As<v8::String>()); - v8_inspector::StringView reason_view(reason.start(), reason.length()); - v8::internal::Vector<uint16_t> details = ToVector(args[1].As<v8::String>()); - v8_inspector::StringView details_view(details.start(), details.length()); + std::vector<uint16_t> reason = + ToVector(args.GetIsolate(), args[0].As<v8::String>()); + v8_inspector::StringView reason_view(reason.data(), reason.size()); + std::vector<uint16_t> details = + ToVector(args.GetIsolate(), args[1].As<v8::String>()); + v8_inspector::StringView details_view(details.data(), details.size()); data->BreakProgram(data->GetContextGroupId(context), reason_view, details_view); } @@ -808,10 +824,12 @@ class InspectorExtension : public IsolateData::SetupGlobalTask { "Internal error: callWithScheduledBreak('reason', 'details')."); Exit(); } - v8::internal::Vector<uint16_t> reason = ToVector(args[1].As<v8::String>()); - v8_inspector::StringView reason_view(reason.start(), reason.length()); - v8::internal::Vector<uint16_t> details = ToVector(args[2].As<v8::String>()); - v8_inspector::StringView details_view(details.start(), details.length()); + std::vector<uint16_t> reason = + ToVector(args.GetIsolate(), args[1].As<v8::String>()); + v8_inspector::StringView reason_view(reason.data(), reason.size()); + std::vector<uint16_t> details = + ToVector(args.GetIsolate(), args[2].As<v8::String>()); + v8_inspector::StringView details_view(details.data(), details.size()); v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); IsolateData* data = IsolateData::FromContext(context); int context_group_id = data->GetContextGroupId(context); @@ -898,10 +916,10 @@ class InspectorExtension : public IsolateData::SetupGlobalTask { v8::Isolate* isolate = args.GetIsolate(); v8::Local<v8::Context> context = isolate->GetCurrentContext(); IsolateData* data = IsolateData::FromContext(context); - v8::internal::Vector<uint16_t> description = - ToVector(args[0].As<v8::String>()); - v8_inspector::StringView description_view(description.start(), - description.length()); + std::vector<uint16_t> description = + ToVector(isolate, args[0].As<v8::String>()); + v8_inspector::StringView description_view(description.data(), + description.size()); v8_inspector::V8StackTraceId id = data->StoreCurrentStackTrace(description_view); v8::Local<v8::ArrayBuffer> buffer = @@ -955,10 +973,9 @@ class InspectorExtension : public IsolateData::SetupGlobalTask { bool with_empty_stack = args[2].As<v8::Boolean>()->Value(); if (with_empty_stack) context->Exit(); - v8::internal::Vector<uint16_t> task_name = - ToVector(args[1].As<v8::String>()); - v8_inspector::StringView task_name_view(task_name.start(), - task_name.length()); + std::vector<uint16_t> task_name = + ToVector(isolate, args[1].As<v8::String>()); + v8_inspector::StringView task_name_view(task_name.data(), task_name.size()); RunAsyncTask(data->task_runner(), task_name_view, new SetTimeoutTask(context_group_id, isolate, @@ -1085,8 +1102,7 @@ int main(int argc, char* argv[]) { if (argv[i] == nullptr || argv[i][0] == '-') continue; bool exists = false; - v8::internal::Vector<const char> chars = - v8::internal::ReadFile(argv[i], &exists, true); + std::string chars = v8::internal::ReadFile(argv[i], &exists, true); if (!exists) { fprintf(stderr, "Internal error: script file doesn't exists: %s\n", argv[i]); diff --git a/deps/v8/test/inspector/isolate-data.cc b/deps/v8/test/inspector/isolate-data.cc index a669cc41a1..57b9af57c2 100644 --- a/deps/v8/test/inspector/isolate-data.cc +++ b/deps/v8/test/inspector/isolate-data.cc @@ -12,10 +12,11 @@ namespace { const int kIsolateDataIndex = 2; const int kContextGroupIdIndex = 3; -v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) { +v8::internal::Vector<uint16_t> ToVector(v8::Isolate* isolate, + v8::Local<v8::String> str) { v8::internal::Vector<uint16_t> buffer = v8::internal::Vector<uint16_t>::New(str->Length()); - str->Write(buffer.start(), 0, str->Length()); + str->Write(isolate, buffer.start(), 0, str->Length()); return buffer; } @@ -137,7 +138,8 @@ v8::MaybeLocal<v8::Module> IsolateData::ModuleResolveCallback( v8::Local<v8::Module> referrer) { IsolateData* data = IsolateData::FromContext(context); std::string str = *v8::String::Utf8Value(data->isolate(), specifier); - return data->modules_[ToVector(specifier)].Get(data->isolate()); + return data->modules_[ToVector(data->isolate(), specifier)].Get( + data->isolate()); } int IsolateData::ConnectSession(int context_group_id, @@ -249,7 +251,7 @@ int IsolateData::HandleMessage(v8::Local<v8::Message> message, int script_id = static_cast<int>(message->GetScriptOrigin().ScriptID()->Value()); if (!stack.IsEmpty() && stack->GetFrameCount() > 0) { - int top_script_id = stack->GetFrame(0)->GetScriptId(); + int top_script_id = stack->GetFrame(isolate, 0)->GetScriptId(); if (top_script_id == script_id) script_id = 0; } int line_number = message->GetLineNumber(context).FromMaybe(0); @@ -258,13 +260,14 @@ int IsolateData::HandleMessage(v8::Local<v8::Message> message, column_number = message->GetStartColumn(context).FromJust() + 1; v8_inspector::StringView detailed_message; - v8::internal::Vector<uint16_t> message_text_string = ToVector(message->Get()); + v8::internal::Vector<uint16_t> message_text_string = + ToVector(isolate, message->Get()); v8_inspector::StringView message_text(message_text_string.start(), message_text_string.length()); v8::internal::Vector<uint16_t> url_string; if (message->GetScriptOrigin().ResourceName()->IsString()) { - url_string = - ToVector(message->GetScriptOrigin().ResourceName().As<v8::String>()); + url_string = ToVector( + isolate, message->GetScriptOrigin().ResourceName().As<v8::String>()); } v8_inspector::StringView url(url_string.start(), url_string.length()); @@ -432,7 +435,7 @@ namespace { class StringBufferImpl : public v8_inspector::StringBuffer { public: StringBufferImpl(v8::Isolate* isolate, v8::Local<v8::String> string) - : data_(ToVector(string)), + : data_(ToVector(isolate, string)), view_(data_.start(), data_.length()) {} const v8_inspector::StringView& string() override { return view_; } @@ -449,6 +452,6 @@ std::unique_ptr<v8_inspector::StringBuffer> IsolateData::resourceNameToUrl( v8::HandleScope handle_scope(isolate); v8::Local<v8::String> name = ToString(isolate, resourceName); v8::Local<v8::String> prefix = resource_name_prefix_.Get(isolate); - v8::Local<v8::String> url = v8::String::Concat(prefix, name); + v8::Local<v8::String> url = v8::String::Concat(isolate, prefix, name); return std::unique_ptr<StringBufferImpl>(new StringBufferImpl(isolate, url)); } |