| 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 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 uint8_t** buffer, | 1048 uint8_t** buffer, |
| 1049 ReAlloc alloc, | 1049 ReAlloc alloc, |
| 1050 intptr_t initial_size) | 1050 intptr_t initial_size) |
| 1051 : BaseWriter(buffer, alloc, initial_size), | 1051 : BaseWriter(buffer, alloc, initial_size), |
| 1052 kind_(kind), | 1052 kind_(kind), |
| 1053 isolate_(Isolate::Current()), | 1053 isolate_(Isolate::Current()), |
| 1054 object_store_(isolate_->object_store()), | 1054 object_store_(isolate_->object_store()), |
| 1055 class_table_(isolate_->class_table()), | 1055 class_table_(isolate_->class_table()), |
| 1056 forward_list_(kMaxPredefinedObjectIds), | 1056 forward_list_(kMaxPredefinedObjectIds), |
| 1057 exception_type_(Exceptions::kNone), | 1057 exception_type_(Exceptions::kNone), |
| 1058 exception_msg_(NULL) { | 1058 exception_msg_(NULL), |
| 1059 unmarked_objects_(false) { |
| 1059 } | 1060 } |
| 1060 | 1061 |
| 1061 | 1062 |
| 1062 void SnapshotWriter::WriteObject(RawObject* rawobj) { | 1063 void SnapshotWriter::WriteObject(RawObject* rawobj) { |
| 1063 WriteObjectImpl(rawobj); | 1064 WriteObjectImpl(rawobj); |
| 1064 WriteForwardedObjects(); | 1065 WriteForwardedObjects(); |
| 1065 } | 1066 } |
| 1066 | 1067 |
| 1067 | 1068 |
| 1068 void SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) { | 1069 void SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) { |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 } else { | 1604 } else { |
| 1604 WriteObjectRef(data[i]); | 1605 WriteObjectRef(data[i]); |
| 1605 } | 1606 } |
| 1606 } | 1607 } |
| 1607 } | 1608 } |
| 1608 | 1609 |
| 1609 | 1610 |
| 1610 void SnapshotWriter::CheckIfSerializable(RawClass* cls) { | 1611 void SnapshotWriter::CheckIfSerializable(RawClass* cls) { |
| 1611 if (Class::IsSignatureClass(cls)) { | 1612 if (Class::IsSignatureClass(cls)) { |
| 1612 // We do not allow closure objects in an isolate message. | 1613 // We do not allow closure objects in an isolate message. |
| 1613 SetWriteException(Exceptions::kArgument, | 1614 Isolate* isolate = Isolate::Current(); |
| 1614 "Illegal argument in isolate message" | 1615 HANDLESCOPE(isolate); |
| 1615 " : (object is a closure)"); | 1616 const char* format = "Illegal argument in isolate message" |
| 1617 " : (object is a closure - %s %s)"; |
| 1618 UnmarkAll(); // Unmark objects now as we are about to print stuff. |
| 1619 const Class& clazz = Class::Handle(isolate, cls); |
| 1620 const Function& func = Function::Handle(isolate, |
| 1621 clazz.signature_function()); |
| 1622 ASSERT(!func.IsNull()); |
| 1623 intptr_t len = OS::SNPrint(NULL, 0, format, |
| 1624 clazz.ToCString(), func.ToCString()) + 1; |
| 1625 char* chars = isolate->current_zone()->Alloc<char>(len); |
| 1626 OS::SNPrint(chars, len, format, clazz.ToCString(), func.ToCString()); |
| 1627 SetWriteException(Exceptions::kArgument, chars); |
| 1616 } | 1628 } |
| 1617 if (cls->ptr()->num_native_fields_ != 0) { | 1629 if (cls->ptr()->num_native_fields_ != 0) { |
| 1618 // We do not allow objects with native fields in an isolate message. | 1630 // We do not allow objects with native fields in an isolate message. |
| 1619 SetWriteException(Exceptions::kArgument, | 1631 Isolate* isolate = Isolate::Current(); |
| 1620 "Illegal argument in isolate message" | 1632 HANDLESCOPE(Isolate::Current()); |
| 1621 " : (object extends NativeWrapper)"); | 1633 const char* format = "Illegal argument in isolate message" |
| 1634 " : (object extends NativeWrapper - %s)"; |
| 1635 UnmarkAll(); // Unmark objects now as we are about to print stuff. |
| 1636 const Class& clazz = Class::Handle(isolate, cls); |
| 1637 intptr_t len = OS::SNPrint(NULL, 0, format, clazz.ToCString()) + 1; |
| 1638 char* chars = isolate->current_zone()->Alloc<char>(len); |
| 1639 OS::SNPrint(chars, len, format, clazz.ToCString()); |
| 1640 SetWriteException(Exceptions::kArgument, chars); |
| 1622 } | 1641 } |
| 1623 } | 1642 } |
| 1624 | 1643 |
| 1625 | 1644 |
| 1626 void SnapshotWriter::SetWriteException(Exceptions::ExceptionType type, | 1645 void SnapshotWriter::SetWriteException(Exceptions::ExceptionType type, |
| 1627 const char* msg) { | 1646 const char* msg) { |
| 1628 set_exception_type(type); | 1647 set_exception_type(type); |
| 1629 set_exception_msg(msg); | 1648 set_exception_msg(msg); |
| 1630 // The more specific error is set up in SnapshotWriter::ThrowException(). | 1649 // The more specific error is set up in SnapshotWriter::ThrowException(). |
| 1631 isolate()->long_jump_base()-> | 1650 isolate()->long_jump_base()-> |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1775 NoGCScope no_gc; | 1794 NoGCScope no_gc; |
| 1776 WriteObject(obj.raw()); | 1795 WriteObject(obj.raw()); |
| 1777 UnmarkAll(); | 1796 UnmarkAll(); |
| 1778 } else { | 1797 } else { |
| 1779 ThrowException(exception_type(), exception_msg()); | 1798 ThrowException(exception_type(), exception_msg()); |
| 1780 } | 1799 } |
| 1781 } | 1800 } |
| 1782 | 1801 |
| 1783 | 1802 |
| 1784 } // namespace dart | 1803 } // namespace dart |
| OLD | NEW |