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

Side by Side Diff: src/d8.cc

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