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

Side by Side Diff: runtime/vm/raw_object_snapshot.cc

Issue 12578009: - Canonicalize types, type_arguments only when the object is marked as being from the core librarie… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months 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
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 // Set all the object fields. 199 // Set all the object fields.
200 // TODO(5411462): Need to assert No GC can happen here, even though 200 // TODO(5411462): Need to assert No GC can happen here, even though
201 // allocations may happen. 201 // allocations may happen.
202 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); 202 intptr_t num_flds = (type.raw()->to() - type.raw()->from());
203 for (intptr_t i = 0; i <= num_flds; i++) { 203 for (intptr_t i = 0; i <= num_flds; i++) {
204 type.StorePointer((type.raw()->from() + i), reader->ReadObjectRef()); 204 type.StorePointer((type.raw()->from() + i), reader->ReadObjectRef());
205 } 205 }
206 206
207 // If object needs to be a canonical object, Canonicalize it. 207 // If object needs to be a canonical object, Canonicalize it.
208 if ((kind != Snapshot::kFull) && RawObject::IsCanonical(tags)) { 208 if (RawObject::IsCanonical(tags)) {
Ivan Posva 2013/03/22 21:17:22 This follows complicated rules and uses informatio
siva 2013/03/22 22:33:19 Added a comment detailing each case (Full, Script
209 type ^= type.Canonicalize(); 209 if ((kind == Snapshot::kScript && RawObject::IsCreatedFromSnapshot(tags)) ||
210 (kind == Snapshot::kMessage)) {
211 type ^= type.Canonicalize();
212 }
210 } 213 }
211 214
212 // Set the object tags (This is done after 'Canonicalize', which 215 // Set the object tags (This is done after 'Canonicalize', which
213 // does not canonicalize a type already marked as canonical). 216 // does not canonicalize a type already marked as canonical).
214 type.set_tags(tags); 217 type.set_tags(tags);
215 218
216 return type.raw(); 219 return type.raw();
217 } 220 }
218 221
219 222
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 reader->isolate(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind)); 454 reader->isolate(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind));
452 reader->AddBackRef(object_id, &type_arguments, kIsDeserialized); 455 reader->AddBackRef(object_id, &type_arguments, kIsDeserialized);
453 456
454 // Now set all the object fields. 457 // Now set all the object fields.
455 for (intptr_t i = 0; i < len; i++) { 458 for (intptr_t i = 0; i < len; i++) {
456 *reader->TypeHandle() ^= reader->ReadObjectImpl(); 459 *reader->TypeHandle() ^= reader->ReadObjectImpl();
457 type_arguments.SetTypeAt(i, *reader->TypeHandle()); 460 type_arguments.SetTypeAt(i, *reader->TypeHandle());
458 } 461 }
459 462
460 // If object needs to be a canonical object, Canonicalize it. 463 // If object needs to be a canonical object, Canonicalize it.
461 if ((kind != Snapshot::kFull) && RawObject::IsCanonical(tags)) { 464 if (RawObject::IsCanonical(tags)) {
Ivan Posva 2013/03/22 21:17:22 ditto
siva 2013/03/22 22:33:19 Done.
462 type_arguments ^= type_arguments.Canonicalize(); 465 if ((kind == Snapshot::kScript && RawObject::IsCreatedFromSnapshot(tags)) ||
466 (kind == Snapshot::kMessage)) {
467 type_arguments ^= type_arguments.Canonicalize();
468 }
463 } 469 }
464 470
465 // Set the object tags (This is done after setting the object fields 471 // Set the object tags (This is done after setting the object fields
466 // because 'SetTypeAt' has an assertion to check if the object is not 472 // because 'SetTypeAt' has an assertion to check if the object is not
467 // already canonical. Also, this is done after 'Canonicalize', which 473 // already canonical. Also, this is done after 'Canonicalize', which
468 // does not canonicalize a type already marked as canonical). 474 // does not canonicalize a type already marked as canonical).
469 type_arguments.set_tags(tags); 475 type_arguments.set_tags(tags);
470 476
471 return type_arguments.raw(); 477 return type_arguments.raw();
472 } 478 }
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 ASSERT(reader != NULL); 1596 ASSERT(reader != NULL);
1591 1597
1592 // Read the 64 bit value for the object. 1598 // Read the 64 bit value for the object.
1593 int64_t value = reader->Read<int64_t>(); 1599 int64_t value = reader->Read<int64_t>();
1594 1600
1595 // Create a Mint object or get canonical one if it is a canonical constant. 1601 // Create a Mint object or get canonical one if it is a canonical constant.
1596 Mint& mint = Mint::ZoneHandle(reader->isolate(), Mint::null()); 1602 Mint& mint = Mint::ZoneHandle(reader->isolate(), Mint::null());
1597 if (kind == Snapshot::kFull) { 1603 if (kind == Snapshot::kFull) {
1598 mint = reader->NewMint(value); 1604 mint = reader->NewMint(value);
1599 } else { 1605 } else {
1600 if (RawObject::IsCanonical(tags)) { 1606 if (RawObject::IsCanonical(tags) &&
Ivan Posva 2013/03/22 21:17:22 ditto
siva 2013/03/22 22:33:19 Done.
1607 (RawObject::IsCreatedFromSnapshot(tags) ||
1608 (kind == Snapshot::kMessage))) {
1601 mint = Mint::NewCanonical(value); 1609 mint = Mint::NewCanonical(value);
1602 } else { 1610 } else {
1603 mint = Mint::New(value, HEAP_SPACE(kind)); 1611 mint = Mint::New(value, HEAP_SPACE(kind));
1604 } 1612 }
1605 } 1613 }
1606 reader->AddBackRef(object_id, &mint, kIsDeserialized); 1614 reader->AddBackRef(object_id, &mint, kIsDeserialized);
1607 1615
1608 // Set the object tags. 1616 // Set the object tags.
1609 mint.set_tags(tags); 1617 mint.set_tags(tags);
1610 1618
(...skipping 30 matching lines...) Expand all
1641 str[len] = '\0'; 1649 str[len] = '\0';
1642 reader->ReadBytes(reinterpret_cast<uint8_t*>(str), len); 1650 reader->ReadBytes(reinterpret_cast<uint8_t*>(str), len);
1643 1651
1644 // Create a Bigint object from HexCString. 1652 // Create a Bigint object from HexCString.
1645 Bigint& obj = Bigint::ZoneHandle( 1653 Bigint& obj = Bigint::ZoneHandle(
1646 reader->isolate(), 1654 reader->isolate(),
1647 ((kind == Snapshot::kFull) ? reader->NewBigint(str) : 1655 ((kind == Snapshot::kFull) ? reader->NewBigint(str) :
1648 BigintOperations::FromHexCString(str, HEAP_SPACE(kind)))); 1656 BigintOperations::FromHexCString(str, HEAP_SPACE(kind))));
1649 1657
1650 // If it is a canonical constant make it one. 1658 // If it is a canonical constant make it one.
1651 if ((kind != Snapshot::kFull) && RawObject::IsCanonical(tags)) { 1659 if (RawObject::IsCanonical(tags)) {
Ivan Posva 2013/03/22 21:17:22 ditto.
siva 2013/03/22 22:33:19 Done.
1652 obj ^= obj.Canonicalize(); 1660 if ((kind == Snapshot::kScript && RawObject::IsCreatedFromSnapshot(tags)) ||
1661 (kind == Snapshot::kMessage)) {
1662 obj ^= obj.Canonicalize();
1663 }
1653 } 1664 }
1654 reader->AddBackRef(object_id, &obj, kIsDeserialized); 1665 reader->AddBackRef(object_id, &obj, kIsDeserialized);
1655 1666
1656 // Set the object tags. 1667 // Set the object tags.
1657 obj.set_tags(tags); 1668 obj.set_tags(tags);
1658 1669
1659 return obj.raw(); 1670 return obj.raw();
1660 } 1671 }
1661 1672
1662 1673
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 Snapshot::Kind kind) { 1719 Snapshot::Kind kind) {
1709 ASSERT(reader != NULL); 1720 ASSERT(reader != NULL);
1710 // Read the double value for the object. 1721 // Read the double value for the object.
1711 double value = reader->Read<double>(); 1722 double value = reader->Read<double>();
1712 1723
1713 // Create a Double object or get canonical one if it is a canonical constant. 1724 // Create a Double object or get canonical one if it is a canonical constant.
1714 Double& dbl = Double::ZoneHandle(reader->isolate(), Double::null()); 1725 Double& dbl = Double::ZoneHandle(reader->isolate(), Double::null());
1715 if (kind == Snapshot::kFull) { 1726 if (kind == Snapshot::kFull) {
1716 dbl = reader->NewDouble(value); 1727 dbl = reader->NewDouble(value);
1717 } else { 1728 } else {
1718 if (RawObject::IsCanonical(tags)) { 1729 if (RawObject::IsCanonical(tags) &&
Ivan Posva 2013/03/22 21:17:22 ditto
siva 2013/03/22 22:33:19 Done.
1730 (RawObject::IsCreatedFromSnapshot(tags) ||
1731 (kind == Snapshot::kMessage))) {
1719 dbl = Double::NewCanonical(value); 1732 dbl = Double::NewCanonical(value);
1720 } else { 1733 } else {
1721 dbl = Double::New(value, HEAP_SPACE(kind)); 1734 dbl = Double::New(value, HEAP_SPACE(kind));
1722 } 1735 }
1723 } 1736 }
1724 reader->AddBackRef(object_id, &dbl, kIsDeserialized); 1737 reader->AddBackRef(object_id, &dbl, kIsDeserialized);
1725 1738
1726 // Set the object tags. 1739 // Set the object tags.
1727 dbl.set_tags(tags); 1740 dbl.set_tags(tags);
1728 1741
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 // Write out the class and tags information. 2809 // Write out the class and tags information.
2797 writer->WriteIndexedObject(kWeakPropertyCid); 2810 writer->WriteIndexedObject(kWeakPropertyCid);
2798 writer->WriteIntptrValue(writer->GetObjectTags(this)); 2811 writer->WriteIntptrValue(writer->GetObjectTags(this));
2799 2812
2800 // Write out all the other fields. 2813 // Write out all the other fields.
2801 writer->Write<RawObject*>(ptr()->key_); 2814 writer->Write<RawObject*>(ptr()->key_);
2802 writer->Write<RawObject*>(ptr()->value_); 2815 writer->Write<RawObject*>(ptr()->value_);
2803 } 2816 }
2804 2817
2805 } // namespace dart 2818 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698