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

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

Issue 221973004: - Handle doubles transferred in message snapshots specially. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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
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/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 } 1762 }
1763 writer->WriteBytes(reinterpret_cast<const uint8_t*>(&(str[2])), (len - 2)); 1763 writer->WriteBytes(reinterpret_cast<const uint8_t*>(&(str[2])), (len - 2));
1764 } 1764 }
1765 1765
1766 1766
1767 RawDouble* Double::ReadFrom(SnapshotReader* reader, 1767 RawDouble* Double::ReadFrom(SnapshotReader* reader,
1768 intptr_t object_id, 1768 intptr_t object_id,
1769 intptr_t tags, 1769 intptr_t tags,
1770 Snapshot::Kind kind) { 1770 Snapshot::Kind kind) {
1771 ASSERT(reader != NULL); 1771 ASSERT(reader != NULL);
1772 ASSERT(kind != Snapshot::kMessage);
1772 // Read the double value for the object. 1773 // Read the double value for the object.
1773 double value = reader->Read<double>(); 1774 double value = reader->ReadDouble();
1774 1775
1775 // Create a Double object or get canonical one if it is a canonical constant. 1776 // Create a Double object or get canonical one if it is a canonical constant.
1776 Double& dbl = Double::ZoneHandle(reader->isolate(), Double::null()); 1777 Double& dbl = Double::ZoneHandle(reader->isolate(), Double::null());
1777 if (kind == Snapshot::kFull) { 1778 if (kind == Snapshot::kFull) {
1778 dbl = reader->NewDouble(value); 1779 dbl = reader->NewDouble(value);
1779 } else { 1780 } else {
1780 // When reading a script snapshot we need to canonicalize only those object 1781 // When reading a script snapshot we need to canonicalize only those object
1781 // references that are objects from the core library (loaded from a 1782 // references that are objects from the core library (loaded from a
1782 // full snapshot). Objects that are only in the script need not be 1783 // full snapshot). Objects that are only in the script need not be
1783 // canonicalized as they are already canonical. 1784 // canonicalized as they are already canonical.
1784 // When reading a message snapshot we always have to canonicalize.
1785 if (RawObject::IsCanonical(tags) && 1785 if (RawObject::IsCanonical(tags) &&
1786 (RawObject::IsCreatedFromSnapshot(tags) || 1786 RawObject::IsCreatedFromSnapshot(tags)) {
1787 (kind == Snapshot::kMessage))) {
1788 dbl = Double::NewCanonical(value); 1787 dbl = Double::NewCanonical(value);
1789 } else { 1788 } else {
1790 dbl = Double::New(value, HEAP_SPACE(kind)); 1789 dbl = Double::New(value, HEAP_SPACE(kind));
1791 } 1790 }
1792 } 1791 }
1793 reader->AddBackRef(object_id, &dbl, kIsDeserialized); 1792 reader->AddBackRef(object_id, &dbl, kIsDeserialized);
1794 1793
1795 // Set the object tags. 1794 // Set the object tags.
1796 dbl.set_tags(tags); 1795 dbl.set_tags(tags);
1797 1796
1798 return dbl.raw(); 1797 return dbl.raw();
1799 } 1798 }
1800 1799
1801 1800
1802 void RawDouble::WriteTo(SnapshotWriter* writer, 1801 void RawDouble::WriteTo(SnapshotWriter* writer,
1803 intptr_t object_id, 1802 intptr_t object_id,
1804 Snapshot::Kind kind) { 1803 Snapshot::Kind kind) {
1805 ASSERT(writer != NULL); 1804 ASSERT(writer != NULL);
1806 1805
1807 // Write out the serialization header value for this object. 1806 // Write out the serialization header value for this object.
1808 writer->WriteInlinedObjectHeader(object_id); 1807 writer->WriteInlinedObjectHeader(object_id);
1809 1808
1810 // Write out the class and tags information. 1809 // Write out the class and tags information.
1811 writer->WriteIndexedObject(kDoubleCid); 1810 writer->WriteIndexedObject(kDoubleCid);
1812 writer->WriteIntptrValue(writer->GetObjectTags(this)); 1811 writer->WriteIntptrValue(writer->GetObjectTags(this));
1813 1812
1814 // Write out the double value. 1813 // Write out the double value.
1815 writer->Write<double>(ptr()->value_); 1814 writer->WriteDouble(ptr()->value_);
1816 } 1815 }
1817 1816
1818 1817
1819 RawString* String::ReadFrom(SnapshotReader* reader, 1818 RawString* String::ReadFrom(SnapshotReader* reader,
1820 intptr_t object_id, 1819 intptr_t object_id,
1821 intptr_t tags, 1820 intptr_t tags,
1822 Snapshot::Kind kind) { 1821 Snapshot::Kind kind) {
1823 UNREACHABLE(); // String is an abstract class. 1822 UNREACHABLE(); // String is an abstract class.
1824 return String::null(); 1823 return String::null();
1825 } 1824 }
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
2687 // We do not allow objects with native fields in an isolate message. 2686 // We do not allow objects with native fields in an isolate message.
2688 writer->SetWriteException(Exceptions::kArgument, 2687 writer->SetWriteException(Exceptions::kArgument,
2689 "Illegal argument in isolate message" 2688 "Illegal argument in isolate message"
2690 " : (object is a MirrorReference)"); 2689 " : (object is a MirrorReference)");
2691 } else { 2690 } else {
2692 UNREACHABLE(); 2691 UNREACHABLE();
2693 } 2692 }
2694 } 2693 }
2695 2694
2696 } // namespace dart 2695 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | runtime/vm/snapshot.h » ('j') | runtime/vm/snapshot.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698