Commit ca16bb7a authored by jochen@chromium.org's avatar jochen@chromium.org

Split out libplatform into a separate libary

Also remove the "use default platform" compile flag. Instead, the embedder
has to provide the platform.

Change all binaries to use the default platfrom from libplatform.

Unless --job-based-sweeping is passed, nothing uses the platform yet, so
nothing will break for embedders (yet).

BUG=none
R=jkummerow@chromium.org
LOG=y

Review URL: https://codereview.chromium.org/345903004

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22180 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d7934d1f
...@@ -14,7 +14,6 @@ v8_enable_verify_heap = false ...@@ -14,7 +14,6 @@ v8_enable_verify_heap = false
v8_interpreted_regexp = false v8_interpreted_regexp = false
v8_object_print = false v8_object_print = false
v8_postmortem_support = false v8_postmortem_support = false
v8_use_default_platform = true
v8_use_snapshot = true v8_use_snapshot = true
v8_use_external_startup_data = false v8_use_external_startup_data = false
v8_enable_extra_checks = is_debug v8_enable_extra_checks = is_debug
...@@ -90,11 +89,6 @@ config("features") { ...@@ -90,11 +89,6 @@ config("features") {
"V8_I18N_SUPPORT", "V8_I18N_SUPPORT",
] ]
} }
if (v8_use_default_platform == true) {
defines += [
"V8_USE_DEFAULT_PLATFORM",
]
}
if (v8_compress_startup_data == "bz2") { if (v8_compress_startup_data == "bz2") {
defines += [ defines += [
"COMPRESS_STARTUP_DATA_BZ2", "COMPRESS_STARTUP_DATA_BZ2",
...@@ -633,13 +627,6 @@ source_set("v8_base") { ...@@ -633,13 +627,6 @@ source_set("v8_base") {
"src/jsregexp-inl.h", "src/jsregexp-inl.h",
"src/jsregexp.cc", "src/jsregexp.cc",
"src/jsregexp.h", "src/jsregexp.h",
# TODO(jochen): move libplatform/ files to their own target.
"src/libplatform/default-platform.cc",
"src/libplatform/default-platform.h",
"src/libplatform/task-queue.cc",
"src/libplatform/task-queue.h",
"src/libplatform/worker-thread.cc",
"src/libplatform/worker-thread.h",
"src/list-inl.h", "src/list-inl.h",
"src/list.h", "src/list.h",
"src/lithium-allocator-inl.h", "src/lithium-allocator-inl.h",
...@@ -1077,6 +1064,26 @@ source_set("v8_libbase") { ...@@ -1077,6 +1064,26 @@ source_set("v8_libbase") {
# TODO(jochen): Add support for qnx, freebsd, openbsd, netbsd, and solaris. # TODO(jochen): Add support for qnx, freebsd, openbsd, netbsd, and solaris.
} }
source_set("v8_libplatform") {
sources = [
"include/libplatform/libplatform.h",
"src/libplatform/default-platform.cc",
"src/libplatform/default-platform.h",
"src/libplatform/task-queue.cc",
"src/libplatform/task-queue.h",
"src/libplatform/worker-thread.cc",
"src/libplatform/worker-thread.h",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ ":internal_config", ":features", ":toolchain" ]
deps = [
":v8_libbase",
]
}
############################################################################### ###############################################################################
# Executables # Executables
# #
...@@ -1095,6 +1102,7 @@ if (current_toolchain == host_toolchain) { ...@@ -1095,6 +1102,7 @@ if (current_toolchain == host_toolchain) {
deps = [ deps = [
":v8_base", ":v8_base",
":v8_libplatform",
":v8_nosnapshot", ":v8_nosnapshot",
] ]
......
...@@ -59,9 +59,6 @@ ...@@ -59,9 +59,6 @@
# Enable compiler warnings when using V8_DEPRECATED apis. # Enable compiler warnings when using V8_DEPRECATED apis.
'v8_deprecation_warnings%': 0, 'v8_deprecation_warnings%': 0,
# Use the v8 provided v8::Platform implementation.
'v8_use_default_platform%': 1,
# Use external files for startup data blobs: # Use external files for startup data blobs:
# the JS builtins sources and the start snapshot. # the JS builtins sources and the start snapshot.
'v8_use_external_startup_data%': 0, 'v8_use_external_startup_data%': 0,
...@@ -92,9 +89,6 @@ ...@@ -92,9 +89,6 @@
['v8_enable_i18n_support==1', { ['v8_enable_i18n_support==1', {
'defines': ['V8_I18N_SUPPORT',], 'defines': ['V8_I18N_SUPPORT',],
}], }],
['v8_use_default_platform==1', {
'defines': ['V8_USE_DEFAULT_PLATFORM',],
}],
['v8_compress_startup_data=="bz2"', { ['v8_compress_startup_data=="bz2"', {
'defines': ['COMPRESS_STARTUP_DATA_BZ2',], 'defines': ['COMPRESS_STARTUP_DATA_BZ2',],
}], }],
......
// Copyright 2014 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_LIBPLATFORM_LIBPLATFORM_H_
#define V8_LIBPLATFORM_LIBPLATFORM_H_
#include "include/v8-platform.h"
namespace v8 {
namespace platform {
/**
* Returns a new instance of the default v8::Platform implementation.
*
* The caller will take ownership of the returned pointer. |thread_pool_size|
* is the number of worker threads to allocate for background jobs. If a value
* of zero is passed, a suitable default based on the current number of
* processors online will be chosen.
*/
v8::Platform* CreateDefaultPlatform(int thread_pool_size);
} // namespace platform
} // namespace v8
#endif // V8_LIBPLATFORM_LIBPLATFORM_H_
...@@ -37,6 +37,8 @@ class Platform { ...@@ -37,6 +37,8 @@ class Platform {
kLongRunningTask kLongRunningTask
}; };
virtual ~Platform() {}
/** /**
* Schedules a task to be invoked on a background thread. |expected_runtime| * Schedules a task to be invoked on a background thread. |expected_runtime|
* indicates that the task will run a long time. The Platform implementation * indicates that the task will run a long time. The Platform implementation
...@@ -53,9 +55,6 @@ class Platform { ...@@ -53,9 +55,6 @@ class Platform {
* scheduling. The definition of "foreground" is opaque to V8. * scheduling. The definition of "foreground" is opaque to V8.
*/ */
virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0; virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0;
protected:
virtual ~Platform() {}
}; };
} // namespace v8 } // namespace v8
......
...@@ -25,9 +25,10 @@ ...@@ -25,9 +25,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <v8.h> #include <include/v8.h>
#include <v8-debug.h> #include <include/libplatform/libplatform.h>
#include <include/v8-debug.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
...@@ -254,8 +255,12 @@ bool RunCppCycle(v8::Handle<v8::Script> script, ...@@ -254,8 +255,12 @@ bool RunCppCycle(v8::Handle<v8::Script> script,
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
v8::V8::InitializeICU(); v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform(0);
v8::V8::InitializePlatform(platform);
int result = RunMain(argc, argv); int result = RunMain(argc, argv);
v8::V8::Dispose(); v8::V8::Dispose();
v8::V8::ShutdownPlatform();
delete platform;
return result; return result;
} }
......
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <v8.h> #include <include/v8.h>
#include <include/libplatform/libplatform.h>
#include <map> #include <map>
#include <string> #include <string>
...@@ -644,6 +646,8 @@ void PrintMap(map<string, string>* m) { ...@@ -644,6 +646,8 @@ void PrintMap(map<string, string>* m) {
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
v8::V8::InitializeICU(); v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform(0);
v8::V8::InitializePlatform(platform);
map<string, string> options; map<string, string> options;
string file; string file;
ParseOptions(argc, argv, &options, &file); ParseOptions(argc, argv, &options, &file);
......
...@@ -35,9 +35,10 @@ ...@@ -35,9 +35,10 @@
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'../tools/gyp/v8.gyp:v8', '../tools/gyp/v8.gyp:v8',
'../tools/gyp/v8.gyp:v8_libplatform',
], ],
'include_dirs': [ 'include_dirs': [
'../include', '..',
], ],
'conditions': [ 'conditions': [
['v8_enable_i18n_support==1', { ['v8_enable_i18n_support==1', {
......
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <v8.h> #include <include/v8.h>
#include <include/libplatform/libplatform.h>
#include <assert.h> #include <assert.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -79,6 +81,8 @@ class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { ...@@ -79,6 +81,8 @@ class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
v8::V8::InitializeICU(); v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform(0);
v8::V8::InitializePlatform(platform);
v8::V8::SetFlagsFromCommandLine(&argc, argv, true); v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
ShellArrayBufferAllocator array_buffer_allocator; ShellArrayBufferAllocator array_buffer_allocator;
v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
...@@ -98,6 +102,8 @@ int main(int argc, char* argv[]) { ...@@ -98,6 +102,8 @@ int main(int argc, char* argv[]) {
if (run_shell) RunShell(context); if (run_shell) RunShell(context);
} }
v8::V8::Dispose(); v8::V8::Dispose();
v8::V8::ShutdownPlatform();
delete platform;
return result; return result;
} }
......
include_rules = [ include_rules = [
"+src", "+src",
"-src/libplatform",
# TODO(jochen): Enable this. "-include/libplatform",
#"-src/libplatform",
] ]
specific_include_rules = {
"(mksnapshot|d8)\.cc": [
"+include/libplatform/libplatform.h",
],
}
...@@ -4963,20 +4963,12 @@ static void* ExternalValue(i::Object* obj) { ...@@ -4963,20 +4963,12 @@ static void* ExternalValue(i::Object* obj) {
void v8::V8::InitializePlatform(Platform* platform) { void v8::V8::InitializePlatform(Platform* platform) {
#ifdef V8_USE_DEFAULT_PLATFORM
FATAL("Can't override v8::Platform when using default implementation");
#else
i::V8::InitializePlatform(platform); i::V8::InitializePlatform(platform);
#endif
} }
void v8::V8::ShutdownPlatform() { void v8::V8::ShutdownPlatform() {
#ifdef V8_USE_DEFAULT_PLATFORM
FATAL("Can't override v8::Platform when using default implementation");
#else
i::V8::ShutdownPlatform(); i::V8::ShutdownPlatform();
#endif
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "src/d8.h" #include "src/d8.h"
#include "include/libplatform/libplatform.h"
#ifndef V8_SHARED #ifndef V8_SHARED
#include "src/api.h" #include "src/api.h"
#include "src/base/cpu.h" #include "src/base/cpu.h"
...@@ -1549,6 +1550,9 @@ class StartupDataHandler { ...@@ -1549,6 +1550,9 @@ class StartupDataHandler {
int Shell::Main(int argc, char* argv[]) { int Shell::Main(int argc, char* argv[]) {
if (!SetOptions(argc, argv)) return 1; if (!SetOptions(argc, argv)) return 1;
v8::V8::InitializeICU(options.icu_data_file); v8::V8::InitializeICU(options.icu_data_file);
v8::Platform* platform =
v8::platform::CreateDefaultPlatform(base::OS::NumberOfProcessorsOnline());
v8::V8::InitializePlatform(platform);
#ifdef V8_USE_EXTERNAL_STARTUP_DATA #ifdef V8_USE_EXTERNAL_STARTUP_DATA
StartupDataHandler startup_data(options.natives_blob, options.snapshot_blob); StartupDataHandler startup_data(options.natives_blob, options.snapshot_blob);
#endif #endif
...@@ -1626,6 +1630,8 @@ int Shell::Main(int argc, char* argv[]) { ...@@ -1626,6 +1630,8 @@ int Shell::Main(int argc, char* argv[]) {
} }
isolate->Dispose(); isolate->Dispose();
V8::Dispose(); V8::Dispose();
V8::ShutdownPlatform();
delete platform;
OnExit(); OnExit();
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'../tools/gyp/v8.gyp:v8', '../tools/gyp/v8.gyp:v8',
'../tools/gyp/v8.gyp:v8_libplatform',
], ],
# Generated source files need this explicitly: # Generated source files need this explicitly:
'include_dirs+': [ 'include_dirs+': [
......
...@@ -15,6 +15,14 @@ namespace v8 { ...@@ -15,6 +15,14 @@ namespace v8 {
namespace platform { namespace platform {
v8::Platform* CreateDefaultPlatform(int thread_pool_size) {
DefaultPlatform* platform = new DefaultPlatform();
platform->SetThreadPoolSize(thread_pool_size);
platform->EnsureInitialized();
return platform;
}
const int DefaultPlatform::kMaxThreadPoolSize = 4; const int DefaultPlatform::kMaxThreadPoolSize = 4;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "src/v8.h" #include "src/v8.h"
#include "include/libplatform/libplatform.h"
#include "src/assembler.h" #include "src/assembler.h"
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/bootstrapper.h" #include "src/bootstrapper.h"
...@@ -317,6 +318,9 @@ void DumpException(Handle<Message> message) { ...@@ -317,6 +318,9 @@ void DumpException(Handle<Message> message) {
int main(int argc, char** argv) { int main(int argc, char** argv) {
V8::InitializeICU(); V8::InitializeICU();
v8::Platform* platform =
v8::platform::CreateDefaultPlatform(base::OS::NumberOfProcessorsOnline());
v8::V8::InitializePlatform(platform);
i::CpuFeatures::Probe(true); i::CpuFeatures::Probe(true);
// By default, log code create information in the snapshot. // By default, log code create information in the snapshot.
...@@ -440,5 +444,7 @@ int main(int argc, char** argv) { ...@@ -440,5 +444,7 @@ int main(int argc, char** argv) {
isolate->Dispose(); isolate->Dispose();
V8::Dispose(); V8::Dispose();
V8::ShutdownPlatform();
delete platform;
return 0; return 0;
} }
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
#include "src/heap-profiler.h" #include "src/heap-profiler.h"
#include "src/hydrogen.h" #include "src/hydrogen.h"
#include "src/isolate.h" #include "src/isolate.h"
#ifdef V8_USE_DEFAULT_PLATFORM
#include "src/libplatform/default-platform.h"
#endif
#include "src/lithium-allocator.h" #include "src/lithium-allocator.h"
#include "src/objects.h" #include "src/objects.h"
#include "src/runtime-profiler.h" #include "src/runtime-profiler.h"
...@@ -41,14 +38,6 @@ bool V8::Initialize(Deserializer* des) { ...@@ -41,14 +38,6 @@ bool V8::Initialize(Deserializer* des) {
if (isolate->IsDead()) return false; if (isolate->IsDead()) return false;
if (isolate->IsInitialized()) return true; if (isolate->IsInitialized()) return true;
#ifdef V8_USE_DEFAULT_PLATFORM
platform::DefaultPlatform* platform =
static_cast<platform::DefaultPlatform*>(platform_);
platform->SetThreadPoolSize(isolate->max_available_threads());
// We currently only start the threads early, if we know that we'll use them.
if (FLAG_job_based_sweeping) platform->EnsureInitialized();
#endif
return isolate->Init(des); return isolate->Init(des);
} }
...@@ -62,13 +51,6 @@ void V8::TearDown() { ...@@ -62,13 +51,6 @@ void V8::TearDown() {
Isolate::GlobalTearDown(); Isolate::GlobalTearDown();
Sampler::TearDown(); Sampler::TearDown();
#ifdef V8_USE_DEFAULT_PLATFORM
platform::DefaultPlatform* platform =
static_cast<platform::DefaultPlatform*>(platform_);
platform_ = NULL;
delete platform;
#endif
} }
...@@ -94,9 +76,6 @@ void V8::InitializeOncePerProcessImpl() { ...@@ -94,9 +76,6 @@ void V8::InitializeOncePerProcessImpl() {
base::OS::Initialize(FLAG_random_seed, FLAG_hard_abort, FLAG_gc_fake_mmap); base::OS::Initialize(FLAG_random_seed, FLAG_hard_abort, FLAG_gc_fake_mmap);
#ifdef V8_USE_DEFAULT_PLATFORM
platform_ = new platform::DefaultPlatform;
#endif
Sampler::SetUp(); Sampler::SetUp();
CpuFeatures::Probe(false); CpuFeatures::Probe(false);
init_memcopy_functions(); init_memcopy_functions();
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "include/v8.h" #include "include/v8.h"
#include "test/cctest/cctest.h" #include "test/cctest/cctest.h"
#include "include/libplatform/libplatform.h"
#include "src/debug.h" #include "src/debug.h"
#include "test/cctest/print-extension.h" #include "test/cctest/print-extension.h"
#include "test/cctest/profiler-extension.h" #include "test/cctest/profiler-extension.h"
...@@ -138,6 +139,9 @@ static void SuggestTestHarness(int tests) { ...@@ -138,6 +139,9 @@ static void SuggestTestHarness(int tests) {
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
v8::V8::InitializeICU(); v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform(
v8::base::OS::NumberOfProcessorsOnline());
v8::V8::InitializePlatform(platform);
v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true); v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
...@@ -205,6 +209,8 @@ int main(int argc, char* argv[]) { ...@@ -205,6 +209,8 @@ int main(int argc, char* argv[]) {
CcTest::TearDown(); CcTest::TearDown();
// TODO(svenpanne) See comment above. // TODO(svenpanne) See comment above.
// if (!disable_automatic_dispose_) v8::V8::Dispose(); // if (!disable_automatic_dispose_) v8::V8::Dispose();
v8::V8::ShutdownPlatform();
delete platform;
return 0; return 0;
} }
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'resources', 'resources',
'../../tools/gyp/v8.gyp:v8_libplatform',
], ],
'include_dirs': [ 'include_dirs': [
'../..', '../..',
......
...@@ -532,13 +532,6 @@ ...@@ -532,13 +532,6 @@
'../../src/jsregexp-inl.h', '../../src/jsregexp-inl.h',
'../../src/jsregexp.cc', '../../src/jsregexp.cc',
'../../src/jsregexp.h', '../../src/jsregexp.h',
# TODO(jochen): move libplatform/ files to their own target.
'../../src/libplatform/default-platform.cc',
'../../src/libplatform/default-platform.h',
'../../src/libplatform/task-queue.cc',
'../../src/libplatform/task-queue.h',
'../../src/libplatform/worker-thread.cc',
'../../src/libplatform/worker-thread.h',
'../../src/list-inl.h', '../../src/list-inl.h',
'../../src/list.h', '../../src/list.h',
'../../src/lithium-allocator-inl.h', '../../src/lithium-allocator-inl.h',
...@@ -1208,6 +1201,41 @@ ...@@ -1208,6 +1201,41 @@
}], }],
], ],
}, },
{
'target_name': 'v8_libplatform',
'type': 'static_library',
'variables': {
'optimize': 'max',
},
'dependencies': [
'v8_libbase',
],
'include_dirs+': [
'../..',
],
'sources': [
'../../include/libplatform/libplatform.h',
'../../src/libplatform/default-platform.cc',
'../../src/libplatform/default-platform.h',
'../../src/libplatform/task-queue.cc',
'../../src/libplatform/task-queue.h',
'../../src/libplatform/worker-thread.cc',
'../../src/libplatform/worker-thread.h',
],
'conditions': [
['want_separate_host_toolset==1', {
'toolsets': ['host', 'target'],
}, {
'toolsets': ['target'],
}],
['component=="shared_library"', {
'defines': [
'BUILDING_V8_SHARED',
'V8_SHARED',
],
}],
],
},
{ {
'target_name': 'natives_blob', 'target_name': 'natives_blob',
'type': 'none', 'type': 'none',
...@@ -1382,7 +1410,7 @@ ...@@ -1382,7 +1410,7 @@
{ {
'target_name': 'mksnapshot', 'target_name': 'mksnapshot',
'type': 'executable', 'type': 'executable',
'dependencies': ['v8_base', 'v8_nosnapshot'], 'dependencies': ['v8_base', 'v8_nosnapshot', 'v8_libplatform'],
'include_dirs+': [ 'include_dirs+': [
'../..', '../..',
], ],
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <vector> #include <vector>
#include "src/v8.h" #include "src/v8.h"
#include "include/libplatform/libplatform.h"
#include "src/api.h" #include "src/api.h"
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/messages.h" #include "src/messages.h"
...@@ -180,6 +181,9 @@ v8::base::TimeDelta ProcessFile( ...@@ -180,6 +181,9 @@ v8::base::TimeDelta ProcessFile(
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
v8::V8::InitializeICU(); v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform(
v8::base::OS::NumberOfProcessorsOnline());
v8::V8::InitializePlatform(platform);
v8::V8::SetFlagsFromCommandLine(&argc, argv, true); v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
Encoding encoding = LATIN1; Encoding encoding = LATIN1;
bool print_tokens = false; bool print_tokens = false;
...@@ -226,5 +230,7 @@ int main(int argc, char* argv[]) { ...@@ -226,5 +230,7 @@ int main(int argc, char* argv[]) {
} }
} }
v8::V8::Dispose(); v8::V8::Dispose();
v8::V8::ShutdownPlatform();
delete platform;
return 0; return 0;
} }
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'../tools/gyp/v8.gyp:v8', '../tools/gyp/v8.gyp:v8',
'../tools/gyp/v8.gyp:v8_libplatform',
], ],
'conditions': [ 'conditions': [
['v8_enable_i18n_support==1', { ['v8_enable_i18n_support==1', {
...@@ -59,6 +60,7 @@ ...@@ -59,6 +60,7 @@
'type': 'executable', 'type': 'executable',
'dependencies': [ 'dependencies': [
'../tools/gyp/v8.gyp:v8', '../tools/gyp/v8.gyp:v8',
'../tools/gyp/v8.gyp:v8_libplatform',
], ],
'conditions': [ 'conditions': [
['v8_enable_i18n_support==1', { ['v8_enable_i18n_support==1', {
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <vector> #include <vector>
#include "src/v8.h" #include "src/v8.h"
#include "include/libplatform/libplatform.h"
#include "src/api.h" #include "src/api.h"
#include "src/compiler.h" #include "src/compiler.h"
#include "src/scanner-character-streams.h" #include "src/scanner-character-streams.h"
...@@ -121,6 +122,9 @@ std::pair<v8::base::TimeDelta, v8::base::TimeDelta> RunBaselineParser( ...@@ -121,6 +122,9 @@ std::pair<v8::base::TimeDelta, v8::base::TimeDelta> RunBaselineParser(
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
v8::V8::InitializeICU(); v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform(
v8::base::OS::NumberOfProcessorsOnline());
v8::V8::InitializePlatform(platform);
v8::V8::SetFlagsFromCommandLine(&argc, argv, true); v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
Encoding encoding = LATIN1; Encoding encoding = LATIN1;
std::vector<std::string> fnames; std::vector<std::string> fnames;
...@@ -168,5 +172,7 @@ int main(int argc, char* argv[]) { ...@@ -168,5 +172,7 @@ int main(int argc, char* argv[]) {
} }
} }
v8::V8::Dispose(); v8::V8::Dispose();
v8::V8::ShutdownPlatform();
delete platform;
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment