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

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
« no previous file with comments | « 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 Snapshot::Kind kind) { 297 Snapshot::Kind kind) {
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 Snapshot::Kind kind) { 304 Snapshot::Kind kind) {
305 ASSERT(reader != NULL); 305 ASSERT(reader != NULL);
306 306
307 const bool is_canonical = reader->Read<bool>();
307 // Read the length so that we can determine instance size to allocate. 308 // Read the length so that we can determine instance size to allocate.
308 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); 309 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>());
309 intptr_t len = Smi::Value(smi_len); 310 intptr_t len = Smi::Value(smi_len);
310 311
311 TypeArguments& type_array = TypeArguments::Handle(TypeArguments::New(len)); 312 TypeArguments& type_arguments =
312 reader->AddBackwardReference(object_id, &type_array); 313 TypeArguments::Handle(TypeArguments::New(len));
314 reader->AddBackwardReference(object_id, &type_arguments);
313 AbstractType& type = AbstractType::Handle(); 315 AbstractType& type = AbstractType::Handle();
314 for (intptr_t i = 0; i < len; i++) { 316 for (intptr_t i = 0; i < len; i++) {
315 type ^= reader->ReadObject(); 317 type ^= reader->ReadObject();
316 type_array.SetTypeAt(i, type); 318 type_arguments.SetTypeAt(i, type);
317 } 319 }
318 return type_array.raw(); 320 type_arguments.set_is_canonical(is_canonical);
321
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 Snapshot::Kind kind) { 328 Snapshot::Kind kind) {
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
337 writer->Write<bool>(ptr()->is_canonical_);
333 // Write out the length field. 338 // Write out the length field.
334 writer->Write<RawObject*>(ptr()->length_); 339 writer->Write<RawObject*>(ptr()->length_);
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
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 // Write out all the other fields. 1385 // Write out all the other fields.
1381 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); 1386 writer->Write<RawObject*>(ptr()->num_bracket_expressions_);
1382 writer->WriteObject(ptr()->pattern_); 1387 writer->WriteObject(ptr()->pattern_);
1383 writer->Write<intptr_t>(ptr()->type_); 1388 writer->Write<intptr_t>(ptr()->type_);
1384 writer->Write<intptr_t>(ptr()->flags_); 1389 writer->Write<intptr_t>(ptr()->flags_);
1385 1390
1386 // Do not write out the data part which is native. 1391 // Do not write out the data part which is native.
1387 } 1392 }
1388 1393
1389 } // namespace dart 1394 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698