OLD | NEW |
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 | 5 |
6 // Defined when linking against shared lib on Windows. | 6 // Defined when linking against shared lib on Windows. |
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) | 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) |
8 #define V8_SHARED | 8 #define V8_SHARED |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 if (thread_ == NULL) return; | 1345 if (thread_ == NULL) return; |
1346 if (Shell::options.last_run) { | 1346 if (Shell::options.last_run) { |
1347 thread_->Join(); | 1347 thread_->Join(); |
1348 } else { | 1348 } else { |
1349 done_semaphore_.Wait(); | 1349 done_semaphore_.Wait(); |
1350 } | 1350 } |
1351 } | 1351 } |
1352 #endif // !V8_SHARED | 1352 #endif // !V8_SHARED |
1353 | 1353 |
1354 | 1354 |
| 1355 void SetFlagsFromString(const char* flags) { |
| 1356 v8::V8::SetFlagsFromString(flags, strlen(flags)); |
| 1357 } |
| 1358 |
| 1359 |
1355 bool Shell::SetOptions(int argc, char* argv[]) { | 1360 bool Shell::SetOptions(int argc, char* argv[]) { |
| 1361 bool logfile_per_isolate = false; |
1356 for (int i = 0; i < argc; i++) { | 1362 for (int i = 0; i < argc; i++) { |
| 1363 // Turn '_' into '-'. |
| 1364 // for (char* c = arg; *c != '\0'; c++) if (*c == '_') *c = '-'; |
1357 if (strcmp(argv[i], "--stress-opt") == 0) { | 1365 if (strcmp(argv[i], "--stress-opt") == 0) { |
1358 options.stress_opt = true; | 1366 options.stress_opt = true; |
1359 argv[i] = NULL; | 1367 argv[i] = NULL; |
1360 } else if (strcmp(argv[i], "--nostress-opt") == 0) { | 1368 } else if (strcmp(argv[i], "--nostress-opt") == 0) { |
1361 options.stress_opt = false; | 1369 options.stress_opt = false; |
1362 argv[i] = NULL; | 1370 argv[i] = NULL; |
1363 } else if (strcmp(argv[i], "--stress-deopt") == 0) { | 1371 } else if (strcmp(argv[i], "--stress-deopt") == 0) { |
1364 options.stress_deopt = true; | 1372 options.stress_deopt = true; |
1365 argv[i] = NULL; | 1373 argv[i] = NULL; |
1366 } else if (strcmp(argv[i], "--mock-arraybuffer-allocator") == 0) { | 1374 } else if (strcmp(argv[i], "--mock-arraybuffer-allocator") == 0) { |
1367 options.mock_arraybuffer_allocator = true; | 1375 options.mock_arraybuffer_allocator = true; |
1368 argv[i] = NULL; | 1376 argv[i] = NULL; |
1369 } else if (strcmp(argv[i], "--noalways-opt") == 0) { | 1377 } else if (strcmp(argv[i], "--noalways-opt") == 0) { |
1370 // No support for stressing if we can't use --always-opt. | 1378 // No support for stressing if we can't use --always-opt. |
1371 options.stress_opt = false; | 1379 options.stress_opt = false; |
1372 options.stress_deopt = false; | 1380 options.stress_deopt = false; |
| 1381 } else if (strcmp(argv[i], "--logfile-per-isolate") == 0) { |
| 1382 logfile_per_isolate = true; |
| 1383 argv[i] = NULL; |
1373 } else if (strcmp(argv[i], "--shell") == 0) { | 1384 } else if (strcmp(argv[i], "--shell") == 0) { |
1374 options.interactive_shell = true; | 1385 options.interactive_shell = true; |
1375 argv[i] = NULL; | 1386 argv[i] = NULL; |
1376 } else if (strcmp(argv[i], "--test") == 0) { | 1387 } else if (strcmp(argv[i], "--test") == 0) { |
1377 options.test_shell = true; | 1388 options.test_shell = true; |
1378 argv[i] = NULL; | 1389 argv[i] = NULL; |
1379 } else if (strcmp(argv[i], "--send-idle-notification") == 0) { | 1390 } else if (strcmp(argv[i], "--send-idle-notification") == 0) { |
1380 options.send_idle_notification = true; | 1391 options.send_idle_notification = true; |
1381 argv[i] = NULL; | 1392 argv[i] = NULL; |
1382 } else if (strcmp(argv[i], "-f") == 0) { | 1393 } else if (strcmp(argv[i], "-f") == 0) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 if (strcmp(str, "--isolate") == 0) { | 1468 if (strcmp(str, "--isolate") == 0) { |
1458 current->End(i); | 1469 current->End(i); |
1459 current++; | 1470 current++; |
1460 current->Begin(argv, i + 1); | 1471 current->Begin(argv, i + 1); |
1461 } else if (strncmp(argv[i], "--", 2) == 0) { | 1472 } else if (strncmp(argv[i], "--", 2) == 0) { |
1462 printf("Warning: unknown flag %s.\nTry --help for options\n", argv[i]); | 1473 printf("Warning: unknown flag %s.\nTry --help for options\n", argv[i]); |
1463 } | 1474 } |
1464 } | 1475 } |
1465 current->End(argc); | 1476 current->End(argc); |
1466 | 1477 |
| 1478 if (!logfile_per_isolate && options.num_isolates) { |
| 1479 SetFlagsFromString("--nologfile_per_isolate"); |
| 1480 } |
| 1481 |
1467 return true; | 1482 return true; |
1468 } | 1483 } |
1469 | 1484 |
1470 | 1485 |
1471 int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) { | 1486 int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) { |
1472 #ifndef V8_SHARED | 1487 #ifndef V8_SHARED |
1473 i::List<i::Thread*> threads(1); | 1488 i::List<i::Thread*> threads(1); |
1474 if (options.parallel_files != NULL) { | 1489 if (options.parallel_files != NULL) { |
1475 for (int i = 0; i < options.num_parallel_files; i++) { | 1490 for (int i = 0; i < options.num_parallel_files; i++) { |
1476 char* files = NULL; | 1491 char* files = NULL; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 for (int i = 0; i < threads.length(); i++) { | 1545 for (int i = 0; i < threads.length(); i++) { |
1531 i::Thread* thread = threads[i]; | 1546 i::Thread* thread = threads[i]; |
1532 thread->Join(); | 1547 thread->Join(); |
1533 delete thread; | 1548 delete thread; |
1534 } | 1549 } |
1535 #endif // !V8_SHARED | 1550 #endif // !V8_SHARED |
1536 return 0; | 1551 return 0; |
1537 } | 1552 } |
1538 | 1553 |
1539 | 1554 |
1540 #ifdef V8_SHARED | |
1541 static void SetStandaloneFlagsViaCommandLine() { | |
1542 int fake_argc = 3; | |
1543 char **fake_argv = new char*[3]; | |
1544 fake_argv[0] = NULL; | |
1545 fake_argv[1] = strdup("--trace-hydrogen-file=hydrogen.cfg"); | |
1546 fake_argv[2] = strdup("--redirect-code-traces-to=code.asm"); | |
1547 v8::V8::SetFlagsFromCommandLine(&fake_argc, fake_argv, false); | |
1548 free(fake_argv[1]); | |
1549 free(fake_argv[2]); | |
1550 delete[] fake_argv; | |
1551 } | |
1552 #endif | |
1553 | |
1554 | |
1555 #ifndef V8_SHARED | 1555 #ifndef V8_SHARED |
1556 static void DumpHeapConstants(i::Isolate* isolate) { | 1556 static void DumpHeapConstants(i::Isolate* isolate) { |
1557 i::Heap* heap = isolate->heap(); | 1557 i::Heap* heap = isolate->heap(); |
1558 | 1558 |
1559 // Dump the INSTANCE_TYPES table to the console. | 1559 // Dump the INSTANCE_TYPES table to the console. |
1560 printf("# List of known V8 instance types.\n"); | 1560 printf("# List of known V8 instance types.\n"); |
1561 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T); | 1561 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T); |
1562 printf("INSTANCE_TYPES = {\n"); | 1562 printf("INSTANCE_TYPES = {\n"); |
1563 INSTANCE_TYPE_LIST(DUMP_TYPE) | 1563 INSTANCE_TYPE_LIST(DUMP_TYPE) |
1564 printf("}\n"); | 1564 printf("}\n"); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 return malloc(0); | 1628 return malloc(0); |
1629 } | 1629 } |
1630 virtual void Free(void*, size_t) V8_OVERRIDE { | 1630 virtual void Free(void*, size_t) V8_OVERRIDE { |
1631 } | 1631 } |
1632 }; | 1632 }; |
1633 | 1633 |
1634 | 1634 |
1635 int Shell::Main(int argc, char* argv[]) { | 1635 int Shell::Main(int argc, char* argv[]) { |
1636 if (!SetOptions(argc, argv)) return 1; | 1636 if (!SetOptions(argc, argv)) return 1; |
1637 v8::V8::InitializeICU(options.icu_data_file); | 1637 v8::V8::InitializeICU(options.icu_data_file); |
1638 #ifndef V8_SHARED | 1638 SetFlagsFromString("--trace-hydrogen-file=hydrogen.cfg"); |
1639 i::FLAG_trace_hydrogen_file = "hydrogen.cfg"; | 1639 SetFlagsFromString("--redirect-code-traces-to=code.asm"); |
1640 i::FLAG_redirect_code_traces_to = "code.asm"; | |
1641 #else | |
1642 SetStandaloneFlagsViaCommandLine(); | |
1643 #endif | |
1644 ShellArrayBufferAllocator array_buffer_allocator; | 1640 ShellArrayBufferAllocator array_buffer_allocator; |
1645 MockArrayBufferAllocator mock_arraybuffer_allocator; | 1641 MockArrayBufferAllocator mock_arraybuffer_allocator; |
1646 if (options.mock_arraybuffer_allocator) { | 1642 if (options.mock_arraybuffer_allocator) { |
1647 v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator); | 1643 v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator); |
1648 } else { | 1644 } else { |
1649 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); | 1645 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); |
1650 } | 1646 } |
1651 int result = 0; | 1647 int result = 0; |
1652 Isolate* isolate = Isolate::New(); | 1648 Isolate* isolate = Isolate::New(); |
1653 #ifndef V8_SHARED | 1649 #ifndef V8_SHARED |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 } | 1728 } |
1733 | 1729 |
1734 } // namespace v8 | 1730 } // namespace v8 |
1735 | 1731 |
1736 | 1732 |
1737 #ifndef GOOGLE3 | 1733 #ifndef GOOGLE3 |
1738 int main(int argc, char* argv[]) { | 1734 int main(int argc, char* argv[]) { |
1739 return v8::Shell::Main(argc, argv); | 1735 return v8::Shell::Main(argc, argv); |
1740 } | 1736 } |
1741 #endif | 1737 #endif |
OLD | NEW |