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

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: Addressed review comments from asiva@ 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
« no previous file with comments | « runtime/vm/dart_api_message.cc ('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/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 if (neg) {
1188 writer->WriteIntptrValue(len - 1); // Include '-' in length.
1189 writer->Write<uint8_t>('-');
1190 } else {
1191 writer->WriteIntptrValue(len - 2);
1192 }
1182 for (intptr_t i = 2; i < len; i++) { 1193 for (intptr_t i = 2; i < len; i++) {
1183 writer->Write<uint8_t>(str[i]); 1194 writer->Write<uint8_t>(str[i]);
1184 } 1195 }
1185 } 1196 }
1186 1197
1187 1198
1188 RawDouble* Double::ReadFrom(SnapshotReader* reader, 1199 RawDouble* Double::ReadFrom(SnapshotReader* reader,
1189 intptr_t object_id, 1200 intptr_t object_id,
1190 intptr_t tags, 1201 intptr_t tags,
1191 Snapshot::Kind kind) { 1202 Snapshot::Kind kind) {
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 // Write out all the other fields. 1835 // Write out all the other fields.
1825 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); 1836 writer->Write<RawObject*>(ptr()->num_bracket_expressions_);
1826 writer->WriteObject(ptr()->pattern_); 1837 writer->WriteObject(ptr()->pattern_);
1827 writer->WriteIntptrValue(ptr()->type_); 1838 writer->WriteIntptrValue(ptr()->type_);
1828 writer->WriteIntptrValue(ptr()->flags_); 1839 writer->WriteIntptrValue(ptr()->flags_);
1829 1840
1830 // Do not write out the data part which is native. 1841 // Do not write out the data part which is native.
1831 } 1842 }
1832 1843
1833 } // namespace dart 1844 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698