| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Generate a snapshot file after loading all the scripts specified on the | 5 // Generate a snapshot file after loading all the scripts specified on the |
| 6 // command line. | 6 // command line. |
| 7 | 7 |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } else { | 74 } else { |
| 75 *script_name = NULL; | 75 *script_name = NULL; |
| 76 } | 76 } |
| 77 | 77 |
| 78 return 0; | 78 return 0; |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 static void WriteSnapshotFile(const uint8_t* buffer, const intptr_t size) { | 82 static void WriteSnapshotFile(const uint8_t* buffer, const intptr_t size) { |
| 83 const bool kWritable = true; | 83 const bool kWritable = true; |
| 84 File* file = File::OpenFile(snapshot_filename, kWritable); | 84 File* file = File::Open(snapshot_filename, kWritable); |
| 85 ASSERT(file != NULL); | 85 ASSERT(file != NULL); |
| 86 for (intptr_t i = 0; i < size; i++) { | 86 for (intptr_t i = 0; i < size; i++) { |
| 87 file->WriteByte(buffer[i]); | 87 file->WriteByte(buffer[i]); |
| 88 } | 88 } |
| 89 delete file; | 89 delete file; |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 static void* SnapshotCreateCallback(void* data) { | 93 static void* SnapshotCreateCallback(void* data) { |
| 94 const char* script_name = reinterpret_cast<const char*>(data); | 94 const char* script_name = reinterpret_cast<const char*>(data); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // and writes out a snapshot. | 175 // and writes out a snapshot. |
| 176 Dart_Isolate isolate = Dart_CreateIsolate(NULL, script_name); | 176 Dart_Isolate isolate = Dart_CreateIsolate(NULL, script_name); |
| 177 if (isolate == NULL) { | 177 if (isolate == NULL) { |
| 178 return 255; | 178 return 255; |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Shutdown the isolate. | 181 // Shutdown the isolate. |
| 182 Dart_ShutdownIsolate(); | 182 Dart_ShutdownIsolate(); |
| 183 return 0; | 183 return 0; |
| 184 } | 184 } |
| OLD | NEW |