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

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

Issue 221943002: Speed up snapshots of *int8lists, by using memmove. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | « no previous file | runtime/vm/raw_object_snapshot.cc » ('j') | runtime/vm/raw_object_snapshot.cc » ('J')
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/bigint_operations.h" 5 #include "vm/bigint_operations.h"
6 #include "vm/dart_api_message.h" 6 #include "vm/dart_api_message.h"
7 #include "vm/object.h" 7 #include "vm/object.h"
8 #include "vm/snapshot_ids.h" 8 #include "vm/snapshot_ids.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 #include "vm/unicode.h" 10 #include "vm/unicode.h"
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 i = 0; 593 i = 0;
594 while (i < len) { 594 while (i < len) {
595 p += Utf8::Encode(Utf16::Next(utf16, &i, len), p); 595 p += Utf8::Encode(Utf16::Next(utf16, &i, len), p);
596 } 596 }
597 *p = '\0'; 597 *p = '\0';
598 ASSERT(p == (object->value.as_string + utf8_len)); 598 ASSERT(p == (object->value.as_string + utf8_len));
599 ::free(utf16); 599 ::free(utf16);
600 return object; 600 return object;
601 } 601 }
602 602
603 #define READ_TYPED_DATA_HEADER(type) \
604 intptr_t len = ReadSmiValue(); \
605 Dart_CObject* object = \
606 AllocateDartCObjectTypedData(Dart_TypedData_k##type, len); \
607 AddBackRef(object_id, object, kIsDeserialized); \
608
609
603 #define READ_TYPED_DATA(type, ctype) \ 610 #define READ_TYPED_DATA(type, ctype) \
604 { \ 611 { \
605 intptr_t len = ReadSmiValue(); \ 612 READ_TYPED_DATA_HEADER(type); \
606 Dart_CObject* object = \
607 AllocateDartCObjectTypedData(Dart_TypedData_k##type, len); \
608 AddBackRef(object_id, object, kIsDeserialized); \
609 if (len > 0) { \ 613 if (len > 0) { \
610 ctype* p = \ 614 ctype* p = \
611 reinterpret_cast<ctype*>(object->value.as_typed_data.values); \ 615 reinterpret_cast<ctype*>(object->value.as_typed_data.values); \
612 for (intptr_t i = 0; i < len; i++) { \ 616 for (intptr_t i = 0; i < len; i++) { \
613 p[i] = Read<ctype>(); \ 617 p[i] = Read<ctype>(); \
614 } \ 618 } \
615 } \ 619 } \
616 return object; \ 620 return object; \
617 } \ 621 } \
618 622
619 case kTypedDataInt8ArrayCid: 623 case kTypedDataInt8ArrayCid:
620 case kExternalTypedDataInt8ArrayCid: 624 case kExternalTypedDataInt8ArrayCid: {
621 READ_TYPED_DATA(Int8, int8_t); 625 READ_TYPED_DATA_HEADER(Int8);
626 if (len > 0) {
627 uint8_t* p =
628 reinterpret_cast<uint8_t*>(object->value.as_typed_data.values);
629 ReadBytes(p, len);
630 }
631 return object;
632 }
622 633
623 case kTypedDataUint8ArrayCid: 634 case kTypedDataUint8ArrayCid:
624 case kExternalTypedDataUint8ArrayCid: 635 case kExternalTypedDataUint8ArrayCid: {
625 READ_TYPED_DATA(Uint8, uint8_t); 636 READ_TYPED_DATA_HEADER(Uint8);
637 if (len > 0) {
638 uint8_t* p =
639 reinterpret_cast<uint8_t*>(object->value.as_typed_data.values);
640 ReadBytes(p, len);
641 }
642 return object;
643 }
626 644
627 case kTypedDataUint8ClampedArrayCid: 645 case kTypedDataUint8ClampedArrayCid:
628 case kExternalTypedDataUint8ClampedArrayCid: 646 case kExternalTypedDataUint8ClampedArrayCid:
629 READ_TYPED_DATA(Uint8Clamped, uint8_t); 647 READ_TYPED_DATA(Uint8Clamped, uint8_t);
630 648
631 case kTypedDataInt16ArrayCid: 649 case kTypedDataInt16ArrayCid:
632 case kExternalTypedDataInt16ArrayCid: 650 case kExternalTypedDataInt16ArrayCid:
633 READ_TYPED_DATA(Int16, int16_t); 651 READ_TYPED_DATA(Int16, int16_t);
634 652
635 case kTypedDataUint16ArrayCid: 653 case kTypedDataUint16ArrayCid:
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 if (!success) { 1191 if (!success) {
1174 UnmarkAllCObjects(object); 1192 UnmarkAllCObjects(object);
1175 return false; 1193 return false;
1176 } 1194 }
1177 } 1195 }
1178 UnmarkAllCObjects(object); 1196 UnmarkAllCObjects(object);
1179 return true; 1197 return true;
1180 } 1198 }
1181 1199
1182 } // namespace dart 1200 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/raw_object_snapshot.cc » ('j') | runtime/vm/raw_object_snapshot.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698