summaryrefslogtreecommitdiff
path: root/test/cctest
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-09-14 13:05:48 +0200
committerAnna Henningsen <anna@addaleax.net>2017-11-12 14:01:54 +0100
commitc7ad729072186594521f5d1033ebb101bfdd36f7 (patch)
tree6c426b5f31eaf70fef48e41f7b87859cee16f0e5 /test/cctest
parenta645d45dd500f5b73efb1e940ffafadcf61f3628 (diff)
downloadandroid-node-v8-c7ad729072186594521f5d1033ebb101bfdd36f7.tar.gz
android-node-v8-c7ad729072186594521f5d1033ebb101bfdd36f7.tar.bz2
android-node-v8-c7ad729072186594521f5d1033ebb101bfdd36f7.zip
src: prepare v8 platform for multi-isolate support
This splits the task queue used for asynchronous tasks scheduled by V8 in per-isolate queues, so that multiple threads can be supported. Original-PR-URL: https://github.com/ayojs/ayo/pull/89 Original-Reviewed-By: Timothy Gu <timothygu99@gmail.com> PR-URL: https://github.com/nodejs/node/pull/16700 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/cctest')
-rw-r--r--test/cctest/node_test_fixture.h4
-rw-r--r--test/cctest/test_environment.cc14
2 files changed, 11 insertions, 7 deletions
diff --git a/test/cctest/node_test_fixture.h b/test/cctest/node_test_fixture.h
index 263f7b96f9..890fe90499 100644
--- a/test/cctest/node_test_fixture.h
+++ b/test/cctest/node_test_fixture.h
@@ -73,6 +73,8 @@ class NodeTestFixture : public ::testing::Test {
public:
static uv_loop_t* CurrentLoop() { return &current_loop; }
+ node::MultiIsolatePlatform* Platform() const { return platform_; }
+
protected:
v8::Isolate::CreateParams params_;
ArrayBufferAllocator allocator_;
@@ -84,7 +86,7 @@ class NodeTestFixture : public ::testing::Test {
virtual void SetUp() {
CHECK_EQ(0, uv_loop_init(&current_loop));
- platform_ = new node::NodePlatform(8, &current_loop, nullptr);
+ platform_ = new node::NodePlatform(8, nullptr);
v8::V8::InitializePlatform(platform_);
v8::V8::Initialize();
params_.array_buffer_allocator = &allocator_;
diff --git a/test/cctest/test_environment.cc b/test/cctest/test_environment.cc
index 8beacfa95e..704efd7a88 100644
--- a/test/cctest/test_environment.cc
+++ b/test/cctest/test_environment.cc
@@ -26,11 +26,13 @@ class EnvironmentTest : public NodeTestFixture {
public:
Env(const v8::HandleScope& handle_scope,
v8::Isolate* isolate,
- const Argv& argv) {
+ const Argv& argv,
+ NodeTestFixture* test_fixture) {
context_ = v8::Context::New(isolate);
CHECK(!context_.IsEmpty());
isolate_data_ = CreateIsolateData(isolate,
- NodeTestFixture::CurrentLoop());
+ NodeTestFixture::CurrentLoop(),
+ test_fixture->Platform());
CHECK_NE(nullptr, isolate_data_);
environment_ = CreateEnvironment(isolate_data_,
context_,
@@ -66,7 +68,7 @@ class EnvironmentTest : public NodeTestFixture {
TEST_F(EnvironmentTest, AtExitWithEnvironment) {
const v8::HandleScope handle_scope(isolate_);
const Argv argv;
- Env env {handle_scope, isolate_, argv};
+ Env env {handle_scope, isolate_, argv, this};
AtExit(*env, at_exit_callback1);
RunAtExit(*env);
@@ -76,7 +78,7 @@ TEST_F(EnvironmentTest, AtExitWithEnvironment) {
TEST_F(EnvironmentTest, AtExitWithArgument) {
const v8::HandleScope handle_scope(isolate_);
const Argv argv;
- Env env {handle_scope, isolate_, argv};
+ Env env {handle_scope, isolate_, argv, this};
std::string arg{"some args"};
AtExit(*env, at_exit_callback1, static_cast<void*>(&arg));
@@ -87,8 +89,8 @@ TEST_F(EnvironmentTest, AtExitWithArgument) {
TEST_F(EnvironmentTest, MultipleEnvironmentsPerIsolate) {
const v8::HandleScope handle_scope(isolate_);
const Argv argv;
- Env env1 {handle_scope, isolate_, argv};
- Env env2 {handle_scope, isolate_, argv};
+ Env env1 {handle_scope, isolate_, argv, this};
+ Env env2 {handle_scope, isolate_, argv, this};
AtExit(*env1, at_exit_callback1);
AtExit(*env2, at_exit_callback2);