From b05152a2a41514846817652f22e2e1d266072cec Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Thu, 24 Mar 2011 10:54:23 +0000 Subject: [PATCH] Make V8 build with the chromium shared library build Fix the shell to not use functions from the v8::internal namespace when building with V8 in a shared library. Remove the v8_preparser library. The dependencies for this target needs to be resolved after isolates have landed. Review URL: http://codereview.chromium.org/6696067 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7337 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- samples/shell.cc | 43 +++++++++++++++++++++++++++++++++++-------- tools/gyp/v8.gyp | 32 -------------------------------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/samples/shell.cc b/samples/shell.cc index 3b2076a..a65d10a 100644 --- a/samples/shell.cc +++ b/samples/shell.cc @@ -33,7 +33,14 @@ #include #include +// When building with V8 in a shared library we cannot use functions which +// is not explicitly a part of the public V8 API. This extensive use of +// #ifndef USING_V8_SHARED/#endif is a hack until we can resolve whether to +// still use the shell sample for testing or change to use the and the +// developer shell d8 TODO(1272). +#ifndef USING_V8_SHARED #include "../src/v8.h" +#endif // USING_V8_SHARED #if !defined(_WIN32) && !defined(_WIN64) #include // NOLINT @@ -66,12 +73,15 @@ static bool last_run = true; class SourceGroup { public: - SourceGroup() : argv_(NULL), - begin_offset_(0), - end_offset_(0), + SourceGroup() : +#ifndef USING_V8_SHARED next_semaphore_(v8::internal::OS::CreateSemaphore(0)), done_semaphore_(v8::internal::OS::CreateSemaphore(0)), - thread_(NULL) { } + thread_(NULL), +#endif // USING_V8_SHARED + argv_(NULL), + begin_offset_(0), + end_offset_(0) { } void Begin(char** argv, int offset) { argv_ = const_cast(argv); @@ -111,6 +121,7 @@ class SourceGroup { } } +#ifndef USING_V8_SHARED void StartExecuteInThread() { if (thread_ == NULL) { thread_ = new IsolateThread(this); @@ -128,8 +139,10 @@ class SourceGroup { done_semaphore_->Wait(); } } +#endif // USING_V8_SHARED private: +#ifndef USING_V8_SHARED static v8::internal::Thread::Options GetThreadOptions() { v8::internal::Thread::Options options; options.name = "IsolateThread"; @@ -173,12 +186,14 @@ class SourceGroup { isolate->Dispose(); } - const char** argv_; - int begin_offset_; - int end_offset_; v8::internal::Semaphore* next_semaphore_; v8::internal::Semaphore* done_semaphore_; v8::internal::Thread* thread_; +#endif // USING_V8_SHARED + + const char** argv_; + int begin_offset_; + int end_offset_; }; @@ -199,7 +214,15 @@ int RunMain(int argc, char* argv[]) { bool run_shell = (argc == 1); int num_isolates = 1; for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "--isolate") == 0) ++num_isolates; + if (strcmp(argv[i], "--isolate") == 0) { +#ifndef USING_V8_SHARED + ++num_isolates; +#else // USING_V8_SHARED + printf("Error: --isolate not supported when linked with shared " + "library\n"); + ExitShell(1); +#endif // USING_V8_SHARED + } } if (isolate_sources == NULL) { isolate_sources = new SourceGroup[num_isolates]; @@ -223,14 +246,18 @@ int RunMain(int argc, char* argv[]) { } current->End(argc); } +#ifndef USING_V8_SHARED for (int i = 1; i < num_isolates; ++i) { isolate_sources[i].StartExecuteInThread(); } +#endif // USING_V8_SHARED isolate_sources[0].Execute(); if (run_shell) RunShell(context); +#ifndef USING_V8_SHARED for (int i = 1; i < num_isolates; ++i) { isolate_sources[i].WaitForThread(); } +#endif // USING_V8_SHARED if (last_run) { delete[] isolate_sources; isolate_sources = NULL; diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index 4d27bc0..4bf0d87 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -211,38 +211,6 @@ }, }, { - 'target_name': 'v8_preparser', - 'include_dirs': [ - '../../include', - '../../src', - ], - 'sources': [ - '../../src/allocation.cc', - '../../src/hashmap.cc', - '../../src/preparse-data.cc', - '../../src/preparser.cc', - '../../src/preparser-api.cc', - '../../src/scanner-base.cc', - '../../src/token.cc', - '../../src/unicode.cc', - ], - 'conditions': [ - ['OS=="win" and component=="shared_library"', { - 'sources': [ '../../src/v8preparserdll-main.cc' ], - 'defines': [ 'BUILDING_V8_SHARED' ], - 'direct_dependent_settings': { - 'defines': [ 'USING_V8_SHARED' ] - }, - 'type': '<(component)', - } , { - 'type': 'none' - }], - ['OS!="win"', { - 'type': '<(library)' - }], - ] - }, - { 'target_name': 'v8_snapshot', 'type': '<(library)', 'conditions': [ -- 2.7.4