| 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/exceptions.h" | 10 #include "vm/exceptions.h" |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 for (intptr_t i = 0; i < len; i++) { | 1032 for (intptr_t i = 0; i < len; i++) { |
| 1033 *PassiveObjectHandle() = is_canonical ? ReadObjectImpl() : ReadObjectRef(); | 1033 *PassiveObjectHandle() = is_canonical ? ReadObjectImpl() : ReadObjectRef(); |
| 1034 result.SetAt(i, *PassiveObjectHandle()); | 1034 result.SetAt(i, *PassiveObjectHandle()); |
| 1035 } | 1035 } |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 | 1038 |
| 1039 SnapshotWriter::SnapshotWriter(Snapshot::Kind kind, | 1039 SnapshotWriter::SnapshotWriter(Snapshot::Kind kind, |
| 1040 uint8_t** buffer, | 1040 uint8_t** buffer, |
| 1041 ReAlloc alloc, | 1041 ReAlloc alloc, |
| 1042 intptr_t initial_size) | 1042 intptr_t initial_size, |
| 1043 bool can_send_any_object) |
| 1043 : BaseWriter(buffer, alloc, initial_size), | 1044 : BaseWriter(buffer, alloc, initial_size), |
| 1044 kind_(kind), | 1045 kind_(kind), |
| 1045 isolate_(Isolate::Current()), | 1046 isolate_(Isolate::Current()), |
| 1046 object_store_(isolate_->object_store()), | 1047 object_store_(isolate_->object_store()), |
| 1047 class_table_(isolate_->class_table()), | 1048 class_table_(isolate_->class_table()), |
| 1048 forward_list_(kMaxPredefinedObjectIds), | 1049 forward_list_(kMaxPredefinedObjectIds), |
| 1049 exception_type_(Exceptions::kNone), | 1050 exception_type_(Exceptions::kNone), |
| 1050 exception_msg_(NULL), | 1051 exception_msg_(NULL), |
| 1051 unmarked_objects_(false) { | 1052 unmarked_objects_(false), |
| 1053 can_send_any_object_(can_send_any_object) { |
| 1052 } | 1054 } |
| 1053 | 1055 |
| 1054 | 1056 |
| 1055 void SnapshotWriter::WriteObject(RawObject* rawobj) { | 1057 void SnapshotWriter::WriteObject(RawObject* rawobj) { |
| 1056 WriteObjectImpl(rawobj); | 1058 WriteObjectImpl(rawobj); |
| 1057 WriteForwardedObjects(); | 1059 WriteForwardedObjects(); |
| 1058 } | 1060 } |
| 1059 | 1061 |
| 1060 | 1062 |
| 1061 void SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) { | 1063 void SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) { |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 WriteInlinedObjectHeader(kOmittedObjectId); | 1703 WriteInlinedObjectHeader(kOmittedObjectId); |
| 1702 | 1704 |
| 1703 // Indicate this is an instance object. | 1705 // Indicate this is an instance object. |
| 1704 Write<int32_t>(SerializedHeaderData::encode(kInstanceObjectId)); | 1706 Write<int32_t>(SerializedHeaderData::encode(kInstanceObjectId)); |
| 1705 | 1707 |
| 1706 // Write out the class information for this object. | 1708 // Write out the class information for this object. |
| 1707 WriteObjectImpl(cls); | 1709 WriteObjectImpl(cls); |
| 1708 } | 1710 } |
| 1709 | 1711 |
| 1710 | 1712 |
| 1713 bool SnapshotWriter::AllowObjectsInDartLibrary(RawLibrary* library) { |
| 1714 return (library == object_store()->collection_library() || |
| 1715 library == object_store()->typed_data_library()); |
| 1716 } |
| 1717 |
| 1718 |
| 1711 void SnapshotWriter::ThrowException(Exceptions::ExceptionType type, | 1719 void SnapshotWriter::ThrowException(Exceptions::ExceptionType type, |
| 1712 const char* msg) { | 1720 const char* msg) { |
| 1713 isolate()->object_store()->clear_sticky_error(); | 1721 object_store()->clear_sticky_error(); |
| 1714 UnmarkAll(); | 1722 UnmarkAll(); |
| 1715 if (msg != NULL) { | 1723 if (msg != NULL) { |
| 1716 const String& msg_obj = String::Handle(String::New(msg)); | 1724 const String& msg_obj = String::Handle(String::New(msg)); |
| 1717 const Array& args = Array::Handle(Array::New(1)); | 1725 const Array& args = Array::Handle(Array::New(1)); |
| 1718 args.SetAt(0, msg_obj); | 1726 args.SetAt(0, msg_obj); |
| 1719 Exceptions::ThrowByType(type, args); | 1727 Exceptions::ThrowByType(type, args); |
| 1720 } else { | 1728 } else { |
| 1721 Exceptions::ThrowByType(type, Object::empty_array()); | 1729 Exceptions::ThrowByType(type, Object::empty_array()); |
| 1722 } | 1730 } |
| 1723 UNREACHABLE(); | 1731 UNREACHABLE(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 NoGCScope no_gc; | 1794 NoGCScope no_gc; |
| 1787 WriteObject(obj.raw()); | 1795 WriteObject(obj.raw()); |
| 1788 UnmarkAll(); | 1796 UnmarkAll(); |
| 1789 } else { | 1797 } else { |
| 1790 ThrowException(exception_type(), exception_msg()); | 1798 ThrowException(exception_type(), exception_msg()); |
| 1791 } | 1799 } |
| 1792 } | 1800 } |
| 1793 | 1801 |
| 1794 | 1802 |
| 1795 } // namespace dart | 1803 } // namespace dart |
| OLD | NEW |