Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: vm/raw_object_snapshot.cc

Issue 11443005: Issue - 7123 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/bigint_operations.h" 5 #include "vm/bigint_operations.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/snapshot.h" 8 #include "vm/snapshot.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 #include "vm/visitor.h" 10 #include "vm/visitor.h"
(...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 Snapshot::Kind kind) { 1600 Snapshot::Kind kind) {
1601 UNREACHABLE(); // String is an abstract class. 1601 UNREACHABLE(); // String is an abstract class.
1602 } 1602 }
1603 1603
1604 1604
1605 template<typename StringType, typename CharacterType> 1605 template<typename StringType, typename CharacterType>
1606 void String::ReadFromImpl(SnapshotReader* reader, 1606 void String::ReadFromImpl(SnapshotReader* reader,
1607 String* str_obj, 1607 String* str_obj,
1608 intptr_t len, 1608 intptr_t len,
1609 intptr_t tags, 1609 intptr_t tags,
1610 RawString* (*NewSymbol)(const CharacterType* chars,
cshapiro 2012/12/05 20:40:16 s/NewSymbol/new_symbol/ Also, see my comment in t
siva 2012/12/05 23:33:14 Done.
1611 intptr_t len),
1610 Snapshot::Kind kind) { 1612 Snapshot::Kind kind) {
1611 ASSERT(reader != NULL); 1613 ASSERT(reader != NULL);
1612 if (RawObject::IsCanonical(tags)) { 1614 if (RawObject::IsCanonical(tags)) {
1613 // Set up canonical string object. 1615 // Set up canonical string object.
1614 ASSERT(reader != NULL); 1616 ASSERT(reader != NULL);
1615 CharacterType* ptr = 1617 CharacterType* ptr =
1616 Isolate::Current()->current_zone()->Alloc<CharacterType>(len); 1618 Isolate::Current()->current_zone()->Alloc<CharacterType>(len);
1617 for (intptr_t i = 0; i < len; i++) { 1619 for (intptr_t i = 0; i < len; i++) {
1618 ptr[i] = reader->Read<CharacterType>(); 1620 ptr[i] = reader->Read<CharacterType>();
1619 } 1621 }
1620 *str_obj ^= Symbols::NewSymbol(ptr, len); 1622 *str_obj ^= (*NewSymbol)(ptr, len);
1621 } else { 1623 } else {
1622 // Set up the string object. 1624 // Set up the string object.
1623 *str_obj = StringType::New(len, HEAP_SPACE(kind)); 1625 *str_obj = StringType::New(len, HEAP_SPACE(kind));
1624 str_obj->set_tags(tags); 1626 str_obj->set_tags(tags);
1625 str_obj->SetHash(0); // Will get computed when needed. 1627 str_obj->SetHash(0); // Will get computed when needed.
1626 for (intptr_t i = 0; i < len; i++) { 1628 for (intptr_t i = 0; i < len; i++) {
1627 *StringType::CharAddr(*str_obj, i) = reader->Read<CharacterType>(); 1629 *StringType::CharAddr(*str_obj, i) = reader->Read<CharacterType>();
1628 } 1630 }
1629 } 1631 }
1630 } 1632 }
(...skipping 15 matching lines...) Expand all
1646 str_obj = obj; 1648 str_obj = obj;
1647 str_obj.set_tags(tags); 1649 str_obj.set_tags(tags);
1648 obj->ptr()->hash_ = Smi::New(hash); 1650 obj->ptr()->hash_ = Smi::New(hash);
1649 if (len > 0) { 1651 if (len > 0) {
1650 uint8_t* raw_ptr = CharAddr(str_obj, 0); 1652 uint8_t* raw_ptr = CharAddr(str_obj, 0);
1651 reader->ReadBytes(raw_ptr, len); 1653 reader->ReadBytes(raw_ptr, len);
1652 } 1654 }
1653 ASSERT((hash == 0) || (String::Hash(str_obj, 0, str_obj.Length()) == hash)); 1655 ASSERT((hash == 0) || (String::Hash(str_obj, 0, str_obj.Length()) == hash));
1654 } else { 1656 } else {
1655 String::ReadFromImpl<OneByteString, uint8_t>( 1657 String::ReadFromImpl<OneByteString, uint8_t>(
1656 reader, &str_obj, len, tags, kind); 1658 reader, &str_obj, len, tags, Symbols::FromLatin1, kind);
1657 } 1659 }
1658 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); 1660 reader->AddBackRef(object_id, &str_obj, kIsDeserialized);
1659 return raw(str_obj); 1661 return raw(str_obj);
1660 } 1662 }
1661 1663
1662 1664
1663 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, 1665 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader,
1664 intptr_t object_id, 1666 intptr_t object_id,
1665 intptr_t tags, 1667 intptr_t tags,
1666 Snapshot::Kind kind) { 1668 Snapshot::Kind kind) {
(...skipping 10 matching lines...) Expand all
1677 obj->ptr()->hash_ = Smi::New(hash); 1679 obj->ptr()->hash_ = Smi::New(hash);
1678 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL; 1680 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL;
1679 for (intptr_t i = 0; i < len; i++) { 1681 for (intptr_t i = 0; i < len; i++) {
1680 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions. 1682 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions.
1681 *raw_ptr = reader->Read<uint16_t>(); 1683 *raw_ptr = reader->Read<uint16_t>();
1682 raw_ptr += 1; 1684 raw_ptr += 1;
1683 } 1685 }
1684 ASSERT(String::Hash(str_obj, 0, str_obj.Length()) == hash); 1686 ASSERT(String::Hash(str_obj, 0, str_obj.Length()) == hash);
1685 } else { 1687 } else {
1686 String::ReadFromImpl<TwoByteString, uint16_t>( 1688 String::ReadFromImpl<TwoByteString, uint16_t>(
1687 reader, &str_obj, len, tags, kind); 1689 reader, &str_obj, len, tags, Symbols::FromUTF16, kind);
1688 } 1690 }
1689 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); 1691 reader->AddBackRef(object_id, &str_obj, kIsDeserialized);
1690 return raw(str_obj); 1692 return raw(str_obj);
1691 } 1693 }
1692 1694
1693 1695
1694 template<typename T> 1696 template<typename T>
1695 static void StringWriteTo(SnapshotWriter* writer, 1697 static void StringWriteTo(SnapshotWriter* writer,
1696 intptr_t object_id, 1698 intptr_t object_id,
1697 Snapshot::Kind kind, 1699 Snapshot::Kind kind,
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 // Write out the class and tags information. 2212 // Write out the class and tags information.
2211 writer->WriteIndexedObject(kWeakPropertyCid); 2213 writer->WriteIndexedObject(kWeakPropertyCid);
2212 writer->WriteIntptrValue(writer->GetObjectTags(this)); 2214 writer->WriteIntptrValue(writer->GetObjectTags(this));
2213 2215
2214 // Write out all the other fields. 2216 // Write out all the other fields.
2215 writer->Write<RawObject*>(ptr()->key_); 2217 writer->Write<RawObject*>(ptr()->key_);
2216 writer->Write<RawObject*>(ptr()->value_); 2218 writer->Write<RawObject*>(ptr()->value_);
2217 } 2219 }
2218 2220
2219 } // namespace dart 2221 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698