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

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