Chromium Code Reviews| 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 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1309 } | 1309 } |
| 1310 #ifdef V8_SHARED | 1310 #ifdef V8_SHARED |
| 1311 else if (strcmp(argv[i], "--dump-counters") == 0) { | 1311 else if (strcmp(argv[i], "--dump-counters") == 0) { |
| 1312 printf("D8 with shared library does not include counters\n"); | 1312 printf("D8 with shared library does not include counters\n"); |
| 1313 return false; | 1313 return false; |
| 1314 } else if (strcmp(argv[i], "--debugger") == 0) { | 1314 } else if (strcmp(argv[i], "--debugger") == 0) { |
| 1315 printf("Javascript debugger not included\n"); | 1315 printf("Javascript debugger not included\n"); |
| 1316 return false; | 1316 return false; |
| 1317 } | 1317 } |
| 1318 #endif // V8_SHARED | 1318 #endif // V8_SHARED |
| 1319 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
| 1320 else if (strncmp(argv[i], "--natives_blob=", 15) == 0) { | |
|
jochen (gone - plz use gerrit)
2014/05/23 11:44:44
using - is more consistent with the other options
vogelheim
2014/05/26 12:36:03
Done.
| |
| 1321 options.natives_blob = argv[i] + 15; | |
| 1322 argv[i] = NULL; | |
| 1323 } else if (strncmp(argv[i], "--snapshot_blob=", 16) == 0) { | |
| 1324 options.snapshot_blob = argv[i] + 16; | |
| 1325 argv[i] = NULL; | |
| 1326 } | |
| 1327 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
| 1319 } | 1328 } |
| 1320 | 1329 |
| 1321 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); | 1330 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
| 1322 | 1331 |
| 1323 // Set up isolated source groups. | 1332 // Set up isolated source groups. |
| 1324 options.isolate_sources = new SourceGroup[options.num_isolates]; | 1333 options.isolate_sources = new SourceGroup[options.num_isolates]; |
| 1325 SourceGroup* current = options.isolate_sources; | 1334 SourceGroup* current = options.isolate_sources; |
| 1326 current->Begin(argv, 1); | 1335 current->Begin(argv, 1); |
| 1327 for (int i = 1; i < argc; i++) { | 1336 for (int i = 1; i < argc; i++) { |
| 1328 const char* str = argv[i]; | 1337 const char* str = argv[i]; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1464 return malloc(0); | 1473 return malloc(0); |
| 1465 } | 1474 } |
| 1466 virtual void* AllocateUninitialized(size_t length) V8_OVERRIDE { | 1475 virtual void* AllocateUninitialized(size_t length) V8_OVERRIDE { |
| 1467 return malloc(0); | 1476 return malloc(0); |
| 1468 } | 1477 } |
| 1469 virtual void Free(void*, size_t) V8_OVERRIDE { | 1478 virtual void Free(void*, size_t) V8_OVERRIDE { |
| 1470 } | 1479 } |
| 1471 }; | 1480 }; |
| 1472 | 1481 |
| 1473 | 1482 |
| 1483 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
| 1484 class StartupDataHandler { | |
| 1485 public: | |
| 1486 StartupDataHandler(const char* natives_blob, | |
| 1487 const char* snapshot_blob) { | |
| 1488 Load(natives_blob, &natives_, v8::V8::SetNativesDataBlob); | |
| 1489 Load(snapshot_blob, &snapshot_, v8::V8::SetSnapshotDataBlob); | |
| 1490 } | |
| 1491 | |
| 1492 ~StartupDataHandler() { | |
| 1493 delete[] natives_.data; | |
| 1494 delete[] snapshot_.data; | |
| 1495 } | |
| 1496 | |
| 1497 private: | |
| 1498 void Load(const char* blob_file, | |
| 1499 v8::StartupData* startup_data, | |
| 1500 void (*setter_fn)(v8::StartupData*)) { | |
| 1501 startup_data->data = NULL; | |
| 1502 startup_data->compressed_size = 0; | |
| 1503 startup_data->raw_size = 0; | |
| 1504 | |
| 1505 if (!blob_file) | |
| 1506 return; | |
| 1507 | |
| 1508 FILE* file = fopen(blob_file, "rb"); | |
| 1509 if (!file) | |
| 1510 return; | |
| 1511 | |
| 1512 fseek(file, 0, SEEK_END); | |
| 1513 startup_data->raw_size = ftell(file); | |
| 1514 rewind(file); | |
| 1515 | |
| 1516 startup_data->data = new char[startup_data->raw_size]; | |
| 1517 startup_data->compressed_size = fread( | |
| 1518 const_cast<char*>(startup_data->data), 1, startup_data->raw_size, | |
| 1519 file); | |
| 1520 fclose(file); | |
| 1521 | |
| 1522 if (startup_data->raw_size == startup_data->compressed_size) | |
| 1523 (*setter_fn)(startup_data); | |
| 1524 } | |
| 1525 | |
| 1526 v8::StartupData natives_; | |
| 1527 v8::StartupData snapshot_; | |
| 1528 }; | |
|
jochen (gone - plz use gerrit)
2014/05/23 11:44:44
nit. DISALLOW_COPY_AND_ASSIGN
vogelheim
2014/05/26 12:36:03
d8.cc seems to avoid including internal v8 headers
| |
| 1529 #endif // V8_USE_EXTERNAL_STARTUP_DATA | |
| 1530 | |
| 1531 | |
| 1474 int Shell::Main(int argc, char* argv[]) { | 1532 int Shell::Main(int argc, char* argv[]) { |
| 1475 if (!SetOptions(argc, argv)) return 1; | 1533 if (!SetOptions(argc, argv)) return 1; |
| 1476 v8::V8::InitializeICU(options.icu_data_file); | 1534 v8::V8::InitializeICU(options.icu_data_file); |
| 1535 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
| 1536 StartupDataHandler startup_data(options.natives_blob, options.snapshot_blob); | |
| 1537 #endif | |
| 1477 SetFlagsFromString("--trace-hydrogen-file=hydrogen.cfg"); | 1538 SetFlagsFromString("--trace-hydrogen-file=hydrogen.cfg"); |
| 1478 SetFlagsFromString("--redirect-code-traces-to=code.asm"); | 1539 SetFlagsFromString("--redirect-code-traces-to=code.asm"); |
| 1479 ShellArrayBufferAllocator array_buffer_allocator; | 1540 ShellArrayBufferAllocator array_buffer_allocator; |
| 1480 MockArrayBufferAllocator mock_arraybuffer_allocator; | 1541 MockArrayBufferAllocator mock_arraybuffer_allocator; |
| 1481 if (options.mock_arraybuffer_allocator) { | 1542 if (options.mock_arraybuffer_allocator) { |
| 1482 v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator); | 1543 v8::V8::SetArrayBufferAllocator(&mock_arraybuffer_allocator); |
| 1483 } else { | 1544 } else { |
| 1484 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); | 1545 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); |
| 1485 } | 1546 } |
| 1486 int result = 0; | 1547 int result = 0; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1556 } | 1617 } |
| 1557 | 1618 |
| 1558 } // namespace v8 | 1619 } // namespace v8 |
| 1559 | 1620 |
| 1560 | 1621 |
| 1561 #ifndef GOOGLE3 | 1622 #ifndef GOOGLE3 |
| 1562 int main(int argc, char* argv[]) { | 1623 int main(int argc, char* argv[]) { |
| 1563 return v8::Shell::Main(argc, argv); | 1624 return v8::Shell::Main(argc, argv); |
| 1564 } | 1625 } |
| 1565 #endif | 1626 #endif |
| OLD | NEW |