summaryrefslogtreecommitdiff
path: root/deps/v8/src/d8.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/d8.cc')
-rw-r--r--deps/v8/src/d8.cc285
1 files changed, 161 insertions, 124 deletions
diff --git a/deps/v8/src/d8.cc b/deps/v8/src/d8.cc
index a8af9de2d1..01801f80f6 100644
--- a/deps/v8/src/d8.cc
+++ b/deps/v8/src/d8.cc
@@ -2,30 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// 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 <stdlib.h>
#include <string.h>
#include <sys/stat.h>
-#ifdef V8_SHARED
-#include <assert.h>
-#endif // V8_SHARED
-
-#ifndef V8_SHARED
#include <algorithm>
#include <fstream>
+#include <map>
+#include <utility>
#include <vector>
-#endif // !V8_SHARED
-
-#ifdef V8_SHARED
-#include "include/v8-testing.h"
-#endif // V8_SHARED
#ifdef ENABLE_VTUNE_JIT_INTERFACE
#include "src/third_party/vtune/v8-vtune.h"
@@ -36,7 +22,6 @@
#include "include/libplatform/libplatform.h"
#include "include/libplatform/v8-tracing.h"
-#ifndef V8_SHARED
#include "src/api.h"
#include "src/base/cpu.h"
#include "src/base/debug/stack_trace.h"
@@ -48,7 +33,6 @@
#include "src/snapshot/natives.h"
#include "src/utils.h"
#include "src/v8.h"
-#endif // !V8_SHARED
#if !defined(_WIN32) && !defined(_WIN64)
#include <unistd.h> // NOLINT
@@ -72,9 +56,7 @@ namespace v8 {
namespace {
const int MB = 1024 * 1024;
-#ifndef V8_SHARED
const int kMaxWorkers = 50;
-#endif
class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
@@ -102,7 +84,6 @@ class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
};
-#ifndef V8_SHARED
// Predictable v8::Platform implementation. All background and foreground
// tasks are run immediately, delayed tasks are not executed at all.
class PredictablePlatform : public Platform {
@@ -136,6 +117,7 @@ class PredictablePlatform : public Platform {
return synthetic_time_in_sec_ += 0.00001;
}
+ using Platform::AddTraceEvent;
uint64_t AddTraceEvent(char phase, const uint8_t* categoryEnabledFlag,
const char* name, const char* scope, uint64_t id,
uint64_t bind_id, int numArgs, const char** argNames,
@@ -163,7 +145,6 @@ class PredictablePlatform : public Platform {
DISALLOW_COPY_AND_ASSIGN(PredictablePlatform);
};
-#endif // !V8_SHARED
v8::Platform* g_platform = NULL;
@@ -176,7 +157,6 @@ static Local<Value> Throw(Isolate* isolate, const char* message) {
}
-#ifndef V8_SHARED
bool FindInObjectList(Local<Object> object, const Shell::ObjectList& list) {
for (int i = 0; i < list.length(); ++i) {
if (list[i]->StrictEquals(object)) {
@@ -202,7 +182,6 @@ Worker* GetWorkerFromInternalField(Isolate* isolate, Local<Object> object) {
return worker;
}
-#endif // !V8_SHARED
} // namespace
@@ -370,7 +349,6 @@ class PerIsolateData {
};
-#ifndef V8_SHARED
CounterMap* Shell::counter_map_;
base::OS::MemoryMappedFile* Shell::counters_file_ = NULL;
CounterCollection Shell::local_counters_;
@@ -383,20 +361,17 @@ base::LazyMutex Shell::workers_mutex_;
bool Shell::allow_new_workers_ = true;
i::List<Worker*> Shell::workers_;
i::List<SharedArrayBuffer::Contents> Shell::externalized_shared_contents_;
-#endif // !V8_SHARED
Global<Context> Shell::evaluation_context_;
ArrayBuffer::Allocator* Shell::array_buffer_allocator;
ShellOptions Shell::options;
base::OnceType Shell::quit_once_ = V8_ONCE_INIT;
-#ifndef V8_SHARED
bool CounterMap::Match(void* key1, void* key2) {
const char* name1 = reinterpret_cast<const char*>(key1);
const char* name2 = reinterpret_cast<const char*>(key2);
return strcmp(name1, name2) == 0;
}
-#endif // !V8_SHARED
// Converts a V8 value to a C string.
@@ -460,18 +435,12 @@ ScriptCompiler::CachedData* CompileForCachedData(
// Compile a string within the current v8 context.
MaybeLocal<Script> Shell::CompileString(
Isolate* isolate, Local<String> source, Local<Value> name,
- ScriptCompiler::CompileOptions compile_options, SourceType source_type) {
+ ScriptCompiler::CompileOptions compile_options) {
Local<Context> context(isolate->GetCurrentContext());
ScriptOrigin origin(name);
- // TODO(adamk): Make use of compile options for Modules.
- if (compile_options == ScriptCompiler::kNoCompileOptions ||
- source_type == MODULE) {
+ if (compile_options == ScriptCompiler::kNoCompileOptions) {
ScriptCompiler::Source script_source(source, origin);
- return source_type == SCRIPT
- ? ScriptCompiler::Compile(context, &script_source,
- compile_options)
- : ScriptCompiler::CompileModule(context, &script_source,
- compile_options);
+ return ScriptCompiler::Compile(context, &script_source, compile_options);
}
ScriptCompiler::CachedData* data =
@@ -485,7 +454,6 @@ MaybeLocal<Script> Shell::CompileString(
DCHECK(false); // A new compile option?
}
if (data == NULL) compile_options = ScriptCompiler::kNoCompileOptions;
- DCHECK_EQ(SCRIPT, source_type);
MaybeLocal<Script> result =
ScriptCompiler::Compile(context, &cached_source, compile_options);
CHECK(data == NULL || !data->rejected);
@@ -496,7 +464,7 @@ MaybeLocal<Script> Shell::CompileString(
// Executes a string within the current v8 context.
bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
Local<Value> name, bool print_result,
- bool report_exceptions, SourceType source_type) {
+ bool report_exceptions) {
HandleScope handle_scope(isolate);
TryCatch try_catch(isolate);
try_catch.SetVerbose(true);
@@ -508,8 +476,8 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
Local<Context>::New(isolate, data->realms_[data->realm_current_]);
Context::Scope context_scope(realm);
Local<Script> script;
- if (!Shell::CompileString(isolate, source, name, options.compile_options,
- source_type).ToLocal(&script)) {
+ if (!Shell::CompileString(isolate, source, name, options.compile_options)
+ .ToLocal(&script)) {
// Print errors that happened during compilation.
if (report_exceptions) ReportException(isolate, &try_catch);
return false;
@@ -527,9 +495,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
}
DCHECK(!try_catch.HasCaught());
if (print_result) {
-#if !defined(V8_SHARED)
if (options.test_shell) {
-#endif
if (!result->IsUndefined()) {
// If all went well and the result wasn't undefined then print
// the returned value.
@@ -537,17 +503,160 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
fwrite(*str, sizeof(**str), str.length(), stdout);
printf("\n");
}
-#if !defined(V8_SHARED)
} else {
v8::String::Utf8Value str(Stringify(isolate, result));
fwrite(*str, sizeof(**str), str.length(), stdout);
printf("\n");
}
-#endif
}
return true;
}
+namespace {
+
+std::string ToSTLString(Local<String> v8_str) {
+ String::Utf8Value utf8(v8_str);
+ // Should not be able to fail since the input is a String.
+ CHECK(*utf8);
+ return *utf8;
+}
+
+bool IsAbsolutePath(const std::string& path) {
+#if defined(_WIN32) || defined(_WIN64)
+ // TODO(adamk): This is an incorrect approximation, but should
+ // work for all our test-running cases.
+ return path.find(':') != std::string::npos;
+#else
+ return path[0] == '/';
+#endif
+}
+
+std::string GetWorkingDirectory() {
+#if defined(_WIN32) || defined(_WIN64)
+ char system_buffer[MAX_PATH];
+ // TODO(adamk): Support Unicode paths.
+ DWORD len = GetCurrentDirectoryA(MAX_PATH, system_buffer);
+ CHECK(len > 0);
+ return system_buffer;
+#else
+ char curdir[PATH_MAX];
+ CHECK_NOT_NULL(getcwd(curdir, PATH_MAX));
+ return curdir;
+#endif
+}
+
+// Returns the directory part of path, without the trailing '/'.
+std::string DirName(const std::string& path) {
+ DCHECK(IsAbsolutePath(path));
+ size_t last_slash = path.find_last_of('/');
+ DCHECK(last_slash != std::string::npos);
+ return path.substr(0, last_slash);
+}
+
+std::string EnsureAbsolutePath(const std::string& path,
+ const std::string& dir_name) {
+ return IsAbsolutePath(path) ? path : dir_name + '/' + path;
+}
+
+MaybeLocal<Module> ResolveModuleCallback(Local<Context> context,
+ Local<String> specifier,
+ Local<Module> referrer,
+ Local<Value> data) {
+ Isolate* isolate = context->GetIsolate();
+ auto module_map = static_cast<std::map<std::string, Global<Module>>*>(
+ External::Cast(*data)->Value());
+ Local<String> dir_name = Local<String>::Cast(referrer->GetEmbedderData());
+ std::string absolute_path =
+ EnsureAbsolutePath(ToSTLString(specifier), ToSTLString(dir_name));
+ auto it = module_map->find(absolute_path);
+ if (it != module_map->end()) {
+ return it->second.Get(isolate);
+ }
+ return MaybeLocal<Module>();
+}
+
+} // anonymous namespace
+
+MaybeLocal<Module> Shell::FetchModuleTree(
+ Isolate* isolate, const std::string& file_name,
+ std::map<std::string, Global<Module>>* module_map) {
+ DCHECK(IsAbsolutePath(file_name));
+ TryCatch try_catch(isolate);
+ try_catch.SetVerbose(true);
+ Local<String> source_text = ReadFile(isolate, file_name.c_str());
+ if (source_text.IsEmpty()) {
+ printf("Error reading '%s'\n", file_name.c_str());
+ Shell::Exit(1);
+ }
+ ScriptOrigin origin(
+ String::NewFromUtf8(isolate, file_name.c_str(), NewStringType::kNormal)
+ .ToLocalChecked());
+ ScriptCompiler::Source source(source_text, origin);
+ Local<Module> module;
+ if (!ScriptCompiler::CompileModule(isolate, &source).ToLocal(&module)) {
+ ReportException(isolate, &try_catch);
+ return MaybeLocal<Module>();
+ }
+ module_map->insert(
+ std::make_pair(file_name, Global<Module>(isolate, module)));
+
+ std::string dir_name = DirName(file_name);
+ module->SetEmbedderData(
+ String::NewFromUtf8(isolate, dir_name.c_str(), NewStringType::kNormal)
+ .ToLocalChecked());
+
+ for (int i = 0, length = module->GetModuleRequestsLength(); i < length; ++i) {
+ Local<String> name = module->GetModuleRequest(i);
+ std::string absolute_path = EnsureAbsolutePath(ToSTLString(name), dir_name);
+ if (!module_map->count(absolute_path)) {
+ if (FetchModuleTree(isolate, absolute_path, module_map).IsEmpty()) {
+ return MaybeLocal<Module>();
+ }
+ }
+ }
+
+ return module;
+}
+
+bool Shell::ExecuteModule(Isolate* isolate, const char* file_name) {
+ HandleScope handle_scope(isolate);
+
+ std::string absolute_path =
+ EnsureAbsolutePath(file_name, GetWorkingDirectory());
+ std::replace(absolute_path.begin(), absolute_path.end(), '\\', '/');
+
+ Local<Module> root_module;
+ std::map<std::string, Global<Module>> module_map;
+ if (!FetchModuleTree(isolate, absolute_path, &module_map)
+ .ToLocal(&root_module)) {
+ return false;
+ }
+
+ TryCatch try_catch(isolate);
+ try_catch.SetVerbose(true);
+
+ MaybeLocal<Value> maybe_result;
+ {
+ PerIsolateData* data = PerIsolateData::Get(isolate);
+ Local<Context> realm = data->realms_[data->realm_current_].Get(isolate);
+ Context::Scope context_scope(realm);
+
+ if (root_module->Instantiate(realm, ResolveModuleCallback,
+ External::New(isolate, &module_map))) {
+ maybe_result = root_module->Evaluate(realm);
+ EmptyMessageQueues(isolate);
+ }
+ }
+ Local<Value> result;
+ if (!maybe_result.ToLocal(&result)) {
+ DCHECK(try_catch.HasCaught());
+ // Print errors that happened during execution.
+ ReportException(isolate, &try_catch);
+ return false;
+ }
+ DCHECK(!try_catch.HasCaught());
+ return true;
+}
PerIsolateData::RealmScope::RealmScope(PerIsolateData* data) : data_(data) {
data_->realm_count_ = 1;
@@ -595,7 +704,6 @@ int PerIsolateData::RealmIndexOrThrow(
}
-#ifndef V8_SHARED
// performance.now() returns a time stamp as double, measured in milliseconds.
// When FLAG_verify_predictable mode is enabled it returns result of
// v8::Platform::MonotonicallyIncreasingTime().
@@ -608,7 +716,6 @@ void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) {
args.GetReturnValue().Set(delta.InMillisecondsF());
}
}
-#endif // !V8_SHARED
// Realm.current() returns the index of the currently active realm.
@@ -879,7 +986,6 @@ void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
-#ifndef V8_SHARED
void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate();
HandleScope handle_scope(isolate);
@@ -1001,16 +1107,13 @@ void Shell::WorkerTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
worker->Terminate();
}
-#endif // !V8_SHARED
void Shell::QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args) {
int exit_code = (*args)[0]
->Int32Value(args->GetIsolate()->GetCurrentContext())
.FromMaybe(0);
-#ifndef V8_SHARED
CleanupWorkers();
-#endif // !V8_SHARED
OnExit(args->GetIsolate());
Exit(exit_code);
}
@@ -1031,14 +1134,12 @@ void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) {
void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) {
HandleScope handle_scope(isolate);
-#ifndef V8_SHARED
Local<Context> context;
bool enter_context = !isolate->InContext();
if (enter_context) {
context = Local<Context>::New(isolate, evaluation_context_);
context->Enter();
}
-#endif // !V8_SHARED
v8::String::Utf8Value exception(try_catch->Exception());
const char* exception_string = ToCString(exception);
Local<Message> message = try_catch->Message();
@@ -1082,13 +1183,10 @@ void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) {
}
}
printf("\n");
-#ifndef V8_SHARED
if (enter_context) context->Exit();
-#endif // !V8_SHARED
}
-#ifndef V8_SHARED
int32_t* Counter::Bind(const char* name, bool is_histogram) {
int i;
for (i = 0; i < kMaxNameSize - 1 && name[i]; i++)
@@ -1217,7 +1315,6 @@ Local<String> Shell::Stringify(Isolate* isolate, Local<Value> value) {
if (result.IsEmpty()) return String::Empty(isolate);
return result.ToLocalChecked().As<String>();
}
-#endif // !V8_SHARED
Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
@@ -1308,7 +1405,6 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
.ToLocalChecked(),
realm_template);
-#ifndef V8_SHARED
Local<ObjectTemplate> performance_template = ObjectTemplate::New(isolate);
performance_template->Set(
String::NewFromUtf8(isolate, "now", NewStringType::kNormal)
@@ -1347,7 +1443,6 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
String::NewFromUtf8(isolate, "Worker", NewStringType::kNormal)
.ToLocalChecked(),
worker_fun_template);
-#endif // !V8_SHARED
Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate);
AddOSMethods(isolate, os_templ);
@@ -1365,21 +1460,17 @@ static void EmptyMessageCallback(Local<Message> message, Local<Value> error) {
}
void Shell::Initialize(Isolate* isolate) {
-#ifndef V8_SHARED
// Set up counters
if (i::StrLength(i::FLAG_map_counters) != 0)
MapCounters(isolate, i::FLAG_map_counters);
-#endif // !V8_SHARED
// Disable default message reporting.
isolate->AddMessageListener(EmptyMessageCallback);
}
Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
-#ifndef V8_SHARED
// This needs to be a critical section since this is not thread-safe
base::LockGuard<base::Mutex> lock_guard(context_mutex_.Pointer());
-#endif // !V8_SHARED
// Initialize the global objects
Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
EscapableHandleScope handle_scope(isolate);
@@ -1387,7 +1478,6 @@ Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
DCHECK(!context.IsEmpty());
Context::Scope scope(context);
-#ifndef V8_SHARED
i::Factory* factory = reinterpret_cast<i::Isolate*>(isolate)->factory();
i::JSArguments js_args = i::FLAG_js_arguments;
i::Handle<i::FixedArray> arguments_array =
@@ -1405,7 +1495,6 @@ Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
.ToLocalChecked(),
Utils::ToLocal(arguments_jsarray))
.FromJust();
-#endif // !V8_SHARED
return handle_scope.Escape(context);
}
@@ -1419,7 +1508,6 @@ void Shell::Exit(int exit_code) {
}
-#ifndef V8_SHARED
struct CounterAndKey {
Counter* counter;
const char* key;
@@ -1444,11 +1532,8 @@ void Shell::WriteIgnitionDispatchCountersFile(v8::Isolate* isolate) {
JSON::Stringify(context, dispatch_counters).ToLocalChecked());
}
-#endif // !V8_SHARED
-
void Shell::OnExit(v8::Isolate* isolate) {
-#ifndef V8_SHARED
if (i::FLAG_dump_counters) {
int number_of_counters = 0;
for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {
@@ -1484,7 +1569,6 @@ void Shell::OnExit(v8::Isolate* isolate) {
delete counters_file_;
delete counter_map_;
-#endif // !V8_SHARED
}
@@ -1618,10 +1702,8 @@ void Shell::RunShell(Isolate* isolate) {
SourceGroup::~SourceGroup() {
-#ifndef V8_SHARED
delete thread_;
thread_ = NULL;
-#endif // !V8_SHARED
}
@@ -1629,7 +1711,6 @@ void SourceGroup::Execute(Isolate* isolate) {
bool exception_was_thrown = false;
for (int i = begin_offset_; i < end_offset_; ++i) {
const char* arg = argv_[i];
- Shell::SourceType source_type = Shell::SCRIPT;
if (strcmp(arg, "-e") == 0 && i + 1 < end_offset_) {
// Execute argument given to -e option directly.
HandleScope handle_scope(isolate);
@@ -1648,8 +1729,13 @@ void SourceGroup::Execute(Isolate* isolate) {
continue;
} else if (strcmp(arg, "--module") == 0 && i + 1 < end_offset_) {
// Treat the next file as a module.
- source_type = Shell::MODULE;
arg = argv_[++i];
+ Shell::options.script_executed = true;
+ if (!Shell::ExecuteModule(isolate, arg)) {
+ exception_was_thrown = true;
+ break;
+ }
+ continue;
} else if (arg[0] == '-') {
// Ignore other options. They have been parsed already.
continue;
@@ -1666,8 +1752,7 @@ void SourceGroup::Execute(Isolate* isolate) {
Shell::Exit(1);
}
Shell::options.script_executed = true;
- if (!Shell::ExecuteString(isolate, source, file_name, false, true,
- source_type)) {
+ if (!Shell::ExecuteString(isolate, source, file_name, false, true)) {
exception_was_thrown = true;
break;
}
@@ -1690,7 +1775,6 @@ Local<String> SourceGroup::ReadFile(Isolate* isolate, const char* name) {
}
-#ifndef V8_SHARED
base::Thread::Options SourceGroup::GetThreadOptions() {
// 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.
@@ -2014,7 +2098,6 @@ void Worker::PostMessageOut(const v8::FunctionCallbackInfo<v8::Value>& args) {
delete data;
}
}
-#endif // !V8_SHARED
void SetFlagsFromString(const char* flags) {
@@ -2070,30 +2153,16 @@ bool Shell::SetOptions(int argc, char* argv[]) {
// JavaScript engines.
continue;
} 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++;
} 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;
argv[i] = NULL;
-#endif // V8_SHARED
} else if (strcmp(argv[i], "--throws") == 0) {
options.expected_to_throw = true;
argv[i] = NULL;
} else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) {
options.icu_data_file = argv[i] + 16;
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
} else if (strncmp(argv[i], "--natives_blob=", 15) == 0) {
options.natives_blob = argv[i] + 15;
@@ -2159,11 +2228,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) {
-#ifndef V8_SHARED
for (int i = 1; i < options.num_isolates; ++i) {
options.isolate_sources[i].StartExecuteInThread();
}
-#endif // !V8_SHARED
{
HandleScope scope(isolate);
Local<Context> context = CreateEvaluationContext(isolate);
@@ -2178,7 +2245,6 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) {
}
}
CollectGarbage(isolate);
-#ifndef V8_SHARED
for (int i = 1; i < options.num_isolates; ++i) {
if (last_run) {
options.isolate_sources[i].JoinThread();
@@ -2187,7 +2253,6 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) {
}
}
CleanupWorkers();
-#endif // !V8_SHARED
return 0;
}
@@ -2209,17 +2274,12 @@ void Shell::CollectGarbage(Isolate* isolate) {
void Shell::EmptyMessageQueues(Isolate* isolate) {
-#ifndef V8_SHARED
if (!i::FLAG_verify_predictable) {
-#endif
while (v8::platform::PumpMessageLoop(g_platform, isolate)) continue;
-#ifndef V8_SHARED
}
-#endif
}
-#ifndef V8_SHARED
bool Shell::SerializeValue(Isolate* isolate, Local<Value> value,
const ObjectList& to_transfer,
ObjectList* seen_objects,
@@ -2534,14 +2594,11 @@ static void DumpHeapConstants(i::Isolate* isolate) {
printf("}\n");
#undef ROOT_LIST_CASE
}
-#endif // !V8_SHARED
int Shell::Main(int argc, char* argv[]) {
std::ofstream trace_file;
-#ifndef V8_SHARED
v8::base::debug::EnableInProcessStackDumping();
-#endif
#if (defined(_WIN32) || defined(_WIN64))
UINT new_flags =
SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
@@ -2559,13 +2616,9 @@ int Shell::Main(int argc, char* argv[]) {
#endif // defined(_WIN32) || defined(_WIN64)
if (!SetOptions(argc, argv)) return 1;
v8::V8::InitializeICUDefaultLocation(argv[0], options.icu_data_file);
-#ifndef V8_SHARED
g_platform = i::FLAG_verify_predictable
? new PredictablePlatform()
: v8::platform::CreateDefaultPlatform();
-#else
- g_platform = v8::platform::CreateDefaultPlatform();
-#endif // !V8_SHARED
v8::V8::InitializePlatform(g_platform);
v8::V8::Initialize();
@@ -2591,7 +2644,6 @@ int Shell::Main(int argc, char* argv[]) {
#ifdef ENABLE_VTUNE_JIT_INTERFACE
create_params.code_event_handler = vTune::GetVtuneCodeEventHandler();
#endif
-#ifndef V8_SHARED
create_params.constraints.ConfigureDefaults(
base::SysInfo::AmountOfPhysicalMemory(),
base::SysInfo::AmountOfVirtualMemory());
@@ -2602,7 +2654,6 @@ int Shell::Main(int argc, char* argv[]) {
create_params.create_histogram_callback = CreateHistogram;
create_params.add_histogram_sample_callback = AddHistogramSample;
}
-#endif
Isolate* isolate = Isolate::New(create_params);
{
Isolate::Scope scope(isolate);
@@ -2632,21 +2683,15 @@ int Shell::Main(int argc, char* argv[]) {
}
tracing_controller->Initialize(trace_buffer);
tracing_controller->StartTracing(trace_config);
-#ifndef V8_SHARED
if (!i::FLAG_verify_predictable) {
platform::SetTracingController(g_platform, tracing_controller);
}
-#else
- platform::SetTracingController(g_platform, tracing_controller);
-#endif
}
-#ifndef V8_SHARED
if (options.dump_heap_constants) {
DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate));
return 0;
}
-#endif
if (options.stress_opt || options.stress_deopt) {
Testing::SetStressRunType(options.stress_opt
@@ -2662,7 +2707,6 @@ int Shell::Main(int argc, char* argv[]) {
}
printf("======== Full Deoptimization =======\n");
Testing::DeoptimizeAll(isolate);
-#if !defined(V8_SHARED)
} else if (i::FLAG_stress_runs > 0) {
options.stress_runs = i::FLAG_stress_runs;
for (int i = 0; i < options.stress_runs && result == 0; i++) {
@@ -2671,7 +2715,6 @@ int Shell::Main(int argc, char* argv[]) {
bool last_run = i == options.stress_runs - 1;
result = RunMain(isolate, argc, argv, last_run);
}
-#endif
} else {
bool last_run = true;
result = RunMain(isolate, argc, argv, last_run);
@@ -2683,29 +2726,23 @@ int Shell::Main(int argc, char* argv[]) {
RunShell(isolate);
}
-#ifndef V8_SHARED
if (i::FLAG_ignition && i::FLAG_trace_ignition_dispatches &&
i::FLAG_trace_ignition_dispatches_output_file != nullptr) {
WriteIgnitionDispatchCountersFile(isolate);
}
-#endif
// Shut down contexts and collect garbage.
evaluation_context_.Reset();
-#ifndef V8_SHARED
stringify_function_.Reset();
-#endif // !V8_SHARED
CollectGarbage(isolate);
}
OnExit(isolate);
-#ifndef V8_SHARED
// Dump basic block profiling data.
if (i::BasicBlockProfiler* profiler =
reinterpret_cast<i::Isolate*>(isolate)->basic_block_profiler()) {
i::OFStream os(stdout);
os << *profiler;
}
-#endif // !V8_SHARED
isolate->Dispose();
V8::Dispose();
V8::ShutdownPlatform();