| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 #include <errno.h> | 5 #include <errno.h> |
| 6 #include <signal.h> | 6 #include <signal.h> |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 void WriteFilePrefix() const { | 63 void WriteFilePrefix() const { |
| 64 fprintf(fp_, "// Autogenerated snapshot file. Do not edit.\n\n"); | 64 fprintf(fp_, "// Autogenerated snapshot file. Do not edit.\n\n"); |
| 65 fprintf(fp_, "#include \"src/v8.h\"\n"); | 65 fprintf(fp_, "#include \"src/v8.h\"\n"); |
| 66 fprintf(fp_, "#include \"src/base/platform/platform.h\"\n\n"); | 66 fprintf(fp_, "#include \"src/base/platform/platform.h\"\n\n"); |
| 67 fprintf(fp_, "#include \"src/snapshot.h\"\n\n"); | 67 fprintf(fp_, "#include \"src/snapshot.h\"\n\n"); |
| 68 fprintf(fp_, "namespace v8 {\n"); | 68 fprintf(fp_, "namespace v8 {\n"); |
| 69 fprintf(fp_, "namespace internal {\n\n"); | 69 fprintf(fp_, "namespace internal {\n\n"); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void WriteFileSuffix() const { | 72 void WriteFileSuffix() const { |
| 73 fprintf(fp_, "const v8::StartupData Snapshot::SnapshotBlob() {\n"); | 73 fprintf(fp_, "const v8::StartupData* Snapshot::DefaultSnapshotBlob() {\n"); |
| 74 fprintf(fp_, " v8::StartupData blob;\n"); | 74 fprintf(fp_, " return &blob;\n"); |
| 75 fprintf(fp_, " blob.data = reinterpret_cast<const char*>(blob_data);\n"); | |
| 76 fprintf(fp_, " blob.raw_size = blob_size;\n"); | |
| 77 fprintf(fp_, " return blob;\n"); | |
| 78 fprintf(fp_, "}\n\n"); | 75 fprintf(fp_, "}\n\n"); |
| 79 fprintf(fp_, "} // namespace internal\n"); | 76 fprintf(fp_, "} // namespace internal\n"); |
| 80 fprintf(fp_, "} // namespace v8\n"); | 77 fprintf(fp_, "} // namespace v8\n"); |
| 81 } | 78 } |
| 82 | 79 |
| 83 void WriteData(const i::Vector<const i::byte>& blob) const { | 80 void WriteData(const i::Vector<const i::byte>& blob) const { |
| 84 fprintf(fp_, "static const byte blob_data[] = {\n"); | 81 fprintf(fp_, "static const byte blob_data[] = {\n"); |
| 85 WriteSnapshotData(blob); | 82 WriteSnapshotData(blob); |
| 86 fprintf(fp_, "};\n"); | 83 fprintf(fp_, "};\n"); |
| 87 fprintf(fp_, "static const int blob_size = %d;\n", blob.length()); | 84 fprintf(fp_, "static const int blob_size = %d;\n", blob.length()); |
| 88 fprintf(fp_, "\n"); | 85 fprintf(fp_, "static const v8::StartupData blob =\n"); |
| 86 fprintf(fp_, "{ (const char*) blob_data, blob_size };\n"); |
| 89 } | 87 } |
| 90 | 88 |
| 91 void WriteSnapshotData(const i::Vector<const i::byte>& blob) const { | 89 void WriteSnapshotData(const i::Vector<const i::byte>& blob) const { |
| 92 for (int i = 0; i < blob.length(); i++) { | 90 for (int i = 0; i < blob.length(); i++) { |
| 93 if ((i & 0x1f) == 0x1f) fprintf(fp_, "\n"); | 91 if ((i & 0x1f) == 0x1f) fprintf(fp_, "\n"); |
| 94 if (i > 0) fprintf(fp_, ","); | 92 if (i > 0) fprintf(fp_, ","); |
| 95 fprintf(fp_, "%u", static_cast<unsigned char>(blob.at(i))); | 93 fprintf(fp_, "%u", static_cast<unsigned char>(blob.at(i))); |
| 96 } | 94 } |
| 97 fprintf(fp_, "\n"); | 95 fprintf(fp_, "\n"); |
| 98 } | 96 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 writer.WriteSnapshot(blob); | 169 writer.WriteSnapshot(blob); |
| 172 delete[] extra_code; | 170 delete[] extra_code; |
| 173 delete[] blob.data; | 171 delete[] blob.data; |
| 174 } | 172 } |
| 175 | 173 |
| 176 V8::Dispose(); | 174 V8::Dispose(); |
| 177 V8::ShutdownPlatform(); | 175 V8::ShutdownPlatform(); |
| 178 delete platform; | 176 delete platform; |
| 179 return 0; | 177 return 0; |
| 180 } | 178 } |
| OLD | NEW |