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

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

Issue 8383029: Implement external strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: pre-review clean-up Created 9 years, 2 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
« runtime/vm/raw_object.h ('K') | « runtime/vm/raw_object.cc ('k') | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 // Write out the hash field. 1127 // Write out the hash field.
1128 writer->Write<RawObject*>(ptr()->hash_); 1128 writer->Write<RawObject*>(ptr()->hash_);
1129 1129
1130 // Write out the string. 1130 // Write out the string.
1131 for (intptr_t i = 0; i < len; i++) { 1131 for (intptr_t i = 0; i < len; i++) {
1132 writer->Write<uint32_t>(ptr()->data_[i]); 1132 writer->Write<uint32_t>(ptr()->data_[i]);
1133 } 1133 }
1134 } 1134 }
1135 1135
1136 1136
1137 RawExternalOneByteString* ExternalOneByteString::ReadFrom(
Anton Muhin 2011/10/25 10:19:02 should we allow to serialize externalized strings?
cshapiro 2011/10/25 20:42:47 No, we should not. What this code does is seriali
1138 SnapshotReader* reader,
1139 intptr_t object_id,
1140 bool classes_serialized) {
1141 UNREACHABLE();
1142 return ExternalOneByteString::null();
1143 }
1144
1145
1146 void RawExternalOneByteString::WriteTo(SnapshotWriter* writer,
1147 intptr_t object_id,
1148 bool serialize_classes) {
1149 ASSERT(writer != NULL);
1150 intptr_t len = Smi::Value(ptr()->length_);
1151
1152 // Write out the serialization header value for this object.
1153 writer->WriteObjectHeader(kInlined, object_id);
1154
1155 // Write out the class information.
1156 writer->WriteObjectHeader(kObjectId, ObjectStore::kOneByteStringClass);
1157
1158 // Write out the length field.
1159 writer->Write<RawObject*>(ptr()->length_);
1160
1161 // Write out the hash field.
1162 writer->Write<RawObject*>(ptr()->hash_);
1163
1164 // Write out the string.
1165 for (int i = 0; i < len; i++) {
1166 writer->Write<uint8_t>(ptr()->data_[i]);
1167 }
1168 }
1169
1170
1171 RawExternalTwoByteString* ExternalTwoByteString::ReadFrom(
1172 SnapshotReader* reader,
1173 intptr_t object_id,
1174 bool classes_serialized) {
1175 UNREACHABLE();
1176 return ExternalTwoByteString::null();
1177 }
1178
1179
1180 void RawExternalTwoByteString::WriteTo(SnapshotWriter* writer,
1181 intptr_t object_id,
1182 bool serialize_classes) {
1183 ASSERT(writer != NULL);
1184 intptr_t len = Smi::Value(ptr()->length_);
1185
1186 // Write out the serialization header value for this object.
1187 writer->WriteObjectHeader(kInlined, object_id);
1188
1189 // Write out the class information.
1190 writer->WriteObjectHeader(kObjectId, ObjectStore::kTwoByteStringClass);
1191
1192 // Write out the length field.
1193 writer->Write<RawObject*>(ptr()->length_);
1194
1195 // Write out the hash field.
1196 writer->Write<RawObject*>(ptr()->hash_);
1197
1198 // Write out the string.
1199 for (int i = 0; i < len; i++) {
1200 writer->Write<uint16_t>(ptr()->data_[i]);
1201 }
1202 }
1203
1204
1205 RawExternalFourByteString* ExternalFourByteString::ReadFrom(
1206 SnapshotReader* reader,
1207 intptr_t object_id,
1208 bool classes_serialized) {
1209 UNREACHABLE();
1210 return ExternalFourByteString::null();
1211 }
1212
1213
1214 void RawExternalFourByteString::WriteTo(SnapshotWriter* writer,
1215 intptr_t object_id,
1216 bool serialize_classes) {
1217 ASSERT(writer != NULL);
1218 intptr_t len = Smi::Value(ptr()->length_);
1219
1220 // Write out the serialization header value for this object.
1221 writer->WriteObjectHeader(kInlined, object_id);
1222
1223 // Write out the class information.
1224 writer->WriteObjectHeader(kObjectId, ObjectStore::kFourByteStringClass);
1225
1226 // Write out the length field.
1227 writer->Write<RawObject*>(ptr()->length_);
1228
1229 // Write out the hash field.
1230 writer->Write<RawObject*>(ptr()->hash_);
1231
1232 // Write out the string.
1233 for (int i = 0; i < len; i++) {
1234 writer->Write<uint32_t>(ptr()->data_[i]);
1235 }
1236 }
1237
1238
1137 RawBool* Bool::ReadFrom(SnapshotReader* reader, 1239 RawBool* Bool::ReadFrom(SnapshotReader* reader,
1138 intptr_t object_id, 1240 intptr_t object_id,
1139 bool classes_serialized) { 1241 bool classes_serialized) {
1140 UNREACHABLE(); 1242 UNREACHABLE();
1141 return Bool::null(); 1243 return Bool::null();
1142 } 1244 }
1143 1245
1144 1246
1145 void RawBool::WriteTo(SnapshotWriter* writer, 1247 void RawBool::WriteTo(SnapshotWriter* writer,
1146 intptr_t object_id, 1248 intptr_t object_id,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 // Write out all the other fields. 1424 // Write out all the other fields.
1323 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); 1425 writer->Write<RawObject*>(ptr()->num_bracket_expressions_);
1324 writer->WriteObject(ptr()->pattern_); 1426 writer->WriteObject(ptr()->pattern_);
1325 writer->Write<intptr_t>(ptr()->type_); 1427 writer->Write<intptr_t>(ptr()->type_);
1326 writer->Write<intptr_t>(ptr()->flags_); 1428 writer->Write<intptr_t>(ptr()->flags_);
1327 1429
1328 // Do not write out the data part which is native. 1430 // Do not write out the data part which is native.
1329 } 1431 }
1330 1432
1331 } // namespace dart 1433 } // namespace dart
OLDNEW
« runtime/vm/raw_object.h ('K') | « runtime/vm/raw_object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698