Version 5.5.335.1 (cherry-pick)
Merged 0e704cdac6c684c965ed57add4d5bbb9cb7acfdb
Revert "[inspector] added inspector test runner [part 1-2]"
BUG=chromium:635948
LOG=N
TBR=hablich@chromium.org,kozyatinskiy@chromium.org
Review URL: https://codereview.chromium.org/2385663002 .
Cr-Commit-Position: refs/heads/5.5.335@{#2}
Cr-Branched-From: a2a9b4a7eaa56908c4611b66a87590dfb917f3be-refs/heads/master@{#39889}
diff --git a/include/v8-version.h b/include/v8-version.h
index 116353d..df1efb7 100644
--- a/include/v8-version.h
+++ b/include/v8-version.h
@@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 5
#define V8_MINOR_VERSION 5
#define V8_BUILD_NUMBER 335
-#define V8_PATCH_LEVEL 0
+#define V8_PATCH_LEVEL 1
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
diff --git a/test/BUILD.gn b/test/BUILD.gn
index e24615a..36ca7a20 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -3,7 +3,6 @@
# found in the LICENSE file.
import("../gni/isolate.gni")
-import("//build_overrides/v8.gni")
group("gn_all") {
testonly = true
@@ -21,10 +20,6 @@
]
}
- if (v8_enable_inspector_override) {
- deps += [ "inspector:inspector-test" ]
- }
-
if (v8_test_isolation_mode != "noop") {
deps += [
":benchmarks_run",
diff --git a/test/inspector/BUILD.gn b/test/inspector/BUILD.gn
deleted file mode 100644
index de5928f..0000000
--- a/test/inspector/BUILD.gn
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2016 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.
-
-import("../../gni/v8.gni")
-
-v8_executable("inspector-test") {
- testonly = true
-
- sources = [
- "inspector-impl.cc",
- "inspector-impl.h",
- "task-runner.cc",
- "task-runner.h",
- ]
-
- configs = [
- "../..:external_config",
- "../..:internal_config_base",
- ]
-
- deps = [
- "../..:v8_libplatform",
- "//build/config/sanitizers:deps",
- "//build/win:default_exe_manifest",
- ]
-
- if (is_component_build) {
- # inspector-test can't be built against a shared library, so we
- # need to depend on the underlying static target in that case.
- deps += [ "../..:v8_maybe_snapshot" ]
- } else {
- deps += [ "../..:v8" ]
- }
-
- cflags = []
- ldflags = []
-}
diff --git a/test/inspector/DEPS b/test/inspector/DEPS
deleted file mode 100644
index 7c2725c..0000000
--- a/test/inspector/DEPS
+++ /dev/null
@@ -1,7 +0,0 @@
-include_rules = [
- "-src",
- "+src/base/macros.h",
- "+src/base/platform/platform.h",
- "+src/inspector/string-16.h",
- "+src/locked-queue-inl.h",
-]
\ No newline at end of file
diff --git a/test/inspector/OWNERS b/test/inspector/OWNERS
deleted file mode 100644
index 9edb707..0000000
--- a/test/inspector/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-dgozman@chromium.org
-kozyatinskiy@chromium.org
diff --git a/test/inspector/inspector-impl.cc b/test/inspector/inspector-impl.cc
deleted file mode 100644
index 37aa274..0000000
--- a/test/inspector/inspector-impl.cc
+++ /dev/null
@@ -1,152 +0,0 @@
-// Copyright 2016 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.
-
-#include "test/inspector/inspector-impl.h"
-
-#include "include/v8.h"
-#include "src/inspector/string-16.h"
-
-namespace {
-
-const int kInspectorClientIndex = v8::Context::kDebugIdIndex + 1;
-
-class ChannelImpl final : public v8_inspector::V8Inspector::Channel {
- public:
- explicit ChannelImpl(InspectorClientImpl::FrontendChannel* frontend_channel)
- : frontend_channel_(frontend_channel) {}
- virtual ~ChannelImpl() = default;
-
- private:
- void sendProtocolResponse(int callId,
- const v8_inspector::StringView& message) override {
- frontend_channel_->SendMessageToFrontend(message);
- }
- void sendProtocolNotification(
- const v8_inspector::StringView& message) override {
- frontend_channel_->SendMessageToFrontend(message);
- }
- void flushProtocolNotifications() override {}
-
- InspectorClientImpl::FrontendChannel* frontend_channel_;
- DISALLOW_COPY_AND_ASSIGN(ChannelImpl);
-};
-
-} // namespace
-
-class ConnectTask : public TaskRunner::Task {
- public:
- ConnectTask(InspectorClientImpl* client, v8::base::Semaphore* ready_semaphore)
- : client_(client), ready_semaphore_(ready_semaphore) {}
- virtual ~ConnectTask() = default;
-
- bool is_inspector_task() final { return true; }
-
- void Run(v8::Isolate* isolate,
- const v8::Global<v8::Context>& global_context) {
- v8::HandleScope handle_scope(isolate);
- v8::Local<v8::Context> context = global_context.Get(isolate);
- client_->connect(context);
- if (ready_semaphore_) ready_semaphore_->Signal();
- }
-
- private:
- InspectorClientImpl* client_;
- v8::base::Semaphore* ready_semaphore_;
-};
-
-InspectorClientImpl::InspectorClientImpl(TaskRunner* task_runner,
- FrontendChannel* frontend_channel,
- v8::base::Semaphore* ready_semaphore)
- : isolate_(nullptr),
- task_runner_(task_runner),
- frontend_channel_(frontend_channel) {
- task_runner_->Append(new ConnectTask(this, ready_semaphore));
-}
-
-InspectorClientImpl::~InspectorClientImpl() {}
-
-void InspectorClientImpl::connect(v8::Local<v8::Context> context) {
- isolate_ = context->GetIsolate();
- channel_.reset(new ChannelImpl(frontend_channel_));
-
- inspector_ = v8_inspector::V8Inspector::create(isolate_, this);
- session_ = inspector_->connect(1, channel_.get(), v8_inspector::StringView());
-
- context->SetAlignedPointerInEmbedderData(kInspectorClientIndex, this);
- inspector_->contextCreated(
- v8_inspector::V8ContextInfo(context, 1, v8_inspector::StringView()));
- context_.Reset(isolate_, context);
-}
-
-v8::Local<v8::Context> InspectorClientImpl::ensureDefaultContextInGroup(int) {
- CHECK(isolate_);
- return context_.Get(isolate_);
-}
-
-double InspectorClientImpl::currentTimeMS() {
- return v8::base::OS::TimeCurrentMillis();
-}
-
-void InspectorClientImpl::runMessageLoopOnPause(int) {
- task_runner_->RunMessageLoop(true);
-}
-
-void InspectorClientImpl::quitMessageLoopOnPause() {
- task_runner_->QuitMessageLoop();
-}
-
-v8_inspector::V8InspectorSession* InspectorClientImpl::SessionFromContext(
- v8::Local<v8::Context> context) {
- InspectorClientImpl* inspector_client = static_cast<InspectorClientImpl*>(
- context->GetAlignedPointerFromEmbedderData(kInspectorClientIndex));
- CHECK(inspector_client);
- return inspector_client->session_.get();
-}
-
-class SendMessageToBackendTask : public TaskRunner::Task {
- public:
- explicit SendMessageToBackendTask(const v8_inspector::String16& message)
- : message_(message) {}
-
- bool is_inspector_task() final { return true; }
-
- void Run(v8::Isolate* isolate,
- const v8::Global<v8::Context>& global_context) override {
- v8_inspector::V8InspectorSession* session = nullptr;
- {
- v8::HandleScope handle_scope(isolate);
- v8::Local<v8::Context> context = global_context.Get(isolate);
- session = InspectorClientImpl::SessionFromContext(context);
- CHECK(session);
- }
- v8_inspector::StringView message_view(
- reinterpret_cast<const uint16_t*>(message_.characters16()),
- message_.length());
- session->dispatchProtocolMessage(message_view);
- }
-
- private:
- v8_inspector::String16 message_;
-};
-
-TaskRunner* SendMessageToBackendExtension::backend_task_runner_ = nullptr;
-
-v8::Local<v8::FunctionTemplate>
-SendMessageToBackendExtension::GetNativeFunctionTemplate(
- v8::Isolate* isolate, v8::Local<v8::String> name) {
- return v8::FunctionTemplate::New(
- isolate, SendMessageToBackendExtension::SendMessageToBackend);
-}
-
-void SendMessageToBackendExtension::SendMessageToBackend(
- const v8::FunctionCallbackInfo<v8::Value>& args) {
- CHECK(backend_task_runner_);
- CHECK(args.Length() == 1 && args[0]->IsString());
- v8::Local<v8::String> message = args[0].As<v8::String>();
- std::unique_ptr<uint16_t[]> buffer(new uint16_t[message->Length()]);
- message.As<v8::String>()->Write(reinterpret_cast<uint16_t*>(buffer.get()), 0,
- message->Length());
- v8_inspector::String16 message_string(buffer.get(), message->Length());
- backend_task_runner_->Append(new SendMessageToBackendTask(message_string));
-}
diff --git a/test/inspector/inspector-impl.h b/test/inspector/inspector-impl.h
deleted file mode 100644
index 781e596..0000000
--- a/test/inspector/inspector-impl.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2016 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 V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_
-#define V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_
-
-#include "include/v8-inspector.h"
-#include "include/v8.h"
-#include "src/base/macros.h"
-#include "src/base/platform/platform.h"
-#include "test/inspector/task-runner.h"
-
-class InspectorClientImpl : public v8_inspector::V8InspectorClient {
- public:
- class FrontendChannel {
- public:
- virtual ~FrontendChannel() = default;
- virtual void SendMessageToFrontend(
- const v8_inspector::StringView& message) = 0;
- };
-
- InspectorClientImpl(TaskRunner* task_runner,
- FrontendChannel* frontend_channel,
- v8::base::Semaphore* ready_semaphore);
- virtual ~InspectorClientImpl();
-
- private:
- // V8InspectorClient implementation.
- v8::Local<v8::Context> ensureDefaultContextInGroup(
- int context_group_id) override;
- double currentTimeMS() override;
- void runMessageLoopOnPause(int context_group_id) override;
- void quitMessageLoopOnPause() override;
-
- static v8_inspector::V8InspectorSession* SessionFromContext(
- v8::Local<v8::Context> context);
-
- friend class SendMessageToBackendTask;
-
- friend class ConnectTask;
- void connect(v8::Local<v8::Context> context);
-
- std::unique_ptr<v8_inspector::V8Inspector> inspector_;
- std::unique_ptr<v8_inspector::V8InspectorSession> session_;
- std::unique_ptr<v8_inspector::V8Inspector::Channel> channel_;
-
- v8::Isolate* isolate_;
- v8::Global<v8::Context> context_;
-
- TaskRunner* task_runner_;
- FrontendChannel* frontend_channel_;
-
- DISALLOW_COPY_AND_ASSIGN(InspectorClientImpl);
-};
-
-class SendMessageToBackendExtension : public v8::Extension {
- public:
- SendMessageToBackendExtension()
- : v8::Extension("v8_inspector/frontend",
- "native function sendMessageToBackend();") {}
- virtual v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
- v8::Isolate* isolate, v8::Local<v8::String> name);
-
- static void set_backend_task_runner(TaskRunner* task_runner) {
- backend_task_runner_ = task_runner;
- }
-
- private:
- static void SendMessageToBackend(
- const v8::FunctionCallbackInfo<v8::Value>& args);
-
- static TaskRunner* backend_task_runner_;
-};
-
-#endif // V8_TEST_INSPECTOR_PROTOCOL_INSPECTOR_IMPL_H_
diff --git a/test/inspector/inspector.gyp b/test/inspector/inspector.gyp
deleted file mode 100644
index 1818a0c..0000000
--- a/test/inspector/inspector.gyp
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2016 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.
-
-{
- 'variables': {
- 'v8_code': 1,
- 'inspector_protocol_sources': [
- 'inspector-impl.cc',
- 'inspector-impl.h',
- 'task-runner.cc',
- 'task-runner.h',
- ],
- },
- 'includes': ['../../gypfiles/toolchain.gypi', '../../gypfiles/features.gypi'],
- 'targets': [
- {
- 'target_name': 'inspector-test',
- 'type': 'executable',
- 'dependencies': [
- '../../src/v8.gyp:v8_libplatform',
- ],
- 'include_dirs': [
- '../..',
- ],
- 'sources': [
- '<@(inspector_protocol_sources)',
- ],
- 'conditions': [
- ['component=="shared_library"', {
- # inspector-test can't be built against a shared library, so we
- # need to depend on the underlying static target in that case.
- 'dependencies': ['../../src/v8.gyp:v8_maybe_snapshot'],
- }, {
- 'dependencies': ['../../src/v8.gyp:v8'],
- }],
- ],
- },
- ],
-}
diff --git a/test/inspector/task-runner.cc b/test/inspector/task-runner.cc
deleted file mode 100644
index 06675ad..0000000
--- a/test/inspector/task-runner.cc
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2016 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.
-
-#include "test/inspector/task-runner.h"
-
-namespace {
-
-const int kTaskRunnerIndex = 2;
-
-void ReportUncaughtException(v8::Isolate* isolate,
- const v8::TryCatch& try_catch) {
- CHECK(try_catch.HasCaught());
- v8::HandleScope handle_scope(isolate);
- std::string message = *v8::String::Utf8Value(try_catch.Message()->Get());
- fprintf(stderr, "Unhandle exception: %s\n", message.data());
-}
-
-} // namespace
-
-TaskRunner::TaskRunner(v8::ExtensionConfiguration* extensions,
- v8::base::Semaphore* ready_semaphore)
- : Thread(Options("Task Runner")),
- extensions_(extensions),
- ready_semaphore_(ready_semaphore),
- isolate_(nullptr),
- process_queue_semaphore_(0),
- nested_loop_count_(0) {
- Start();
-}
-
-TaskRunner::~TaskRunner() { Join(); }
-
-void TaskRunner::InitializeContext() {
- v8::Isolate::CreateParams params;
- params.array_buffer_allocator =
- v8::ArrayBuffer::Allocator::NewDefaultAllocator();
- isolate_ = v8::Isolate::New(params);
- isolate_->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped);
- v8::Isolate::Scope isolate_scope(isolate_);
- v8::HandleScope handle_scope(isolate_);
-
- v8::Local<v8::ObjectTemplate> global_template =
- v8::ObjectTemplate::New(isolate_);
- v8::Local<v8::Context> context =
- v8::Context::New(isolate_, extensions_, global_template);
- context->SetAlignedPointerInEmbedderData(kTaskRunnerIndex, this);
- context_.Reset(isolate_, context);
-
- if (ready_semaphore_) ready_semaphore_->Signal();
-}
-
-void TaskRunner::Run() {
- InitializeContext();
- RunMessageLoop(false);
-}
-
-void TaskRunner::RunMessageLoop(bool only_protocol) {
- int loop_number = ++nested_loop_count_;
- while (nested_loop_count_ == loop_number) {
- TaskRunner::Task* task = GetNext(only_protocol);
- v8::Isolate::Scope isolate_scope(isolate_);
- v8::TryCatch try_catch(isolate_);
- task->Run(isolate_, context_);
- delete task;
- if (try_catch.HasCaught()) {
- ReportUncaughtException(isolate_, try_catch);
- fflush(stdout);
- fflush(stderr);
- _exit(0);
- }
- }
-}
-
-void TaskRunner::QuitMessageLoop() {
- DCHECK(nested_loop_count_ > 0);
- --nested_loop_count_;
-}
-
-void TaskRunner::Append(Task* task) {
- queue_.Enqueue(task);
- process_queue_semaphore_.Signal();
-}
-
-TaskRunner::Task* TaskRunner::GetNext(bool only_protocol) {
- for (;;) {
- if (only_protocol) {
- Task* task = nullptr;
- if (queue_.Dequeue(&task)) {
- if (task->is_inspector_task()) return task;
- deffered_queue_.Enqueue(task);
- }
- } else {
- Task* task = nullptr;
- if (deffered_queue_.Dequeue(&task)) return task;
- if (queue_.Dequeue(&task)) return task;
- }
- process_queue_semaphore_.Wait();
- }
- UNREACHABLE();
- return nullptr;
-}
-
-TaskRunner* TaskRunner::FromContext(v8::Local<v8::Context> context) {
- return static_cast<TaskRunner*>(
- context->GetAlignedPointerFromEmbedderData(kTaskRunnerIndex));
-}
-
-ExecuteStringTask::ExecuteStringTask(const v8_inspector::String16& expression)
- : expression_(expression) {}
-
-void ExecuteStringTask::Run(v8::Isolate* isolate,
- const v8::Global<v8::Context>& context) {
- v8::MicrotasksScope microtasks_scope(isolate,
- v8::MicrotasksScope::kRunMicrotasks);
- v8::HandleScope handle_scope(isolate);
- v8::Local<v8::Context> local_context = context.Get(isolate);
- v8::Context::Scope context_scope(local_context);
-
- v8::ScriptOrigin origin(v8::String::Empty(isolate));
- v8::Local<v8::String> source =
- v8::String::NewFromTwoByte(isolate, expression_.characters16(),
- v8::NewStringType::kNormal,
- expression_.length())
- .ToLocalChecked();
-
- v8::ScriptCompiler::Source scriptSource(source, origin);
- v8::Local<v8::Script> script;
- if (!v8::ScriptCompiler::Compile(local_context, &scriptSource)
- .ToLocal(&script))
- return;
- v8::MaybeLocal<v8::Value> result;
- result = script->Run(local_context);
-}
-
-// main to make compiler happy before other patch will be landed.
-int main(int argc, char* argv[]) { return 0; }
diff --git a/test/inspector/task-runner.h b/test/inspector/task-runner.h
deleted file mode 100644
index 4a3f2e5..0000000
--- a/test/inspector/task-runner.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2016 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 V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_
-#define V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_
-
-#include "include/v8-inspector.h"
-#include "include/v8-platform.h"
-#include "include/v8.h"
-#include "src/base/macros.h"
-#include "src/base/platform/platform.h"
-#include "src/inspector/string-16.h"
-#include "src/locked-queue-inl.h"
-
-class TaskRunner : public v8::base::Thread {
- public:
- class Task {
- public:
- virtual ~Task() {}
- virtual bool is_inspector_task() = 0;
- virtual void Run(v8::Isolate* isolate,
- const v8::Global<v8::Context>& context) = 0;
- };
-
- explicit TaskRunner(v8::ExtensionConfiguration* extensions,
- v8::base::Semaphore* ready_semaphore);
- virtual ~TaskRunner();
-
- // Thread implementation.
- void Run() override;
-
- // Should be called from the same thread and only from task.
- void RunMessageLoop(bool only_protocol);
- void QuitMessageLoop();
-
- // TaskRunner takes ownership.
- void Append(Task* task);
-
- static TaskRunner* FromContext(v8::Local<v8::Context>);
-
- private:
- void InitializeContext();
- Task* GetNext(bool only_protocol);
-
- v8::ExtensionConfiguration* extensions_;
- v8::base::Semaphore* ready_semaphore_;
-
- v8::Isolate* isolate_;
- v8::Global<v8::Context> context_;
-
- // deferred_queue_ combined with queue_ (in this order) have all tasks in the
- // correct order.
- // Sometimes we skip non-protocol tasks by moving them from queue_ to
- // deferred_queue_.
- v8::internal::LockedQueue<Task*> queue_;
- v8::internal::LockedQueue<Task*> deffered_queue_;
- v8::base::Semaphore process_queue_semaphore_;
-
- int nested_loop_count_;
-
- DISALLOW_COPY_AND_ASSIGN(TaskRunner);
-};
-
-class ExecuteStringTask : public TaskRunner::Task {
- public:
- explicit ExecuteStringTask(const v8_inspector::String16& expression);
- bool is_inspector_task() override { return false; }
-
- void Run(v8::Isolate* isolate,
- const v8::Global<v8::Context>& context) override;
-
- private:
- v8_inspector::String16 expression_;
-
- DISALLOW_COPY_AND_ASSIGN(ExecuteStringTask);
-};
-
-#endif // V8_TEST_INSPECTOR_PROTOCOL_TASK_RUNNER_H_
diff --git a/tools/presubmit.py b/tools/presubmit.py
index 3be9caf..0fa76f9 100755
--- a/tools/presubmit.py
+++ b/tools/presubmit.py
@@ -203,7 +203,7 @@
def GetPathsToSearch(self):
return ['src', 'include', 'samples', join('test', 'cctest'),
- join('test', 'unittests'), join('test', 'inspector')]
+ join('test', 'unittests')]
def GetCpplintScript(self, prio_path):
for path in [prio_path] + os.environ["PATH"].split(os.pathsep):
diff --git a/tools/verify_source_deps.py b/tools/verify_source_deps.py
index a3fdb2e..e62ec8f 100755
--- a/tools/verify_source_deps.py
+++ b/tools/verify_source_deps.py
@@ -30,7 +30,6 @@
os.path.join(V8_BASE, 'test', 'cctest', 'cctest.gyp'),
os.path.join(V8_BASE, 'test', 'fuzzer', 'fuzzer.gyp'),
os.path.join(V8_BASE, 'test', 'unittests', 'unittests.gyp'),
- os.path.join(V8_BASE, 'test', 'inspector', 'inspector.gyp'),
os.path.join(V8_BASE, 'testing', 'gmock.gyp'),
os.path.join(V8_BASE, 'testing', 'gtest.gyp'),
os.path.join(V8_BASE, 'tools', 'parser-shell.gyp'),
@@ -48,7 +47,6 @@
os.path.join('test', 'common'),
os.path.join('test', 'fuzzer'),
os.path.join('test', 'unittests'),
- os.path.join('test', 'inspector'),
]
GYP_UNSUPPORTED_FEATURES = [
@@ -62,7 +60,6 @@
os.path.join(V8_BASE, 'src', 'inspector', 'BUILD.gn'),
os.path.join(V8_BASE, 'test', 'cctest', 'BUILD.gn'),
os.path.join(V8_BASE, 'test', 'unittests', 'BUILD.gn'),
- os.path.join(V8_BASE, 'test', 'inspector', 'BUILD.gn'),
os.path.join(V8_BASE, 'tools', 'BUILD.gn'),
]
@@ -86,7 +83,6 @@
'testing',
os.path.join('test', 'cctest'),
os.path.join('test', 'unittests'),
- os.path.join('test', 'inspector'),
]
def pathsplit(path):