30 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
34 #ifdef COMPRESS_STARTUP_DATA_BZ2
45 #include "../include/v8-testing.h"
60 #if !defined(_WIN32) && !defined(_WIN64)
65 #define ASSERT(condition) assert(condition)
70 LineEditor *LineEditor::first_ =
NULL;
84 while (current !=
NULL) {
85 if (current->type_ > best->type_)
87 current = current->next_;
100 static DumbLineEditor dumb_line_editor;
104 printf(
"%s", prompt);
111 i::OS::MemoryMappedFile* Shell::counters_file_ =
NULL;
124 const int MB = 1024 * 1024;
128 bool CounterMap::Match(
void* key1,
void* key2) {
129 const char* name1 =
reinterpret_cast<const char*
>(key1);
130 const char* name2 =
reinterpret_cast<const char*
>(key2);
131 return strcmp(name1, name2) == 0;
138 return *value ? *value :
"<string conversion failed>";
146 bool report_exceptions) {
147 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
148 bool FLAG_debugger = i::FLAG_debugger;
150 bool FLAG_debugger =
false;
151 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
162 if (report_exceptions && !FLAG_debugger)
170 if (report_exceptions && !FLAG_debugger)
179 size_t count = fwrite(*str,
sizeof(**str), str.
length(), stdout);
198 for (
int i = 0; i < args.
Length(); i++) {
210 int n =
static_cast<int>(fwrite(*str,
sizeof(**str), str.
length(), stdout));
212 printf(
"Error in fwrite\n");
246 static const int kBufferSize = 256;
247 char buffer[kBufferSize];
257 input = fgets(buffer, kBufferSize, stdin);
260 length =
static_cast<int>(strlen(buffer));
263 }
else if (buffer[length-1] !=
'\n') {
265 }
else if (length > 1 && buffer[length-2] ==
'\\') {
266 buffer[length-2] =
'\n';
276 for (
int i = 0; i < args.
Length(); i++) {
298 Local<Value> number = value_in->
ToNumber();
301 ASSERT(number->IsNumber());
302 Local<Int32> int32 = number->ToInt32();
303 if (try_catch->
HasCaught() || int32.IsEmpty())
return 0;
305 int32_t value = int32->Int32Value();
312 static int32_t convertToUint(Local<Value> value_in, TryCatch* try_catch) {
313 int32_t raw_value = convertToInt(value_in, try_catch);
314 if (try_catch->HasCaught())
return 0;
321 static const int kMaxLength = 0x3fffffff;
325 if (raw_value > static_cast<int32_t>(kMaxLength)) {
327 String::New(
"Array length exceeds maximum length."));
341 static const int32_t kMaxSize = 0x7fffffff;
343 if (length < 0 || length > kMaxSize) {
346 uint8_t* data =
new uint8_t[length];
350 memset(data, 0, length);
354 persistent_array.
MakeWeak(data, ExternalArrayWeakCallback);
358 buffer->SetIndexedPropertiesToExternalArrayData(
369 for (
int i = 0; i < args.
Length(); ++i) rec_args[i] = args[i];
377 String::New(
"ArrayBuffer constructor must have one argument"));
380 int32_t length = convertToUint(args[0], &try_catch);
383 return CreateExternalArrayBuffer(args.
This(), length);
394 ASSERT(element_size == 1 || element_size == 2 ||
395 element_size == 4 || element_size == 8);
396 ASSERT(byteLength == length * element_size);
398 void* data = buffer->GetIndexedPropertiesExternalArrayData();
401 array->SetIndexedPropertiesToExternalArrayData(
402 static_cast<uint8_t*>(data) + byteOffset, type, length);
414 Handle<Value> Shell::CreateExternalArray(
const Arguments& args,
417 if (!args.IsConstructCall()) {
418 Handle<Value>* rec_args =
new Handle<Value>[args.Length()];
419 for (
int i = 0; i < args.Length(); ++i) rec_args[i] = args[i];
420 Handle<Value> result = args.Callee()->NewInstance(args.Length(), rec_args);
426 ASSERT(element_size == 1 || element_size == 2 ||
427 element_size == 4 || element_size == 8);
436 Handle<Object> buffer;
440 bool init_from_array =
false;
441 if (args.Length() == 0) {
443 String::New(
"Array constructor must have at least one argument"));
445 if (args[0]->IsObject() &&
446 !args[0]->ToObject()->GetHiddenValue(
449 buffer = args[0]->ToObject();
451 convertToUint(buffer->Get(
String::New(
"byteLength")), &try_catch);
452 if (try_catch.HasCaught())
return try_catch.ReThrow();
454 if (args.Length() < 2 || args[1]->IsUndefined()) {
457 byteOffset = convertToUint(args[1], &try_catch);
458 if (try_catch.HasCaught())
return try_catch.ReThrow();
459 if (byteOffset > bufferLength) {
462 if (byteOffset % element_size != 0) {
464 String::New(
"byteOffset must be multiple of element size"));
468 if (args.Length() < 3 || args[2]->IsUndefined()) {
469 byteLength = bufferLength - byteOffset;
470 length = byteLength / element_size;
471 if (byteLength % element_size != 0) {
473 String::New(
"buffer size must be multiple of element size"));
476 length = convertToUint(args[2], &try_catch);
477 if (try_catch.HasCaught())
return try_catch.ReThrow();
478 byteLength = length * element_size;
479 if (byteOffset + byteLength > bufferLength) {
484 if (args[0]->IsObject() &&
487 length = convertToUint(
488 args[0]->ToObject()->Get(
String::New(
"length")), &try_catch);
489 if (try_catch.HasCaught())
return try_catch.ReThrow();
490 init_from_array =
true;
493 length = convertToUint(args[0], &try_catch);
494 if (try_catch.HasCaught())
return try_catch.ReThrow();
496 byteLength = length * element_size;
500 Handle<Value> array_buffer = global->Get(
String::New(
"ArrayBuffer"));
501 ASSERT(!try_catch.HasCaught() && array_buffer->IsFunction());
502 Handle<Value> buffer_args[] = {
Uint32::New(byteLength) };
505 if (try_catch.HasCaught())
return result;
506 buffer = result->ToObject();
509 Handle<Object> array = CreateExternalArray(
510 args.This(), buffer, type, length, byteLength, byteOffset, element_size);
512 if (init_from_array) {
513 Handle<Object> init = args[0]->
ToObject();
514 for (
int i = 0; i < length; ++i) array->Set(i, init->Get(i));
524 if (!args.
This()->IsObject()) {
526 String::New(
"'slice' invoked on non-object receiver"));
534 String::New(
"'slice' invoked on wrong receiver type"));
538 convertToUint(self->Get(
String::New(
"byteLength")), &try_catch);
543 String::New(
"'slice' must have at least one argument"));
545 int32_t begin = convertToInt(args[0], &try_catch);
547 if (begin < 0) begin += length;
548 if (begin < 0) begin = 0;
549 if (begin > length) begin = length;
552 if (args.
Length() < 2 || args[1]->IsUndefined()) {
555 end = convertToInt(args[1], &try_catch);
557 if (end < 0) end += length;
558 if (end < 0) end = 0;
559 if (end > length) end = length;
560 if (end < begin) end = begin;
565 Handle<Value> result = constructor->NewInstance(1, new_args);
566 if (try_catch.
HasCaught())
return result;
569 static_cast<uint8_t*
>(buffer->GetIndexedPropertiesExternalArrayData());
570 uint8_t* src = begin +
static_cast<uint8_t*
>(
571 self->GetIndexedPropertiesExternalArrayData());
572 memcpy(dest, src, end - begin);
581 if (!args.
This()->IsObject()) {
583 String::New(
"'subarray' invoked on non-object receiver"));
590 String::New(
"'subarray' invoked on wrong receiver type"));
596 convertToUint(self->Get(
String::New(
"length")), &try_catch);
599 convertToUint(self->Get(
String::New(
"byteOffset")), &try_catch);
602 convertToUint(self->Get(
String::New(
"BYTES_PER_ELEMENT")), &try_catch);
607 String::New(
"'subarray' must have at least one argument"));
609 int32_t begin = convertToInt(args[0], &try_catch);
611 if (begin < 0) begin += length;
612 if (begin < 0) begin = 0;
613 if (begin > length) begin = length;
616 if (args.
Length() < 2 || args[1]->IsUndefined()) {
619 end = convertToInt(args[1], &try_catch);
621 if (end < 0) end += length;
622 if (end < 0) end = 0;
623 if (end > length) end = length;
624 if (end < begin) end = begin;
627 length = end - begin;
628 byteOffset += begin * element_size;
634 return constructor->NewInstance(3, construct_args);
641 if (!args.
This()->IsObject()) {
643 String::New(
"'set' invoked on non-object receiver"));
650 String::New(
"'set' invoked on wrong receiver type"));
653 convertToUint(self->Get(
String::New(
"length")), &try_catch);
656 convertToUint(self->Get(
String::New(
"BYTES_PER_ELEMENT")), &try_catch);
661 String::New(
"'set' must have at least one argument"));
663 if (!args[0]->IsObject() ||
664 !args[0]->ToObject()->Has(
String::New(
"length"))) {
666 String::New(
"'set' invoked with non-array argument"));
670 convertToUint(source->Get(
String::New(
"length")), &try_catch);
674 if (args.
Length() < 2 || args[1]->IsUndefined()) {
677 offset = convertToUint(args[1], &try_catch);
680 if (offset + source_length > length) {
686 source_element_size = 0;
688 source_element_size =
689 convertToUint(source->Get(
String::New(
"BYTES_PER_ELEMENT")), &try_catch);
693 if (element_size == source_element_size &&
694 self->GetConstructor()->StrictEquals(source->GetConstructor())) {
702 convertToUint(self->Get(
String::New(
"byteOffset")), &try_catch);
705 convertToUint(source->Get(
String::New(
"byteOffset")), &try_catch);
708 uint8_t* dest = byteOffset + offset * element_size +
static_cast<uint8_t*
>(
709 buffer->GetIndexedPropertiesExternalArrayData());
710 uint8_t* src = source_byteOffset +
static_cast<uint8_t*
>(
711 source_buffer->GetIndexedPropertiesExternalArrayData());
712 memmove(dest, src, source_length * element_size);
713 }
else if (source_element_size == 0) {
715 for (
int i = 0; i < source_length; ++i) {
716 self->Set(offset + i, source->Get(i));
727 if (buffer->StrictEquals(source_buffer)) {
732 convertToUint(self->Get(
String::New(
"byteOffset")), &try_catch);
735 convertToUint(source->Get(
String::New(
"byteOffset")), &try_catch);
740 int32_t next_dest_offset = byteOffset + (offset + 1) * element_size;
741 int32_t next_src_offset = source_byteOffset + source_element_size;
742 while (i < length && next_dest_offset <= next_src_offset) {
743 self->Set(offset + i, source->Get(i));
745 next_dest_offset += element_size;
746 next_src_offset += source_element_size;
750 int32_t dest_offset = byteOffset + (offset + j) * element_size;
751 int32_t src_offset = source_byteOffset + j * source_element_size;
752 while (j >= i && dest_offset >= src_offset) {
753 self->Set(offset + j, source->Get(j));
755 dest_offset -= element_size;
756 src_offset -= source_element_size;
762 for (
int k = i; k <= j; ++k) {
763 temp[k - i] = source->Get(k);
765 for (
int k = i; k <= j; ++k) {
766 self->Set(offset + k, temp[k - i]);
770 for (
int i = 0; i < source_length; ++i)
771 self->Set(offset + i, source->Get(i));
782 object->ToObject()->Get(
String::New(
"byteLength"))->Uint32Value();
784 delete[]
static_cast<uint8_t*
>(data);
805 return CreateExternalArray(
821 return CreateExternalArray(
827 return CreateExternalArray(
844 int exit_code = args[0]->Int32Value();
860 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
862 if (enter_context) utility_context_->Enter();
863 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
865 const char* exception_string =
ToCString(exception);
870 printf(
"%s\n", exception_string);
874 const char* filename_string =
ToCString(filename);
875 int linenum = message->GetLineNumber();
876 printf(
"%s:%i: %s\n", filename_string, linenum, exception_string);
879 const char* sourceline_string =
ToCString(sourceline);
880 printf(
"%s\n", sourceline_string);
882 int start = message->GetStartColumn();
883 for (
int i = 0; i < start; i++) {
886 int end = message->GetEndColumn();
887 for (
int i = start; i < end; i++) {
892 if (stack_trace.length() > 0) {
893 const char* stack_trace_string =
ToCString(stack_trace);
894 printf(
"%s\n", stack_trace_string);
898 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
899 if (enter_context) utility_context_->Exit();
900 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
910 static const int kArgc = 3;
911 Handle<Value> argv[kArgc] = { evaluation_context_->Global(), text, full };
917 #ifdef ENABLE_DEBUGGER_SUPPORT
922 static const int kArgc = 1;
929 Handle<Value> Shell::DebugCommandToJSONRequest(Handle<String> command) {
930 Context::Scope context_scope(utility_context_);
931 Handle<Object> global = utility_context_->Global();
932 Handle<Value> fun = global->Get(
String::New(
"DebugCommandToJSONRequest"));
933 static const int kArgc = 1;
934 Handle<Value> argv[kArgc] = { command };
940 void Shell::DispatchDebugMessages() {
944 #endif // ENABLE_DEBUGGER_SUPPORT
952 name_[i] = static_cast<char>(name[i]);
966 magic_number_ = 0xDEADFACE;
967 max_counters_ = kMaxCounters;
969 counters_in_use_ = 0;
974 if (counters_in_use_ == kMaxCounters)
return NULL;
975 return &counters_[counters_in_use_++];
980 counters_file_ = i::OS::MemoryMappedFile::create(
983 NULL : counters_file_->memory();
984 if (memory ==
NULL) {
985 printf(
"Could not map counters file %s\n", name);
995 int CounterMap::Hash(
const char* name) {
998 while ((c = *name++) != 0) {
1006 Counter* Shell::GetCounter(
const char* name,
bool is_histogram) {
1009 if (counter ==
NULL) {
1011 if (counter !=
NULL) {
1012 counter_map_->
Set(name, counter);
1013 counter->
Bind(name, is_histogram);
1016 ASSERT(counter->is_histogram() == is_histogram);
1023 Counter* counter = GetCounter(name,
false);
1025 if (counter !=
NULL) {
1026 return counter->
ptr();
1037 return GetCounter(name,
true);
1047 void Shell::InstallUtilityScript() {
1052 utility_context_->SetSecurityToken(
Undefined());
1053 evaluation_context_->SetSecurityToken(
Undefined());
1056 #ifdef ENABLE_DEBUGGER_SUPPORT
1057 if (i::FLAG_debugger) printf(
"JavaScript debugger enabled\n");
1059 i::Debug* debug = i::Isolate::Current()->debug();
1063 utility_context_->Global()->Set(
String::New(
"$debug"),
1065 debug->debug_context()->set_security_token(
HEAP->undefined_value());
1066 #endif // ENABLE_DEBUGGER_SUPPORT
1077 shell_source_name.
length());
1087 i::SharedFunctionInfo::cast(*compiled_script)->script()));
1090 #ifdef ENABLE_DEBUGGER_SUPPORT
1092 if (i::FLAG_debugger && !i::FLAG_debugger_agent) {
1095 #endif // ENABLE_DEBUGGER_SUPPORT
1100 #ifdef COMPRESS_STARTUP_DATA_BZ2
1103 virtual ~BZip2Decompressor() { }
1106 virtual int DecompressData(
char* raw_data,
1108 const char* compressed_data,
1109 int compressed_data_size) {
1112 unsigned int decompressed_size = *raw_data_size;
1114 BZ2_bzBuffToBuffDecompress(raw_data,
1116 const_cast<char*>(compressed_data),
1117 compressed_data_size,
1119 if (result == BZ_OK) {
1120 *raw_data_size = decompressed_size;
1128 Handle<FunctionTemplate> Shell::CreateArrayBufferTemplate(
1131 Local<Template> proto_template = buffer_template->PrototypeTemplate();
1134 return buffer_template;
1140 Local<Template> proto_template = array_template->PrototypeTemplate();
1144 return array_template;
1148 Handle<ObjectTemplate> Shell::CreateGlobalTemplate() {
1160 global_template->Set(
String::New(
"enableProfiler"),
1162 global_template->Set(
String::New(
"disableProfiler"),
1186 global_template->Set(
String::New(
"Uint8ClampedArray"),
1189 #ifdef LIVE_OBJECT_LIST
1195 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64)
1198 global_template->Set(
String::New(
"os"), os_templ);
1201 return global_template;
1205 void Shell::Initialize() {
1206 #ifdef COMPRESS_STARTUP_DATA_BZ2
1207 BZip2Decompressor startup_data_decompressor;
1208 int bz2_result = startup_data_decompressor.Decompress();
1209 if (bz2_result != BZ_OK) {
1210 fprintf(stderr,
"bzip error code: %d\n", bz2_result);
1216 Shell::counter_map_ =
new CounterMap();
1220 if (i::FLAG_dump_counters || i::FLAG_track_gc_object_stats) {
1231 Handle<ObjectTemplate> global_template = CreateGlobalTemplate();
1234 #ifdef ENABLE_DEBUGGER_SUPPORT
1236 if (i::FLAG_debugger_agent) {
1240 #endif // ENABLE_DEBUGGER_SUPPORT
1260 for (
int j = 0; j < js_args.
argc(); j++) {
1263 arguments_array->set(j, *arg);
1266 FACTORY->NewJSArrayWithElements(arguments_array);
1291 return strcmp(static_cast<const CounterAndKey*>(a)->key,
1292 static_cast<const CounterAndKey*>(b)->key);
1298 if (i::FLAG_dump_counters) {
1299 int number_of_counters = 0;
1301 number_of_counters++;
1306 counters[j].
counter = i.CurrentValue();
1307 counters[j].
key = i.CurrentKey();
1309 qsort(counters, number_of_counters,
sizeof(counters[0]),
CompareKeys);
1310 printf(
"+----------------------------------------------------------------+"
1311 "-------------+\n");
1314 printf(
"+----------------------------------------------------------------+"
1315 "-------------+\n");
1316 for (j = 0; j < number_of_counters; j++) {
1318 const char* key = counters[j].
key;
1320 printf(
"| c:%-60s | %11i |\n", key, counter->
count());
1321 printf(
"| t:%-60s | %11i |\n", key, counter->
sample_total());
1323 printf(
"| %-62s | %11i |\n", key, counter->
count());
1326 printf(
"+----------------------------------------------------------------+"
1327 "-------------+\n");
1330 delete counters_file_;
1331 delete counter_map_;
1336 static FILE* FOpen(
const char* path,
const char* mode) {
1337 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))
1339 if (fopen_s(&result, path, mode) == 0) {
1345 FILE* file = fopen(path, mode);
1347 struct stat file_stat;
1348 if (fstat(fileno(file), &file_stat) != 0)
return NULL;
1349 bool is_regular_file = ((file_stat.st_mode & S_IFREG) != 0);
1350 if (is_regular_file)
return file;
1357 static char* ReadChars(
const char* name,
int* size_out) {
1360 FILE* file = FOpen(name,
"rb");
1363 fseek(file, 0, SEEK_END);
1364 int size = ftell(file);
1367 char* chars =
new char[size + 1];
1369 for (
int i = 0; i < size;) {
1370 int read =
static_cast<int>(fread(&chars[i], 1, size - i, file));
1380 ASSERT(
sizeof(
char) ==
sizeof(uint8_t));
1383 if (*filename ==
NULL) {
1387 uint8_t* data =
reinterpret_cast<uint8_t*
>(ReadChars(*filename, &length));
1394 persistent_buffer.
MakeWeak(data, ExternalArrayWeakCallback);
1398 buffer->SetIndexedPropertiesToExternalArrayData(
1407 static char* ReadToken(
char* data,
char token) {
1418 static char* ReadLine(
char* data) {
1419 return ReadToken(data,
'\n');
1423 static char* ReadWord(
char* data) {
1424 return ReadToken(data,
' ');
1432 char* chars = ReadChars(name, &size);
1463 :
Thread(
"d8:ShellThread"),
1464 no_(no), files_(files) { }
1479 while ((ptr !=
NULL) && (*ptr !=
'\0')) {
1481 char* next_line = ReadLine(ptr);
1495 while ((ptr !=
NULL) && (*ptr !=
'\0')) {
1497 char* filename = ptr;
1498 ptr = ReadWord(ptr);
1501 if (strlen(filename) == 0) {
1507 printf(
"File '%s' not found\n", filename);
1523 delete next_semaphore_;
1524 next_semaphore_ =
NULL;
1525 delete done_semaphore_;
1526 done_semaphore_ =
NULL;
1534 for (
int i = begin_offset_; i < end_offset_; ++i) {
1535 const char* arg = argv_[i];
1536 if (strcmp(arg,
"-e") == 0 && i + 1 < end_offset_) {
1545 }
else if (arg[0] ==
'-') {
1553 printf(
"Error reading '%s'\n", arg);
1566 char* chars = ReadChars(name, &size);
1575 i::Thread::Options SourceGroup::GetThreadOptions() {
1580 return i::Thread::Options(
"IsolateThread", 2 *
MB);
1584 void SourceGroup::ExecuteInThread() {
1587 if (next_semaphore_ !=
NULL) next_semaphore_->
Wait();
1589 Isolate::Scope iscope(isolate);
1590 Locker lock(isolate);
1594 Context::Scope cscope(context);
1599 const int kLongIdlePauseInMs = 1000;
1604 if (done_semaphore_ !=
NULL) done_semaphore_->
Signal();
1611 if (thread_ ==
NULL) {
1612 thread_ =
new IsolateThread(
this);
1615 next_semaphore_->
Signal();
1620 if (thread_ ==
NULL)
return;
1624 done_semaphore_->
Wait();
1630 bool Shell::SetOptions(
int argc,
char* argv[]) {
1631 for (
int i = 0; i < argc; i++) {
1632 if (strcmp(argv[i],
"--stress-opt") == 0) {
1635 }
else if (strcmp(argv[i],
"--stress-deopt") == 0) {
1638 }
else if (strcmp(argv[i],
"--noalways-opt") == 0) {
1642 }
else if (strcmp(argv[i],
"--shell") == 0) {
1645 }
else if (strcmp(argv[i],
"--test") == 0) {
1648 }
else if (strcmp(argv[i],
"--send-idle-notification") == 0) {
1651 }
else if (strcmp(argv[i],
"--preemption") == 0) {
1653 printf(
"D8 with shared library does not support multi-threading\n");
1659 }
else if (strcmp(argv[i],
"--nopreemption") == 0) {
1661 printf(
"D8 with shared library does not support multi-threading\n");
1667 }
else if (strcmp(argv[i],
"--preemption-interval") == 0) {
1669 printf(
"D8 with shared library does not support multi-threading\n");
1678 || errno == ERANGE) {
1679 printf(
"Invalid value for --preemption-interval '%s'\n", argv[i]);
1684 printf(
"Missing value for --preemption-interval\n");
1688 }
else if (strcmp(argv[i],
"-f") == 0) {
1692 }
else if (strcmp(argv[i],
"--isolate") == 0) {
1694 printf(
"D8 with shared library does not support multi-threading\n");
1698 }
else if (strcmp(argv[i],
"-p") == 0) {
1700 printf(
"D8 with shared library does not support multi-threading\n");
1707 else if (strcmp(argv[i],
"--dump-counters") == 0) {
1708 printf(
"D8 with shared library does not include counters\n");
1710 }
else if (strcmp(argv[i],
"--debugger") == 0) {
1711 printf(
"Javascript debugger not included\n");
1720 int parallel_files_set = 0;
1721 for (
int i = 1; i < argc; i++) {
1722 if (argv[i] ==
NULL)
continue;
1723 if (strcmp(argv[i],
"-p") == 0 && i + 1 < argc) {
1725 printf(
"-p is not compatible with --isolate\n");
1731 parallel_files_set++;
1736 printf(
"-p requires a file containing a list of files as parameter\n");
1746 current->
Begin(argv, 1);
1747 for (
int i = 1; i < argc; i++) {
1748 const char* str = argv[i];
1749 if (strcmp(str,
"--isolate") == 0) {
1752 current->Begin(argv, i + 1);
1753 }
else if (strncmp(argv[i],
"--", 2) == 0) {
1754 printf(
"Warning: unknown flag %s.\nTry --help for options\n", argv[i]);
1773 if (files ==
NULL) {
1779 threads.
Add(thread);
1792 evaluation_context_ = context;
1793 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
1796 if (i::FLAG_debugger) {
1797 InstallUtilityScript();
1799 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
1808 const int kLongIdlePauseInMs = 1000;
1816 if (threads.length() > 0
1828 for (
int i = 0; i < threads.length(); i++) {
1844 if (!SetOptions(argc, argv))
return 1;
1853 for (
int i = 0; i < stress_runs && result == 0; i++) {
1854 printf(
"============ Stress %d/%d ============\n", i + 1, stress_runs);
1859 printf(
"======== Full Deoptimization =======\n");
1861 #if !defined(V8_SHARED)
1862 }
else if (i::FLAG_stress_runs > 0) {
1863 int stress_runs = i::FLAG_stress_runs;
1864 for (
int i = 0; i < stress_runs && result == 0; i++) {
1865 printf(
"============ Run %d/%d ============\n", i + 1, stress_runs);
1875 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
1878 InstallUtilityScript();
1882 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
1890 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
1891 if (!i::FLAG_debugger) {
1892 InstallUtilityScript();
1894 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
static Local< Context > GetCurrent()
static Isolate * GetCurrent()
static void Exit(int exit_code)
void MakeWeak(void *parameters, WeakReferenceCallback callback)
static Handle< Array > GetCompletions(Handle< String > text, Handle< String > full)
void Set(const char *name, Counter *value)
static Local< Script > Compile(Handle< String > source, ScriptOrigin *origin=NULL, ScriptData *pre_data=NULL, Handle< String > script_data=Handle< String >())
void RunRemoteDebugger(int port)
static const int kMaxLength
static Local< FunctionTemplate > New(InvocationCallback callback=0, Handle< Value > data=Handle< Value >(), Handle< Signature > signature=Handle< Signature >())
Handle< Boolean > V8EXPORT True()
static int GetStressRuns()
Thread(const Options &options)
Local< Value > Exception() const
static Handle< Value > ArrayBufferSlice(const Arguments &args)
static void SetAddHistogramSampleFunction(AddHistogramSampleCallback)
static Handle< Value > Version(const Arguments &args)
static Smi * FromInt(int value)
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)
static Handle< Value > Int32Array(const Arguments &args)
static Handle< Value > Float32Array(const Arguments &args)
static Vector< const char > GetRawScriptSource(int index)
static Vector< const char > GetScriptName(int index)
static V8EXPORT Local< String > New(const char *data, int length=-1)
Local< Function > Callee() const
static Handle< Value > ReadLine(const Arguments &args)
static void AddOSMethods(Handle< ObjectTemplate > os_template)
static LineEditor * Get()
static Handle< T > Cast(Handle< S > that)
MUST_USE_RESULT MaybeObject * ToObject()
Counter * GetNextCounter()
int32_t * Bind(const char *name, bool histogram)
#define ASSERT(condition)
V8EXPORT Local< Number > ToNumber() const
static Handle< Value > Int16Array(const Arguments &args)
static Script * cast(Object *obj)
const char kArrayMarkerPropName[]
int main(int argc, char *argv[])
static const int kMaxNameSize
static intptr_t AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes)
void SetVerbose(bool value)
int32_t * Bind(const char *name)
static Handle< Value > Uint16Array(const Arguments &args)
ShellThread(int no, char *files)
static LineEditor * console
static const char * GetVersion()
static ShellOptions options
LineEditor(Type type, const char *name)
static bool SetDebugEventListener(EventCallback that, Handle< Value > data=Handle< Value >())
Handle< Value >(* InvocationCallback)(const Arguments &args)
static Local< ObjectTemplate > New()
static Handle< Value > ArrayBuffer(const Arguments &args)
Handle< Value > ReThrow()
static Handle< Value > EnableProfiler(const Arguments &args)
static const char * ToCString(const v8::String::Utf8Value &value)
static Handle< Value > DisableProfiler(const Arguments &args)
static void ResumeProfiler()
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit 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 SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available 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 MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting 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 more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage message
static int ContextDisposedNotification()
V8EXPORT int32_t Int32Value() const
static Handle< Value > Read(const Arguments &args)
SourceGroup * isolate_sources
static void SetStressRunType(StressType type)
static Mutex * CreateMutex()
static const char * kPrompt
static Persistent< T > New(Handle< T > that)
static Handle< Value > ArraySet(const Arguments &args)
int CompareKeys(const void *a, const void *b)
static bool EnableAgent(const char *name, int port, bool wait_for_connection=false)
static void * CreateHistogram(const char *name, int min, int max, size_t buckets)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit 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 SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available 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 MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting 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
Handle< Boolean > V8EXPORT False()
static Handle< Value > Int8Array(const Arguments &args)
Vector< const char > CStrVector(const char *data)
int StrLength(const char *string)
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
Local< Object > This() const
static Local< T > Cast(Local< S > that)
static Handle< Value > Write(const Arguments &args)
Local< Value > StackTrace() const
static Handle< Value > Load(const Arguments &args)
Counter * Lookup(const char *name)
virtual Handle< String > Prompt(const char *prompt)=0
static void SetDebugMessageDispatchHandler(DebugMessageDispatchHandler handler, bool provide_locker=false)
static Handle< Value > ReadBuffer(const Arguments &args)
static Handle< Value > Print(const Arguments &args)
static bool ExecuteString(Handle< String > source, Handle< Value > name, bool print_result, bool report_exceptions)
static Handle< Value > Float64Array(const Arguments &args)
static Persistent< Context > CreateEvaluationContext()
static Handle< String > ReadFile(const char *name)
#define ASSERT_EQ(v1, v2)
static V8EXPORT Local< Integer > New(int32_t value)
void Begin(char **argv, int offset)
static void MapCounters(const char *name)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit 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 SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available 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 MIPS FPU instructions if NULL
static void PrepareStressRun(int run)
static void StartPreemption(int every_n_ms)
static void SetCreateHistogramFunction(CreateHistogramCallback)
Local< T > Close(Handle< T > value)
static void ReportException(TryCatch *try_catch)
static Handle< Value > Uint8Array(const Arguments &args)
Handle< Primitive > V8EXPORT Undefined()
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
static V8EXPORT Local< String > Concat(Handle< String > left, Handle< String > right)
static Handle< String > ReadFromStdin()
static Handle< Value > Uint8ClampedArray(const Arguments &args)
static Persistent< Context > New(ExtensionConfiguration *extensions=NULL, Handle< ObjectTemplate > global_template=Handle< ObjectTemplate >(), Handle< Value > global_object=Handle< Value >())
V8EXPORT Local< Object > ToObject() const
static Handle< Value > Quit(const Arguments &args)
static Handle< Value > ArraySubArray(const Arguments &args)
static Handle< Value > Uint32Array(const Arguments &args)
static void SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
static int * LookupCounter(const char *name)
static Handle< Value > Yield(const Arguments &args)
V8EXPORT bool IsInt32() const
static void StopPreemption()
Handle< Value > V8EXPORT ThrowException(Handle< Value > exception)
static StartupData::CompressionAlgorithm GetCompressedStartupDataAlgorithm()
bool IsConstructCall() const
bool send_idle_notification
static void DeoptimizeAll()
const char kArrayBufferMarkerPropName[]
static void ProcessDebugMessages()
void RunShell(v8::Handle< v8::Context > context)
static void PauseProfiler()
Local< v8::Message > Message() const
void StartExecuteInThread()
static int RunMain(int argc, char *argv[])
virtual Handle< String > Prompt(const char *prompt)
void HandleDebugEvent(DebugEvent event, Handle< Object > exec_state, Handle< Object > event_data, Handle< Value > data)
static V8EXPORT Local< Object > New()
static char * StrChr(char *str, int c)
static void SetCounterFunction(CounterLookupCallback)
static bool IdleNotification(int hint=1000)
static JSFunction * cast(Object *obj)