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

Side by Side Diff: src/d8.cc

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