Chromium Code Reviews| 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/object.h" | 5 #include "vm/object.h" |
| 6 #include "vm/object_store.h" | 6 #include "vm/object_store.h" |
| 7 #include "vm/snapshot.h" | 7 #include "vm/snapshot.h" |
| 8 #include "vm/stub_code.h" | 8 #include "vm/stub_code.h" |
| 9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
| 10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 597 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 598 | 598 |
| 599 // Write out the serialization header value for this object. | 599 // Write out the serialization header value for this object. |
| 600 writer->WriteInlinedObjectHeader(object_id); | 600 writer->WriteInlinedObjectHeader(object_id); |
| 601 | 601 |
| 602 // Write out the class and tags information. | 602 // Write out the class and tags information. |
| 603 writer->WriteVMIsolateObject(kClosureDataCid); | 603 writer->WriteVMIsolateObject(kClosureDataCid); |
| 604 writer->WriteTags(writer->GetObjectTags(this)); | 604 writer->WriteTags(writer->GetObjectTags(this)); |
| 605 | 605 |
| 606 // Context scope. | 606 // Context scope. |
| 607 // We don't write the context scope in the snapshot. | 607 if (ptr()->context_scope_ == Object::empty_context_scope().raw()) { |
| 608 writer->WriteVMIsolateObject(kEmptyContextScopeObject); | |
| 609 } else { | |
| 610 if (ptr()->context_scope_->ptr()->is_implicit_) { | |
| 611 writer->WriteObjectImpl(ptr()->context_scope_, kAsInlinedObject); | |
| 612 } else { | |
| 613 // We don't write non implicit context scopes in the snapshot. | |
| 614 writer->WriteVMIsolateObject(kNullObject); | |
| 615 } | |
| 616 } | |
| 617 | |
| 608 writer->WriteObjectImpl(Object::null(), kAsInlinedObject); | 618 writer->WriteObjectImpl(Object::null(), kAsInlinedObject); |
|
rmacnak
2015/09/02 01:19:50
Remove this one - this CL increases the number of
| |
| 609 | 619 |
| 610 // Parent function. | 620 // Parent function. |
| 611 writer->WriteObjectImpl(ptr()->parent_function_, kAsInlinedObject); | 621 writer->WriteObjectImpl(ptr()->parent_function_, kAsInlinedObject); |
| 612 | 622 |
| 613 // Signature class. | 623 // Signature class. |
| 614 writer->WriteObjectImpl(ptr()->signature_class_, kAsInlinedObject); | 624 writer->WriteObjectImpl(ptr()->signature_class_, kAsInlinedObject); |
| 615 | 625 |
| 616 // Static closure/Closure allocation stub. | 626 // Static closure/Closure allocation stub. |
| 617 // We don't write the closure or allocation stub in the snapshot. | 627 // We don't write the closure or allocation stub in the snapshot. |
| 618 writer->WriteObjectImpl(Object::null(), kAsInlinedObject); | 628 writer->WriteVMIsolateObject(kNullObject); |
| 619 } | 629 } |
| 620 | 630 |
| 621 | 631 |
| 622 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader, | 632 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader, |
| 623 intptr_t object_id, | 633 intptr_t object_id, |
| 624 intptr_t tags, | 634 intptr_t tags, |
| 625 Snapshot::Kind kind) { | 635 Snapshot::Kind kind) { |
| 626 ASSERT(reader != NULL); | 636 ASSERT(reader != NULL); |
| 627 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 637 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 628 | 638 |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1612 SnapshotWriterVisitor visitor(writer); | 1622 SnapshotWriterVisitor visitor(writer); |
| 1613 visitor.VisitPointers(from(), to(num_variables)); | 1623 visitor.VisitPointers(from(), to(num_variables)); |
| 1614 } | 1624 } |
| 1615 } | 1625 } |
| 1616 | 1626 |
| 1617 | 1627 |
| 1618 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, | 1628 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, |
| 1619 intptr_t object_id, | 1629 intptr_t object_id, |
| 1620 intptr_t tags, | 1630 intptr_t tags, |
| 1621 Snapshot::Kind kind) { | 1631 Snapshot::Kind kind) { |
| 1632 ASSERT(reader != NULL); | |
| 1633 | |
| 1634 // Allocate context object. | |
| 1635 bool is_implicit = reader->Read<bool>(); | |
| 1636 if (is_implicit) { | |
| 1637 ContextScope& context_scope = | |
| 1638 ContextScope::ZoneHandle(ContextScope::New(1, true)); | |
|
rmacnak
2015/09/02 01:19:50
ContextScope::New fails
Thread::Current()->no_safe
| |
| 1639 reader->AddBackRef(object_id, &context_scope, kIsDeserialized); | |
| 1640 | |
| 1641 *reader->TypeHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); | |
| 1642 | |
| 1643 // Create a descriptor for 'this' variable. | |
| 1644 context_scope.SetTokenIndexAt(0, 0); | |
| 1645 context_scope.SetNameAt(0, Symbols::This()); | |
| 1646 context_scope.SetIsFinalAt(0, true); | |
| 1647 context_scope.SetIsConstAt(0, false); | |
| 1648 context_scope.SetTypeAt(0, *reader->TypeHandle()); | |
| 1649 context_scope.SetContextIndexAt(0, 0); | |
| 1650 context_scope.SetContextLevelAt(0, 0); | |
| 1651 return context_scope.raw(); | |
| 1652 } | |
| 1622 UNREACHABLE(); | 1653 UNREACHABLE(); |
| 1623 return NULL; | 1654 return NULL; |
| 1624 } | 1655 } |
| 1625 | 1656 |
| 1626 | 1657 |
| 1627 void RawContextScope::WriteTo(SnapshotWriter* writer, | 1658 void RawContextScope::WriteTo(SnapshotWriter* writer, |
| 1628 intptr_t object_id, | 1659 intptr_t object_id, |
| 1629 Snapshot::Kind kind) { | 1660 Snapshot::Kind kind) { |
| 1661 ASSERT(writer != NULL); | |
| 1662 | |
| 1663 if (ptr()->is_implicit_) { | |
| 1664 ASSERT(ptr()->num_variables_ == 1); | |
| 1665 const VariableDesc* var = ptr()->VariableDescAddr(0); | |
| 1666 | |
| 1667 // Write out the serialization header value for this object. | |
| 1668 writer->WriteInlinedObjectHeader(object_id); | |
| 1669 | |
| 1670 // Write out the class and tags information. | |
| 1671 writer->WriteVMIsolateObject(kContextScopeCid); | |
| 1672 writer->WriteTags(writer->GetObjectTags(this)); | |
| 1673 | |
| 1674 // Write out is_implicit flag for the context scope. | |
| 1675 writer->Write<bool>(true); | |
| 1676 | |
| 1677 // Write out the type of 'this' the variable. | |
| 1678 writer->WriteObjectImpl(var->type, kAsInlinedObject); | |
| 1679 | |
| 1680 return; | |
| 1681 } | |
| 1630 UNREACHABLE(); | 1682 UNREACHABLE(); |
| 1631 } | 1683 } |
| 1632 | 1684 |
| 1633 | 1685 |
| 1634 RawICData* ICData::ReadFrom(SnapshotReader* reader, | 1686 RawICData* ICData::ReadFrom(SnapshotReader* reader, |
| 1635 intptr_t object_id, | 1687 intptr_t object_id, |
| 1636 intptr_t tags, | 1688 intptr_t tags, |
| 1637 Snapshot::Kind kind) { | 1689 Snapshot::Kind kind) { |
| 1638 UNREACHABLE(); // Untested. | 1690 UNREACHABLE(); // Untested. |
| 1639 ASSERT(reader->snapshot_code()); | 1691 ASSERT(reader->snapshot_code()); |
| (...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3253 // We do not allow objects with native fields in an isolate message. | 3305 // We do not allow objects with native fields in an isolate message. |
| 3254 writer->SetWriteException(Exceptions::kArgument, | 3306 writer->SetWriteException(Exceptions::kArgument, |
| 3255 "Illegal argument in isolate message" | 3307 "Illegal argument in isolate message" |
| 3256 " : (object is a UserTag)"); | 3308 " : (object is a UserTag)"); |
| 3257 } else { | 3309 } else { |
| 3258 UNREACHABLE(); | 3310 UNREACHABLE(); |
| 3259 } | 3311 } |
| 3260 } | 3312 } |
| 3261 | 3313 |
| 3262 } // namespace dart | 3314 } // namespace dart |
| OLD | NEW |