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

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

Issue 8773026: Canonicalize TypeArguments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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.h ('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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 293
294 294
295 void RawAbstractTypeArguments::WriteTo(SnapshotWriter* writer, 295 void RawAbstractTypeArguments::WriteTo(SnapshotWriter* writer,
296 intptr_t object_id, 296 intptr_t object_id,
297 bool serialize_classes) { 297 bool serialize_classes) {
298 UNREACHABLE(); // AbstractTypeArguments is an abstract class. 298 UNREACHABLE(); // AbstractTypeArguments is an abstract class.
299 } 299 }
300 300
301 301
302 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader, 302 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader,
303 intptr_t object_id, 303 intptr_t object_id,
304 bool classes_serialized) { 304 bool classes_serialized) {
305 ASSERT(reader != NULL); 305 ASSERT(reader != NULL);
306 306
307 // Read the length so that we can determine instance size to allocate. 307 // Read the length so that we can determine instance size to allocate.
308 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); 308 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>());
309 intptr_t len = Smi::Value(smi_len); 309 intptr_t len = Smi::Value(smi_len);
310 Bool& is_canonical = Bool::Handle();
311 is_canonical ^= reader->ReadObject();
310 312
311 TypeArguments& type_array = TypeArguments::Handle(TypeArguments::New(len)); 313 TypeArguments& type_arguments =
312 reader->AddBackwardReference(object_id, &type_array); 314 TypeArguments::Handle(TypeArguments::New(len));
315 type_arguments.set_is_canonical(is_canonical.raw() == Bool::True());
316 reader->AddBackwardReference(object_id, &type_arguments);
313 AbstractType& type = AbstractType::Handle(); 317 AbstractType& type = AbstractType::Handle();
314 for (intptr_t i = 0; i < len; i++) { 318 for (intptr_t i = 0; i < len; i++) {
315 type ^= reader->ReadObject(); 319 type ^= reader->ReadObject();
316 type_array.SetTypeAt(i, type); 320 type_arguments.SetTypeAt(i, type);
317 } 321 }
318 return type_array.raw(); 322 return type_arguments.raw();
319 } 323 }
320 324
321 325
322 void RawTypeArguments::WriteTo(SnapshotWriter* writer, 326 void RawTypeArguments::WriteTo(SnapshotWriter* writer,
323 intptr_t object_id, 327 intptr_t object_id,
324 bool serialize_classes) { 328 bool serialize_classes) {
325 ASSERT(writer != NULL); 329 ASSERT(writer != NULL);
326 330
327 // Write out the serialization header value for this object. 331 // Write out the serialization header value for this object.
328 writer->WriteObjectHeader(kInlined, object_id); 332 writer->WriteObjectHeader(kInlined, object_id);
329 333
330 // Write out the class information. 334 // Write out the class information.
331 writer->WriteObjectHeader(kObjectId, Object::kTypeArgumentsClass); 335 writer->WriteObjectHeader(kObjectId, Object::kTypeArgumentsClass);
332 336
333 // Write out the length field. 337 // Write out the length field.
334 writer->Write<RawObject*>(ptr()->length_); 338 writer->Write<RawObject*>(ptr()->length_);
339 writer->WriteObject(ptr()->is_canonical_);
335 340
336 // Write out the individual types. 341 // Write out the individual types.
337 intptr_t len = Smi::Value(ptr()->length_); 342 intptr_t len = Smi::Value(ptr()->length_);
338 for (intptr_t i = 0; i < len; i++) { 343 for (intptr_t i = 0; i < len; i++) {
339 writer->WriteObject(ptr()->types_[i]); 344 writer->WriteObject(ptr()->types_[i]);
340 } 345 }
341 } 346 }
342 347
343 348
344 RawInstantiatedTypeArguments* InstantiatedTypeArguments::ReadFrom( 349 RawInstantiatedTypeArguments* InstantiatedTypeArguments::ReadFrom(
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 // Write out all the other fields. 1390 // Write out all the other fields.
1386 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); 1391 writer->Write<RawObject*>(ptr()->num_bracket_expressions_);
1387 writer->WriteObject(ptr()->pattern_); 1392 writer->WriteObject(ptr()->pattern_);
1388 writer->Write<intptr_t>(ptr()->type_); 1393 writer->Write<intptr_t>(ptr()->type_);
1389 writer->Write<intptr_t>(ptr()->flags_); 1394 writer->Write<intptr_t>(ptr()->flags_);
1390 1395
1391 // Do not write out the data part which is native. 1396 // Do not write out the data part which is native.
1392 } 1397 }
1393 1398
1394 } // namespace dart 1399 } // namespace dart
OLDNEW
« runtime/vm/raw_object.h ('K') | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698