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 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 ~StartupDataHandler() { | 1563 ~StartupDataHandler() { |
1564 delete[] natives_.data; | 1564 delete[] natives_.data; |
1565 delete[] snapshot_.data; | 1565 delete[] snapshot_.data; |
1566 } | 1566 } |
1567 | 1567 |
1568 private: | 1568 private: |
1569 void Load(const char* blob_file, | 1569 void Load(const char* blob_file, |
1570 v8::StartupData* startup_data, | 1570 v8::StartupData* startup_data, |
1571 void (*setter_fn)(v8::StartupData*)) { | 1571 void (*setter_fn)(v8::StartupData*)) { |
1572 startup_data->data = NULL; | 1572 startup_data->data = NULL; |
1573 startup_data->compressed_size = 0; | |
1574 startup_data->raw_size = 0; | 1573 startup_data->raw_size = 0; |
1575 | 1574 |
1576 if (!blob_file) | 1575 if (!blob_file) |
1577 return; | 1576 return; |
1578 | 1577 |
1579 FILE* file = fopen(blob_file, "rb"); | 1578 FILE* file = fopen(blob_file, "rb"); |
1580 if (!file) | 1579 if (!file) |
1581 return; | 1580 return; |
1582 | 1581 |
1583 fseek(file, 0, SEEK_END); | 1582 fseek(file, 0, SEEK_END); |
1584 startup_data->raw_size = ftell(file); | 1583 startup_data->raw_size = ftell(file); |
1585 rewind(file); | 1584 rewind(file); |
1586 | 1585 |
1587 startup_data->data = new char[startup_data->raw_size]; | 1586 startup_data->data = new char[startup_data->raw_size]; |
1588 startup_data->compressed_size = | 1587 int read_size = |
1589 static_cast<int>(fread(const_cast<char*>(startup_data->data), 1, | 1588 static_cast<int>(fread(const_cast<char*>(startup_data->data), 1, |
1590 startup_data->raw_size, file)); | 1589 startup_data->raw_size, file)); |
1591 fclose(file); | 1590 fclose(file); |
1592 | 1591 |
1593 if (startup_data->raw_size == startup_data->compressed_size) | 1592 if (startup_data->raw_size == read_size) (*setter_fn)(startup_data); |
1594 (*setter_fn)(startup_data); | |
1595 } | 1593 } |
1596 | 1594 |
1597 v8::StartupData natives_; | 1595 v8::StartupData natives_; |
1598 v8::StartupData snapshot_; | 1596 v8::StartupData snapshot_; |
1599 | 1597 |
1600 // Disallow copy & assign. | 1598 // Disallow copy & assign. |
1601 StartupDataHandler(const StartupDataHandler& other); | 1599 StartupDataHandler(const StartupDataHandler& other); |
1602 void operator=(const StartupDataHandler& other); | 1600 void operator=(const StartupDataHandler& other); |
1603 }; | 1601 }; |
1604 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 1602 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1724 } | 1722 } |
1725 | 1723 |
1726 } // namespace v8 | 1724 } // namespace v8 |
1727 | 1725 |
1728 | 1726 |
1729 #ifndef GOOGLE3 | 1727 #ifndef GOOGLE3 |
1730 int main(int argc, char* argv[]) { | 1728 int main(int argc, char* argv[]) { |
1731 return v8::Shell::Main(argc, argv); | 1729 return v8::Shell::Main(argc, argv); |
1732 } | 1730 } |
1733 #endif | 1731 #endif |
OLD | NEW |