Commit 298ee9cd authored by machenbach's avatar machenbach Committed by Commit bot

Revert of [d8] Fix the shared-library build (patchset #12 id:20002 of...

Revert of [d8] Fix the shared-library build (patchset #12 id:20002 of https://codereview.chromium.org/2342563002/ )

Reason for revert:
Unblocking roll

Original issue's description:
> [d8] Fix the shared-library build
>
> This commit ensures that the d8 shared library build uses the same logic as
> the standard static build by exporting relevant functions and classes.
>
> BUG=chromium:646337
>
> Committed: https://crrev.com/2c10ca8086a4d595ecf9aa843d2031b068470d65
> Cr-Commit-Position: refs/heads/master@{#39503}

TBR=jochen@chromium.org,vogelheim@chromium.org,bmeurer@chromium.org,titzer@chromium.org,jgruber@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=chromium:646337

Review-Url: https://codereview.chromium.org/2356703003
Cr-Commit-Position: refs/heads/master@{#39526}
parent d86038db
...@@ -115,7 +115,10 @@ config("internal_config") { ...@@ -115,7 +115,10 @@ config("internal_config") {
include_dirs = [ "." ] include_dirs = [ "." ]
if (is_component_build) { if (is_component_build) {
defines = [ "BUILDING_V8_SHARED" ] defines = [
"V8_SHARED",
"BUILDING_V8_SHARED",
]
} }
} }
...@@ -139,7 +142,10 @@ config("libsampler_config") { ...@@ -139,7 +142,10 @@ config("libsampler_config") {
# itself. # itself.
config("external_config") { config("external_config") {
if (is_component_build) { if (is_component_build) {
defines = [ "USING_V8_SHARED" ] defines = [
"V8_SHARED",
"USING_V8_SHARED",
]
} }
include_dirs = [ "include" ] include_dirs = [ "include" ]
if (v8_enable_inspector_override) { if (v8_enable_inspector_override) {
...@@ -2383,7 +2389,6 @@ if (is_component_build) { ...@@ -2383,7 +2389,6 @@ if (is_component_build) {
v8_executable("d8") { v8_executable("d8") {
sources = [ sources = [
"$target_gen_dir/d8-js.cc",
"src/d8.cc", "src/d8.cc",
"src/d8.h", "src/d8.h",
] ]
...@@ -2411,6 +2416,9 @@ v8_executable("d8") { ...@@ -2411,6 +2416,9 @@ v8_executable("d8") {
sources += [ "src/d8-windows.cc" ] sources += [ "src/d8-windows.cc" ]
} }
if (!is_component_build) {
sources += [ "$target_gen_dir/d8-js.cc" ]
}
if (v8_enable_i18n_support) { if (v8_enable_i18n_support) {
deps += [ "//third_party/icu" ] deps += [ "//third_party/icu" ]
} }
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
#else // V8_OS_WIN #else // V8_OS_WIN
// Setup for Linux shared library export. // Setup for Linux shared library export.
#if V8_HAS_ATTRIBUTE_VISIBILITY #if V8_HAS_ATTRIBUTE_VISIBILITY && defined(V8_SHARED)
# ifdef BUILDING_V8_SHARED # ifdef BUILDING_V8_SHARED
# define V8_EXPORT __attribute__ ((visibility("default"))) # define V8_EXPORT __attribute__ ((visibility("default")))
# else # else
......
...@@ -13,10 +13,10 @@ namespace internal { ...@@ -13,10 +13,10 @@ namespace internal {
// Called when allocation routines fail to allocate. // Called when allocation routines fail to allocate.
// This function should not return, but should terminate the current // This function should not return, but should terminate the current
// processing. // processing.
V8_EXPORT_PRIVATE void FatalProcessOutOfMemory(const char* message); void FatalProcessOutOfMemory(const char* message);
// Superclass for classes managed with new & delete. // Superclass for classes managed with new & delete.
class V8_EXPORT_PRIVATE Malloced { class Malloced {
public: public:
void* operator new(size_t size) { return New(size); } void* operator new(size_t size) { return New(size); }
void operator delete(void* p) { Delete(p); } void operator delete(void* p) { Delete(p); }
...@@ -72,7 +72,7 @@ void DeleteArray(T* array) { ...@@ -72,7 +72,7 @@ void DeleteArray(T* array) {
// The normal strdup functions use malloc. These versions of StrDup // The normal strdup functions use malloc. These versions of StrDup
// and StrNDup uses new and calls the FatalProcessOutOfMemory handler // and StrNDup uses new and calls the FatalProcessOutOfMemory handler
// if allocation fails. // if allocation fails.
V8_EXPORT_PRIVATE char* StrDup(const char* str); char* StrDup(const char* str);
char* StrNDup(const char* str, int n); char* StrNDup(const char* str, int n);
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <vector> #include <vector>
#include "src/base/macros.h" #include "src/base/macros.h"
#include "src/globals.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -59,16 +58,15 @@ class BasicBlockProfiler { ...@@ -59,16 +58,15 @@ class BasicBlockProfiler {
const DataList* data_list() { return &data_list_; } const DataList* data_list() { return &data_list_; }
private: private:
friend V8_EXPORT_PRIVATE std::ostream& operator<<( friend std::ostream& operator<<(std::ostream& os,
std::ostream& os, const BasicBlockProfiler& s); const BasicBlockProfiler& s);
DataList data_list_; DataList data_list_;
DISALLOW_COPY_AND_ASSIGN(BasicBlockProfiler); DISALLOW_COPY_AND_ASSIGN(BasicBlockProfiler);
}; };
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler& s);
const BasicBlockProfiler& s);
std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler::Data& s); std::ostream& operator<<(std::ostream& os, const BasicBlockProfiler::Data& s);
} // namespace internal } // namespace internal
......
...@@ -2,14 +2,30 @@ ...@@ -2,14 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Defined when linking against shared lib on Windows.
#if defined(USING_V8_SHARED) && !defined(V8_SHARED)
#define V8_SHARED
#endif
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef V8_SHARED
#include <assert.h>
#endif // V8_SHARED
#ifndef V8_SHARED
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
#include <vector> #include <vector>
#endif // !V8_SHARED
#ifdef V8_SHARED
#include "include/v8-testing.h"
#endif // V8_SHARED
#ifdef ENABLE_VTUNE_JIT_INTERFACE #ifdef ENABLE_VTUNE_JIT_INTERFACE
#include "src/third_party/vtune/v8-vtune.h" #include "src/third_party/vtune/v8-vtune.h"
...@@ -20,6 +36,7 @@ ...@@ -20,6 +36,7 @@
#include "include/libplatform/libplatform.h" #include "include/libplatform/libplatform.h"
#include "include/libplatform/v8-tracing.h" #include "include/libplatform/v8-tracing.h"
#ifndef V8_SHARED
#include "src/api.h" #include "src/api.h"
#include "src/base/cpu.h" #include "src/base/cpu.h"
#include "src/base/debug/stack_trace.h" #include "src/base/debug/stack_trace.h"
...@@ -31,6 +48,7 @@ ...@@ -31,6 +48,7 @@
#include "src/snapshot/natives.h" #include "src/snapshot/natives.h"
#include "src/utils.h" #include "src/utils.h"
#include "src/v8.h" #include "src/v8.h"
#endif // !V8_SHARED
#if !defined(_WIN32) && !defined(_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
#include <unistd.h> // NOLINT #include <unistd.h> // NOLINT
...@@ -54,7 +72,9 @@ namespace v8 { ...@@ -54,7 +72,9 @@ namespace v8 {
namespace { namespace {
const int MB = 1024 * 1024; const int MB = 1024 * 1024;
#ifndef V8_SHARED
const int kMaxWorkers = 50; const int kMaxWorkers = 50;
#endif
class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
...@@ -82,6 +102,7 @@ class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator { ...@@ -82,6 +102,7 @@ class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
}; };
#ifndef V8_SHARED
// Predictable v8::Platform implementation. All background and foreground // Predictable v8::Platform implementation. All background and foreground
// tasks are run immediately, delayed tasks are not executed at all. // tasks are run immediately, delayed tasks are not executed at all.
class PredictablePlatform : public Platform { class PredictablePlatform : public Platform {
...@@ -142,6 +163,7 @@ class PredictablePlatform : public Platform { ...@@ -142,6 +163,7 @@ class PredictablePlatform : public Platform {
DISALLOW_COPY_AND_ASSIGN(PredictablePlatform); DISALLOW_COPY_AND_ASSIGN(PredictablePlatform);
}; };
#endif // !V8_SHARED
v8::Platform* g_platform = NULL; v8::Platform* g_platform = NULL;
...@@ -154,6 +176,7 @@ static Local<Value> Throw(Isolate* isolate, const char* message) { ...@@ -154,6 +176,7 @@ static Local<Value> Throw(Isolate* isolate, const char* message) {
} }
#ifndef V8_SHARED
bool FindInObjectList(Local<Object> object, const Shell::ObjectList& list) { bool FindInObjectList(Local<Object> object, const Shell::ObjectList& list) {
for (int i = 0; i < list.length(); ++i) { for (int i = 0; i < list.length(); ++i) {
if (list[i]->StrictEquals(object)) { if (list[i]->StrictEquals(object)) {
...@@ -179,6 +202,7 @@ Worker* GetWorkerFromInternalField(Isolate* isolate, Local<Object> object) { ...@@ -179,6 +202,7 @@ Worker* GetWorkerFromInternalField(Isolate* isolate, Local<Object> object) {
return worker; return worker;
} }
#endif // !V8_SHARED
} // namespace } // namespace
...@@ -346,6 +370,7 @@ class PerIsolateData { ...@@ -346,6 +370,7 @@ class PerIsolateData {
}; };
#ifndef V8_SHARED
CounterMap* Shell::counter_map_; CounterMap* Shell::counter_map_;
base::OS::MemoryMappedFile* Shell::counters_file_ = NULL; base::OS::MemoryMappedFile* Shell::counters_file_ = NULL;
CounterCollection Shell::local_counters_; CounterCollection Shell::local_counters_;
...@@ -358,17 +383,20 @@ base::LazyMutex Shell::workers_mutex_; ...@@ -358,17 +383,20 @@ base::LazyMutex Shell::workers_mutex_;
bool Shell::allow_new_workers_ = true; bool Shell::allow_new_workers_ = true;
i::List<Worker*> Shell::workers_; i::List<Worker*> Shell::workers_;
i::List<SharedArrayBuffer::Contents> Shell::externalized_shared_contents_; i::List<SharedArrayBuffer::Contents> Shell::externalized_shared_contents_;
#endif // !V8_SHARED
Global<Context> Shell::evaluation_context_; Global<Context> Shell::evaluation_context_;
ArrayBuffer::Allocator* Shell::array_buffer_allocator; ArrayBuffer::Allocator* Shell::array_buffer_allocator;
ShellOptions Shell::options; ShellOptions Shell::options;
base::OnceType Shell::quit_once_ = V8_ONCE_INIT; base::OnceType Shell::quit_once_ = V8_ONCE_INIT;
#ifndef V8_SHARED
bool CounterMap::Match(void* key1, void* key2) { bool CounterMap::Match(void* key1, void* key2) {
const char* name1 = reinterpret_cast<const char*>(key1); const char* name1 = reinterpret_cast<const char*>(key1);
const char* name2 = reinterpret_cast<const char*>(key2); const char* name2 = reinterpret_cast<const char*>(key2);
return strcmp(name1, name2) == 0; return strcmp(name1, name2) == 0;
} }
#endif // !V8_SHARED
// Converts a V8 value to a C string. // Converts a V8 value to a C string.
...@@ -509,7 +537,9 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source, ...@@ -509,7 +537,9 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
} }
DCHECK(!try_catch.HasCaught()); DCHECK(!try_catch.HasCaught());
if (print_result) { if (print_result) {
#if !defined(V8_SHARED)
if (options.test_shell) { if (options.test_shell) {
#endif
if (!result->IsUndefined()) { if (!result->IsUndefined()) {
// If all went well and the result wasn't undefined then print // If all went well and the result wasn't undefined then print
// the returned value. // the returned value.
...@@ -517,11 +547,13 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source, ...@@ -517,11 +547,13 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
fwrite(*str, sizeof(**str), str.length(), stdout); fwrite(*str, sizeof(**str), str.length(), stdout);
printf("\n"); printf("\n");
} }
#if !defined(V8_SHARED)
} else { } else {
v8::String::Utf8Value str(Stringify(isolate, result)); v8::String::Utf8Value str(Stringify(isolate, result));
fwrite(*str, sizeof(**str), str.length(), stdout); fwrite(*str, sizeof(**str), str.length(), stdout);
printf("\n"); printf("\n");
} }
#endif
} }
return true; return true;
} }
...@@ -573,6 +605,7 @@ int PerIsolateData::RealmIndexOrThrow( ...@@ -573,6 +605,7 @@ int PerIsolateData::RealmIndexOrThrow(
} }
#ifndef V8_SHARED
// performance.now() returns a time stamp as double, measured in milliseconds. // performance.now() returns a time stamp as double, measured in milliseconds.
// When FLAG_verify_predictable mode is enabled it returns result of // When FLAG_verify_predictable mode is enabled it returns result of
// v8::Platform::MonotonicallyIncreasingTime(). // v8::Platform::MonotonicallyIncreasingTime().
...@@ -585,6 +618,7 @@ void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -585,6 +618,7 @@ void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) {
args.GetReturnValue().Set(delta.InMillisecondsF()); args.GetReturnValue().Set(delta.InMillisecondsF());
} }
} }
#endif // !V8_SHARED
// Realm.current() returns the index of the currently active realm. // Realm.current() returns the index of the currently active realm.
...@@ -855,6 +889,7 @@ void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -855,6 +889,7 @@ void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
} }
#ifndef V8_SHARED
void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) { void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate(); Isolate* isolate = args.GetIsolate();
HandleScope handle_scope(isolate); HandleScope handle_scope(isolate);
...@@ -976,13 +1011,16 @@ void Shell::WorkerTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -976,13 +1011,16 @@ void Shell::WorkerTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
worker->Terminate(); worker->Terminate();
} }
#endif // !V8_SHARED
void Shell::QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args) { void Shell::QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args) {
int exit_code = (*args)[0] int exit_code = (*args)[0]
->Int32Value(args->GetIsolate()->GetCurrentContext()) ->Int32Value(args->GetIsolate()->GetCurrentContext())
.FromMaybe(0); .FromMaybe(0);
#ifndef V8_SHARED
CleanupWorkers(); CleanupWorkers();
#endif // !V8_SHARED
OnExit(args->GetIsolate()); OnExit(args->GetIsolate());
Exit(exit_code); Exit(exit_code);
} }
...@@ -1003,12 +1041,14 @@ void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -1003,12 +1041,14 @@ void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) {
void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) { void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) {
HandleScope handle_scope(isolate); HandleScope handle_scope(isolate);
#ifndef V8_SHARED
Local<Context> context; Local<Context> context;
bool enter_context = !isolate->InContext(); bool enter_context = !isolate->InContext();
if (enter_context) { if (enter_context) {
context = Local<Context>::New(isolate, evaluation_context_); context = Local<Context>::New(isolate, evaluation_context_);
context->Enter(); context->Enter();
} }
#endif // !V8_SHARED
v8::String::Utf8Value exception(try_catch->Exception()); v8::String::Utf8Value exception(try_catch->Exception());
const char* exception_string = ToCString(exception); const char* exception_string = ToCString(exception);
Local<Message> message = try_catch->Message(); Local<Message> message = try_catch->Message();
...@@ -1052,10 +1092,13 @@ void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) { ...@@ -1052,10 +1092,13 @@ void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) {
} }
} }
printf("\n"); printf("\n");
#ifndef V8_SHARED
if (enter_context) context->Exit(); if (enter_context) context->Exit();
#endif // !V8_SHARED
} }
#ifndef V8_SHARED
int32_t* Counter::Bind(const char* name, bool is_histogram) { int32_t* Counter::Bind(const char* name, bool is_histogram) {
int i; int i;
for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) for (i = 0; i < kMaxNameSize - 1 && name[i]; i++)
...@@ -1184,6 +1227,7 @@ Local<String> Shell::Stringify(Isolate* isolate, Local<Value> value) { ...@@ -1184,6 +1227,7 @@ Local<String> Shell::Stringify(Isolate* isolate, Local<Value> value) {
if (result.IsEmpty()) return String::Empty(isolate); if (result.IsEmpty()) return String::Empty(isolate);
return result.ToLocalChecked().As<String>(); return result.ToLocalChecked().As<String>();
} }
#endif // !V8_SHARED
Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) { Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
...@@ -1274,6 +1318,7 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) { ...@@ -1274,6 +1318,7 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
.ToLocalChecked(), .ToLocalChecked(),
realm_template); realm_template);
#ifndef V8_SHARED
Local<ObjectTemplate> performance_template = ObjectTemplate::New(isolate); Local<ObjectTemplate> performance_template = ObjectTemplate::New(isolate);
performance_template->Set( performance_template->Set(
String::NewFromUtf8(isolate, "now", NewStringType::kNormal) String::NewFromUtf8(isolate, "now", NewStringType::kNormal)
...@@ -1312,6 +1357,7 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) { ...@@ -1312,6 +1357,7 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
String::NewFromUtf8(isolate, "Worker", NewStringType::kNormal) String::NewFromUtf8(isolate, "Worker", NewStringType::kNormal)
.ToLocalChecked(), .ToLocalChecked(),
worker_fun_template); worker_fun_template);
#endif // !V8_SHARED
Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate);
AddOSMethods(isolate, os_templ); AddOSMethods(isolate, os_templ);
...@@ -1329,17 +1375,21 @@ static void EmptyMessageCallback(Local<Message> message, Local<Value> error) { ...@@ -1329,17 +1375,21 @@ static void EmptyMessageCallback(Local<Message> message, Local<Value> error) {
} }
void Shell::Initialize(Isolate* isolate) { void Shell::Initialize(Isolate* isolate) {
#ifndef V8_SHARED
// Set up counters // Set up counters
if (i::StrLength(i::FLAG_map_counters) != 0) if (i::StrLength(i::FLAG_map_counters) != 0)
MapCounters(isolate, i::FLAG_map_counters); MapCounters(isolate, i::FLAG_map_counters);
#endif // !V8_SHARED
// Disable default message reporting. // Disable default message reporting.
isolate->AddMessageListener(EmptyMessageCallback); isolate->AddMessageListener(EmptyMessageCallback);
} }
Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) { Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
#ifndef V8_SHARED
// This needs to be a critical section since this is not thread-safe // This needs to be a critical section since this is not thread-safe
base::LockGuard<base::Mutex> lock_guard(context_mutex_.Pointer()); base::LockGuard<base::Mutex> lock_guard(context_mutex_.Pointer());
#endif // !V8_SHARED
// Initialize the global objects // Initialize the global objects
Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
EscapableHandleScope handle_scope(isolate); EscapableHandleScope handle_scope(isolate);
...@@ -1347,6 +1397,7 @@ Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) { ...@@ -1347,6 +1397,7 @@ Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
DCHECK(!context.IsEmpty()); DCHECK(!context.IsEmpty());
Context::Scope scope(context); Context::Scope scope(context);
#ifndef V8_SHARED
i::Factory* factory = reinterpret_cast<i::Isolate*>(isolate)->factory(); i::Factory* factory = reinterpret_cast<i::Isolate*>(isolate)->factory();
i::JSArguments js_args = i::FLAG_js_arguments; i::JSArguments js_args = i::FLAG_js_arguments;
i::Handle<i::FixedArray> arguments_array = i::Handle<i::FixedArray> arguments_array =
...@@ -1364,6 +1415,7 @@ Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) { ...@@ -1364,6 +1415,7 @@ Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
.ToLocalChecked(), .ToLocalChecked(),
Utils::ToLocal(arguments_jsarray)) Utils::ToLocal(arguments_jsarray))
.FromJust(); .FromJust();
#endif // !V8_SHARED
return handle_scope.Escape(context); return handle_scope.Escape(context);
} }
...@@ -1377,6 +1429,7 @@ void Shell::Exit(int exit_code) { ...@@ -1377,6 +1429,7 @@ void Shell::Exit(int exit_code) {
} }
#ifndef V8_SHARED
struct CounterAndKey { struct CounterAndKey {
Counter* counter; Counter* counter;
const char* key; const char* key;
...@@ -1401,8 +1454,11 @@ void Shell::WriteIgnitionDispatchCountersFile(v8::Isolate* isolate) { ...@@ -1401,8 +1454,11 @@ void Shell::WriteIgnitionDispatchCountersFile(v8::Isolate* isolate) {
JSON::Stringify(context, dispatch_counters).ToLocalChecked()); JSON::Stringify(context, dispatch_counters).ToLocalChecked());
} }
#endif // !V8_SHARED
void Shell::OnExit(v8::Isolate* isolate) { void Shell::OnExit(v8::Isolate* isolate) {
#ifndef V8_SHARED
if (i::FLAG_dump_counters) { if (i::FLAG_dump_counters) {
int number_of_counters = 0; int number_of_counters = 0;
for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {
...@@ -1438,6 +1494,7 @@ void Shell::OnExit(v8::Isolate* isolate) { ...@@ -1438,6 +1494,7 @@ void Shell::OnExit(v8::Isolate* isolate) {
delete counters_file_; delete counters_file_;
delete counter_map_; delete counter_map_;
#endif // !V8_SHARED
} }
...@@ -1571,8 +1628,10 @@ void Shell::RunShell(Isolate* isolate) { ...@@ -1571,8 +1628,10 @@ void Shell::RunShell(Isolate* isolate) {
SourceGroup::~SourceGroup() { SourceGroup::~SourceGroup() {
#ifndef V8_SHARED
delete thread_; delete thread_;
thread_ = NULL; thread_ = NULL;
#endif // !V8_SHARED
} }
...@@ -1641,6 +1700,7 @@ Local<String> SourceGroup::ReadFile(Isolate* isolate, const char* name) { ...@@ -1641,6 +1700,7 @@ Local<String> SourceGroup::ReadFile(Isolate* isolate, const char* name) {
} }
#ifndef V8_SHARED
base::Thread::Options SourceGroup::GetThreadOptions() { base::Thread::Options SourceGroup::GetThreadOptions() {
// On some systems (OSX 10.6) the stack size default is 0.5Mb or less // On some systems (OSX 10.6) the stack size default is 0.5Mb or less
// which is not enough to parse the big literal expressions used in tests. // which is not enough to parse the big literal expressions used in tests.
...@@ -1964,6 +2024,7 @@ void Worker::PostMessageOut(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -1964,6 +2024,7 @@ void Worker::PostMessageOut(const v8::FunctionCallbackInfo<v8::Value>& args) {
delete data; delete data;
} }
} }
#endif // !V8_SHARED
void SetFlagsFromString(const char* flags) { void SetFlagsFromString(const char* flags) {
...@@ -2019,16 +2080,30 @@ bool Shell::SetOptions(int argc, char* argv[]) { ...@@ -2019,16 +2080,30 @@ bool Shell::SetOptions(int argc, char* argv[]) {
// JavaScript engines. // JavaScript engines.
continue; continue;
} else if (strcmp(argv[i], "--isolate") == 0) { } else if (strcmp(argv[i], "--isolate") == 0) {
#ifdef V8_SHARED
printf("D8 with shared library does not support multi-threading\n");
return false;
#endif // V8_SHARED
options.num_isolates++; options.num_isolates++;
} else if (strcmp(argv[i], "--dump-heap-constants") == 0) { } else if (strcmp(argv[i], "--dump-heap-constants") == 0) {
#ifdef V8_SHARED
printf("D8 with shared library does not support constant dumping\n");
return false;
#else
options.dump_heap_constants = true; options.dump_heap_constants = true;
argv[i] = NULL; argv[i] = NULL;
#endif // V8_SHARED
} else if (strcmp(argv[i], "--throws") == 0) { } else if (strcmp(argv[i], "--throws") == 0) {
options.expected_to_throw = true; options.expected_to_throw = true;
argv[i] = NULL; argv[i] = NULL;
} else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) { } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) {
options.icu_data_file = argv[i] + 16; options.icu_data_file = argv[i] + 16;
argv[i] = NULL; argv[i] = NULL;
#ifdef V8_SHARED
} else if (strcmp(argv[i], "--dump-counters") == 0) {
printf("D8 with shared library does not include counters\n");
return false;
#endif // V8_SHARED
#ifdef V8_USE_EXTERNAL_STARTUP_DATA #ifdef V8_USE_EXTERNAL_STARTUP_DATA
} else if (strncmp(argv[i], "--natives_blob=", 15) == 0) { } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) {
options.natives_blob = argv[i] + 15; options.natives_blob = argv[i] + 15;
...@@ -2094,9 +2169,11 @@ bool Shell::SetOptions(int argc, char* argv[]) { ...@@ -2094,9 +2169,11 @@ bool Shell::SetOptions(int argc, char* argv[]) {
int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) { int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) {
#ifndef V8_SHARED
for (int i = 1; i < options.num_isolates; ++i) { for (int i = 1; i < options.num_isolates; ++i) {
options.isolate_sources[i].StartExecuteInThread(); options.isolate_sources[i].StartExecuteInThread();
} }
#endif // !V8_SHARED
{ {
HandleScope scope(isolate); HandleScope scope(isolate);
Local<Context> context = CreateEvaluationContext(isolate); Local<Context> context = CreateEvaluationContext(isolate);
...@@ -2111,6 +2188,7 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) { ...@@ -2111,6 +2188,7 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) {
} }
} }
CollectGarbage(isolate); CollectGarbage(isolate);
#ifndef V8_SHARED
for (int i = 1; i < options.num_isolates; ++i) { for (int i = 1; i < options.num_isolates; ++i) {
if (last_run) { if (last_run) {
options.isolate_sources[i].JoinThread(); options.isolate_sources[i].JoinThread();
...@@ -2119,6 +2197,7 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) { ...@@ -2119,6 +2197,7 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) {
} }
} }
CleanupWorkers(); CleanupWorkers();
#endif // !V8_SHARED
return 0; return 0;
} }
...@@ -2140,12 +2219,17 @@ void Shell::CollectGarbage(Isolate* isolate) { ...@@ -2140,12 +2219,17 @@ void Shell::CollectGarbage(Isolate* isolate) {
void Shell::EmptyMessageQueues(Isolate* isolate) { void Shell::EmptyMessageQueues(Isolate* isolate) {
#ifndef V8_SHARED
if (!i::FLAG_verify_predictable) { if (!i::FLAG_verify_predictable) {
#endif
while (v8::platform::PumpMessageLoop(g_platform, isolate)) continue; while (v8::platform::PumpMessageLoop(g_platform, isolate)) continue;
#ifndef V8_SHARED
} }
#endif
} }
#ifndef V8_SHARED
bool Shell::SerializeValue(Isolate* isolate, Local<Value> value, bool Shell::SerializeValue(Isolate* isolate, Local<Value> value,
const ObjectList& to_transfer, const ObjectList& to_transfer,
ObjectList* seen_objects, ObjectList* seen_objects,
...@@ -2460,11 +2544,14 @@ static void DumpHeapConstants(i::Isolate* isolate) { ...@@ -2460,11 +2544,14 @@ static void DumpHeapConstants(i::Isolate* isolate) {
printf("}\n"); printf("}\n");
#undef ROOT_LIST_CASE #undef ROOT_LIST_CASE
} }
#endif // !V8_SHARED
int Shell::Main(int argc, char* argv[]) { int Shell::Main(int argc, char* argv[]) {
std::ofstream trace_file; std::ofstream trace_file;
#ifndef V8_SHARED
v8::base::debug::EnableInProcessStackDumping(); v8::base::debug::EnableInProcessStackDumping();
#endif
#if (defined(_WIN32) || defined(_WIN64)) #if (defined(_WIN32) || defined(_WIN64))
UINT new_flags = UINT new_flags =
SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
...@@ -2482,9 +2569,13 @@ int Shell::Main(int argc, char* argv[]) { ...@@ -2482,9 +2569,13 @@ int Shell::Main(int argc, char* argv[]) {
#endif // defined(_WIN32) || defined(_WIN64) #endif // defined(_WIN32) || defined(_WIN64)
if (!SetOptions(argc, argv)) return 1; if (!SetOptions(argc, argv)) return 1;
v8::V8::InitializeICUDefaultLocation(argv[0], options.icu_data_file); v8::V8::InitializeICUDefaultLocation(argv[0], options.icu_data_file);
#ifndef V8_SHARED
g_platform = i::FLAG_verify_predictable g_platform = i::FLAG_verify_predictable
? new PredictablePlatform() ? new PredictablePlatform()
: v8::platform::CreateDefaultPlatform(); : v8::platform::CreateDefaultPlatform();
#else
g_platform = v8::platform::CreateDefaultPlatform();
#endif // !V8_SHARED
v8::V8::InitializePlatform(g_platform); v8::V8::InitializePlatform(g_platform);
v8::V8::Initialize(); v8::V8::Initialize();
...@@ -2510,6 +2601,7 @@ int Shell::Main(int argc, char* argv[]) { ...@@ -2510,6 +2601,7 @@ int Shell::Main(int argc, char* argv[]) {
#ifdef ENABLE_VTUNE_JIT_INTERFACE #ifdef ENABLE_VTUNE_JIT_INTERFACE
create_params.code_event_handler = vTune::GetVtuneCodeEventHandler(); create_params.code_event_handler = vTune::GetVtuneCodeEventHandler();
#endif #endif
#ifndef V8_SHARED
create_params.constraints.ConfigureDefaults( create_params.constraints.ConfigureDefaults(
base::SysInfo::AmountOfPhysicalMemory(), base::SysInfo::AmountOfPhysicalMemory(),
base::SysInfo::AmountOfVirtualMemory()); base::SysInfo::AmountOfVirtualMemory());
...@@ -2520,6 +2612,7 @@ int Shell::Main(int argc, char* argv[]) { ...@@ -2520,6 +2612,7 @@ int Shell::Main(int argc, char* argv[]) {
create_params.create_histogram_callback = CreateHistogram; create_params.create_histogram_callback = CreateHistogram;
create_params.add_histogram_sample_callback = AddHistogramSample; create_params.add_histogram_sample_callback = AddHistogramSample;
} }
#endif
Isolate* isolate = Isolate::New(create_params); Isolate* isolate = Isolate::New(create_params);
{ {
Isolate::Scope scope(isolate); Isolate::Scope scope(isolate);
...@@ -2549,15 +2642,21 @@ int Shell::Main(int argc, char* argv[]) { ...@@ -2549,15 +2642,21 @@ int Shell::Main(int argc, char* argv[]) {
} }
tracing_controller->Initialize(trace_buffer); tracing_controller->Initialize(trace_buffer);
tracing_controller->StartTracing(trace_config); tracing_controller->StartTracing(trace_config);
#ifndef V8_SHARED
if (!i::FLAG_verify_predictable) { if (!i::FLAG_verify_predictable) {
platform::SetTracingController(g_platform, tracing_controller); platform::SetTracingController(g_platform, tracing_controller);
} }
#else
platform::SetTracingController(g_platform, tracing_controller);
#endif
} }
#ifndef V8_SHARED
if (options.dump_heap_constants) { if (options.dump_heap_constants) {
DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate)); DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate));
return 0; return 0;
} }
#endif
if (options.stress_opt || options.stress_deopt) { if (options.stress_opt || options.stress_deopt) {
Testing::SetStressRunType(options.stress_opt Testing::SetStressRunType(options.stress_opt
...@@ -2573,6 +2672,7 @@ int Shell::Main(int argc, char* argv[]) { ...@@ -2573,6 +2672,7 @@ int Shell::Main(int argc, char* argv[]) {
} }
printf("======== Full Deoptimization =======\n"); printf("======== Full Deoptimization =======\n");
Testing::DeoptimizeAll(isolate); Testing::DeoptimizeAll(isolate);
#if !defined(V8_SHARED)
} else if (i::FLAG_stress_runs > 0) { } else if (i::FLAG_stress_runs > 0) {
options.stress_runs = i::FLAG_stress_runs; options.stress_runs = i::FLAG_stress_runs;
for (int i = 0; i < options.stress_runs && result == 0; i++) { for (int i = 0; i < options.stress_runs && result == 0; i++) {
...@@ -2581,6 +2681,7 @@ int Shell::Main(int argc, char* argv[]) { ...@@ -2581,6 +2681,7 @@ int Shell::Main(int argc, char* argv[]) {
bool last_run = i == options.stress_runs - 1; bool last_run = i == options.stress_runs - 1;
result = RunMain(isolate, argc, argv, last_run); result = RunMain(isolate, argc, argv, last_run);
} }
#endif
} else { } else {
bool last_run = true; bool last_run = true;
result = RunMain(isolate, argc, argv, last_run); result = RunMain(isolate, argc, argv, last_run);
...@@ -2592,23 +2693,29 @@ int Shell::Main(int argc, char* argv[]) { ...@@ -2592,23 +2693,29 @@ int Shell::Main(int argc, char* argv[]) {
RunShell(isolate); RunShell(isolate);
} }
#ifndef V8_SHARED
if (i::FLAG_ignition && i::FLAG_trace_ignition_dispatches && if (i::FLAG_ignition && i::FLAG_trace_ignition_dispatches &&
i::FLAG_trace_ignition_dispatches_output_file != nullptr) { i::FLAG_trace_ignition_dispatches_output_file != nullptr) {
WriteIgnitionDispatchCountersFile(isolate); WriteIgnitionDispatchCountersFile(isolate);
} }
#endif
// Shut down contexts and collect garbage. // Shut down contexts and collect garbage.
evaluation_context_.Reset(); evaluation_context_.Reset();
#ifndef V8_SHARED
stringify_function_.Reset(); stringify_function_.Reset();
#endif // !V8_SHARED
CollectGarbage(isolate); CollectGarbage(isolate);
} }
OnExit(isolate); OnExit(isolate);
#ifndef V8_SHARED
// Dump basic block profiling data. // Dump basic block profiling data.
if (i::BasicBlockProfiler* profiler = if (i::BasicBlockProfiler* profiler =
reinterpret_cast<i::Isolate*>(isolate)->basic_block_profiler()) { reinterpret_cast<i::Isolate*>(isolate)->basic_block_profiler()) {
i::OFStream os(stdout); i::OFStream os(stdout);
os << *profiler; os << *profiler;
} }
#endif // !V8_SHARED
isolate->Dispose(); isolate->Dispose();
V8::Dispose(); V8::Dispose();
V8::ShutdownPlatform(); V8::ShutdownPlatform();
......
...@@ -49,18 +49,10 @@ ...@@ -49,18 +49,10 @@
'sources': [ 'sources': [
'd8.h', 'd8.h',
'd8.cc', 'd8.cc',
'<(SHARED_INTERMEDIATE_DIR)/d8-js.cc',
], ],
'conditions': [ 'conditions': [
[ 'want_separate_host_toolset==1', { [ 'want_separate_host_toolset==1', {
'toolsets': [ 'target', ], 'toolsets': [ 'target', ],
'dependencies': [
'd8_js2c#host',
],
}, {
'dependencies': [
'd8_js2c',
],
}], }],
['(OS=="linux" or OS=="mac" or OS=="freebsd" or OS=="netbsd" \ ['(OS=="linux" or OS=="mac" or OS=="freebsd" or OS=="netbsd" \
or OS=="openbsd" or OS=="solaris" or OS=="android" \ or OS=="openbsd" or OS=="solaris" or OS=="android" \
...@@ -71,7 +63,19 @@ ...@@ -71,7 +63,19 @@
'sources': [ 'd8-windows.cc', ] 'sources': [ 'd8-windows.cc', ]
}], }],
[ 'component!="shared_library"', { [ 'component!="shared_library"', {
'sources': [
'<(SHARED_INTERMEDIATE_DIR)/d8-js.cc',
],
'conditions': [ 'conditions': [
[ 'want_separate_host_toolset==1', {
'dependencies': [
'd8_js2c#host',
],
}, {
'dependencies': [
'd8_js2c',
],
}],
[ 'v8_postmortem_support=="true"', { [ 'v8_postmortem_support=="true"', {
'xcode_settings': { 'xcode_settings': {
'OTHER_LDFLAGS': [ 'OTHER_LDFLAGS': [
......
...@@ -5,10 +5,15 @@ ...@@ -5,10 +5,15 @@
#ifndef V8_D8_H_ #ifndef V8_D8_H_
#define V8_D8_H_ #define V8_D8_H_
#ifndef V8_SHARED
#include "src/allocation.h" #include "src/allocation.h"
#include "src/base/hashmap.h" #include "src/base/hashmap.h"
#include "src/base/platform/time.h" #include "src/base/platform/time.h"
#include "src/list.h" #include "src/list.h"
#else
#include "include/v8.h"
#include "src/base/compiler-specific.h"
#endif // !V8_SHARED
#include "src/base/once.h" #include "src/base/once.h"
...@@ -16,6 +21,7 @@ ...@@ -16,6 +21,7 @@
namespace v8 { namespace v8 {
#ifndef V8_SHARED
// A single counter in a counter collection. // A single counter in a counter collection.
class Counter { class Counter {
public: public:
...@@ -84,14 +90,17 @@ class CounterMap { ...@@ -84,14 +90,17 @@ class CounterMap {
static bool Match(void* key1, void* key2); static bool Match(void* key1, void* key2);
base::HashMap hash_map_; base::HashMap hash_map_;
}; };
#endif // !V8_SHARED
class SourceGroup { class SourceGroup {
public: public:
SourceGroup() : SourceGroup() :
#ifndef V8_SHARED
next_semaphore_(0), next_semaphore_(0),
done_semaphore_(0), done_semaphore_(0),
thread_(NULL), thread_(NULL),
#endif // !V8_SHARED
argv_(NULL), argv_(NULL),
begin_offset_(0), begin_offset_(0),
end_offset_(0) {} end_offset_(0) {}
...@@ -107,6 +116,7 @@ class SourceGroup { ...@@ -107,6 +116,7 @@ class SourceGroup {
void Execute(Isolate* isolate); void Execute(Isolate* isolate);
#ifndef V8_SHARED
void StartExecuteInThread(); void StartExecuteInThread();
void WaitForThread(); void WaitForThread();
void JoinThread(); void JoinThread();
...@@ -131,6 +141,7 @@ class SourceGroup { ...@@ -131,6 +141,7 @@ class SourceGroup {
base::Semaphore next_semaphore_; base::Semaphore next_semaphore_;
base::Semaphore done_semaphore_; base::Semaphore done_semaphore_;
base::Thread* thread_; base::Thread* thread_;
#endif // !V8_SHARED
void ExitShell(int exit_code); void ExitShell(int exit_code);
Local<String> ReadFile(Isolate* isolate, const char* name); Local<String> ReadFile(Isolate* isolate, const char* name);
...@@ -140,6 +151,7 @@ class SourceGroup { ...@@ -140,6 +151,7 @@ class SourceGroup {
int end_offset_; int end_offset_;
}; };
#ifndef V8_SHARED
enum SerializationTag { enum SerializationTag {
kSerializationTagUndefined, kSerializationTagUndefined,
kSerializationTagNull, kSerializationTagNull,
...@@ -255,6 +267,7 @@ class Worker { ...@@ -255,6 +267,7 @@ class Worker {
char* script_; char* script_;
base::Atomic32 running_; base::Atomic32 running_;
}; };
#endif // !V8_SHARED
class ShellOptions { class ShellOptions {
...@@ -311,7 +324,12 @@ class ShellOptions { ...@@ -311,7 +324,12 @@ class ShellOptions {
const char* trace_config; const char* trace_config;
}; };
#ifdef V8_SHARED
class Shell {
#else
class Shell : public i::AllStatic { class Shell : public i::AllStatic {
#endif // V8_SHARED
public: public:
enum SourceType { SCRIPT, MODULE }; enum SourceType { SCRIPT, MODULE };
...@@ -333,6 +351,7 @@ class Shell : public i::AllStatic { ...@@ -333,6 +351,7 @@ class Shell : public i::AllStatic {
static void CollectGarbage(Isolate* isolate); static void CollectGarbage(Isolate* isolate);
static void EmptyMessageQueues(Isolate* isolate); static void EmptyMessageQueues(Isolate* isolate);
#ifndef V8_SHARED
// TODO(binji): stupid implementation for now. Is there an easy way to hash an // TODO(binji): stupid implementation for now. Is there an easy way to hash an
// object for use in base::HashMap? By pointer? // object for use in base::HashMap? By pointer?
typedef i::List<Local<Object>> ObjectList; typedef i::List<Local<Object>> ObjectList;
...@@ -353,6 +372,7 @@ class Shell : public i::AllStatic { ...@@ -353,6 +372,7 @@ class Shell : public i::AllStatic {
static void MapCounters(v8::Isolate* isolate, const char* name); static void MapCounters(v8::Isolate* isolate, const char* name);
static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args); static void PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args);
#endif // !V8_SHARED
static void RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args); static void RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args);
static void RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args); static void RealmOwner(const v8::FunctionCallbackInfo<v8::Value>& args);
...@@ -430,6 +450,7 @@ class Shell : public i::AllStatic { ...@@ -430,6 +450,7 @@ class Shell : public i::AllStatic {
private: private:
static Global<Context> evaluation_context_; static Global<Context> evaluation_context_;
static base::OnceType quit_once_; static base::OnceType quit_once_;
#ifndef V8_SHARED
static Global<Function> stringify_function_; static Global<Function> stringify_function_;
static CounterMap* counter_map_; static CounterMap* counter_map_;
// We statically allocate a set of local counters to be used if we // We statically allocate a set of local counters to be used if we
...@@ -448,6 +469,7 @@ class Shell : public i::AllStatic { ...@@ -448,6 +469,7 @@ class Shell : public i::AllStatic {
static void WriteIgnitionDispatchCountersFile(v8::Isolate* isolate); static void WriteIgnitionDispatchCountersFile(v8::Isolate* isolate);
static Counter* GetCounter(const char* name, bool is_histogram); static Counter* GetCounter(const char* name, bool is_histogram);
static Local<String> Stringify(Isolate* isolate, Local<Value> value); static Local<String> Stringify(Isolate* isolate, Local<Value> value);
#endif // !V8_SHARED
static void Initialize(Isolate* isolate); static void Initialize(Isolate* isolate);
static void RunShell(Isolate* isolate); static void RunShell(Isolate* isolate);
static bool SetOptions(int argc, char* argv[]); static bool SetOptions(int argc, char* argv[]);
......
...@@ -28,8 +28,9 @@ class Factory final { ...@@ -28,8 +28,9 @@ class Factory final {
byte kind); byte kind);
// Allocates a fixed array initialized with undefined values. // Allocates a fixed array initialized with undefined values.
V8_EXPORT_PRIVATE Handle<FixedArray> NewFixedArray( Handle<FixedArray> NewFixedArray(
int size, PretenureFlag pretenure = NOT_TENURED); int size,
PretenureFlag pretenure = NOT_TENURED);
// Allocate a new fixed array with non-existing entries (the hole). // Allocate a new fixed array with non-existing entries (the hole).
Handle<FixedArray> NewFixedArrayWithHoles( Handle<FixedArray> NewFixedArrayWithHoles(
...@@ -164,8 +165,9 @@ class Factory final { ...@@ -164,8 +165,9 @@ class Factory final {
// UTF8 strings are pretenured when used for regexp literal patterns and // UTF8 strings are pretenured when used for regexp literal patterns and
// flags in the parser. // flags in the parser.
MUST_USE_RESULT V8_EXPORT_PRIVATE MaybeHandle<String> NewStringFromUtf8( MUST_USE_RESULT MaybeHandle<String> NewStringFromUtf8(
Vector<const char> str, PretenureFlag pretenure = NOT_TENURED); Vector<const char> str,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT MaybeHandle<String> NewStringFromTwoByte( MUST_USE_RESULT MaybeHandle<String> NewStringFromTwoByte(
Vector<const uc16> str, Vector<const uc16> str,
...@@ -455,11 +457,11 @@ class Factory final { ...@@ -455,11 +457,11 @@ class Factory final {
} }
// Create a JSArray with the given elements. // Create a JSArray with the given elements.
V8_EXPORT_PRIVATE Handle<JSArray> NewJSArrayWithElements( Handle<JSArray> NewJSArrayWithElements(Handle<FixedArrayBase> elements,
Handle<FixedArrayBase> elements, ElementsKind elements_kind, int length, ElementsKind elements_kind, int length,
PretenureFlag pretenure = NOT_TENURED); PretenureFlag pretenure = NOT_TENURED);
V8_EXPORT_PRIVATE Handle<JSArray> NewJSArrayWithElements( Handle<JSArray> NewJSArrayWithElements(
Handle<FixedArrayBase> elements, Handle<FixedArrayBase> elements,
ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND, ElementsKind elements_kind = TERMINAL_FAST_ELEMENTS_KIND,
PretenureFlag pretenure = NOT_TENURED) { PretenureFlag pretenure = NOT_TENURED) {
......
...@@ -23,21 +23,14 @@ ...@@ -23,21 +23,14 @@
// this will just be an extern declaration, but for a readonly flag we let the // this will just be an extern declaration, but for a readonly flag we let the
// compiler make better optimizations by giving it the value. // compiler make better optimizations by giving it the value.
#if defined(FLAG_MODE_DECLARE) #if defined(FLAG_MODE_DECLARE)
#define FLAG_FULL(ftype, ctype, nam, def, cmt) \ #define FLAG_FULL(ftype, ctype, nam, def, cmt) extern ctype FLAG_##nam;
V8_EXPORT_PRIVATE extern ctype FLAG_##nam;
#define FLAG_READONLY(ftype, ctype, nam, def, cmt) \ #define FLAG_READONLY(ftype, ctype, nam, def, cmt) \
static ctype const FLAG_##nam = def; static ctype const FLAG_##nam = def;
// We want to supply the actual storage and value for the flag variable in the // We want to supply the actual storage and value for the flag variable in the
// .cc file. We only do this for writable flags. // .cc file. We only do this for writable flags.
#elif defined(FLAG_MODE_DEFINE) #elif defined(FLAG_MODE_DEFINE)
#ifdef USING_V8_SHARED #define FLAG_FULL(ftype, ctype, nam, def, cmt) ctype FLAG_##nam = def;
#define FLAG_FULL(ftype, ctype, nam, def, cmt) \
V8_EXPORT_PRIVATE extern ctype FLAG_##nam;
#else
#define FLAG_FULL(ftype, ctype, nam, def, cmt) \
V8_EXPORT_PRIVATE ctype FLAG_##nam = def;
#endif
// We need to define all of our default values so that the Flag structure can // We need to define all of our default values so that the Flag structure can
// access them by pointer. These are just used internally inside of one .cc, // access them by pointer. These are just used internally inside of one .cc,
......
...@@ -14,32 +14,6 @@ ...@@ -14,32 +14,6 @@
#include "src/base/logging.h" #include "src/base/logging.h"
#include "src/base/macros.h" #include "src/base/macros.h"
#ifdef V8_OS_WIN
// Setup for Windows shared library export.
#ifdef BUILDING_V8_SHARED
#define V8_EXPORT_PRIVATE __declspec(dllexport)
#elif USING_V8_SHARED
#define V8_EXPORT_PRIVATE __declspec(dllimport)
#else
#define V8_EXPORT_PRIVATE
#endif // BUILDING_V8_SHARED
#else // V8_OS_WIN
// Setup for Linux shared library export.
#if V8_HAS_ATTRIBUTE_VISIBILITY
#ifdef BUILDING_V8_SHARED
#define V8_EXPORT_PRIVATE __attribute__((visibility("default")))
#else
#define V8_EXPORT_PRIVATE
#endif
#else
#define V8_EXPORT_PRIVATE
#endif
#endif // V8_OS_WIN
// Unfortunately, the INFINITY macro cannot be used with the '-pedantic' // Unfortunately, the INFINITY macro cannot be used with the '-pedantic'
// warning flag and certain versions of GCC due to a bug: // warning flag and certain versions of GCC due to a bug:
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931
......
...@@ -2426,7 +2426,7 @@ class AllSpaces BASE_EMBEDDED { ...@@ -2426,7 +2426,7 @@ class AllSpaces BASE_EMBEDDED {
// Space iterator for iterating over all old spaces of the heap: Old space // Space iterator for iterating over all old spaces of the heap: Old space
// and code space. Returns each space in turn, and null when it is done. // and code space. Returns each space in turn, and null when it is done.
class V8_EXPORT_PRIVATE OldSpaces BASE_EMBEDDED { class OldSpaces BASE_EMBEDDED {
public: public:
explicit OldSpaces(Heap* heap) : heap_(heap), counter_(OLD_SPACE) {} explicit OldSpaces(Heap* heap) : heap_(heap), counter_(OLD_SPACE) {}
OldSpace* next(); OldSpace* next();
......
...@@ -154,8 +154,8 @@ class IncrementalMarking { ...@@ -154,8 +154,8 @@ class IncrementalMarking {
INLINE(void RecordWriteOfCodeEntry(JSFunction* host, Object** slot, INLINE(void RecordWriteOfCodeEntry(JSFunction* host, Object** slot,
Code* value)); Code* value));
V8_EXPORT_PRIVATE void RecordWriteSlow(HeapObject* obj, Object** slot,
Object* value); void RecordWriteSlow(HeapObject* obj, Object** slot, Object* value);
void RecordWriteIntoCodeSlow(Code* host, RelocInfo* rinfo, Object* value); void RecordWriteIntoCodeSlow(Code* host, RelocInfo* rinfo, Object* value);
void RecordWriteOfCodeEntrySlow(JSFunction* host, Object** slot, Code* value); void RecordWriteOfCodeEntrySlow(JSFunction* host, Object** slot, Code* value);
void RecordCodeTargetPatch(Code* host, Address pc, HeapObject* value); void RecordCodeTargetPatch(Code* host, Address pc, HeapObject* value);
......
...@@ -776,7 +776,8 @@ class EvacuationScope BASE_EMBEDDED { ...@@ -776,7 +776,8 @@ class EvacuationScope BASE_EMBEDDED {
MarkCompactCollector* collector_; MarkCompactCollector* collector_;
}; };
V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space);
const char* AllocationSpaceName(AllocationSpace space);
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -463,7 +463,7 @@ class MemoryChunk { ...@@ -463,7 +463,7 @@ class MemoryChunk {
} }
inline LocalArrayBufferTracker* local_tracker() { return local_tracker_; } inline LocalArrayBufferTracker* local_tracker() { return local_tracker_; }
V8_EXPORT_PRIVATE void AllocateOldToNewSlots(); void AllocateOldToNewSlots();
void ReleaseOldToNewSlots(); void ReleaseOldToNewSlots();
void AllocateOldToOldSlots(); void AllocateOldToOldSlots();
void ReleaseOldToOldSlots(); void ReleaseOldToOldSlots();
...@@ -1430,7 +1430,7 @@ class MemoryAllocator { ...@@ -1430,7 +1430,7 @@ class MemoryAllocator {
// method which is used to avoid using virtual functions // method which is used to avoid using virtual functions
// iterating a specific space. // iterating a specific space.
class V8_EXPORT_PRIVATE ObjectIterator : public Malloced { class ObjectIterator : public Malloced {
public: public:
virtual ~ObjectIterator() {} virtual ~ObjectIterator() {}
virtual HeapObject* Next() = 0; virtual HeapObject* Next() = 0;
...@@ -1481,7 +1481,7 @@ class PageRange { ...@@ -1481,7 +1481,7 @@ class PageRange {
// If objects are allocated in the page during iteration the iterator may // If objects are allocated in the page during iteration the iterator may
// or may not iterate over those objects. The caller must create a new // or may not iterate over those objects. The caller must create a new
// iterator in order to be sure to visit these new objects. // iterator in order to be sure to visit these new objects.
class V8_EXPORT_PRIVATE HeapObjectIterator : public ObjectIterator { class HeapObjectIterator : public ObjectIterator {
public: public:
// Creates a new object iterator in a given space. // Creates a new object iterator in a given space.
explicit HeapObjectIterator(PagedSpace* space); explicit HeapObjectIterator(PagedSpace* space);
......
...@@ -106,7 +106,10 @@ config("inspector_config") { ...@@ -106,7 +106,10 @@ config("inspector_config") {
] ]
} }
if (is_component_build) { if (is_component_build) {
defines = [ "BUILDING_V8_SHARED" ] defines = [
"V8_SHARED",
"BUILDING_V8_SHARED",
]
} }
} }
......
...@@ -56,7 +56,7 @@ class Interpreter { ...@@ -56,7 +56,7 @@ class Interpreter {
void TraceCodegen(Handle<Code> code); void TraceCodegen(Handle<Code> code);
const char* LookupNameOfBytecodeHandler(Code* code); const char* LookupNameOfBytecodeHandler(Code* code);
V8_EXPORT_PRIVATE Local<v8::Object> GetDispatchCountersObject(); Local<v8::Object> GetDispatchCountersObject();
Address dispatch_table_address() { Address dispatch_table_address() {
return reinterpret_cast<Address>(&dispatch_table_[0]); return reinterpret_cast<Address>(&dispatch_table_[0]);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "include/v8config.h" #include "include/v8config.h"
#include "src/base/macros.h" #include "src/base/macros.h"
#include "src/globals.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -34,7 +33,7 @@ class OFStreamBase : public std::streambuf { ...@@ -34,7 +33,7 @@ class OFStreamBase : public std::streambuf {
// An output stream writing to a file. // An output stream writing to a file.
class V8_EXPORT_PRIVATE OFStream : public std::ostream { class OFStream : public std::ostream {
public: public:
explicit OFStream(FILE* f); explicit OFStream(FILE* f);
virtual ~OFStream(); virtual ~OFStream();
......
...@@ -22,15 +22,8 @@ enum NativeType { ...@@ -22,15 +22,8 @@ enum NativeType {
TEST TEST
}; };
// Extra handling for V8_EXPORT_PRIVATE in combination with USING_V8_SHARED
// since definition of methods of classes marked as dllimport is not allowed.
template <NativeType type> template <NativeType type>
#ifdef USING_V8_SHARED
class NativesCollection { class NativesCollection {
#else
class V8_EXPORT_PRIVATE NativesCollection {
#endif // USING_V8_SHARED
public: public:
// The following methods are implemented in js2c-generated code: // The following methods are implemented in js2c-generated code:
......
...@@ -437,7 +437,7 @@ void init_memcopy_functions(Isolate* isolate); ...@@ -437,7 +437,7 @@ void init_memcopy_functions(Isolate* isolate);
const int kMinComplexMemCopy = 64; const int kMinComplexMemCopy = 64;
// Copy memory area. No restrictions. // Copy memory area. No restrictions.
V8_EXPORT_PRIVATE void MemMove(void* dest, const void* src, size_t size); void MemMove(void* dest, const void* src, size_t size);
typedef void (*MemMoveFunction)(void* dest, const void* src, size_t size); typedef void (*MemMoveFunction)(void* dest, const void* src, size_t size);
// Keep the distinction of "move" vs. "copy" for the benefit of other // Keep the distinction of "move" vs. "copy" for the benefit of other
...@@ -459,8 +459,7 @@ V8_INLINE void MemCopy(void* dest, const void* src, size_t size) { ...@@ -459,8 +459,7 @@ V8_INLINE void MemCopy(void* dest, const void* src, size_t size) {
(*memcopy_uint8_function)(reinterpret_cast<uint8_t*>(dest), (*memcopy_uint8_function)(reinterpret_cast<uint8_t*>(dest),
reinterpret_cast<const uint8_t*>(src), size); reinterpret_cast<const uint8_t*>(src), size);
} }
V8_EXPORT_PRIVATE V8_INLINE void MemMove(void* dest, const void* src, V8_INLINE void MemMove(void* dest, const void* src, size_t size) {
size_t size) {
memmove(dest, src, size); memmove(dest, src, size);
} }
...@@ -489,8 +488,7 @@ V8_INLINE void MemCopy(void* dest, const void* src, size_t size) { ...@@ -489,8 +488,7 @@ V8_INLINE void MemCopy(void* dest, const void* src, size_t size) {
(*memcopy_uint8_function)(reinterpret_cast<uint8_t*>(dest), (*memcopy_uint8_function)(reinterpret_cast<uint8_t*>(dest),
reinterpret_cast<const uint8_t*>(src), size); reinterpret_cast<const uint8_t*>(src), size);
} }
V8_EXPORT_PRIVATE V8_INLINE void MemMove(void* dest, const void* src, V8_INLINE void MemMove(void* dest, const void* src, size_t size) {
size_t size) {
memmove(dest, src, size); memmove(dest, src, size);
} }
#else #else
...@@ -498,8 +496,7 @@ V8_EXPORT_PRIVATE V8_INLINE void MemMove(void* dest, const void* src, ...@@ -498,8 +496,7 @@ V8_EXPORT_PRIVATE V8_INLINE void MemMove(void* dest, const void* src,
V8_INLINE void MemCopy(void* dest, const void* src, size_t size) { V8_INLINE void MemCopy(void* dest, const void* src, size_t size) {
memcpy(dest, src, size); memcpy(dest, src, size);
} }
V8_EXPORT_PRIVATE V8_INLINE void MemMove(void* dest, const void* src, V8_INLINE void MemMove(void* dest, const void* src, size_t size) {
size_t size) {
memmove(dest, src, size); memmove(dest, src, size);
} }
const int kMinComplexMemCopy = 16 * kPointerSize; const int kMinComplexMemCopy = 16 * kPointerSize;
......
...@@ -61,10 +61,12 @@ ...@@ -61,10 +61,12 @@
'..', '..',
], ],
'defines': [ 'defines': [
'V8_SHARED',
'BUILDING_V8_SHARED', 'BUILDING_V8_SHARED',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'defines': [ 'defines': [
'V8_SHARED',
'USING_V8_SHARED', 'USING_V8_SHARED',
], ],
}, },
...@@ -162,10 +164,12 @@ ...@@ -162,10 +164,12 @@
}], }],
['component=="shared_library"', { ['component=="shared_library"', {
'defines': [ 'defines': [
'V8_SHARED',
'BUILDING_V8_SHARED', 'BUILDING_V8_SHARED',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'defines': [ 'defines': [
'V8_SHARED',
'USING_V8_SHARED', 'USING_V8_SHARED',
], ],
}, },
...@@ -255,6 +259,7 @@ ...@@ -255,6 +259,7 @@
['component=="shared_library"', { ['component=="shared_library"', {
'defines': [ 'defines': [
'BUILDING_V8_SHARED', 'BUILDING_V8_SHARED',
'V8_SHARED',
], ],
}], }],
] ]
...@@ -281,10 +286,12 @@ ...@@ -281,10 +286,12 @@
}], }],
['component=="shared_library"', { ['component=="shared_library"', {
'defines': [ 'defines': [
'V8_SHARED',
'BUILDING_V8_SHARED', 'BUILDING_V8_SHARED',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'defines': [ 'defines': [
'V8_SHARED',
'USING_V8_SHARED', 'USING_V8_SHARED',
], ],
}, },
...@@ -1706,6 +1713,7 @@ ...@@ -1706,6 +1713,7 @@
['component=="shared_library"', { ['component=="shared_library"', {
'defines': [ 'defines': [
'BUILDING_V8_SHARED', 'BUILDING_V8_SHARED',
'V8_SHARED',
], ],
}], }],
['v8_postmortem_support=="true"', { ['v8_postmortem_support=="true"', {
......
...@@ -5,8 +5,13 @@ ...@@ -5,8 +5,13 @@
#ifndef V8_WASM_JS_H_ #ifndef V8_WASM_JS_H_
#define V8_WASM_JS_H_ #define V8_WASM_JS_H_
#ifndef V8_SHARED
#include "src/allocation.h" #include "src/allocation.h"
#include "src/base/hashmap.h" #include "src/base/hashmap.h"
#else
#include "include/v8.h"
#include "src/base/compiler-specific.h"
#endif // !V8_SHARED
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
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