OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "bin/snapshot_utils.h" | 5 #include "bin/snapshot_utils.h" |
6 | 6 |
7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
8 #include "bin/error_exit.h" | 8 #include "bin/error_exit.h" |
9 #include "bin/extensions.h" | 9 #include "bin/extensions.h" |
10 #include "bin/file.h" | 10 #include "bin/file.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 const uint8_t* buffer, | 252 const uint8_t* buffer, |
253 const intptr_t size) { | 253 const intptr_t size) { |
254 File* file = File::Open(filename, File::kWriteTruncate); | 254 File* file = File::Open(filename, File::kWriteTruncate); |
255 if (file == NULL) { | 255 if (file == NULL) { |
256 ErrorExit(kErrorExitCode, "Unable to open file %s for writing snapshot\n", | 256 ErrorExit(kErrorExitCode, "Unable to open file %s for writing snapshot\n", |
257 filename); | 257 filename); |
258 } | 258 } |
259 | 259 |
260 if (write_magic_number) { | 260 if (write_magic_number) { |
261 // Write the magic number to indicate file is a script snapshot. | 261 // Write the magic number to indicate file is a script snapshot. |
262 DartUtils::WriteMagicNumber(file); | 262 DartUtils::WriteSnapshotMagicNumber(file); |
263 } | 263 } |
264 | 264 |
265 if (!file->WriteFully(buffer, size)) { | 265 if (!file->WriteFully(buffer, size)) { |
266 ErrorExit(kErrorExitCode, "Unable to write file %s for writing snapshot\n", | 266 ErrorExit(kErrorExitCode, "Unable to write file %s for writing snapshot\n", |
267 filename); | 267 filename); |
268 } | 268 } |
269 file->Release(); | 269 file->Release(); |
270 } | 270 } |
271 | 271 |
272 static bool WriteInt64(File* file, int64_t size) { | 272 static bool WriteInt64(File* file, int64_t size) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 Dart_Handle result = | 396 Dart_Handle result = |
397 Dart_CreateAppAOTSnapshotAsAssembly(&assembly_buffer, &assembly_size); | 397 Dart_CreateAppAOTSnapshotAsAssembly(&assembly_buffer, &assembly_size); |
398 if (Dart_IsError(result)) { | 398 if (Dart_IsError(result)) { |
399 ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result)); | 399 ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result)); |
400 } | 400 } |
401 WriteSnapshotFile(snapshot_filename, false, assembly_buffer, assembly_size); | 401 WriteSnapshotFile(snapshot_filename, false, assembly_buffer, assembly_size); |
402 } | 402 } |
403 | 403 |
404 } // namespace bin | 404 } // namespace bin |
405 } // namespace dart | 405 } // namespace dart |
OLD | NEW |