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

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

Issue 9348048: Add support for medium 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/snapshot.h ('k') | runtime/vm/snapshot_test.cc » ('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/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/heap.h" 10 #include "vm/heap.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 UnmarkCObject(object); 495 UnmarkCObject(object);
496 if (object->type == Dart_CObject::kArray) { 496 if (object->type == Dart_CObject::kArray) {
497 for (int i = 0; i < object->value.as_array.length; i++) { 497 for (int i = 0; i < object->value.as_array.length; i++) {
498 Dart_CObject* element = object->value.as_array.values[i]; 498 Dart_CObject* element = object->value.as_array.values[i];
499 UnmarkAllCObjects(element); 499 UnmarkAllCObjects(element);
500 } 500 }
501 } 501 }
502 } 502 }
503 503
504 504
505 void MessageWriter::WriteSmi(int32_t value) { 505 void MessageWriter::WriteSmi(int64_t value) {
506 ASSERT(Smi::IsValid64(value));
506 Write<RawObject*>(Smi::New(value)); 507 Write<RawObject*>(Smi::New(value));
507 } 508 }
508 509
509 510
511 void MessageWriter::WriteMint(Dart_CObject* object, int64_t value) {
512 ASSERT(!Smi::IsValid64(value));
513 // Write out the serialization header value for mint object.
514 WriteInlinedHeader(object);
515 // Write out the class and tags information.
516 WriteObjectHeader(ObjectStore::kMintClass, 0);
517 // Write the 64-bit value.
518 Write<int64_t>(value);
519 }
520
521
522 void MessageWriter::WriteInt32(Dart_CObject* object) {
523 int64_t value = object->value.as_int32;
524 if (Smi::IsValid64(value)) {
525 WriteSmi(value);
526 } else {
527 WriteMint(object, value);
528 }
529 }
530
531
532 void MessageWriter::WriteInt64(Dart_CObject* object) {
533 int64_t value = object->value.as_int64;
534 if (Smi::IsValid64(value)) {
535 WriteSmi(value);
536 } else {
537 WriteMint(object, value);
538 }
539 }
540
541
510 void MessageWriter::WriteInlinedHeader(Dart_CObject* object) { 542 void MessageWriter::WriteInlinedHeader(Dart_CObject* object) {
511 // Write out the serialization header value for this object. 543 // Write out the serialization header value for this object.
512 WriteSerializationMarker(kInlined, kMaxPredefinedObjectIds + object_id_); 544 WriteSerializationMarker(kInlined, kMaxPredefinedObjectIds + object_id_);
513 // Mark object with its object id. 545 // Mark object with its object id.
514 MarkCObject(object, object_id_); 546 MarkCObject(object, object_id_);
515 // Advance object id. 547 // Advance object id.
516 object_id_++; 548 object_id_++;
517 } 549 }
518 550
519 551
520 void MessageWriter::WriteCObject(Dart_CObject* object) { 552 void MessageWriter::WriteCObject(Dart_CObject* object) {
521 if (IsCObjectMarked(object)) { 553 if (IsCObjectMarked(object)) {
522 intptr_t object_id = GetMarkedCObjectMark(object); 554 intptr_t object_id = GetMarkedCObjectMark(object);
523 WriteIndexedObject(kMaxPredefinedObjectIds + object_id); 555 WriteIndexedObject(kMaxPredefinedObjectIds + object_id);
524 return; 556 return;
525 } 557 }
526 558
527 switch (object->type) { 559 switch (object->type) {
528 case Dart_CObject::kNull: 560 case Dart_CObject::kNull:
529 WriteIndexedObject(Object::kNullObject); 561 WriteIndexedObject(Object::kNullObject);
530 break; 562 break;
531 case Dart_CObject::kBool: 563 case Dart_CObject::kBool:
532 if (object->value.as_bool) { 564 if (object->value.as_bool) {
533 WriteIndexedObject(ObjectStore::kTrueValue); 565 WriteIndexedObject(ObjectStore::kTrueValue);
534 } else { 566 } else {
535 WriteIndexedObject(ObjectStore::kFalseValue); 567 WriteIndexedObject(ObjectStore::kFalseValue);
536 } 568 }
537 break; 569 break;
538 case Dart_CObject::kInt32: { 570 case Dart_CObject::kInt32:
539 WriteSmi(object->value.as_int32); 571 WriteInt32(object);
540 break; 572 break;
541 } 573 case Dart_CObject::kInt64:
574 WriteInt64(object);
575 break;
542 case Dart_CObject::kDouble: 576 case Dart_CObject::kDouble:
543 // Write out the serialization header value for this object. 577 // Write out the serialization header value for this object.
544 WriteInlinedHeader(object); 578 WriteInlinedHeader(object);
545 // Write out the class and tags information. 579 // Write out the class and tags information.
546 WriteObjectHeader(ObjectStore::kDoubleClass, 0); 580 WriteObjectHeader(ObjectStore::kDoubleClass, 0);
547 // Write double value. 581 // Write double value.
548 Write<double>(object->value.as_double); 582 Write<double>(object->value.as_double);
549 break; 583 break;
550 case Dart_CObject::kString: { 584 case Dart_CObject::kString: {
551 // Write out the serialization header value for this object. 585 // Write out the serialization header value for this object.
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 839
806 840
807 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) { 841 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) {
808 for (RawObject** current = first; current <= last; current++) { 842 for (RawObject** current = first; current <= last; current++) {
809 RawObject* raw_obj = *current; 843 RawObject* raw_obj = *current;
810 writer_->WriteObject(raw_obj); 844 writer_->WriteObject(raw_obj);
811 } 845 }
812 } 846 }
813 847
814 } // namespace dart 848 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/snapshot.h ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698