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

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

Issue 343803002: Finishes removing intptr_t from raw object fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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/raw_object.cc ('k') | runtime/vm/scopes.cc » ('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/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 822
823 // Create the literal token object. 823 // Create the literal token object.
824 LiteralToken& literal_token = LiteralToken::ZoneHandle( 824 LiteralToken& literal_token = LiteralToken::ZoneHandle(
825 reader->isolate(), NEW_OBJECT(LiteralToken)); 825 reader->isolate(), NEW_OBJECT(LiteralToken));
826 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); 826 reader->AddBackRef(object_id, &literal_token, kIsDeserialized);
827 827
828 // Set the object tags. 828 // Set the object tags.
829 literal_token.set_tags(tags); 829 literal_token.set_tags(tags);
830 830
831 // Read the token attributes. 831 // Read the token attributes.
832 Token::Kind token_kind = static_cast<Token::Kind>(reader->ReadIntptrValue()); 832 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>());
833 literal_token.set_kind(token_kind); 833 literal_token.set_kind(token_kind);
834 *reader->StringHandle() ^= reader->ReadObjectImpl(); 834 *reader->StringHandle() ^= reader->ReadObjectImpl();
835 literal_token.set_literal(*reader->StringHandle()); 835 literal_token.set_literal(*reader->StringHandle());
836 *reader->PassiveObjectHandle() = reader->ReadObjectImpl(); 836 *reader->PassiveObjectHandle() = reader->ReadObjectImpl();
837 literal_token.set_value(*reader->PassiveObjectHandle()); 837 literal_token.set_value(*reader->PassiveObjectHandle());
838 838
839 return literal_token.raw(); 839 return literal_token.raw();
840 } 840 }
841 841
842 842
843 void RawLiteralToken::WriteTo(SnapshotWriter* writer, 843 void RawLiteralToken::WriteTo(SnapshotWriter* writer,
844 intptr_t object_id, 844 intptr_t object_id,
845 Snapshot::Kind kind) { 845 Snapshot::Kind kind) {
846 ASSERT(writer != NULL); 846 ASSERT(writer != NULL);
847 ASSERT(kind != Snapshot::kMessage); 847 ASSERT(kind != Snapshot::kMessage);
848 848
849 // Write out the serialization header value for this object. 849 // Write out the serialization header value for this object.
850 writer->WriteInlinedObjectHeader(object_id); 850 writer->WriteInlinedObjectHeader(object_id);
851 851
852 // Write out the class and tags information. 852 // Write out the class and tags information.
853 writer->WriteVMIsolateObject(kLiteralTokenCid); 853 writer->WriteVMIsolateObject(kLiteralTokenCid);
854 writer->WriteTags(writer->GetObjectTags(this)); 854 writer->WriteTags(writer->GetObjectTags(this));
855 855
856 // Write out the kind field. 856 // Write out the kind field.
857 writer->Write<intptr_t>(ptr()->kind_); 857 writer->Write<int32_t>(ptr()->kind_);
858 858
859 // Write out literal and value fields. 859 // Write out literal and value fields.
860 writer->WriteObjectImpl(ptr()->literal_); 860 writer->WriteObjectImpl(ptr()->literal_);
861 writer->WriteObjectImpl(ptr()->value_); 861 writer->WriteObjectImpl(ptr()->value_);
862 } 862 }
863 863
864 864
865 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, 865 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader,
866 intptr_t object_id, 866 intptr_t object_id,
867 intptr_t tags, 867 intptr_t tags,
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 } 1316 }
1317 1317
1318 1318
1319 RawContext* Context::ReadFrom(SnapshotReader* reader, 1319 RawContext* Context::ReadFrom(SnapshotReader* reader,
1320 intptr_t object_id, 1320 intptr_t object_id,
1321 intptr_t tags, 1321 intptr_t tags,
1322 Snapshot::Kind kind) { 1322 Snapshot::Kind kind) {
1323 ASSERT(reader != NULL); 1323 ASSERT(reader != NULL);
1324 1324
1325 // Allocate context object. 1325 // Allocate context object.
1326 intptr_t num_vars = reader->ReadIntptrValue(); 1326 int32_t num_vars = reader->Read<int32_t>();
1327 Context& context = Context::ZoneHandle(reader->isolate(), Context::null()); 1327 Context& context = Context::ZoneHandle(reader->isolate(), Context::null());
1328 if (kind == Snapshot::kFull) { 1328 if (kind == Snapshot::kFull) {
1329 context = reader->NewContext(num_vars); 1329 context = reader->NewContext(num_vars);
1330 } else { 1330 } else {
1331 context = Context::New(num_vars, HEAP_SPACE(kind)); 1331 context = Context::New(num_vars, HEAP_SPACE(kind));
1332 } 1332 }
1333 reader->AddBackRef(object_id, &context, kIsDeserialized); 1333 reader->AddBackRef(object_id, &context, kIsDeserialized);
1334 1334
1335 // Set the object tags. 1335 // Set the object tags.
1336 context.set_tags(tags); 1336 context.set_tags(tags);
(...skipping 21 matching lines...) Expand all
1358 ASSERT(writer != NULL); 1358 ASSERT(writer != NULL);
1359 1359
1360 // Write out the serialization header value for this object. 1360 // Write out the serialization header value for this object.
1361 writer->WriteInlinedObjectHeader(object_id); 1361 writer->WriteInlinedObjectHeader(object_id);
1362 1362
1363 // Write out the class and tags information. 1363 // Write out the class and tags information.
1364 writer->WriteVMIsolateObject(kContextCid); 1364 writer->WriteVMIsolateObject(kContextCid);
1365 writer->WriteTags(writer->GetObjectTags(this)); 1365 writer->WriteTags(writer->GetObjectTags(this));
1366 1366
1367 // Write out num of variables in the context. 1367 // Write out num of variables in the context.
1368 writer->WriteIntptrValue(ptr()->num_variables_); 1368 writer->Write<int32_t>(ptr()->num_variables_);
1369 1369
1370 // Can't serialize the isolate pointer, we set it implicitly on read. 1370 // Can't serialize the isolate pointer, we set it implicitly on read.
1371 1371
1372 // Write out all the object pointer fields. 1372 // Write out all the object pointer fields.
1373 SnapshotWriterVisitor visitor(writer); 1373 SnapshotWriterVisitor visitor(writer);
1374 visitor.VisitPointers(from(), to(ptr()->num_variables_)); 1374 visitor.VisitPointers(from(), to(ptr()->num_variables_));
1375 } 1375 }
1376 1376
1377 1377
1378 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, 1378 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader,
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 } 1711 }
1712 1712
1713 1713
1714 RawBigint* Bigint::ReadFrom(SnapshotReader* reader, 1714 RawBigint* Bigint::ReadFrom(SnapshotReader* reader,
1715 intptr_t object_id, 1715 intptr_t object_id,
1716 intptr_t tags, 1716 intptr_t tags,
1717 Snapshot::Kind kind) { 1717 Snapshot::Kind kind) {
1718 ASSERT(reader != NULL); 1718 ASSERT(reader != NULL);
1719 1719
1720 // Read in the HexCString representation of the bigint. 1720 // Read in the HexCString representation of the bigint.
1721 intptr_t len = reader->ReadIntptrValue(); 1721 int32_t len = reader->Read<int32_t>();
1722 char* str = reader->isolate()->current_zone()->Alloc<char>(len + 1); 1722 char* str = reader->isolate()->current_zone()->Alloc<char>(len + 1);
1723 str[len] = '\0'; 1723 str[len] = '\0';
1724 reader->ReadBytes(reinterpret_cast<uint8_t*>(str), len); 1724 reader->ReadBytes(reinterpret_cast<uint8_t*>(str), len);
1725 1725
1726 // Create a Bigint object from HexCString. 1726 // Create a Bigint object from HexCString.
1727 Bigint& obj = Bigint::ZoneHandle( 1727 Bigint& obj = Bigint::ZoneHandle(
1728 reader->isolate(), 1728 reader->isolate(),
1729 ((kind == Snapshot::kFull) ? reader->NewBigint(str) : 1729 ((kind == Snapshot::kFull) ? reader->NewBigint(str) :
1730 BigintOperations::FromHexCString(str, HEAP_SPACE(kind)))); 1730 BigintOperations::FromHexCString(str, HEAP_SPACE(kind))));
1731 1731
(...skipping 26 matching lines...) Expand all
1758 ASSERT(writer != NULL); 1758 ASSERT(writer != NULL);
1759 1759
1760 // Write out the serialization header value for this object. 1760 // Write out the serialization header value for this object.
1761 writer->WriteInlinedObjectHeader(object_id); 1761 writer->WriteInlinedObjectHeader(object_id);
1762 1762
1763 // Write out the class and tags information. 1763 // Write out the class and tags information.
1764 writer->WriteIndexedObject(kBigintCid); 1764 writer->WriteIndexedObject(kBigintCid);
1765 writer->WriteTags(writer->GetObjectTags(this)); 1765 writer->WriteTags(writer->GetObjectTags(this));
1766 1766
1767 // Write out the bigint value as a HEXCstring. 1767 // Write out the bigint value as a HEXCstring.
1768 intptr_t length = ptr()->signed_length_; 1768 int32_t length = ptr()->signed_length_;
1769 bool is_negative = false; 1769 bool is_negative = false;
1770 if (length <= 0) { 1770 if (length <= 0) {
1771 length = -length; 1771 length = -length;
1772 is_negative = true; 1772 is_negative = true;
1773 } 1773 }
1774 uword data_start = reinterpret_cast<uword>(ptr()) + sizeof(RawBigint); 1774 uword data_start = reinterpret_cast<uword>(ptr()) + sizeof(RawBigint);
1775 const char* str = BigintOperations::ToHexCString( 1775 const char* str = BigintOperations::ToHexCString(
1776 length, 1776 length,
1777 is_negative, 1777 is_negative,
1778 reinterpret_cast<void*>(data_start), 1778 reinterpret_cast<void*>(data_start),
1779 &BigintAllocator); 1779 &BigintAllocator);
1780 bool neg = false; 1780 bool neg = false;
1781 if (*str == '-') { 1781 if (*str == '-') {
1782 neg = true; 1782 neg = true;
1783 str++; 1783 str++;
1784 } 1784 }
1785 intptr_t len = strlen(str); 1785 intptr_t len = strlen(str);
1786 ASSERT(len > 2 && str[0] == '0' && str[1] == 'x'); 1786 ASSERT(len > 2 && str[0] == '0' && str[1] == 'x');
1787 if (neg) { 1787 if (neg) {
1788 writer->WriteIntptrValue(len - 1); // Include '-' in length. 1788 writer->Write<int32_t>(len - 1); // Include '-' in length.
1789 writer->Write<uint8_t>('-'); 1789 writer->Write<uint8_t>('-');
1790 } else { 1790 } else {
1791 writer->WriteIntptrValue(len - 2); 1791 writer->Write<int32_t>(len - 2);
1792 } 1792 }
1793 writer->WriteBytes(reinterpret_cast<const uint8_t*>(&(str[2])), (len - 2)); 1793 writer->WriteBytes(reinterpret_cast<const uint8_t*>(&(str[2])), (len - 2));
1794 } 1794 }
1795 1795
1796 1796
1797 RawDouble* Double::ReadFrom(SnapshotReader* reader, 1797 RawDouble* Double::ReadFrom(SnapshotReader* reader,
1798 intptr_t object_id, 1798 intptr_t object_id,
1799 intptr_t tags, 1799 intptr_t tags,
1800 Snapshot::Kind kind) { 1800 Snapshot::Kind kind) {
1801 ASSERT(reader != NULL); 1801 ASSERT(reader != NULL);
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 reader->isolate(), JSRegExp::New(len, HEAP_SPACE(kind))); 2748 reader->isolate(), JSRegExp::New(len, HEAP_SPACE(kind)));
2749 reader->AddBackRef(object_id, &regex, kIsDeserialized); 2749 reader->AddBackRef(object_id, &regex, kIsDeserialized);
2750 2750
2751 // Set the object tags. 2751 // Set the object tags.
2752 regex.set_tags(tags); 2752 regex.set_tags(tags);
2753 2753
2754 // Read and Set all the other fields. 2754 // Read and Set all the other fields.
2755 regex.raw_ptr()->num_bracket_expressions_ = reader->ReadAsSmi(); 2755 regex.raw_ptr()->num_bracket_expressions_ = reader->ReadAsSmi();
2756 *reader->StringHandle() ^= reader->ReadObjectImpl(); 2756 *reader->StringHandle() ^= reader->ReadObjectImpl();
2757 regex.set_pattern(*reader->StringHandle()); 2757 regex.set_pattern(*reader->StringHandle());
2758 regex.raw_ptr()->type_ = reader->ReadIntptrValue(); 2758 regex.raw_ptr()->type_flags_ = reader->Read<int8_t>();
2759 regex.raw_ptr()->flags_ = reader->ReadIntptrValue();
2760 2759
2761 // TODO(5411462): Need to implement a way of recompiling the regex. 2760 // TODO(5411462): Need to implement a way of recompiling the regex.
2762 2761
2763 return regex.raw(); 2762 return regex.raw();
2764 } 2763 }
2765 2764
2766 2765
2767 void RawJSRegExp::WriteTo(SnapshotWriter* writer, 2766 void RawJSRegExp::WriteTo(SnapshotWriter* writer,
2768 intptr_t object_id, 2767 intptr_t object_id,
2769 Snapshot::Kind kind) { 2768 Snapshot::Kind kind) {
2770 ASSERT(writer != NULL); 2769 ASSERT(writer != NULL);
2771 ASSERT(kind == Snapshot::kMessage); 2770 ASSERT(kind == Snapshot::kMessage);
2772 2771
2773 // Write out the serialization header value for this object. 2772 // Write out the serialization header value for this object.
2774 writer->WriteInlinedObjectHeader(object_id); 2773 writer->WriteInlinedObjectHeader(object_id);
2775 2774
2776 // Write out the class and tags information. 2775 // Write out the class and tags information.
2777 writer->WriteIndexedObject(kJSRegExpCid); 2776 writer->WriteIndexedObject(kJSRegExpCid);
2778 writer->WriteTags(writer->GetObjectTags(this)); 2777 writer->WriteTags(writer->GetObjectTags(this));
2779 2778
2780 // Write out the data length field. 2779 // Write out the data length field.
2781 writer->Write<RawObject*>(ptr()->data_length_); 2780 writer->Write<RawObject*>(ptr()->data_length_);
2782 2781
2783 // Write out all the other fields. 2782 // Write out all the other fields.
2784 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); 2783 writer->Write<RawObject*>(ptr()->num_bracket_expressions_);
2785 writer->WriteObjectImpl(ptr()->pattern_); 2784 writer->WriteObjectImpl(ptr()->pattern_);
2786 writer->WriteIntptrValue(ptr()->type_); 2785 writer->Write<int8_t>(ptr()->type_flags_);
2787 writer->WriteIntptrValue(ptr()->flags_);
2788 2786
2789 // Do not write out the data part which is native. 2787 // Do not write out the data part which is native.
2790 } 2788 }
2791 2789
2792 2790
2793 RawWeakProperty* WeakProperty::ReadFrom(SnapshotReader* reader, 2791 RawWeakProperty* WeakProperty::ReadFrom(SnapshotReader* reader,
2794 intptr_t object_id, 2792 intptr_t object_id,
2795 intptr_t tags, 2793 intptr_t tags,
2796 Snapshot::Kind kind) { 2794 Snapshot::Kind kind) {
2797 ASSERT(reader != NULL); 2795 ASSERT(reader != NULL);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2869 // We do not allow objects with native fields in an isolate message. 2867 // We do not allow objects with native fields in an isolate message.
2870 writer->SetWriteException(Exceptions::kArgument, 2868 writer->SetWriteException(Exceptions::kArgument,
2871 "Illegal argument in isolate message" 2869 "Illegal argument in isolate message"
2872 " : (object is a UserTag)"); 2870 " : (object is a UserTag)");
2873 } else { 2871 } else {
2874 UNREACHABLE(); 2872 UNREACHABLE();
2875 } 2873 }
2876 } 2874 }
2877 2875
2878 } // namespace dart 2876 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.cc ('k') | runtime/vm/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698