30 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
34 #ifdef COMPRESS_STARTUP_DATA_BZ2
52 #include "../include/v8-testing.h"
55 #ifdef ENABLE_VTUNE_JIT_INTERFACE
56 #include "third_party/vtune/v8-vtune.h"
72 #if !defined(_WIN32) && !defined(_WIN64)
77 #define ASSERT(condition) assert(condition)
83 static Handle<Value> Throw(Isolate* isolate,
const char*
message) {
132 : type_(type), name_(name) {
148 printf(
"%s", prompt);
149 #if defined(__native_client__)
160 i::OS::MemoryMappedFile* Shell::counters_file_ =
NULL;
163 i::Mutex Shell::context_mutex_;
164 const i::TimeTicks Shell::kInitialTicks = i::TimeTicks::HighResolutionNow();
174 const int MB = 1024 * 1024;
176 bool CounterMap::Match(
void* key1,
void* key2) {
177 const char* name1 =
reinterpret_cast<const char*
>(key1);
178 const char* name2 =
reinterpret_cast<const char*
>(key2);
179 return strcmp(name1, name2) == 0;
186 return *value ? *value :
"<string conversion failed>";
195 bool report_exceptions) {
196 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
197 bool FLAG_debugger = i::FLAG_debugger;
199 bool FLAG_debugger =
false;
200 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
214 if (report_exceptions && !FLAG_debugger)
222 Handle<Value> result = script->BindToCurrentContext()->Run();
224 data->realm_current_ = data->realm_switch_;
228 if (report_exceptions && !FLAG_debugger)
234 #if !defined(V8_SHARED)
241 fwrite(*str,
sizeof(**str), str.
length(), stdout);
244 #if !defined(V8_SHARED)
257 fwrite(*str,
sizeof(**str), str.
length(), stdout);
269 data_->realm_count_ = 1;
270 data_->realm_current_ = 0;
271 data_->realm_switch_ = 0;
273 data_->realms_[0].
Reset(data_->isolate_,
280 for (
int i = 0; i < data_->realm_count_; ++i)
281 data_->realms_[i].Reset();
282 delete[] data_->realms_;
283 if (!data_->realm_shared_.IsEmpty())
284 data_->realm_shared_.Reset();
289 for (
int i = 0; i < realm_count_; ++i) {
290 if (realms_[i] == context)
return i;
296 int PerIsolateData::RealmIndexOrThrow(
299 if (args.
Length() < arg_offset || !args[arg_offset]->IsNumber()) {
303 int index = args[arg_offset]->Int32Value();
305 index >= realm_count_ ||
306 realms_[index].IsEmpty()) {
307 Throw(args.
GetIsolate(),
"Invalid realm index");
317 i::TimeDelta delta = i::TimeTicks::HighResolutionNow() - kInitialTicks;
328 if (index == -1)
return;
337 if (args.
Length() < 1 || !args[0]->IsObject()) {
341 int index = data->RealmFind(args[0]->ToObject()->CreationContext());
342 if (index == -1)
return;
351 int index = data->RealmIndexOrThrow(args, 0);
352 if (index == -1)
return;
363 int index = data->realm_count_;
365 for (
int i = 0; i < index; ++i) {
366 data->realms_[i].
Reset(isolate, old_realms[i]);
370 data->realms_[index].
Reset(
380 int index = data->RealmIndexOrThrow(args, 0);
381 if (index == -1)
return;
383 index == data->realm_current_ || index == data->realm_switch_) {
384 Throw(args.
GetIsolate(),
"Invalid realm index");
387 data->realms_[index].
Reset();
395 int index = data->RealmIndexOrThrow(args, 0);
396 if (index == -1)
return;
397 data->realm_switch_ = index;
405 int index = data->RealmIndexOrThrow(args, 0);
406 if (index == -1)
return;
407 if (args.
Length() < 2 || !args[1]->IsString()) {
413 isolate, &script_source);
417 Handle<Value> result = script->BindToCurrentContext()->Run();
428 if (data->realm_shared_.IsEmpty())
return;
437 data->realm_shared_.Reset(isolate, value);
449 for (
int i = 0; i < args.
Length(); i++) {
464 int n =
static_cast<int>(fwrite(*str,
sizeof(**str), str.
length(), stdout));
466 printf(
"Error in fwrite\n");
476 Throw(args.
GetIsolate(),
"Error loading file");
481 Throw(args.
GetIsolate(),
"Error loading file");
489 static const int kBufferSize = 256;
490 char buffer[kBufferSize];
500 input = fgets(buffer, kBufferSize, stdin);
503 length =
static_cast<int>(strlen(buffer));
506 }
else if (buffer[length-1] !=
'\n') {
510 }
else if (length > 1 && buffer[length-2] ==
'\\') {
511 buffer[length-2] =
'\n';
525 for (
int i = 0; i < args.
Length(); i++) {
529 Throw(args.
GetIsolate(),
"Error loading file");
534 Throw(args.
GetIsolate(),
"Error loading file");
542 Throw(args.
GetIsolate(),
"Error executing file");
550 int exit_code = args[0]->Int32Value();
564 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
566 bool enter_context = !isolate->
InContext();
569 utility_context->
Enter();
571 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
573 const char* exception_string =
ToCString(exception);
578 printf(
"%s\n", exception_string);
582 const char* filename_string =
ToCString(filename);
583 int linenum = message->GetLineNumber();
584 printf(
"%s:%i: %s\n", filename_string, linenum, exception_string);
587 const char* sourceline_string =
ToCString(sourceline);
588 printf(
"%s\n", sourceline_string);
590 int start = message->GetStartColumn();
591 for (
int i = 0; i < start; i++) {
594 int end = message->GetEndColumn();
595 for (
int i = start; i < end; i++) {
600 if (stack_trace.length() > 0) {
601 const char* stack_trace_string =
ToCString(stack_trace);
602 printf(
"%s\n", stack_trace_string);
606 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
607 if (enter_context) utility_context->
Exit();
608 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
623 static const int kArgc = 3;
632 #ifdef ENABLE_DEBUGGER_SUPPORT
642 static const int kArgc = 1;
649 Local<Value> Shell::DebugCommandToJSONRequest(Isolate* isolate,
650 Handle<String> command) {
651 EscapableHandleScope handle_scope(isolate);
655 Handle<Object> global = context->
Global();
658 static const int kArgc = 1;
659 Handle<Value> argv[kArgc] = { command };
661 return handle_scope.Escape(Local<Value>(val));
665 void Shell::DispatchDebugMessages() {
667 HandleScope handle_scope(isolate);
673 #endif // ENABLE_DEBUGGER_SUPPORT
680 for (i = 0; i < kMaxNameSize - 1 && name[i]; i++)
681 name_[i] = static_cast<char>(name[i]);
683 is_histogram_ = is_histogram;
695 magic_number_ = 0xDEADFACE;
696 max_counters_ = kMaxCounters;
698 counters_in_use_ = 0;
703 if (counters_in_use_ == kMaxCounters)
return NULL;
704 return &counters_[counters_in_use_++];
709 counters_file_ = i::OS::MemoryMappedFile::create(
712 NULL : counters_file_->memory();
713 if (memory ==
NULL) {
714 printf(
"Could not map counters file %s\n", name);
724 int CounterMap::Hash(
const char*
name) {
727 while ((c = *name++) != 0) {
735 Counter* Shell::GetCounter(
const char* name,
bool is_histogram) {
736 Counter* counter = counter_map_->Lookup(name);
738 if (counter ==
NULL) {
739 counter = counters_->GetNextCounter();
740 if (counter !=
NULL) {
741 counter_map_->Set(name, counter);
742 counter->Bind(name, is_histogram);
745 ASSERT(counter->is_histogram() == is_histogram);
752 Counter* counter = GetCounter(name,
false);
754 if (counter !=
NULL) {
755 return counter->
ptr();
766 return GetCounter(name,
true);
776 void Shell::InstallUtilityScript(
Isolate* isolate) {
789 #ifdef ENABLE_DEBUGGER_SUPPORT
790 if (i::FLAG_debugger) printf(
"JavaScript debugger enabled\n");
792 i::Debug* debug =
reinterpret_cast<i::Isolate*
>(isolate)->debug();
798 debug->debug_context()->set_security_token(
799 reinterpret_cast<i::Isolate*>(isolate)->heap()->undefined_value());
800 #endif // ENABLE_DEBUGGER_SUPPORT
824 i::SharedFunctionInfo::cast(*compiled_script)->script()));
827 #ifdef ENABLE_DEBUGGER_SUPPORT
829 if (i::FLAG_debugger && !i::FLAG_debugger_agent) {
832 #endif // ENABLE_DEBUGGER_SUPPORT
837 #ifdef COMPRESS_STARTUP_DATA_BZ2
840 virtual ~BZip2Decompressor() { }
843 virtual int DecompressData(
char* raw_data,
845 const char* compressed_data,
846 int compressed_data_size) {
849 unsigned int decompressed_size = *raw_data_size;
851 BZ2_bzBuffToBuffDecompress(raw_data,
853 const_cast<char*>(compressed_data),
854 compressed_data_size,
856 if (result == BZ_OK) {
857 *raw_data_size = decompressed_size;
865 Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
901 RealmSharedGet, RealmSharedSet);
909 performance_template);
912 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64)
914 AddOSMethods(isolate, os_templ);
918 return global_template;
922 void Shell::Initialize(Isolate* isolate) {
923 #ifdef COMPRESS_STARTUP_DATA_BZ2
924 BZip2Decompressor startup_data_decompressor;
925 int bz2_result = startup_data_decompressor.Decompress();
926 if (bz2_result != BZ_OK) {
927 fprintf(stderr,
"bzip error code: %d\n", bz2_result);
933 Shell::counter_map_ =
new CounterMap();
936 MapCounters(i::FLAG_map_counters);
937 if (i::FLAG_dump_counters || i::FLAG_track_gc_object_stats) {
946 void Shell::InitializeDebugger(Isolate* isolate) {
947 if (options.test_shell)
return;
949 Locker lock(isolate);
950 HandleScope scope(isolate);
952 utility_context_.Reset(isolate,
955 #ifdef ENABLE_DEBUGGER_SUPPORT
957 if (i::FLAG_debugger_agent) {
961 #endif // ENABLE_DEBUGGER_SUPPORT
969 i::LockGuard<i::Mutex> lock_guard(&context_mutex_);
983 for (
int j = 0; j < js_args.
argc; j++) {
986 arguments_array->set(j, *arg);
993 return handle_scope.
Escape(context);
1014 return strcmp(lhs.
key, rhs.
key) < 0;
1021 if (line_editor) line_editor->
Close();
1023 if (i::FLAG_dump_counters) {
1024 int number_of_counters = 0;
1026 number_of_counters++;
1031 counters[j].
counter = i.CurrentValue();
1032 counters[j].
key = i.CurrentKey();
1034 std::sort(counters, counters + number_of_counters);
1035 printf(
"+----------------------------------------------------------------+"
1036 "-------------+\n");
1039 printf(
"+----------------------------------------------------------------+"
1040 "-------------+\n");
1041 for (j = 0; j < number_of_counters; j++) {
1043 const char* key = counters[j].
key;
1045 printf(
"| c:%-60s | %11i |\n", key, counter->
count());
1046 printf(
"| t:%-60s | %11i |\n", key, counter->
sample_total());
1048 printf(
"| %-62s | %11i |\n", key, counter->
count());
1051 printf(
"+----------------------------------------------------------------+"
1052 "-------------+\n");
1055 delete counters_file_;
1056 delete counter_map_;
1062 static FILE* FOpen(
const char* path,
const char*
mode) {
1063 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))
1065 if (fopen_s(&result, path, mode) == 0) {
1071 FILE* file = fopen(path, mode);
1073 struct stat file_stat;
1074 if (fstat(fileno(file), &file_stat) != 0)
return NULL;
1075 bool is_regular_file = ((file_stat.st_mode & S_IFREG) != 0);
1076 if (is_regular_file)
return file;
1083 static char* ReadChars(Isolate* isolate,
const char* name,
int* size_out) {
1086 FILE* file = FOpen(name,
"rb");
1089 fseek(file, 0, SEEK_END);
1090 int size = ftell(file);
1093 char* chars =
new char[size + 1];
1095 for (
int i = 0; i <
size;) {
1096 int read =
static_cast<int>(fread(&chars[i], 1, size - i, file));
1111 static void ReadBufferWeakCallback(
1113 size_t byte_length = data.
GetValue()->ByteLength();
1114 data.
GetIsolate()->AdjustAmountOfExternalAllocatedMemory(
1115 -static_cast<intptr_t>(byte_length));
1124 ASSERT(
sizeof(
char) ==
sizeof(uint8_t));
1127 if (*filename ==
NULL) {
1128 Throw(args.
GetIsolate(),
"Error loading file");
1134 data->
data =
reinterpret_cast<uint8_t*
>(
1135 ReadChars(args.
GetIsolate(), *filename, &length));
1138 Throw(args.
GetIsolate(),
"Error reading file");
1143 data->
handle.Reset(isolate, buffer);
1144 data->
handle.SetWeak(data, ReadBufferWeakCallback);
1145 data->
handle.MarkIndependent();
1153 static char* ReadToken(
char* data,
char token) {
1164 static char* ReadLine(
char* data) {
1165 return ReadToken(data,
'\n');
1169 static char* ReadWord(
char* data) {
1170 return ReadToken(data,
' ');
1178 char* chars = ReadChars(isolate, name, &size);
1187 void Shell::RunShell(
Isolate* isolate) {
1197 console->
Open(isolate);
1213 : Thread(
"d8:ShellThread"),
1214 isolate_(isolate), files_(files) { }
1229 while ((ptr !=
NULL) && (*ptr !=
'\0')) {
1231 char* next_line = ReadLine(ptr);
1247 while ((ptr !=
NULL) && (*ptr !=
'\0')) {
1249 char* filename = ptr;
1250 ptr = ReadWord(ptr);
1253 if (strlen(filename) == 0) {
1259 printf(
"File '%s' not found\n", filename);
1282 bool exception_was_thrown =
false;
1283 for (
int i = begin_offset_; i < end_offset_; ++i) {
1284 const char* arg = argv_[i];
1285 if (strcmp(arg,
"-e") == 0 && i + 1 < end_offset_) {
1291 exception_was_thrown =
true;
1295 }
else if (arg[0] ==
'-') {
1303 printf(
"Error reading '%s'\n", arg);
1307 exception_was_thrown =
true;
1320 char* chars = ReadChars(isolate, name, &size);
1330 i::Thread::Options SourceGroup::GetThreadOptions() {
1335 return i::Thread::Options(
"IsolateThread", 2 *
MB);
1339 void SourceGroup::ExecuteInThread() {
1342 next_semaphore_.Wait();
1344 Isolate::Scope iscope(isolate);
1345 Locker lock(isolate);
1347 HandleScope scope(isolate);
1351 Context::Scope cscope(context);
1357 const int kLongIdlePauseInMs = 1000;
1362 done_semaphore_.Signal();
1369 if (thread_ ==
NULL) {
1370 thread_ =
new IsolateThread(
this);
1373 next_semaphore_.Signal();
1378 if (thread_ ==
NULL)
return;
1382 done_semaphore_.Wait();
1388 bool Shell::SetOptions(
int argc,
char* argv[]) {
1389 for (
int i = 0; i < argc; i++) {
1390 if (strcmp(argv[i],
"--stress-opt") == 0) {
1391 options.stress_opt =
true;
1393 }
else if (strcmp(argv[i],
"--nostress-opt") == 0) {
1394 options.stress_opt =
false;
1396 }
else if (strcmp(argv[i],
"--stress-deopt") == 0) {
1397 options.stress_deopt =
true;
1399 }
else if (strcmp(argv[i],
"--mock-arraybuffer-allocator") == 0) {
1400 options.mock_arraybuffer_allocator =
true;
1402 }
else if (strcmp(argv[i],
"--noalways-opt") == 0) {
1404 options.stress_opt =
false;
1405 options.stress_deopt =
false;
1406 }
else if (strcmp(argv[i],
"--shell") == 0) {
1407 options.interactive_shell =
true;
1409 }
else if (strcmp(argv[i],
"--test") == 0) {
1410 options.test_shell =
true;
1412 }
else if (strcmp(argv[i],
"--send-idle-notification") == 0) {
1413 options.send_idle_notification =
true;
1415 }
else if (strcmp(argv[i],
"-f") == 0) {
1419 }
else if (strcmp(argv[i],
"--isolate") == 0) {
1421 printf(
"D8 with shared library does not support multi-threading\n");
1424 options.num_isolates++;
1425 }
else if (strcmp(argv[i],
"-p") == 0) {
1427 printf(
"D8 with shared library does not support multi-threading\n");
1430 options.num_parallel_files++;
1432 }
else if (strcmp(argv[i],
"--dump-heap-constants") == 0) {
1434 printf(
"D8 with shared library does not support constant dumping\n");
1437 options.dump_heap_constants =
true;
1440 }
else if (strcmp(argv[i],
"--throws") == 0) {
1441 options.expected_to_throw =
true;
1443 }
else if (strncmp(argv[i],
"--icu-data-file=", 16) == 0) {
1444 options.icu_data_file = argv[i] + 16;
1448 else if (strcmp(argv[i],
"--dump-counters") == 0) {
1449 printf(
"D8 with shared library does not include counters\n");
1451 }
else if (strcmp(argv[i],
"--debugger") == 0) {
1452 printf(
"Javascript debugger not included\n");
1460 options.parallel_files =
new char*[options.num_parallel_files];
1461 int parallel_files_set = 0;
1462 for (
int i = 1; i < argc; i++) {
1463 if (argv[i] ==
NULL)
continue;
1464 if (strcmp(argv[i],
"-p") == 0 && i + 1 < argc) {
1465 if (options.num_isolates > 1) {
1466 printf(
"-p is not compatible with --isolate\n");
1471 options.parallel_files[parallel_files_set] = argv[i];
1472 parallel_files_set++;
1476 if (parallel_files_set != options.num_parallel_files) {
1477 printf(
"-p requires a file containing a list of files as parameter\n");
1485 options.isolate_sources =
new SourceGroup[options.num_isolates];
1486 SourceGroup* current = options.isolate_sources;
1487 current->Begin(argv, 1);
1488 for (
int i = 1; i < argc; i++) {
1489 const char* str = argv[i];
1490 if (strcmp(str,
"--isolate") == 0) {
1493 current->Begin(argv, i + 1);
1494 }
else if (strncmp(argv[i],
"--", 2) == 0) {
1495 printf(
"Warning: unknown flag %s.\nTry --help for options\n", argv[i]);
1507 if (options.parallel_files !=
NULL) {
1508 for (
int i = 0; i < options.num_parallel_files; i++) {
1512 files = ReadChars(isolate, options.parallel_files[i], &size);
1514 if (files ==
NULL) {
1515 printf(
"File list '%s' not found\n", options.parallel_files[i]);
1520 threads.
Add(thread);
1523 for (
int i = 1; i < options.num_isolates; ++i) {
1524 options.isolate_sources[i].StartExecuteInThread();
1532 if (options.last_run) {
1534 evaluation_context_.Reset(isolate, context);
1535 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
1538 if (i::FLAG_debugger) {
1539 InstallUtilityScript(isolate);
1541 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
1546 options.isolate_sources[0].Execute(isolate);
1549 if (!options.last_run) {
1550 if (options.send_idle_notification) {
1551 const int kLongIdlePauseInMs = 1000;
1559 for (
int i = 1; i < options.num_isolates; ++i) {
1560 options.isolate_sources[i].WaitForThread();
1563 for (
int i = 0; i < threads.length(); i++) {
1574 static void SetStandaloneFlagsViaCommandLine() {
1576 char **fake_argv =
new char*[3];
1577 fake_argv[0] =
NULL;
1578 fake_argv[1] = strdup(
"--trace-hydrogen-file=hydrogen.cfg");
1579 fake_argv[2] = strdup(
"--redirect-code-traces-to=code.asm");
1589 static void DumpHeapConstants(
i::Isolate* isolate) {
1593 printf(
"# List of known V8 instance types.\n");
1594 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T);
1595 printf(
"INSTANCE_TYPES = {\n");
1601 printf(
"\n# List of known V8 maps.\n");
1602 #define ROOT_LIST_CASE(type, name, camel_name) \
1603 if (n == NULL && o == heap->name()) n = #camel_name;
1604 #define STRUCT_LIST_CASE(upper_name, camel_name, name) \
1605 if (n == NULL && o == heap->name##_map()) n = #camel_name "Map";
1607 printf(
"KNOWN_MAPS = {\n");
1610 const char* n =
NULL;
1611 intptr_t p =
reinterpret_cast<intptr_t
>(m) & 0xfffff;
1615 if (n ==
NULL) continue;
1616 printf(" 0x%05"
V8PRIxPTR ": (%d, \"%s\"),\n", p, t, n);
1619 #undef STRUCT_LIST_CASE
1620 #undef ROOT_LIST_CASE
1623 printf(
"\n# List of known V8 objects.\n");
1624 #define ROOT_LIST_CASE(type, name, camel_name) \
1625 if (n == NULL && o == heap->name()) n = #camel_name;
1626 i::OldSpaces spit(heap);
1627 printf(
"KNOWN_OBJECTS = {\n");
1632 const char* n =
NULL;
1633 intptr_t p =
reinterpret_cast<intptr_t
>(o) & 0xfffff;
1635 if (n ==
NULL) continue;
1636 printf(" (\"%s\", 0x%05"
V8PRIxPTR "): \"%s\",\n", sname, p, n);
1640 #undef ROOT_LIST_CASE
1648 void* result = malloc(length);
1649 memset(result, 0, length);
1653 return malloc(length);
1655 virtual void Free(
void* data,
size_t) { free(data); }
1679 if (!SetOptions(argc, argv))
return 1;
1682 i::FLAG_trace_hydrogen_file =
"hydrogen.cfg";
1683 i::FLAG_redirect_code_traces_to =
"code.asm";
1685 SetStandaloneFlagsViaCommandLine();
1689 if (options.mock_arraybuffer_allocator) {
1699 i::CPU::NumberOfProcessorsOnline());
1704 Initialize(isolate);
1705 #ifdef ENABLE_VTUNE_JIT_INTERFACE
1706 vTune::InitializeVtuneForV8();
1709 InitializeDebugger(isolate);
1712 if (options.dump_heap_constants) {
1713 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate));
1718 if (options.stress_opt || options.stress_deopt) {
1723 for (
int i = 0; i < stress_runs && result == 0; i++) {
1724 printf(
"============ Stress %d/%d ============\n", i + 1, stress_runs);
1726 options.last_run = (i == stress_runs - 1);
1727 result =
RunMain(isolate, argc, argv);
1729 printf(
"======== Full Deoptimization =======\n");
1731 #if !defined(V8_SHARED)
1732 }
else if (i::FLAG_stress_runs > 0) {
1733 int stress_runs = i::FLAG_stress_runs;
1734 for (
int i = 0; i < stress_runs && result == 0; i++) {
1735 printf(
"============ Run %d/%d ============\n", i + 1, stress_runs);
1736 options.last_run = (i == stress_runs - 1);
1737 result =
RunMain(isolate, argc, argv);
1741 result =
RunMain(isolate, argc, argv);
1745 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
1747 if (i::FLAG_remote_debugger && !options.test_shell) {
1748 InstallUtilityScript(isolate);
1752 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
1757 if (( options.interactive_shell || !options.script_executed )
1758 && !options.test_shell ) {
1759 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
1760 if (!i::FLAG_debugger) {
1761 InstallUtilityScript(isolate);
1763 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
ShellThread(Isolate *isolate, char *files)
static Isolate * GetCurrent()
static void Exit(int exit_code)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
static V8_INLINE Local< T > New(Isolate *isolate, Handle< T > that)
static LineEditor * Get()
const char * ToCString(const v8::String::Utf8Value &value)
static int GetStressRuns()
#define INSTANCE_TYPE_LIST(V)
void SetSecurityToken(Handle< Value > token)
Local< Value > Exception() const
static void Read(const v8::FunctionCallbackInfo< v8::Value > &args)
V8_INLINE Isolate * GetIsolate() const
static void SetAddHistogramSampleFunction(AddHistogramSampleCallback)
Local< Value > Get(Handle< Value > key)
static Smi * FromInt(int value)
virtual void * AllocateUninitialized(size_t length)
static bool ExecuteString(Isolate *isolate, Handle< String > source, Handle< Value > name, bool print_result, bool report_exceptions)
static int Main(int argc, char *argv[])
static int GetIndex(const char *name)
static void AddHistogramSample(void *histogram, int sample)
void AddSample(int32_t sample)
V8_INLINE ReturnValue< T > GetReturnValue() const
static int RunMain(Isolate *isolate, int argc, char *argv[])
virtual void Free(void *data, size_t)
static Vector< const char > GetRawScriptSource(int index)
static Vector< const char > GetScriptName(int index)
Local< Context > GetEnteredContext()
V8_INLINE int Length() const
static Map * cast(Object *obj)
Handle< JSArray > NewJSArrayWithElements(Handle< FixedArrayBase > elements, ElementsKind elements_kind, int length, PretenureFlag pretenure=NOT_TENURED)
static Handle< Array > GetCompletions(Isolate *isolate, Handle< String > text, Handle< String > full)
static void ReportException(Isolate *isolate, TryCatch *try_catch)
V8_INLINE Local< T > GetValue() const
Counter * GetNextCounter()
V8_INLINE Local< T > Escape(Local< T > value)
int32_t * Bind(const char *name, bool histogram)
const char * AllocationSpaceName(AllocationSpace space)
#define ASSERT(condition)
static Script * cast(Object *obj)
void Quit(const v8::FunctionCallbackInfo< v8::Value > &args)
virtual void * AllocateUninitialized(size_t length) V8_OVERRIDE
static void RealmCurrent(const v8::FunctionCallbackInfo< v8::Value > &args)
int main(int argc, char *argv[])
static const int kMaxNameSize
void SetVerbose(bool value)
void Read(const v8::FunctionCallbackInfo< v8::Value > &args)
static void RealmSharedGet(Local< String > property, const PropertyCallbackInfo< Value > &info)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage message
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object size
static Local< UnboundScript > CompileUnbound(Isolate *isolate, Source *source, CompileOptions options=kNoCompileOptions)
static void Version(const v8::FunctionCallbackInfo< v8::Value > &args)
void RunRemoteDebugger(Isolate *isolate, int port)
static const char * GetVersion()
static Local< Context > CreateEvaluationContext(Isolate *isolate)
static ShellOptions options
Handle< String > NewStringFromUtf8(Vector< const char > str, PretenureFlag pretenure=NOT_TENURED)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable memory(in Mbytes)") DEFINE_bool(gc_global
static void Quit(const v8::FunctionCallbackInfo< v8::Value > &args)
static void SetArrayBufferAllocator(ArrayBuffer::Allocator *allocator)
LineEditor(Type type, const char *name)
RealmScope(PerIsolateData *data)
static Local< ObjectTemplate > New()
V8_INLINE Isolate * GetIsolate() const
static Handle< String > ReadFile(Isolate *isolate, const char *name)
virtual void Free(void *data)
void HandleDebugEvent(const Debug::EventDetails &event_details)
static void Print(const v8::FunctionCallbackInfo< v8::Value > &args)
Handle< Value > ReThrow()
V8_INLINE Isolate * GetIsolate() const
bool V8_EXPORT SetResourceConstraints(Isolate *isolate, ResourceConstraints *constraints)
static const char * ToCString(const v8::String::Utf8Value &value)
Vector< const char > ReadFile(const char *filename, bool *exists, bool verbose)
static void RealmGlobal(const v8::FunctionCallbackInfo< v8::Value > &args)
static int ContextDisposedNotification()
static Local< FunctionTemplate > New(Isolate *isolate, FunctionCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >(), int length=0)
V8_INLINE void SetData(uint32_t slot, void *data)
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *script_data=NULL)
void Version(const v8::FunctionCallbackInfo< v8::Value > &args)
static V8_INLINE Handle< T > Cast(Handle< S > that)
static Local< ArrayBuffer > New(Isolate *isolate, size_t byte_length)
Handle< FixedArray > NewFixedArray(int size, PretenureFlag pretenure=NOT_TENURED)
V8_INLINE ReturnValue< T > GetReturnValue() const
static void SetStressRunType(StressType type)
bool operator<(const CounterAndKey &lhs, const CounterAndKey &rhs)
static const char * kPrompt
void Execute(Isolate *isolate)
#define ROOT_LIST_CASE(type, name, camel_name)
v8::Handle< v8::ObjectTemplate > CreateGlobalTemplate(v8::Isolate *isolate, v8::FunctionCallback terminate, v8::FunctionCallback doloop)
static bool EnableAgent(const char *name, int port, bool wait_for_connection=false)
Persistent< ArrayBuffer > handle
static void * CreateHistogram(const char *name, int min, int max, size_t buckets)
virtual void * Allocate(size_t length)
V8_INLINE bool IsUndefined() const
static void RealmCreate(const v8::FunctionCallbackInfo< v8::Value > &args)
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
V8_INLINE Handle< Primitive > Undefined(Isolate *isolate)
static V8_INLINE Local< T > Cast(Local< S > that)
Vector< const char > CStrVector(const char *data)
V8_INLINE P * GetParameter() const
int StrLength(const char *string)
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
virtual void * Allocate(size_t) V8_OVERRIDE
static Local< Context > New(Isolate *isolate, ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
Local< Value > StackTrace() const
void Load(const v8::FunctionCallbackInfo< v8::Value > &args)
virtual void Free(void *, size_t) V8_OVERRIDE
virtual Handle< String > Prompt(const char *prompt)=0
static void RealmSharedSet(Local< String > property, Local< Value > value, const PropertyCallbackInfo< void > &info)
static void SetDebugMessageDispatchHandler(DebugMessageDispatchHandler handler, bool provide_locker=false)
V8_INLINE bool IsEmpty() const
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
static void RealmEval(const v8::FunctionCallbackInfo< v8::Value > &args)
static PerIsolateData * Get(Isolate *isolate)
static bool SetDebugEventListener2(EventCallback2 that, Handle< Value > data=Handle< Value >())
V8_INLINE void * GetData(uint32_t slot)
static void Load(const v8::FunctionCallbackInfo< v8::Value > &args)
virtual bool Open(Isolate *isolate)
static bool InitializeICU(const char *icu_data_file=NULL)
static void RealmSwitch(const v8::FunctionCallbackInfo< v8::Value > &args)
#define ASSERT_EQ(v1, v2)
InstanceType instance_type()
DumbLineEditor(Isolate *isolate)
static void MapCounters(const char *name)
static void PrepareStressRun(int run)
static void SetCreateHistogramFunction(CreateHistogramCallback)
int RunMain(int argc, char *argv[])
void Print(const v8::FunctionCallbackInfo< v8::Value > &args)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
static Local< String > Concat(Handle< String > left, Handle< String > right)
bool ExecuteString(v8::Isolate *isolate, v8::Handle< v8::String > source, v8::Handle< v8::Value > name, bool print_result, bool report_exceptions)
int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes)
static void RealmDispose(const v8::FunctionCallbackInfo< v8::Value > &args)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_string(expose_natives_as
static void Write(const v8::FunctionCallbackInfo< v8::Value > &args)
#define STRUCT_LIST_CASE(upper_name, camel_name, name)
static void SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
static void ReadBuffer(const v8::FunctionCallbackInfo< v8::Value > &args)
static int * LookupCounter(const char *name)
void ConfigureDefaults(uint64_t physical_memory, uint32_t number_of_processors)
PerIsolateData(Isolate *isolate)
static StartupData::CompressionAlgorithm GetCompressedStartupDataAlgorithm()
static Handle< String > ReadFromStdin(Isolate *isolate)
static void DeoptimizeAll()
static void PerformanceNow(const v8::FunctionCallbackInfo< v8::Value > &args)
static void ProcessDebugMessages()
void RunShell(v8::Handle< v8::Context > context)
Local< v8::Message > Message() const
void StartExecuteInThread()
virtual Handle< String > Prompt(const char *prompt)
static void RealmOwner(const v8::FunctionCallbackInfo< v8::Value > &args)
static char * StrChr(char *str, int c)
static void SetCounterFunction(CounterLookupCallback)
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)
static bool IdleNotification(int hint=1000)
static JSFunction * cast(Object *obj)
static uint64_t TotalPhysicalMemory()