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

Side by Side Diff: runtime/vm/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: 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
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 <openssl/crypto.h>
6
5 #include "vm/snapshot.h" 7 #include "vm/snapshot.h"
6 8
7 #include "platform/assert.h" 9 #include "platform/assert.h"
8 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
9 #include "vm/exceptions.h" 11 #include "vm/exceptions.h"
10 #include "vm/heap.h" 12 #include "vm/heap.h"
11 #include "vm/object.h" 13 #include "vm/object.h"
12 #include "vm/object_store.h" 14 #include "vm/object_store.h"
13 15
14 namespace dart { 16 namespace dart {
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if (object->value.as_bool) { 534 if (object->value.as_bool) {
533 WriteIndexedObject(ObjectStore::kTrueValue); 535 WriteIndexedObject(ObjectStore::kTrueValue);
534 } else { 536 } else {
535 WriteIndexedObject(ObjectStore::kFalseValue); 537 WriteIndexedObject(ObjectStore::kFalseValue);
536 } 538 }
537 break; 539 break;
538 case Dart_CObject::kInt32: { 540 case Dart_CObject::kInt32: {
539 WriteSmi(object->value.as_int32); 541 WriteSmi(object->value.as_int32);
540 break; 542 break;
541 } 543 }
544 case Dart_CObject::kBigint: {
545 // Write out the serialization header value for this object.
546 WriteInlinedHeader(object);
547 // Write out the class and tags information.
548 WriteObjectHeader(ObjectStore::kBigintClass, 0);
549 BIGNUM* bn = BN_new();
550 BN_dec2bn(&bn, object->value.as_bigint);
551 char* hex_string = BN_bn2hex(bn);
siva 2012/02/09 01:47:27 Somebody came up with the BigintOperations class i
Søren Gjesse 2012/02/09 14:08:33 After changing to using the hex format for the dat
552 intptr_t len = strlen(hex_string);
553 WriteIntptrValue(len);
554 for (intptr_t i = 0; i < len; i++) {
555 Write<uint8_t>(hex_string[i]);
556 }
557 OPENSSL_free(hex_string);
558 BN_free(bn);
559 break;
560 }
542 case Dart_CObject::kDouble: 561 case Dart_CObject::kDouble:
543 // Write out the serialization header value for this object. 562 // Write out the serialization header value for this object.
544 WriteInlinedHeader(object); 563 WriteInlinedHeader(object);
545 // Write out the class and tags information. 564 // Write out the class and tags information.
546 WriteObjectHeader(ObjectStore::kDoubleClass, 0); 565 WriteObjectHeader(ObjectStore::kDoubleClass, 0);
547 // Write double value. 566 // Write double value.
548 Write<double>(object->value.as_double); 567 Write<double>(object->value.as_double);
549 break; 568 break;
550 case Dart_CObject::kString: { 569 case Dart_CObject::kString: {
551 // Write out the serialization header value for this object. 570 // Write out the serialization header value for this object.
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 811
793 812
794 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) { 813 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) {
795 for (RawObject** current = first; current <= last; current++) { 814 for (RawObject** current = first; current <= last; current++) {
796 RawObject* raw_obj = *current; 815 RawObject* raw_obj = *current;
797 writer_->WriteObject(raw_obj); 816 writer_->WriteObject(raw_obj);
798 } 817 }
799 } 818 }
800 819
801 } // namespace dart 820 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698