Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: src/d8.cc

Issue 2356703003: Revert of [d8] Fix the shared-library build (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/d8.h ('k') | src/d8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5
6 // Defined when linking against shared lib on Windows.
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
8 #define V8_SHARED
9 #endif
10
5 #include <errno.h> 11 #include <errno.h>
6 #include <stdlib.h> 12 #include <stdlib.h>
7 #include <string.h> 13 #include <string.h>
8 #include <sys/stat.h> 14 #include <sys/stat.h>
9 15
16 #ifdef V8_SHARED
17 #include <assert.h>
18 #endif // V8_SHARED
19
20 #ifndef V8_SHARED
10 #include <algorithm> 21 #include <algorithm>
11 #include <fstream> 22 #include <fstream>
12 #include <vector> 23 #include <vector>
24 #endif // !V8_SHARED
25
26 #ifdef V8_SHARED
27 #include "include/v8-testing.h"
28 #endif // V8_SHARED
13 29
14 #ifdef ENABLE_VTUNE_JIT_INTERFACE 30 #ifdef ENABLE_VTUNE_JIT_INTERFACE
15 #include "src/third_party/vtune/v8-vtune.h" 31 #include "src/third_party/vtune/v8-vtune.h"
16 #endif 32 #endif
17 33
18 #include "src/d8.h" 34 #include "src/d8.h"
19 #include "src/ostreams.h" 35 #include "src/ostreams.h"
20 36
21 #include "include/libplatform/libplatform.h" 37 #include "include/libplatform/libplatform.h"
22 #include "include/libplatform/v8-tracing.h" 38 #include "include/libplatform/v8-tracing.h"
39 #ifndef V8_SHARED
23 #include "src/api.h" 40 #include "src/api.h"
24 #include "src/base/cpu.h" 41 #include "src/base/cpu.h"
25 #include "src/base/debug/stack_trace.h" 42 #include "src/base/debug/stack_trace.h"
26 #include "src/base/logging.h" 43 #include "src/base/logging.h"
27 #include "src/base/platform/platform.h" 44 #include "src/base/platform/platform.h"
28 #include "src/base/sys-info.h" 45 #include "src/base/sys-info.h"
29 #include "src/basic-block-profiler.h" 46 #include "src/basic-block-profiler.h"
30 #include "src/interpreter/interpreter.h" 47 #include "src/interpreter/interpreter.h"
31 #include "src/snapshot/natives.h" 48 #include "src/snapshot/natives.h"
32 #include "src/utils.h" 49 #include "src/utils.h"
33 #include "src/v8.h" 50 #include "src/v8.h"
51 #endif // !V8_SHARED
34 52
35 #if !defined(_WIN32) && !defined(_WIN64) 53 #if !defined(_WIN32) && !defined(_WIN64)
36 #include <unistd.h> // NOLINT 54 #include <unistd.h> // NOLINT
37 #else 55 #else
38 #include <windows.h> // NOLINT 56 #include <windows.h> // NOLINT
39 #if defined(_MSC_VER) 57 #if defined(_MSC_VER)
40 #include <crtdbg.h> // NOLINT 58 #include <crtdbg.h> // NOLINT
41 #endif // defined(_MSC_VER) 59 #endif // defined(_MSC_VER)
42 #endif // !defined(_WIN32) && !defined(_WIN64) 60 #endif // !defined(_WIN32) && !defined(_WIN64)
43 61
44 #ifndef DCHECK 62 #ifndef DCHECK
45 #define DCHECK(condition) assert(condition) 63 #define DCHECK(condition) assert(condition)
46 #endif 64 #endif
47 65
48 #ifndef CHECK 66 #ifndef CHECK
49 #define CHECK(condition) assert(condition) 67 #define CHECK(condition) assert(condition)
50 #endif 68 #endif
51 69
52 namespace v8 { 70 namespace v8 {
53 71
54 namespace { 72 namespace {
55 73
56 const int MB = 1024 * 1024; 74 const int MB = 1024 * 1024;
75 #ifndef V8_SHARED
57 const int kMaxWorkers = 50; 76 const int kMaxWorkers = 50;
77 #endif
58 78
59 79
60 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { 80 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
61 public: 81 public:
62 virtual void* Allocate(size_t length) { 82 virtual void* Allocate(size_t length) {
63 void* data = AllocateUninitialized(length); 83 void* data = AllocateUninitialized(length);
64 return data == NULL ? data : memset(data, 0, length); 84 return data == NULL ? data : memset(data, 0, length);
65 } 85 }
66 virtual void* AllocateUninitialized(size_t length) { return malloc(length); } 86 virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
67 virtual void Free(void* data, size_t) { free(data); } 87 virtual void Free(void* data, size_t) { free(data); }
68 }; 88 };
69 89
70 90
71 class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator { 91 class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
72 public: 92 public:
73 void* Allocate(size_t length) override { 93 void* Allocate(size_t length) override {
74 size_t actual_length = length > 10 * MB ? 1 : length; 94 size_t actual_length = length > 10 * MB ? 1 : length;
75 void* data = AllocateUninitialized(actual_length); 95 void* data = AllocateUninitialized(actual_length);
76 return data == NULL ? data : memset(data, 0, actual_length); 96 return data == NULL ? data : memset(data, 0, actual_length);
77 } 97 }
78 void* AllocateUninitialized(size_t length) override { 98 void* AllocateUninitialized(size_t length) override {
79 return length > 10 * MB ? malloc(1) : malloc(length); 99 return length > 10 * MB ? malloc(1) : malloc(length);
80 } 100 }
81 void Free(void* p, size_t) override { free(p); } 101 void Free(void* p, size_t) override { free(p); }
82 }; 102 };
83 103
84 104
105 #ifndef V8_SHARED
85 // Predictable v8::Platform implementation. All background and foreground 106 // Predictable v8::Platform implementation. All background and foreground
86 // tasks are run immediately, delayed tasks are not executed at all. 107 // tasks are run immediately, delayed tasks are not executed at all.
87 class PredictablePlatform : public Platform { 108 class PredictablePlatform : public Platform {
88 public: 109 public:
89 PredictablePlatform() {} 110 PredictablePlatform() {}
90 111
91 void CallOnBackgroundThread(Task* task, 112 void CallOnBackgroundThread(Task* task,
92 ExpectedRuntime expected_runtime) override { 113 ExpectedRuntime expected_runtime) override {
93 task->Run(); 114 task->Run();
94 delete task; 115 delete task;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 const uint8_t* categoryEnabledFlag) override { 156 const uint8_t* categoryEnabledFlag) override {
136 static const char* dummy = "dummy"; 157 static const char* dummy = "dummy";
137 return dummy; 158 return dummy;
138 } 159 }
139 160
140 private: 161 private:
141 double synthetic_time_in_sec_ = 0.0; 162 double synthetic_time_in_sec_ = 0.0;
142 163
143 DISALLOW_COPY_AND_ASSIGN(PredictablePlatform); 164 DISALLOW_COPY_AND_ASSIGN(PredictablePlatform);
144 }; 165 };
166 #endif // !V8_SHARED
145 167
146 168
147 v8::Platform* g_platform = NULL; 169 v8::Platform* g_platform = NULL;
148 170
149 171
150 static Local<Value> Throw(Isolate* isolate, const char* message) { 172 static Local<Value> Throw(Isolate* isolate, const char* message) {
151 return isolate->ThrowException( 173 return isolate->ThrowException(
152 String::NewFromUtf8(isolate, message, NewStringType::kNormal) 174 String::NewFromUtf8(isolate, message, NewStringType::kNormal)
153 .ToLocalChecked()); 175 .ToLocalChecked());
154 } 176 }
155 177
156 178
179 #ifndef V8_SHARED
157 bool FindInObjectList(Local<Object> object, const Shell::ObjectList& list) { 180 bool FindInObjectList(Local<Object> object, const Shell::ObjectList& list) {
158 for (int i = 0; i < list.length(); ++i) { 181 for (int i = 0; i < list.length(); ++i) {
159 if (list[i]->StrictEquals(object)) { 182 if (list[i]->StrictEquals(object)) {
160 return true; 183 return true;
161 } 184 }
162 } 185 }
163 return false; 186 return false;
164 } 187 }
165 188
166 189
167 Worker* GetWorkerFromInternalField(Isolate* isolate, Local<Object> object) { 190 Worker* GetWorkerFromInternalField(Isolate* isolate, Local<Object> object) {
168 if (object->InternalFieldCount() != 1) { 191 if (object->InternalFieldCount() != 1) {
169 Throw(isolate, "this is not a Worker"); 192 Throw(isolate, "this is not a Worker");
170 return NULL; 193 return NULL;
171 } 194 }
172 195
173 Worker* worker = 196 Worker* worker =
174 static_cast<Worker*>(object->GetAlignedPointerFromInternalField(0)); 197 static_cast<Worker*>(object->GetAlignedPointerFromInternalField(0));
175 if (worker == NULL) { 198 if (worker == NULL) {
176 Throw(isolate, "Worker is defunct because main thread is terminating"); 199 Throw(isolate, "Worker is defunct because main thread is terminating");
177 return NULL; 200 return NULL;
178 } 201 }
179 202
180 return worker; 203 return worker;
181 } 204 }
205 #endif // !V8_SHARED
182 206
183 207
184 } // namespace 208 } // namespace
185 209
186 namespace tracing { 210 namespace tracing {
187 211
188 namespace { 212 namespace {
189 213
190 // String options that can be used to initialize TraceOptions. 214 // String options that can be used to initialize TraceOptions.
191 const char kRecordUntilFull[] = "record-until-full"; 215 const char kRecordUntilFull[] = "record-until-full";
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 int realm_switch_; 363 int realm_switch_;
340 Global<Context>* realms_; 364 Global<Context>* realms_;
341 Global<Value> realm_shared_; 365 Global<Value> realm_shared_;
342 366
343 int RealmIndexOrThrow(const v8::FunctionCallbackInfo<v8::Value>& args, 367 int RealmIndexOrThrow(const v8::FunctionCallbackInfo<v8::Value>& args,
344 int arg_offset); 368 int arg_offset);
345 int RealmFind(Local<Context> context); 369 int RealmFind(Local<Context> context);
346 }; 370 };
347 371
348 372
373 #ifndef V8_SHARED
349 CounterMap* Shell::counter_map_; 374 CounterMap* Shell::counter_map_;
350 base::OS::MemoryMappedFile* Shell::counters_file_ = NULL; 375 base::OS::MemoryMappedFile* Shell::counters_file_ = NULL;
351 CounterCollection Shell::local_counters_; 376 CounterCollection Shell::local_counters_;
352 CounterCollection* Shell::counters_ = &local_counters_; 377 CounterCollection* Shell::counters_ = &local_counters_;
353 base::LazyMutex Shell::context_mutex_; 378 base::LazyMutex Shell::context_mutex_;
354 const base::TimeTicks Shell::kInitialTicks = 379 const base::TimeTicks Shell::kInitialTicks =
355 base::TimeTicks::HighResolutionNow(); 380 base::TimeTicks::HighResolutionNow();
356 Global<Function> Shell::stringify_function_; 381 Global<Function> Shell::stringify_function_;
357 base::LazyMutex Shell::workers_mutex_; 382 base::LazyMutex Shell::workers_mutex_;
358 bool Shell::allow_new_workers_ = true; 383 bool Shell::allow_new_workers_ = true;
359 i::List<Worker*> Shell::workers_; 384 i::List<Worker*> Shell::workers_;
360 i::List<SharedArrayBuffer::Contents> Shell::externalized_shared_contents_; 385 i::List<SharedArrayBuffer::Contents> Shell::externalized_shared_contents_;
386 #endif // !V8_SHARED
361 387
362 Global<Context> Shell::evaluation_context_; 388 Global<Context> Shell::evaluation_context_;
363 ArrayBuffer::Allocator* Shell::array_buffer_allocator; 389 ArrayBuffer::Allocator* Shell::array_buffer_allocator;
364 ShellOptions Shell::options; 390 ShellOptions Shell::options;
365 base::OnceType Shell::quit_once_ = V8_ONCE_INIT; 391 base::OnceType Shell::quit_once_ = V8_ONCE_INIT;
366 392
393 #ifndef V8_SHARED
367 bool CounterMap::Match(void* key1, void* key2) { 394 bool CounterMap::Match(void* key1, void* key2) {
368 const char* name1 = reinterpret_cast<const char*>(key1); 395 const char* name1 = reinterpret_cast<const char*>(key1);
369 const char* name2 = reinterpret_cast<const char*>(key2); 396 const char* name2 = reinterpret_cast<const char*>(key2);
370 return strcmp(name1, name2) == 0; 397 return strcmp(name1, name2) == 0;
371 } 398 }
399 #endif // !V8_SHARED
372 400
373 401
374 // Converts a V8 value to a C string. 402 // Converts a V8 value to a C string.
375 const char* Shell::ToCString(const v8::String::Utf8Value& value) { 403 const char* Shell::ToCString(const v8::String::Utf8Value& value) {
376 return *value ? *value : "<string conversion failed>"; 404 return *value ? *value : "<string conversion failed>";
377 } 405 }
378 406
379 407
380 ScriptCompiler::CachedData* CompileForCachedData( 408 ScriptCompiler::CachedData* CompileForCachedData(
381 Local<String> source, Local<Value> name, 409 Local<String> source, Local<Value> name,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 520 }
493 Local<Value> result; 521 Local<Value> result;
494 if (!maybe_result.ToLocal(&result)) { 522 if (!maybe_result.ToLocal(&result)) {
495 DCHECK(try_catch.HasCaught()); 523 DCHECK(try_catch.HasCaught());
496 // Print errors that happened during execution. 524 // Print errors that happened during execution.
497 if (report_exceptions) ReportException(isolate, &try_catch); 525 if (report_exceptions) ReportException(isolate, &try_catch);
498 return false; 526 return false;
499 } 527 }
500 DCHECK(!try_catch.HasCaught()); 528 DCHECK(!try_catch.HasCaught());
501 if (print_result) { 529 if (print_result) {
530 #if !defined(V8_SHARED)
502 if (options.test_shell) { 531 if (options.test_shell) {
532 #endif
503 if (!result->IsUndefined()) { 533 if (!result->IsUndefined()) {
504 // If all went well and the result wasn't undefined then print 534 // If all went well and the result wasn't undefined then print
505 // the returned value. 535 // the returned value.
506 v8::String::Utf8Value str(result); 536 v8::String::Utf8Value str(result);
507 fwrite(*str, sizeof(**str), str.length(), stdout); 537 fwrite(*str, sizeof(**str), str.length(), stdout);
508 printf("\n"); 538 printf("\n");
509 } 539 }
540 #if !defined(V8_SHARED)
510 } else { 541 } else {
511 v8::String::Utf8Value str(Stringify(isolate, result)); 542 v8::String::Utf8Value str(Stringify(isolate, result));
512 fwrite(*str, sizeof(**str), str.length(), stdout); 543 fwrite(*str, sizeof(**str), str.length(), stdout);
513 printf("\n"); 544 printf("\n");
514 } 545 }
546 #endif
515 } 547 }
516 return true; 548 return true;
517 } 549 }
518 550
519 551
520 PerIsolateData::RealmScope::RealmScope(PerIsolateData* data) : data_(data) { 552 PerIsolateData::RealmScope::RealmScope(PerIsolateData* data) : data_(data) {
521 data_->realm_count_ = 1; 553 data_->realm_count_ = 1;
522 data_->realm_current_ = 0; 554 data_->realm_current_ = 0;
523 data_->realm_switch_ = 0; 555 data_->realm_switch_ = 0;
524 data_->realms_ = new Global<Context>[1]; 556 data_->realms_ = new Global<Context>[1];
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 ->Int32Value(args.GetIsolate()->GetCurrentContext()) 588 ->Int32Value(args.GetIsolate()->GetCurrentContext())
557 .FromMaybe(-1); 589 .FromMaybe(-1);
558 if (index < 0 || index >= realm_count_ || realms_[index].IsEmpty()) { 590 if (index < 0 || index >= realm_count_ || realms_[index].IsEmpty()) {
559 Throw(args.GetIsolate(), "Invalid realm index"); 591 Throw(args.GetIsolate(), "Invalid realm index");
560 return -1; 592 return -1;
561 } 593 }
562 return index; 594 return index;
563 } 595 }
564 596
565 597
598 #ifndef V8_SHARED
566 // performance.now() returns a time stamp as double, measured in milliseconds. 599 // performance.now() returns a time stamp as double, measured in milliseconds.
567 // When FLAG_verify_predictable mode is enabled it returns result of 600 // When FLAG_verify_predictable mode is enabled it returns result of
568 // v8::Platform::MonotonicallyIncreasingTime(). 601 // v8::Platform::MonotonicallyIncreasingTime().
569 void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) { 602 void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) {
570 if (i::FLAG_verify_predictable) { 603 if (i::FLAG_verify_predictable) {
571 args.GetReturnValue().Set(g_platform->MonotonicallyIncreasingTime()); 604 args.GetReturnValue().Set(g_platform->MonotonicallyIncreasingTime());
572 } else { 605 } else {
573 base::TimeDelta delta = 606 base::TimeDelta delta =
574 base::TimeTicks::HighResolutionNow() - kInitialTicks; 607 base::TimeTicks::HighResolutionNow() - kInitialTicks;
575 args.GetReturnValue().Set(delta.InMillisecondsF()); 608 args.GetReturnValue().Set(delta.InMillisecondsF());
576 } 609 }
577 } 610 }
611 #endif // !V8_SHARED
578 612
579 613
580 // Realm.current() returns the index of the currently active realm. 614 // Realm.current() returns the index of the currently active realm.
581 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) { 615 void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) {
582 Isolate* isolate = args.GetIsolate(); 616 Isolate* isolate = args.GetIsolate();
583 PerIsolateData* data = PerIsolateData::Get(isolate); 617 PerIsolateData* data = PerIsolateData::Get(isolate);
584 int index = data->RealmFind(isolate->GetEnteredContext()); 618 int index = data->RealmFind(isolate->GetEnteredContext());
585 if (index == -1) return; 619 if (index == -1) return;
586 args.GetReturnValue().Set(index); 620 args.GetReturnValue().Set(index);
587 } 621 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 String::NewFromUtf8(args.GetIsolate(), *file, 872 String::NewFromUtf8(args.GetIsolate(), *file,
839 NewStringType::kNormal).ToLocalChecked(), 873 NewStringType::kNormal).ToLocalChecked(),
840 false, true)) { 874 false, true)) {
841 Throw(args.GetIsolate(), "Error executing file"); 875 Throw(args.GetIsolate(), "Error executing file");
842 return; 876 return;
843 } 877 }
844 } 878 }
845 } 879 }
846 880
847 881
882 #ifndef V8_SHARED
848 void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) { 883 void Shell::WorkerNew(const v8::FunctionCallbackInfo<v8::Value>& args) {
849 Isolate* isolate = args.GetIsolate(); 884 Isolate* isolate = args.GetIsolate();
850 HandleScope handle_scope(isolate); 885 HandleScope handle_scope(isolate);
851 if (args.Length() < 1 || !args[0]->IsString()) { 886 if (args.Length() < 1 || !args[0]->IsString()) {
852 Throw(args.GetIsolate(), "1st argument must be string"); 887 Throw(args.GetIsolate(), "1st argument must be string");
853 return; 888 return;
854 } 889 }
855 890
856 if (!args.IsConstructCall()) { 891 if (!args.IsConstructCall()) {
857 Throw(args.GetIsolate(), "Worker must be constructed with new"); 892 Throw(args.GetIsolate(), "Worker must be constructed with new");
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 void Shell::WorkerTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) { 994 void Shell::WorkerTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
960 Isolate* isolate = args.GetIsolate(); 995 Isolate* isolate = args.GetIsolate();
961 HandleScope handle_scope(isolate); 996 HandleScope handle_scope(isolate);
962 Worker* worker = GetWorkerFromInternalField(isolate, args.Holder()); 997 Worker* worker = GetWorkerFromInternalField(isolate, args.Holder());
963 if (!worker) { 998 if (!worker) {
964 return; 999 return;
965 } 1000 }
966 1001
967 worker->Terminate(); 1002 worker->Terminate();
968 } 1003 }
1004 #endif // !V8_SHARED
969 1005
970 1006
971 void Shell::QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args) { 1007 void Shell::QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args) {
972 int exit_code = (*args)[0] 1008 int exit_code = (*args)[0]
973 ->Int32Value(args->GetIsolate()->GetCurrentContext()) 1009 ->Int32Value(args->GetIsolate()->GetCurrentContext())
974 .FromMaybe(0); 1010 .FromMaybe(0);
1011 #ifndef V8_SHARED
975 CleanupWorkers(); 1012 CleanupWorkers();
1013 #endif // !V8_SHARED
976 OnExit(args->GetIsolate()); 1014 OnExit(args->GetIsolate());
977 Exit(exit_code); 1015 Exit(exit_code);
978 } 1016 }
979 1017
980 1018
981 void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { 1019 void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) {
982 base::CallOnce(&quit_once_, &QuitOnce, 1020 base::CallOnce(&quit_once_, &QuitOnce,
983 const_cast<v8::FunctionCallbackInfo<v8::Value>*>(&args)); 1021 const_cast<v8::FunctionCallbackInfo<v8::Value>*>(&args));
984 } 1022 }
985 1023
986 1024
987 void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) { 1025 void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) {
988 args.GetReturnValue().Set( 1026 args.GetReturnValue().Set(
989 String::NewFromUtf8(args.GetIsolate(), V8::GetVersion(), 1027 String::NewFromUtf8(args.GetIsolate(), V8::GetVersion(),
990 NewStringType::kNormal).ToLocalChecked()); 1028 NewStringType::kNormal).ToLocalChecked());
991 } 1029 }
992 1030
993 1031
994 void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) { 1032 void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) {
995 HandleScope handle_scope(isolate); 1033 HandleScope handle_scope(isolate);
1034 #ifndef V8_SHARED
996 Local<Context> context; 1035 Local<Context> context;
997 bool enter_context = !isolate->InContext(); 1036 bool enter_context = !isolate->InContext();
998 if (enter_context) { 1037 if (enter_context) {
999 context = Local<Context>::New(isolate, evaluation_context_); 1038 context = Local<Context>::New(isolate, evaluation_context_);
1000 context->Enter(); 1039 context->Enter();
1001 } 1040 }
1041 #endif // !V8_SHARED
1002 v8::String::Utf8Value exception(try_catch->Exception()); 1042 v8::String::Utf8Value exception(try_catch->Exception());
1003 const char* exception_string = ToCString(exception); 1043 const char* exception_string = ToCString(exception);
1004 Local<Message> message = try_catch->Message(); 1044 Local<Message> message = try_catch->Message();
1005 if (message.IsEmpty()) { 1045 if (message.IsEmpty()) {
1006 // V8 didn't provide any extra information about this error; just 1046 // V8 didn't provide any extra information about this error; just
1007 // print the exception. 1047 // print the exception.
1008 printf("%s\n", exception_string); 1048 printf("%s\n", exception_string);
1009 } else { 1049 } else {
1010 // Print (filename):(line number): (message). 1050 // Print (filename):(line number): (message).
1011 v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName()); 1051 v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName());
(...skipping 23 matching lines...) Expand all
1035 Local<Value> stack_trace_string; 1075 Local<Value> stack_trace_string;
1036 if (try_catch->StackTrace(isolate->GetCurrentContext()) 1076 if (try_catch->StackTrace(isolate->GetCurrentContext())
1037 .ToLocal(&stack_trace_string) && 1077 .ToLocal(&stack_trace_string) &&
1038 stack_trace_string->IsString()) { 1078 stack_trace_string->IsString()) {
1039 v8::String::Utf8Value stack_trace( 1079 v8::String::Utf8Value stack_trace(
1040 Local<String>::Cast(stack_trace_string)); 1080 Local<String>::Cast(stack_trace_string));
1041 printf("%s\n", ToCString(stack_trace)); 1081 printf("%s\n", ToCString(stack_trace));
1042 } 1082 }
1043 } 1083 }
1044 printf("\n"); 1084 printf("\n");
1085 #ifndef V8_SHARED
1045 if (enter_context) context->Exit(); 1086 if (enter_context) context->Exit();
1087 #endif // !V8_SHARED
1046 } 1088 }
1047 1089
1048 1090
1091 #ifndef V8_SHARED
1049 int32_t* Counter::Bind(const char* name, bool is_histogram) { 1092 int32_t* Counter::Bind(const char* name, bool is_histogram) {
1050 int i; 1093 int i;
1051 for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) 1094 for (i = 0; i < kMaxNameSize - 1 && name[i]; i++)
1052 name_[i] = static_cast<char>(name[i]); 1095 name_[i] = static_cast<char>(name[i]);
1053 name_[i] = '\0'; 1096 name_[i] = '\0';
1054 is_histogram_ = is_histogram; 1097 is_histogram_ = is_histogram;
1055 return ptr(); 1098 return ptr();
1056 } 1099 }
1057 1100
1058 1101
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 stringify_function_.Reset( 1210 stringify_function_.Reset(
1168 isolate, script->Run(context).ToLocalChecked().As<Function>()); 1211 isolate, script->Run(context).ToLocalChecked().As<Function>());
1169 } 1212 }
1170 Local<Function> fun = Local<Function>::New(isolate, stringify_function_); 1213 Local<Function> fun = Local<Function>::New(isolate, stringify_function_);
1171 Local<Value> argv[1] = {value}; 1214 Local<Value> argv[1] = {value};
1172 v8::TryCatch try_catch(isolate); 1215 v8::TryCatch try_catch(isolate);
1173 MaybeLocal<Value> result = fun->Call(context, Undefined(isolate), 1, argv); 1216 MaybeLocal<Value> result = fun->Call(context, Undefined(isolate), 1, argv);
1174 if (result.IsEmpty()) return String::Empty(isolate); 1217 if (result.IsEmpty()) return String::Empty(isolate);
1175 return result.ToLocalChecked().As<String>(); 1218 return result.ToLocalChecked().As<String>();
1176 } 1219 }
1220 #endif // !V8_SHARED
1177 1221
1178 1222
1179 Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) { 1223 Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
1180 Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate); 1224 Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate);
1181 global_template->Set( 1225 global_template->Set(
1182 String::NewFromUtf8(isolate, "print", NewStringType::kNormal) 1226 String::NewFromUtf8(isolate, "print", NewStringType::kNormal)
1183 .ToLocalChecked(), 1227 .ToLocalChecked(),
1184 FunctionTemplate::New(isolate, Print)); 1228 FunctionTemplate::New(isolate, Print));
1185 global_template->Set( 1229 global_template->Set(
1186 String::NewFromUtf8(isolate, "write", NewStringType::kNormal) 1230 String::NewFromUtf8(isolate, "write", NewStringType::kNormal)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 FunctionTemplate::New(isolate, RealmEval)); 1301 FunctionTemplate::New(isolate, RealmEval));
1258 realm_template->SetAccessor( 1302 realm_template->SetAccessor(
1259 String::NewFromUtf8(isolate, "shared", NewStringType::kNormal) 1303 String::NewFromUtf8(isolate, "shared", NewStringType::kNormal)
1260 .ToLocalChecked(), 1304 .ToLocalChecked(),
1261 RealmSharedGet, RealmSharedSet); 1305 RealmSharedGet, RealmSharedSet);
1262 global_template->Set( 1306 global_template->Set(
1263 String::NewFromUtf8(isolate, "Realm", NewStringType::kNormal) 1307 String::NewFromUtf8(isolate, "Realm", NewStringType::kNormal)
1264 .ToLocalChecked(), 1308 .ToLocalChecked(),
1265 realm_template); 1309 realm_template);
1266 1310
1311 #ifndef V8_SHARED
1267 Local<ObjectTemplate> performance_template = ObjectTemplate::New(isolate); 1312 Local<ObjectTemplate> performance_template = ObjectTemplate::New(isolate);
1268 performance_template->Set( 1313 performance_template->Set(
1269 String::NewFromUtf8(isolate, "now", NewStringType::kNormal) 1314 String::NewFromUtf8(isolate, "now", NewStringType::kNormal)
1270 .ToLocalChecked(), 1315 .ToLocalChecked(),
1271 FunctionTemplate::New(isolate, PerformanceNow)); 1316 FunctionTemplate::New(isolate, PerformanceNow));
1272 global_template->Set( 1317 global_template->Set(
1273 String::NewFromUtf8(isolate, "performance", NewStringType::kNormal) 1318 String::NewFromUtf8(isolate, "performance", NewStringType::kNormal)
1274 .ToLocalChecked(), 1319 .ToLocalChecked(),
1275 performance_template); 1320 performance_template);
1276 1321
(...skipping 18 matching lines...) Expand all
1295 worker_fun_template->PrototypeTemplate()->Set( 1340 worker_fun_template->PrototypeTemplate()->Set(
1296 String::NewFromUtf8(isolate, "getMessage", NewStringType::kNormal) 1341 String::NewFromUtf8(isolate, "getMessage", NewStringType::kNormal)
1297 .ToLocalChecked(), 1342 .ToLocalChecked(),
1298 FunctionTemplate::New(isolate, WorkerGetMessage, Local<Value>(), 1343 FunctionTemplate::New(isolate, WorkerGetMessage, Local<Value>(),
1299 worker_signature)); 1344 worker_signature));
1300 worker_fun_template->InstanceTemplate()->SetInternalFieldCount(1); 1345 worker_fun_template->InstanceTemplate()->SetInternalFieldCount(1);
1301 global_template->Set( 1346 global_template->Set(
1302 String::NewFromUtf8(isolate, "Worker", NewStringType::kNormal) 1347 String::NewFromUtf8(isolate, "Worker", NewStringType::kNormal)
1303 .ToLocalChecked(), 1348 .ToLocalChecked(),
1304 worker_fun_template); 1349 worker_fun_template);
1350 #endif // !V8_SHARED
1305 1351
1306 Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); 1352 Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate);
1307 AddOSMethods(isolate, os_templ); 1353 AddOSMethods(isolate, os_templ);
1308 global_template->Set( 1354 global_template->Set(
1309 String::NewFromUtf8(isolate, "os", NewStringType::kNormal) 1355 String::NewFromUtf8(isolate, "os", NewStringType::kNormal)
1310 .ToLocalChecked(), 1356 .ToLocalChecked(),
1311 os_templ); 1357 os_templ);
1312 1358
1313 return global_template; 1359 return global_template;
1314 } 1360 }
1315 1361
1316 static void EmptyMessageCallback(Local<Message> message, Local<Value> error) { 1362 static void EmptyMessageCallback(Local<Message> message, Local<Value> error) {
1317 // Nothing to be done here, exceptions thrown up to the shell will be reported 1363 // Nothing to be done here, exceptions thrown up to the shell will be reported
1318 // separately by {Shell::ReportException} after they are caught. 1364 // separately by {Shell::ReportException} after they are caught.
1319 } 1365 }
1320 1366
1321 void Shell::Initialize(Isolate* isolate) { 1367 void Shell::Initialize(Isolate* isolate) {
1368 #ifndef V8_SHARED
1322 // Set up counters 1369 // Set up counters
1323 if (i::StrLength(i::FLAG_map_counters) != 0) 1370 if (i::StrLength(i::FLAG_map_counters) != 0)
1324 MapCounters(isolate, i::FLAG_map_counters); 1371 MapCounters(isolate, i::FLAG_map_counters);
1372 #endif // !V8_SHARED
1325 // Disable default message reporting. 1373 // Disable default message reporting.
1326 isolate->AddMessageListener(EmptyMessageCallback); 1374 isolate->AddMessageListener(EmptyMessageCallback);
1327 } 1375 }
1328 1376
1329 1377
1330 Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) { 1378 Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
1379 #ifndef V8_SHARED
1331 // This needs to be a critical section since this is not thread-safe 1380 // This needs to be a critical section since this is not thread-safe
1332 base::LockGuard<base::Mutex> lock_guard(context_mutex_.Pointer()); 1381 base::LockGuard<base::Mutex> lock_guard(context_mutex_.Pointer());
1382 #endif // !V8_SHARED
1333 // Initialize the global objects 1383 // Initialize the global objects
1334 Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); 1384 Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
1335 EscapableHandleScope handle_scope(isolate); 1385 EscapableHandleScope handle_scope(isolate);
1336 Local<Context> context = Context::New(isolate, NULL, global_template); 1386 Local<Context> context = Context::New(isolate, NULL, global_template);
1337 DCHECK(!context.IsEmpty()); 1387 DCHECK(!context.IsEmpty());
1338 Context::Scope scope(context); 1388 Context::Scope scope(context);
1339 1389
1390 #ifndef V8_SHARED
1340 i::Factory* factory = reinterpret_cast<i::Isolate*>(isolate)->factory(); 1391 i::Factory* factory = reinterpret_cast<i::Isolate*>(isolate)->factory();
1341 i::JSArguments js_args = i::FLAG_js_arguments; 1392 i::JSArguments js_args = i::FLAG_js_arguments;
1342 i::Handle<i::FixedArray> arguments_array = 1393 i::Handle<i::FixedArray> arguments_array =
1343 factory->NewFixedArray(js_args.argc); 1394 factory->NewFixedArray(js_args.argc);
1344 for (int j = 0; j < js_args.argc; j++) { 1395 for (int j = 0; j < js_args.argc; j++) {
1345 i::Handle<i::String> arg = 1396 i::Handle<i::String> arg =
1346 factory->NewStringFromUtf8(i::CStrVector(js_args[j])).ToHandleChecked(); 1397 factory->NewStringFromUtf8(i::CStrVector(js_args[j])).ToHandleChecked();
1347 arguments_array->set(j, *arg); 1398 arguments_array->set(j, *arg);
1348 } 1399 }
1349 i::Handle<i::JSArray> arguments_jsarray = 1400 i::Handle<i::JSArray> arguments_jsarray =
1350 factory->NewJSArrayWithElements(arguments_array); 1401 factory->NewJSArrayWithElements(arguments_array);
1351 context->Global() 1402 context->Global()
1352 ->Set(context, 1403 ->Set(context,
1353 String::NewFromUtf8(isolate, "arguments", NewStringType::kNormal) 1404 String::NewFromUtf8(isolate, "arguments", NewStringType::kNormal)
1354 .ToLocalChecked(), 1405 .ToLocalChecked(),
1355 Utils::ToLocal(arguments_jsarray)) 1406 Utils::ToLocal(arguments_jsarray))
1356 .FromJust(); 1407 .FromJust();
1408 #endif // !V8_SHARED
1357 return handle_scope.Escape(context); 1409 return handle_scope.Escape(context);
1358 } 1410 }
1359 1411
1360 1412
1361 void Shell::Exit(int exit_code) { 1413 void Shell::Exit(int exit_code) {
1362 // Use _exit instead of exit to avoid races between isolate 1414 // Use _exit instead of exit to avoid races between isolate
1363 // threads and static destructors. 1415 // threads and static destructors.
1364 fflush(stdout); 1416 fflush(stdout);
1365 fflush(stderr); 1417 fflush(stderr);
1366 _exit(exit_code); 1418 _exit(exit_code);
1367 } 1419 }
1368 1420
1369 1421
1422 #ifndef V8_SHARED
1370 struct CounterAndKey { 1423 struct CounterAndKey {
1371 Counter* counter; 1424 Counter* counter;
1372 const char* key; 1425 const char* key;
1373 }; 1426 };
1374 1427
1375 1428
1376 inline bool operator<(const CounterAndKey& lhs, const CounterAndKey& rhs) { 1429 inline bool operator<(const CounterAndKey& lhs, const CounterAndKey& rhs) {
1377 return strcmp(lhs.key, rhs.key) < 0; 1430 return strcmp(lhs.key, rhs.key) < 0;
1378 } 1431 }
1379 1432
1380 void Shell::WriteIgnitionDispatchCountersFile(v8::Isolate* isolate) { 1433 void Shell::WriteIgnitionDispatchCountersFile(v8::Isolate* isolate) {
1381 HandleScope handle_scope(isolate); 1434 HandleScope handle_scope(isolate);
1382 Local<Context> context = Context::New(isolate); 1435 Local<Context> context = Context::New(isolate);
1383 Context::Scope context_scope(context); 1436 Context::Scope context_scope(context);
1384 1437
1385 Local<Object> dispatch_counters = reinterpret_cast<i::Isolate*>(isolate) 1438 Local<Object> dispatch_counters = reinterpret_cast<i::Isolate*>(isolate)
1386 ->interpreter() 1439 ->interpreter()
1387 ->GetDispatchCountersObject(); 1440 ->GetDispatchCountersObject();
1388 std::ofstream dispatch_counters_stream( 1441 std::ofstream dispatch_counters_stream(
1389 i::FLAG_trace_ignition_dispatches_output_file); 1442 i::FLAG_trace_ignition_dispatches_output_file);
1390 dispatch_counters_stream << *String::Utf8Value( 1443 dispatch_counters_stream << *String::Utf8Value(
1391 JSON::Stringify(context, dispatch_counters).ToLocalChecked()); 1444 JSON::Stringify(context, dispatch_counters).ToLocalChecked());
1392 } 1445 }
1393 1446
1447 #endif // !V8_SHARED
1448
1394 1449
1395 void Shell::OnExit(v8::Isolate* isolate) { 1450 void Shell::OnExit(v8::Isolate* isolate) {
1451 #ifndef V8_SHARED
1396 if (i::FLAG_dump_counters) { 1452 if (i::FLAG_dump_counters) {
1397 int number_of_counters = 0; 1453 int number_of_counters = 0;
1398 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { 1454 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {
1399 number_of_counters++; 1455 number_of_counters++;
1400 } 1456 }
1401 CounterAndKey* counters = new CounterAndKey[number_of_counters]; 1457 CounterAndKey* counters = new CounterAndKey[number_of_counters];
1402 int j = 0; 1458 int j = 0;
1403 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next(), j++) { 1459 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next(), j++) {
1404 counters[j].counter = i.CurrentValue(); 1460 counters[j].counter = i.CurrentValue();
1405 counters[j].key = i.CurrentKey(); 1461 counters[j].key = i.CurrentKey();
(...skipping 15 matching lines...) Expand all
1421 printf("| %-62s | %11i |\n", key, counter->count()); 1477 printf("| %-62s | %11i |\n", key, counter->count());
1422 } 1478 }
1423 } 1479 }
1424 printf("+----------------------------------------------------------------+" 1480 printf("+----------------------------------------------------------------+"
1425 "-------------+\n"); 1481 "-------------+\n");
1426 delete [] counters; 1482 delete [] counters;
1427 } 1483 }
1428 1484
1429 delete counters_file_; 1485 delete counters_file_;
1430 delete counter_map_; 1486 delete counter_map_;
1487 #endif // !V8_SHARED
1431 } 1488 }
1432 1489
1433 1490
1434 1491
1435 static FILE* FOpen(const char* path, const char* mode) { 1492 static FILE* FOpen(const char* path, const char* mode) {
1436 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)) 1493 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))
1437 FILE* result; 1494 FILE* result;
1438 if (fopen_s(&result, path, mode) == 0) { 1495 if (fopen_s(&result, path, mode) == 0) {
1439 return result; 1496 return result;
1440 } else { 1497 } else {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 printf("d8> "); 1611 printf("d8> ");
1555 Local<String> input = Shell::ReadFromStdin(isolate); 1612 Local<String> input = Shell::ReadFromStdin(isolate);
1556 if (input.IsEmpty()) break; 1613 if (input.IsEmpty()) break;
1557 ExecuteString(isolate, input, name, true, true); 1614 ExecuteString(isolate, input, name, true, true);
1558 } 1615 }
1559 printf("\n"); 1616 printf("\n");
1560 } 1617 }
1561 1618
1562 1619
1563 SourceGroup::~SourceGroup() { 1620 SourceGroup::~SourceGroup() {
1621 #ifndef V8_SHARED
1564 delete thread_; 1622 delete thread_;
1565 thread_ = NULL; 1623 thread_ = NULL;
1624 #endif // !V8_SHARED
1566 } 1625 }
1567 1626
1568 1627
1569 void SourceGroup::Execute(Isolate* isolate) { 1628 void SourceGroup::Execute(Isolate* isolate) {
1570 bool exception_was_thrown = false; 1629 bool exception_was_thrown = false;
1571 for (int i = begin_offset_; i < end_offset_; ++i) { 1630 for (int i = begin_offset_; i < end_offset_; ++i) {
1572 const char* arg = argv_[i]; 1631 const char* arg = argv_[i];
1573 Shell::SourceType source_type = Shell::SCRIPT; 1632 Shell::SourceType source_type = Shell::SCRIPT;
1574 if (strcmp(arg, "-e") == 0 && i + 1 < end_offset_) { 1633 if (strcmp(arg, "-e") == 0 && i + 1 < end_offset_) {
1575 // Execute argument given to -e option directly. 1634 // Execute argument given to -e option directly.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 char* chars = ReadChars(isolate, name, &size); 1683 char* chars = ReadChars(isolate, name, &size);
1625 if (chars == NULL) return Local<String>(); 1684 if (chars == NULL) return Local<String>();
1626 Local<String> result = 1685 Local<String> result =
1627 String::NewFromUtf8(isolate, chars, NewStringType::kNormal, size) 1686 String::NewFromUtf8(isolate, chars, NewStringType::kNormal, size)
1628 .ToLocalChecked(); 1687 .ToLocalChecked();
1629 delete[] chars; 1688 delete[] chars;
1630 return result; 1689 return result;
1631 } 1690 }
1632 1691
1633 1692
1693 #ifndef V8_SHARED
1634 base::Thread::Options SourceGroup::GetThreadOptions() { 1694 base::Thread::Options SourceGroup::GetThreadOptions() {
1635 // On some systems (OSX 10.6) the stack size default is 0.5Mb or less 1695 // On some systems (OSX 10.6) the stack size default is 0.5Mb or less
1636 // which is not enough to parse the big literal expressions used in tests. 1696 // which is not enough to parse the big literal expressions used in tests.
1637 // The stack size should be at least StackGuard::kLimitSize + some 1697 // The stack size should be at least StackGuard::kLimitSize + some
1638 // OS-specific padding for thread startup code. 2Mbytes seems to be enough. 1698 // OS-specific padding for thread startup code. 2Mbytes seems to be enough.
1639 return base::Thread::Options("IsolateThread", 2 * MB); 1699 return base::Thread::Options("IsolateThread", 2 * MB);
1640 } 1700 }
1641 1701
1642 1702
1643 void SourceGroup::ExecuteInThread() { 1703 void SourceGroup::ExecuteInThread() {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 data)) { 2007 data)) {
1948 DCHECK(args.Data()->IsExternal()); 2008 DCHECK(args.Data()->IsExternal());
1949 Local<External> this_value = Local<External>::Cast(args.Data()); 2009 Local<External> this_value = Local<External>::Cast(args.Data());
1950 Worker* worker = static_cast<Worker*>(this_value->Value()); 2010 Worker* worker = static_cast<Worker*>(this_value->Value());
1951 worker->out_queue_.Enqueue(data); 2011 worker->out_queue_.Enqueue(data);
1952 worker->out_semaphore_.Signal(); 2012 worker->out_semaphore_.Signal();
1953 } else { 2013 } else {
1954 delete data; 2014 delete data;
1955 } 2015 }
1956 } 2016 }
2017 #endif // !V8_SHARED
1957 2018
1958 2019
1959 void SetFlagsFromString(const char* flags) { 2020 void SetFlagsFromString(const char* flags) {
1960 v8::V8::SetFlagsFromString(flags, static_cast<int>(strlen(flags))); 2021 v8::V8::SetFlagsFromString(flags, static_cast<int>(strlen(flags)));
1961 } 2022 }
1962 2023
1963 2024
1964 bool Shell::SetOptions(int argc, char* argv[]) { 2025 bool Shell::SetOptions(int argc, char* argv[]) {
1965 bool logfile_per_isolate = false; 2026 bool logfile_per_isolate = false;
1966 for (int i = 0; i < argc; i++) { 2027 for (int i = 0; i < argc; i++) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 options.send_idle_notification = true; 2063 options.send_idle_notification = true;
2003 argv[i] = NULL; 2064 argv[i] = NULL;
2004 } else if (strcmp(argv[i], "--omit-quit") == 0) { 2065 } else if (strcmp(argv[i], "--omit-quit") == 0) {
2005 options.omit_quit = true; 2066 options.omit_quit = true;
2006 argv[i] = NULL; 2067 argv[i] = NULL;
2007 } else if (strcmp(argv[i], "-f") == 0) { 2068 } else if (strcmp(argv[i], "-f") == 0) {
2008 // Ignore any -f flags for compatibility with other stand-alone 2069 // Ignore any -f flags for compatibility with other stand-alone
2009 // JavaScript engines. 2070 // JavaScript engines.
2010 continue; 2071 continue;
2011 } else if (strcmp(argv[i], "--isolate") == 0) { 2072 } else if (strcmp(argv[i], "--isolate") == 0) {
2073 #ifdef V8_SHARED
2074 printf("D8 with shared library does not support multi-threading\n");
2075 return false;
2076 #endif // V8_SHARED
2012 options.num_isolates++; 2077 options.num_isolates++;
2013 } else if (strcmp(argv[i], "--dump-heap-constants") == 0) { 2078 } else if (strcmp(argv[i], "--dump-heap-constants") == 0) {
2079 #ifdef V8_SHARED
2080 printf("D8 with shared library does not support constant dumping\n");
2081 return false;
2082 #else
2014 options.dump_heap_constants = true; 2083 options.dump_heap_constants = true;
2015 argv[i] = NULL; 2084 argv[i] = NULL;
2085 #endif // V8_SHARED
2016 } else if (strcmp(argv[i], "--throws") == 0) { 2086 } else if (strcmp(argv[i], "--throws") == 0) {
2017 options.expected_to_throw = true; 2087 options.expected_to_throw = true;
2018 argv[i] = NULL; 2088 argv[i] = NULL;
2019 } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) { 2089 } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) {
2020 options.icu_data_file = argv[i] + 16; 2090 options.icu_data_file = argv[i] + 16;
2021 argv[i] = NULL; 2091 argv[i] = NULL;
2092 #ifdef V8_SHARED
2093 } else if (strcmp(argv[i], "--dump-counters") == 0) {
2094 printf("D8 with shared library does not include counters\n");
2095 return false;
2096 #endif // V8_SHARED
2022 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 2097 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
2023 } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) { 2098 } else if (strncmp(argv[i], "--natives_blob=", 15) == 0) {
2024 options.natives_blob = argv[i] + 15; 2099 options.natives_blob = argv[i] + 15;
2025 argv[i] = NULL; 2100 argv[i] = NULL;
2026 } else if (strncmp(argv[i], "--snapshot_blob=", 16) == 0) { 2101 } else if (strncmp(argv[i], "--snapshot_blob=", 16) == 0) {
2027 options.snapshot_blob = argv[i] + 16; 2102 options.snapshot_blob = argv[i] + 16;
2028 argv[i] = NULL; 2103 argv[i] = NULL;
2029 #endif // V8_USE_EXTERNAL_STARTUP_DATA 2104 #endif // V8_USE_EXTERNAL_STARTUP_DATA
2030 } else if (strcmp(argv[i], "--cache") == 0 || 2105 } else if (strcmp(argv[i], "--cache") == 0 ||
2031 strncmp(argv[i], "--cache=", 8) == 0) { 2106 strncmp(argv[i], "--cache=", 8) == 0) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 2152
2078 if (!logfile_per_isolate && options.num_isolates) { 2153 if (!logfile_per_isolate && options.num_isolates) {
2079 SetFlagsFromString("--nologfile_per_isolate"); 2154 SetFlagsFromString("--nologfile_per_isolate");
2080 } 2155 }
2081 2156
2082 return true; 2157 return true;
2083 } 2158 }
2084 2159
2085 2160
2086 int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) { 2161 int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) {
2162 #ifndef V8_SHARED
2087 for (int i = 1; i < options.num_isolates; ++i) { 2163 for (int i = 1; i < options.num_isolates; ++i) {
2088 options.isolate_sources[i].StartExecuteInThread(); 2164 options.isolate_sources[i].StartExecuteInThread();
2089 } 2165 }
2166 #endif // !V8_SHARED
2090 { 2167 {
2091 HandleScope scope(isolate); 2168 HandleScope scope(isolate);
2092 Local<Context> context = CreateEvaluationContext(isolate); 2169 Local<Context> context = CreateEvaluationContext(isolate);
2093 if (last_run && options.use_interactive_shell()) { 2170 if (last_run && options.use_interactive_shell()) {
2094 // Keep using the same context in the interactive shell. 2171 // Keep using the same context in the interactive shell.
2095 evaluation_context_.Reset(isolate, context); 2172 evaluation_context_.Reset(isolate, context);
2096 } 2173 }
2097 { 2174 {
2098 Context::Scope cscope(context); 2175 Context::Scope cscope(context);
2099 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); 2176 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
2100 options.isolate_sources[0].Execute(isolate); 2177 options.isolate_sources[0].Execute(isolate);
2101 } 2178 }
2102 } 2179 }
2103 CollectGarbage(isolate); 2180 CollectGarbage(isolate);
2181 #ifndef V8_SHARED
2104 for (int i = 1; i < options.num_isolates; ++i) { 2182 for (int i = 1; i < options.num_isolates; ++i) {
2105 if (last_run) { 2183 if (last_run) {
2106 options.isolate_sources[i].JoinThread(); 2184 options.isolate_sources[i].JoinThread();
2107 } else { 2185 } else {
2108 options.isolate_sources[i].WaitForThread(); 2186 options.isolate_sources[i].WaitForThread();
2109 } 2187 }
2110 } 2188 }
2111 CleanupWorkers(); 2189 CleanupWorkers();
2190 #endif // !V8_SHARED
2112 return 0; 2191 return 0;
2113 } 2192 }
2114 2193
2115 2194
2116 void Shell::CollectGarbage(Isolate* isolate) { 2195 void Shell::CollectGarbage(Isolate* isolate) {
2117 if (options.send_idle_notification) { 2196 if (options.send_idle_notification) {
2118 const double kLongIdlePauseInSeconds = 1.0; 2197 const double kLongIdlePauseInSeconds = 1.0;
2119 isolate->ContextDisposedNotification(); 2198 isolate->ContextDisposedNotification();
2120 isolate->IdleNotificationDeadline( 2199 isolate->IdleNotificationDeadline(
2121 g_platform->MonotonicallyIncreasingTime() + kLongIdlePauseInSeconds); 2200 g_platform->MonotonicallyIncreasingTime() + kLongIdlePauseInSeconds);
2122 } 2201 }
2123 if (options.invoke_weak_callbacks) { 2202 if (options.invoke_weak_callbacks) {
2124 // By sending a low memory notifications, we will try hard to collect all 2203 // By sending a low memory notifications, we will try hard to collect all
2125 // garbage and will therefore also invoke all weak callbacks of actually 2204 // garbage and will therefore also invoke all weak callbacks of actually
2126 // unreachable persistent handles. 2205 // unreachable persistent handles.
2127 isolate->LowMemoryNotification(); 2206 isolate->LowMemoryNotification();
2128 } 2207 }
2129 } 2208 }
2130 2209
2131 2210
2132 void Shell::EmptyMessageQueues(Isolate* isolate) { 2211 void Shell::EmptyMessageQueues(Isolate* isolate) {
2212 #ifndef V8_SHARED
2133 if (!i::FLAG_verify_predictable) { 2213 if (!i::FLAG_verify_predictable) {
2214 #endif
2134 while (v8::platform::PumpMessageLoop(g_platform, isolate)) continue; 2215 while (v8::platform::PumpMessageLoop(g_platform, isolate)) continue;
2216 #ifndef V8_SHARED
2135 } 2217 }
2218 #endif
2136 } 2219 }
2137 2220
2138 2221
2222 #ifndef V8_SHARED
2139 bool Shell::SerializeValue(Isolate* isolate, Local<Value> value, 2223 bool Shell::SerializeValue(Isolate* isolate, Local<Value> value,
2140 const ObjectList& to_transfer, 2224 const ObjectList& to_transfer,
2141 ObjectList* seen_objects, 2225 ObjectList* seen_objects,
2142 SerializationData* out_data) { 2226 SerializationData* out_data) {
2143 DCHECK(out_data); 2227 DCHECK(out_data);
2144 Local<Context> context = isolate->GetCurrentContext(); 2228 Local<Context> context = isolate->GetCurrentContext();
2145 2229
2146 if (value->IsUndefined()) { 2230 if (value->IsUndefined()) {
2147 out_data->WriteTag(kSerializationTagUndefined); 2231 out_data->WriteTag(kSerializationTagUndefined);
2148 } else if (value->IsNull()) { 2232 } else if (value->IsNull()) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2443 const char* n = NULL; 2527 const char* n = NULL;
2444 intptr_t p = reinterpret_cast<intptr_t>(o) & 0xfffff; 2528 intptr_t p = reinterpret_cast<intptr_t>(o) & 0xfffff;
2445 ROOT_LIST(ROOT_LIST_CASE) 2529 ROOT_LIST(ROOT_LIST_CASE)
2446 if (n == NULL) continue; 2530 if (n == NULL) continue;
2447 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n); 2531 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n);
2448 } 2532 }
2449 } 2533 }
2450 printf("}\n"); 2534 printf("}\n");
2451 #undef ROOT_LIST_CASE 2535 #undef ROOT_LIST_CASE
2452 } 2536 }
2537 #endif // !V8_SHARED
2453 2538
2454 2539
2455 int Shell::Main(int argc, char* argv[]) { 2540 int Shell::Main(int argc, char* argv[]) {
2456 std::ofstream trace_file; 2541 std::ofstream trace_file;
2542 #ifndef V8_SHARED
2457 v8::base::debug::EnableInProcessStackDumping(); 2543 v8::base::debug::EnableInProcessStackDumping();
2544 #endif
2458 #if (defined(_WIN32) || defined(_WIN64)) 2545 #if (defined(_WIN32) || defined(_WIN64))
2459 UINT new_flags = 2546 UINT new_flags =
2460 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; 2547 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
2461 UINT existing_flags = SetErrorMode(new_flags); 2548 UINT existing_flags = SetErrorMode(new_flags);
2462 SetErrorMode(existing_flags | new_flags); 2549 SetErrorMode(existing_flags | new_flags);
2463 #if defined(_MSC_VER) 2550 #if defined(_MSC_VER)
2464 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); 2551 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
2465 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); 2552 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
2466 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); 2553 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
2467 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); 2554 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
2468 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); 2555 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
2469 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); 2556 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
2470 _set_error_mode(_OUT_TO_STDERR); 2557 _set_error_mode(_OUT_TO_STDERR);
2471 #endif // defined(_MSC_VER) 2558 #endif // defined(_MSC_VER)
2472 #endif // defined(_WIN32) || defined(_WIN64) 2559 #endif // defined(_WIN32) || defined(_WIN64)
2473 if (!SetOptions(argc, argv)) return 1; 2560 if (!SetOptions(argc, argv)) return 1;
2474 v8::V8::InitializeICUDefaultLocation(argv[0], options.icu_data_file); 2561 v8::V8::InitializeICUDefaultLocation(argv[0], options.icu_data_file);
2562 #ifndef V8_SHARED
2475 g_platform = i::FLAG_verify_predictable 2563 g_platform = i::FLAG_verify_predictable
2476 ? new PredictablePlatform() 2564 ? new PredictablePlatform()
2477 : v8::platform::CreateDefaultPlatform(); 2565 : v8::platform::CreateDefaultPlatform();
2566 #else
2567 g_platform = v8::platform::CreateDefaultPlatform();
2568 #endif // !V8_SHARED
2478 2569
2479 v8::V8::InitializePlatform(g_platform); 2570 v8::V8::InitializePlatform(g_platform);
2480 v8::V8::Initialize(); 2571 v8::V8::Initialize();
2481 if (options.natives_blob || options.snapshot_blob) { 2572 if (options.natives_blob || options.snapshot_blob) {
2482 v8::V8::InitializeExternalStartupData(options.natives_blob, 2573 v8::V8::InitializeExternalStartupData(options.natives_blob,
2483 options.snapshot_blob); 2574 options.snapshot_blob);
2484 } else { 2575 } else {
2485 v8::V8::InitializeExternalStartupData(argv[0]); 2576 v8::V8::InitializeExternalStartupData(argv[0]);
2486 } 2577 }
2487 SetFlagsFromString("--trace-hydrogen-file=hydrogen.cfg"); 2578 SetFlagsFromString("--trace-hydrogen-file=hydrogen.cfg");
2488 SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg"); 2579 SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg");
2489 SetFlagsFromString("--redirect-code-traces-to=code.asm"); 2580 SetFlagsFromString("--redirect-code-traces-to=code.asm");
2490 int result = 0; 2581 int result = 0;
2491 Isolate::CreateParams create_params; 2582 Isolate::CreateParams create_params;
2492 ShellArrayBufferAllocator shell_array_buffer_allocator; 2583 ShellArrayBufferAllocator shell_array_buffer_allocator;
2493 MockArrayBufferAllocator mock_arraybuffer_allocator; 2584 MockArrayBufferAllocator mock_arraybuffer_allocator;
2494 if (options.mock_arraybuffer_allocator) { 2585 if (options.mock_arraybuffer_allocator) {
2495 Shell::array_buffer_allocator = &mock_arraybuffer_allocator; 2586 Shell::array_buffer_allocator = &mock_arraybuffer_allocator;
2496 } else { 2587 } else {
2497 Shell::array_buffer_allocator = &shell_array_buffer_allocator; 2588 Shell::array_buffer_allocator = &shell_array_buffer_allocator;
2498 } 2589 }
2499 create_params.array_buffer_allocator = Shell::array_buffer_allocator; 2590 create_params.array_buffer_allocator = Shell::array_buffer_allocator;
2500 #ifdef ENABLE_VTUNE_JIT_INTERFACE 2591 #ifdef ENABLE_VTUNE_JIT_INTERFACE
2501 create_params.code_event_handler = vTune::GetVtuneCodeEventHandler(); 2592 create_params.code_event_handler = vTune::GetVtuneCodeEventHandler();
2502 #endif 2593 #endif
2594 #ifndef V8_SHARED
2503 create_params.constraints.ConfigureDefaults( 2595 create_params.constraints.ConfigureDefaults(
2504 base::SysInfo::AmountOfPhysicalMemory(), 2596 base::SysInfo::AmountOfPhysicalMemory(),
2505 base::SysInfo::AmountOfVirtualMemory()); 2597 base::SysInfo::AmountOfVirtualMemory());
2506 2598
2507 Shell::counter_map_ = new CounterMap(); 2599 Shell::counter_map_ = new CounterMap();
2508 if (i::FLAG_dump_counters || i::FLAG_track_gc_object_stats) { 2600 if (i::FLAG_dump_counters || i::FLAG_track_gc_object_stats) {
2509 create_params.counter_lookup_callback = LookupCounter; 2601 create_params.counter_lookup_callback = LookupCounter;
2510 create_params.create_histogram_callback = CreateHistogram; 2602 create_params.create_histogram_callback = CreateHistogram;
2511 create_params.add_histogram_sample_callback = AddHistogramSample; 2603 create_params.add_histogram_sample_callback = AddHistogramSample;
2512 } 2604 }
2605 #endif
2513 Isolate* isolate = Isolate::New(create_params); 2606 Isolate* isolate = Isolate::New(create_params);
2514 { 2607 {
2515 Isolate::Scope scope(isolate); 2608 Isolate::Scope scope(isolate);
2516 Initialize(isolate); 2609 Initialize(isolate);
2517 PerIsolateData data(isolate); 2610 PerIsolateData data(isolate);
2518 2611
2519 if (options.trace_enabled) { 2612 if (options.trace_enabled) {
2520 trace_file.open("v8_trace.json"); 2613 trace_file.open("v8_trace.json");
2521 platform::tracing::TracingController* tracing_controller = 2614 platform::tracing::TracingController* tracing_controller =
2522 new platform::tracing::TracingController(); 2615 new platform::tracing::TracingController();
2523 platform::tracing::TraceBuffer* trace_buffer = 2616 platform::tracing::TraceBuffer* trace_buffer =
2524 platform::tracing::TraceBuffer::CreateTraceBufferRingBuffer( 2617 platform::tracing::TraceBuffer::CreateTraceBufferRingBuffer(
2525 platform::tracing::TraceBuffer::kRingBufferChunks, 2618 platform::tracing::TraceBuffer::kRingBufferChunks,
2526 platform::tracing::TraceWriter::CreateJSONTraceWriter( 2619 platform::tracing::TraceWriter::CreateJSONTraceWriter(
2527 trace_file)); 2620 trace_file));
2528 platform::tracing::TraceConfig* trace_config; 2621 platform::tracing::TraceConfig* trace_config;
2529 if (options.trace_config) { 2622 if (options.trace_config) {
2530 int size = 0; 2623 int size = 0;
2531 char* trace_config_json_str = 2624 char* trace_config_json_str =
2532 ReadChars(nullptr, options.trace_config, &size); 2625 ReadChars(nullptr, options.trace_config, &size);
2533 trace_config = 2626 trace_config =
2534 tracing::CreateTraceConfigFromJSON(isolate, trace_config_json_str); 2627 tracing::CreateTraceConfigFromJSON(isolate, trace_config_json_str);
2535 delete[] trace_config_json_str; 2628 delete[] trace_config_json_str;
2536 } else { 2629 } else {
2537 trace_config = 2630 trace_config =
2538 platform::tracing::TraceConfig::CreateDefaultTraceConfig(); 2631 platform::tracing::TraceConfig::CreateDefaultTraceConfig();
2539 } 2632 }
2540 tracing_controller->Initialize(trace_buffer); 2633 tracing_controller->Initialize(trace_buffer);
2541 tracing_controller->StartTracing(trace_config); 2634 tracing_controller->StartTracing(trace_config);
2635 #ifndef V8_SHARED
2542 if (!i::FLAG_verify_predictable) { 2636 if (!i::FLAG_verify_predictable) {
2543 platform::SetTracingController(g_platform, tracing_controller); 2637 platform::SetTracingController(g_platform, tracing_controller);
2544 } 2638 }
2639 #else
2640 platform::SetTracingController(g_platform, tracing_controller);
2641 #endif
2545 } 2642 }
2546 2643
2644 #ifndef V8_SHARED
2547 if (options.dump_heap_constants) { 2645 if (options.dump_heap_constants) {
2548 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate)); 2646 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate));
2549 return 0; 2647 return 0;
2550 } 2648 }
2649 #endif
2551 2650
2552 if (options.stress_opt || options.stress_deopt) { 2651 if (options.stress_opt || options.stress_deopt) {
2553 Testing::SetStressRunType(options.stress_opt 2652 Testing::SetStressRunType(options.stress_opt
2554 ? Testing::kStressTypeOpt 2653 ? Testing::kStressTypeOpt
2555 : Testing::kStressTypeDeopt); 2654 : Testing::kStressTypeDeopt);
2556 options.stress_runs = Testing::GetStressRuns(); 2655 options.stress_runs = Testing::GetStressRuns();
2557 for (int i = 0; i < options.stress_runs && result == 0; i++) { 2656 for (int i = 0; i < options.stress_runs && result == 0; i++) {
2558 printf("============ Stress %d/%d ============\n", i + 1, 2657 printf("============ Stress %d/%d ============\n", i + 1,
2559 options.stress_runs); 2658 options.stress_runs);
2560 Testing::PrepareStressRun(i); 2659 Testing::PrepareStressRun(i);
2561 bool last_run = i == options.stress_runs - 1; 2660 bool last_run = i == options.stress_runs - 1;
2562 result = RunMain(isolate, argc, argv, last_run); 2661 result = RunMain(isolate, argc, argv, last_run);
2563 } 2662 }
2564 printf("======== Full Deoptimization =======\n"); 2663 printf("======== Full Deoptimization =======\n");
2565 Testing::DeoptimizeAll(isolate); 2664 Testing::DeoptimizeAll(isolate);
2665 #if !defined(V8_SHARED)
2566 } else if (i::FLAG_stress_runs > 0) { 2666 } else if (i::FLAG_stress_runs > 0) {
2567 options.stress_runs = i::FLAG_stress_runs; 2667 options.stress_runs = i::FLAG_stress_runs;
2568 for (int i = 0; i < options.stress_runs && result == 0; i++) { 2668 for (int i = 0; i < options.stress_runs && result == 0; i++) {
2569 printf("============ Run %d/%d ============\n", i + 1, 2669 printf("============ Run %d/%d ============\n", i + 1,
2570 options.stress_runs); 2670 options.stress_runs);
2571 bool last_run = i == options.stress_runs - 1; 2671 bool last_run = i == options.stress_runs - 1;
2572 result = RunMain(isolate, argc, argv, last_run); 2672 result = RunMain(isolate, argc, argv, last_run);
2573 } 2673 }
2674 #endif
2574 } else { 2675 } else {
2575 bool last_run = true; 2676 bool last_run = true;
2576 result = RunMain(isolate, argc, argv, last_run); 2677 result = RunMain(isolate, argc, argv, last_run);
2577 } 2678 }
2578 2679
2579 // Run interactive shell if explicitly requested or if no script has been 2680 // Run interactive shell if explicitly requested or if no script has been
2580 // executed, but never on --test 2681 // executed, but never on --test
2581 if (options.use_interactive_shell()) { 2682 if (options.use_interactive_shell()) {
2582 RunShell(isolate); 2683 RunShell(isolate);
2583 } 2684 }
2584 2685
2686 #ifndef V8_SHARED
2585 if (i::FLAG_ignition && i::FLAG_trace_ignition_dispatches && 2687 if (i::FLAG_ignition && i::FLAG_trace_ignition_dispatches &&
2586 i::FLAG_trace_ignition_dispatches_output_file != nullptr) { 2688 i::FLAG_trace_ignition_dispatches_output_file != nullptr) {
2587 WriteIgnitionDispatchCountersFile(isolate); 2689 WriteIgnitionDispatchCountersFile(isolate);
2588 } 2690 }
2691 #endif
2589 2692
2590 // Shut down contexts and collect garbage. 2693 // Shut down contexts and collect garbage.
2591 evaluation_context_.Reset(); 2694 evaluation_context_.Reset();
2695 #ifndef V8_SHARED
2592 stringify_function_.Reset(); 2696 stringify_function_.Reset();
2697 #endif // !V8_SHARED
2593 CollectGarbage(isolate); 2698 CollectGarbage(isolate);
2594 } 2699 }
2595 OnExit(isolate); 2700 OnExit(isolate);
2701 #ifndef V8_SHARED
2596 // Dump basic block profiling data. 2702 // Dump basic block profiling data.
2597 if (i::BasicBlockProfiler* profiler = 2703 if (i::BasicBlockProfiler* profiler =
2598 reinterpret_cast<i::Isolate*>(isolate)->basic_block_profiler()) { 2704 reinterpret_cast<i::Isolate*>(isolate)->basic_block_profiler()) {
2599 i::OFStream os(stdout); 2705 i::OFStream os(stdout);
2600 os << *profiler; 2706 os << *profiler;
2601 } 2707 }
2708 #endif // !V8_SHARED
2602 isolate->Dispose(); 2709 isolate->Dispose();
2603 V8::Dispose(); 2710 V8::Dispose();
2604 V8::ShutdownPlatform(); 2711 V8::ShutdownPlatform();
2605 delete g_platform; 2712 delete g_platform;
2606 2713
2607 return result; 2714 return result;
2608 } 2715 }
2609 2716
2610 } // namespace v8 2717 } // namespace v8
2611 2718
2612 2719
2613 #ifndef GOOGLE3 2720 #ifndef GOOGLE3
2614 int main(int argc, char* argv[]) { 2721 int main(int argc, char* argv[]) {
2615 return v8::Shell::Main(argc, argv); 2722 return v8::Shell::Main(argc, argv);
2616 } 2723 }
2617 #endif 2724 #endif
OLDNEW
« no previous file with comments | « src/d8.h ('k') | src/d8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698