| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 options.stress_deopt = false; | 1370 options.stress_deopt = false; |
| 1371 } else if (strcmp(argv[i], "--shell") == 0) { | 1371 } else if (strcmp(argv[i], "--shell") == 0) { |
| 1372 options.interactive_shell = true; | 1372 options.interactive_shell = true; |
| 1373 argv[i] = NULL; | 1373 argv[i] = NULL; |
| 1374 } else if (strcmp(argv[i], "--test") == 0) { | 1374 } else if (strcmp(argv[i], "--test") == 0) { |
| 1375 options.test_shell = true; | 1375 options.test_shell = true; |
| 1376 argv[i] = NULL; | 1376 argv[i] = NULL; |
| 1377 } else if (strcmp(argv[i], "--send-idle-notification") == 0) { | 1377 } else if (strcmp(argv[i], "--send-idle-notification") == 0) { |
| 1378 options.send_idle_notification = true; | 1378 options.send_idle_notification = true; |
| 1379 argv[i] = NULL; | 1379 argv[i] = NULL; |
| 1380 } else if (strcmp(argv[i], "--preemption") == 0) { | |
| 1381 #ifdef V8_SHARED | |
| 1382 printf("D8 with shared library does not support multi-threading\n"); | |
| 1383 return false; | |
| 1384 #else | |
| 1385 options.use_preemption = true; | |
| 1386 argv[i] = NULL; | |
| 1387 #endif // V8_SHARED | |
| 1388 } else if (strcmp(argv[i], "--nopreemption") == 0) { | |
| 1389 #ifdef V8_SHARED | |
| 1390 printf("D8 with shared library does not support multi-threading\n"); | |
| 1391 return false; | |
| 1392 #else | |
| 1393 options.use_preemption = false; | |
| 1394 argv[i] = NULL; | |
| 1395 #endif // V8_SHARED | |
| 1396 } else if (strcmp(argv[i], "--preemption-interval") == 0) { | |
| 1397 #ifdef V8_SHARED | |
| 1398 printf("D8 with shared library does not support multi-threading\n"); | |
| 1399 return false; | |
| 1400 #else | |
| 1401 if (++i < argc) { | |
| 1402 argv[i-1] = NULL; | |
| 1403 char* end = NULL; | |
| 1404 options.preemption_interval = strtol(argv[i], &end, 10); // NOLINT | |
| 1405 if (options.preemption_interval <= 0 | |
| 1406 || *end != '\0' | |
| 1407 || errno == ERANGE) { | |
| 1408 printf("Invalid value for --preemption-interval '%s'\n", argv[i]); | |
| 1409 return false; | |
| 1410 } | |
| 1411 argv[i] = NULL; | |
| 1412 } else { | |
| 1413 printf("Missing value for --preemption-interval\n"); | |
| 1414 return false; | |
| 1415 } | |
| 1416 #endif // V8_SHARED | |
| 1417 } else if (strcmp(argv[i], "-f") == 0) { | 1380 } else if (strcmp(argv[i], "-f") == 0) { |
| 1418 // Ignore any -f flags for compatibility with other stand-alone | 1381 // Ignore any -f flags for compatibility with other stand-alone |
| 1419 // JavaScript engines. | 1382 // JavaScript engines. |
| 1420 continue; | 1383 continue; |
| 1421 } else if (strcmp(argv[i], "--isolate") == 0) { | 1384 } else if (strcmp(argv[i], "--isolate") == 0) { |
| 1422 #ifdef V8_SHARED | 1385 #ifdef V8_SHARED |
| 1423 printf("D8 with shared library does not support multi-threading\n"); | 1386 printf("D8 with shared library does not support multi-threading\n"); |
| 1424 return false; | 1387 return false; |
| 1425 #endif // V8_SHARED | 1388 #endif // V8_SHARED |
| 1426 options.num_isolates++; | 1389 options.num_isolates++; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 options.isolate_sources[0].Execute(isolate); | 1508 options.isolate_sources[0].Execute(isolate); |
| 1546 } | 1509 } |
| 1547 } | 1510 } |
| 1548 if (!options.last_run) { | 1511 if (!options.last_run) { |
| 1549 if (options.send_idle_notification) { | 1512 if (options.send_idle_notification) { |
| 1550 const int kLongIdlePauseInMs = 1000; | 1513 const int kLongIdlePauseInMs = 1000; |
| 1551 V8::ContextDisposedNotification(); | 1514 V8::ContextDisposedNotification(); |
| 1552 V8::IdleNotification(kLongIdlePauseInMs); | 1515 V8::IdleNotification(kLongIdlePauseInMs); |
| 1553 } | 1516 } |
| 1554 } | 1517 } |
| 1555 | |
| 1556 #ifndef V8_SHARED | |
| 1557 // Start preemption if threads have been created and preemption is enabled. | |
| 1558 if (threads.length() > 0 | |
| 1559 && options.use_preemption) { | |
| 1560 Locker::StartPreemption(isolate, options.preemption_interval); | |
| 1561 } | |
| 1562 #endif // V8_SHARED | |
| 1563 } | 1518 } |
| 1564 | 1519 |
| 1565 #ifndef V8_SHARED | 1520 #ifndef V8_SHARED |
| 1566 for (int i = 1; i < options.num_isolates; ++i) { | 1521 for (int i = 1; i < options.num_isolates; ++i) { |
| 1567 options.isolate_sources[i].WaitForThread(); | 1522 options.isolate_sources[i].WaitForThread(); |
| 1568 } | 1523 } |
| 1569 | 1524 |
| 1570 for (int i = 0; i < threads.length(); i++) { | 1525 for (int i = 0; i < threads.length(); i++) { |
| 1571 i::Thread* thread = threads[i]; | 1526 i::Thread* thread = threads[i]; |
| 1572 thread->Join(); | 1527 thread->Join(); |
| 1573 delete thread; | 1528 delete thread; |
| 1574 } | 1529 } |
| 1575 | |
| 1576 if (threads.length() > 0 && options.use_preemption) { | |
| 1577 Locker lock(isolate); | |
| 1578 Locker::StopPreemption(isolate); | |
| 1579 } | |
| 1580 #endif // V8_SHARED | 1530 #endif // V8_SHARED |
| 1581 return 0; | 1531 return 0; |
| 1582 } | 1532 } |
| 1583 | 1533 |
| 1584 | 1534 |
| 1585 #ifdef V8_SHARED | 1535 #ifdef V8_SHARED |
| 1586 static void SetStandaloneFlagsViaCommandLine() { | 1536 static void SetStandaloneFlagsViaCommandLine() { |
| 1587 int fake_argc = 2; | 1537 int fake_argc = 2; |
| 1588 char **fake_argv = new char*[2]; | 1538 char **fake_argv = new char*[2]; |
| 1589 fake_argv[0] = NULL; | 1539 fake_argv[0] = NULL; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 } | 1714 } |
| 1765 | 1715 |
| 1766 } // namespace v8 | 1716 } // namespace v8 |
| 1767 | 1717 |
| 1768 | 1718 |
| 1769 #ifndef GOOGLE3 | 1719 #ifndef GOOGLE3 |
| 1770 int main(int argc, char* argv[]) { | 1720 int main(int argc, char* argv[]) { |
| 1771 return v8::Shell::Main(argc, argv); | 1721 return v8::Shell::Main(argc, argv); |
| 1772 } | 1722 } |
| 1773 #endif | 1723 #endif |
| OLD | NEW |