OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "vm/dart.h" | 5 #include "vm/dart.h" |
6 | 6 |
7 #include "vm/dart_api_state.h" | 7 #include "vm/dart_api_state.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/freelist.h" | 9 #include "vm/freelist.h" |
10 #include "vm/handles.h" | 10 #include "vm/handles.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 if (snapshot_buffer == NULL) { | 135 if (snapshot_buffer == NULL) { |
136 const Error& error = Error::Handle(Object::Init(isolate)); | 136 const Error& error = Error::Handle(Object::Init(isolate)); |
137 if (!error.IsNull()) { | 137 if (!error.IsNull()) { |
138 return error.raw(); | 138 return error.raw(); |
139 } | 139 } |
140 } else { | 140 } else { |
141 // Initialize from snapshot (this should replicate the functionality | 141 // Initialize from snapshot (this should replicate the functionality |
142 // of Object::Init(..) in a regular isolate creation path. | 142 // of Object::Init(..) in a regular isolate creation path. |
143 Object::InitFromSnapshot(isolate); | 143 Object::InitFromSnapshot(isolate); |
144 const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer); | 144 const Snapshot* snapshot = |
| 145 Snapshot::SetupFromBuffer(snapshot_buffer, Snapshot::kTrustedLength); |
| 146 if (snapshot == NULL) { |
| 147 const String& message = String::Handle(String::New( |
| 148 "Unexpected error during snapshot parsing.")); |
| 149 return ApiError::New(message); |
| 150 } |
145 if (FLAG_trace_isolates) { | 151 if (FLAG_trace_isolates) { |
146 OS::Print("Size of isolate snapshot = %ld\n", snapshot->length()); | 152 OS::Print("Size of isolate snapshot = %ld\n", snapshot->length()); |
147 } | 153 } |
148 SnapshotReader reader(snapshot, isolate); | 154 SnapshotReader reader(snapshot, isolate); |
149 reader.ReadFullSnapshot(); | 155 reader.ReadFullSnapshot(); |
150 if (FLAG_trace_isolates) { | 156 if (FLAG_trace_isolates) { |
151 isolate->heap()->PrintSizes(); | 157 isolate->heap()->PrintSizes(); |
152 } | 158 } |
153 if (FLAG_print_bootstrap) { | 159 if (FLAG_print_bootstrap) { |
154 PrintLibrarySources(isolate); | 160 PrintLibrarySources(isolate); |
(...skipping 16 matching lines...) Expand all Loading... |
171 isolate->Shutdown(); | 177 isolate->Shutdown(); |
172 delete isolate; | 178 delete isolate; |
173 | 179 |
174 Dart_IsolateShutdownCallback callback = Isolate::ShutdownCallback(); | 180 Dart_IsolateShutdownCallback callback = Isolate::ShutdownCallback(); |
175 if (callback != NULL) { | 181 if (callback != NULL) { |
176 (callback)(callback_data); | 182 (callback)(callback_data); |
177 } | 183 } |
178 } | 184 } |
179 | 185 |
180 } // namespace dart | 186 } // namespace dart |
OLD | NEW |