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/snapshot.h" | 5 #include "vm/snapshot.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 } | 296 } |
297 | 297 |
298 | 298 |
299 intptr_t SnapshotReader::NextAvailableObjectId() const { | 299 intptr_t SnapshotReader::NextAvailableObjectId() const { |
300 return backward_references_->length() + | 300 return backward_references_->length() + |
301 kMaxPredefinedObjectIds + max_vm_isolate_object_id_; | 301 kMaxPredefinedObjectIds + max_vm_isolate_object_id_; |
302 } | 302 } |
303 | 303 |
304 | 304 |
305 void SnapshotReader::SetReadException(const char* msg) { | 305 void SnapshotReader::SetReadException(const char* msg) { |
306 Isolate* isolate = Isolate::Current(); | 306 Thread* thread = Thread::Current(); |
307 const String& error_str = String::Handle(isolate, String::New(msg)); | 307 Zone* zone = thread->zone(); |
308 const Array& args = Array::Handle(isolate, Array::New(1)); | 308 const String& error_str = String::Handle(zone, String::New(msg)); |
| 309 const Array& args = Array::Handle(zone, Array::New(1)); |
309 args.SetAt(0, error_str); | 310 args.SetAt(0, error_str); |
310 Object& result = Object::Handle(isolate); | 311 Object& result = Object::Handle(zone); |
311 const Library& library = Library::Handle(isolate, Library::CoreLibrary()); | 312 const Library& library = Library::Handle(zone, Library::CoreLibrary()); |
312 result = DartLibraryCalls::InstanceCreate(library, | 313 result = DartLibraryCalls::InstanceCreate(library, |
313 Symbols::ArgumentError(), | 314 Symbols::ArgumentError(), |
314 Symbols::Dot(), | 315 Symbols::Dot(), |
315 args); | 316 args); |
316 const Stacktrace& stacktrace = Stacktrace::Handle(isolate); | 317 const Stacktrace& stacktrace = Stacktrace::Handle(zone); |
317 const UnhandledException& error = UnhandledException::Handle( | 318 const UnhandledException& error = UnhandledException::Handle( |
318 isolate, UnhandledException::New(Instance::Cast(result), stacktrace)); | 319 zone, UnhandledException::New(Instance::Cast(result), stacktrace)); |
319 isolate->long_jump_base()->Jump(1, error); | 320 thread->long_jump_base()->Jump(1, error); |
320 } | 321 } |
321 | 322 |
322 | 323 |
323 RawObject* SnapshotReader::VmIsolateSnapshotObject(intptr_t index) const { | 324 RawObject* SnapshotReader::VmIsolateSnapshotObject(intptr_t index) const { |
324 return Object::vm_isolate_snapshot_object_table().At(index); | 325 return Object::vm_isolate_snapshot_object_table().At(index); |
325 } | 326 } |
326 | 327 |
327 | 328 |
328 bool SnapshotReader::is_vm_isolate() const { | 329 bool SnapshotReader::is_vm_isolate() const { |
329 return isolate_ == Dart::vm_isolate(); | 330 return isolate_ == Dart::vm_isolate(); |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 uword address = | 1059 uword address = |
1059 old_space()->TryAllocateSmiInitializedLocked(size, | 1060 old_space()->TryAllocateSmiInitializedLocked(size, |
1060 PageSpace::kForceGrowth); | 1061 PageSpace::kForceGrowth); |
1061 if (address == 0) { | 1062 if (address == 0) { |
1062 // Use the preallocated out of memory exception to avoid calling | 1063 // Use the preallocated out of memory exception to avoid calling |
1063 // into dart code or allocating any code. | 1064 // into dart code or allocating any code. |
1064 // We do a longjmp at this point to unwind out of the entire | 1065 // We do a longjmp at this point to unwind out of the entire |
1065 // read part and return the error object back. | 1066 // read part and return the error object back. |
1066 const UnhandledException& error = UnhandledException::Handle( | 1067 const UnhandledException& error = UnhandledException::Handle( |
1067 object_store()->preallocated_unhandled_exception()); | 1068 object_store()->preallocated_unhandled_exception()); |
1068 Isolate::Current()->long_jump_base()->Jump(1, error); | 1069 Thread::Current()->long_jump_base()->Jump(1, error); |
1069 } | 1070 } |
1070 VerifiedMemory::Accept(address, size); | 1071 VerifiedMemory::Accept(address, size); |
1071 | 1072 |
1072 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); | 1073 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); |
1073 uword tags = 0; | 1074 uword tags = 0; |
1074 ASSERT(class_id != kIllegalCid); | 1075 ASSERT(class_id != kIllegalCid); |
1075 tags = RawObject::ClassIdTag::update(class_id, tags); | 1076 tags = RawObject::ClassIdTag::update(class_id, tags); |
1076 tags = RawObject::SizeTag::update(size, tags); | 1077 tags = RawObject::SizeTag::update(size, tags); |
1077 tags = RawObject::VMHeapObjectTag::update(is_vm_isolate(), tags); | 1078 tags = RawObject::VMHeapObjectTag::update(is_vm_isolate(), tags); |
1078 raw_obj->ptr()->tags_ = tags; | 1079 raw_obj->ptr()->tags_ = tags; |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2171 SetWriteException(Exceptions::kArgument, chars); | 2172 SetWriteException(Exceptions::kArgument, chars); |
2172 } | 2173 } |
2173 } | 2174 } |
2174 | 2175 |
2175 | 2176 |
2176 void SnapshotWriter::SetWriteException(Exceptions::ExceptionType type, | 2177 void SnapshotWriter::SetWriteException(Exceptions::ExceptionType type, |
2177 const char* msg) { | 2178 const char* msg) { |
2178 set_exception_type(type); | 2179 set_exception_type(type); |
2179 set_exception_msg(msg); | 2180 set_exception_msg(msg); |
2180 // The more specific error is set up in SnapshotWriter::ThrowException(). | 2181 // The more specific error is set up in SnapshotWriter::ThrowException(). |
2181 isolate()->long_jump_base()-> | 2182 thread()->long_jump_base()-> |
2182 Jump(1, Object::snapshot_writer_error()); | 2183 Jump(1, Object::snapshot_writer_error()); |
2183 } | 2184 } |
2184 | 2185 |
2185 | 2186 |
2186 void SnapshotWriter::WriteInstance(intptr_t object_id, | 2187 void SnapshotWriter::WriteInstance(intptr_t object_id, |
2187 RawObject* raw, | 2188 RawObject* raw, |
2188 RawClass* cls, | 2189 RawClass* cls, |
2189 intptr_t tags) { | 2190 intptr_t tags) { |
2190 // Check if the instance has native fields and throw an exception if it does. | 2191 // Check if the instance has native fields and throw an exception if it does. |
2191 CheckForNativeFields(cls); | 2192 CheckForNativeFields(cls); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2397 NoSafepointScope no_safepoint; | 2398 NoSafepointScope no_safepoint; |
2398 WriteObject(obj.raw()); | 2399 WriteObject(obj.raw()); |
2399 UnmarkAll(); | 2400 UnmarkAll(); |
2400 } else { | 2401 } else { |
2401 ThrowException(exception_type(), exception_msg()); | 2402 ThrowException(exception_type(), exception_msg()); |
2402 } | 2403 } |
2403 } | 2404 } |
2404 | 2405 |
2405 | 2406 |
2406 } // namespace dart | 2407 } // namespace dart |
OLD | NEW |