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

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

Issue 9363023: Add support for big integers to the native message format (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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/visitor.h" 9 #include "vm/visitor.h"
10 10
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 1170
1171 // Write out the serialization header value for this object. 1171 // Write out the serialization header value for this object.
1172 writer->WriteSerializationMarker(kInlined, object_id); 1172 writer->WriteSerializationMarker(kInlined, object_id);
1173 1173
1174 // Write out the class and tags information. 1174 // Write out the class and tags information.
1175 writer->WriteObjectHeader(ObjectStore::kBigintClass, ptr()->tags_); 1175 writer->WriteObjectHeader(ObjectStore::kBigintClass, ptr()->tags_);
1176 1176
1177 // Write out the bigint value as a HEXCstring. 1177 // Write out the bigint value as a HEXCstring.
1178 ptr()->bn_.d = ptr()->data_; 1178 ptr()->bn_.d = ptr()->data_;
1179 const char* str = BigintOperations::ToHexCString(&ptr()->bn_, &ZoneAllocator); 1179 const char* str = BigintOperations::ToHexCString(&ptr()->bn_, &ZoneAllocator);
1180 bool neg = false;
1181 if (*str == '-') {
1182 neg = true;
1183 str++;
1184 }
1180 intptr_t len = strlen(str); 1185 intptr_t len = strlen(str);
1181 writer->WriteIntptrValue(len-2); 1186 ASSERT(len > 2 && str[0] == '0' && str[1] == 'x');
1187 writer->WriteIntptrValue(len - 2 + (neg ? 1 : 0));
1188 if (neg) writer->Write<uint8_t>('-');
siva 2012/02/09 01:47:27 Could you restruct as follows to make it more clea
Søren Gjesse 2012/02/09 14:08:33 Done.
1182 for (intptr_t i = 2; i < len; i++) { 1189 for (intptr_t i = 2; i < len; i++) {
1183 writer->Write<uint8_t>(str[i]); 1190 writer->Write<uint8_t>(str[i]);
1184 } 1191 }
1185 } 1192 }
1186 1193
1187 1194
1188 RawDouble* Double::ReadFrom(SnapshotReader* reader, 1195 RawDouble* Double::ReadFrom(SnapshotReader* reader,
1189 intptr_t object_id, 1196 intptr_t object_id,
1190 intptr_t tags, 1197 intptr_t tags,
1191 Snapshot::Kind kind) { 1198 Snapshot::Kind kind) {
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 // Write out all the other fields. 1831 // Write out all the other fields.
1825 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); 1832 writer->Write<RawObject*>(ptr()->num_bracket_expressions_);
1826 writer->WriteObject(ptr()->pattern_); 1833 writer->WriteObject(ptr()->pattern_);
1827 writer->WriteIntptrValue(ptr()->type_); 1834 writer->WriteIntptrValue(ptr()->type_);
1828 writer->WriteIntptrValue(ptr()->flags_); 1835 writer->WriteIntptrValue(ptr()->flags_);
1829 1836
1830 // Do not write out the data part which is native. 1837 // Do not write out the data part which is native.
1831 } 1838 }
1832 1839
1833 } // namespace dart 1840 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698