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

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

Issue 14296006: Fast copy between TypedData and ExternalTypedData (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 12587 matching lines...) Expand 10 before | Expand all | Expand 10 after
12598 4, // kTypedDataInt32ArrayCid. 12598 4, // kTypedDataInt32ArrayCid.
12599 4, // kTypedDataUint32ArrayCid. 12599 4, // kTypedDataUint32ArrayCid.
12600 8, // kTypedDataInt64ArrayCid. 12600 8, // kTypedDataInt64ArrayCid.
12601 8, // kTypedDataUint64ArrayCid. 12601 8, // kTypedDataUint64ArrayCid.
12602 4, // kTypedDataFloat32ArrayCid. 12602 4, // kTypedDataFloat32ArrayCid.
12603 8, // kTypedDataFloat64ArrayCid. 12603 8, // kTypedDataFloat64ArrayCid.
12604 16, // kTypedDataFloat32x4ArrayCid. 12604 16, // kTypedDataFloat32x4ArrayCid.
12605 }; 12605 };
12606 12606
12607 12607
12608 void TypedData::Copy(const TypedData& dst,
12609 intptr_t dst_offset_in_bytes,
12610 const TypedData& src,
12611 intptr_t src_offset_in_bytes,
12612 intptr_t length_in_bytes) {
12613 ASSERT(Utils::RangeCheck(src_offset_in_bytes,
12614 length_in_bytes,
12615 src.LengthInBytes()));
12616 ASSERT(Utils::RangeCheck(dst_offset_in_bytes,
12617 length_in_bytes,
12618 dst.LengthInBytes()));
12619 {
12620 NoGCScope no_gc;
12621 if (length_in_bytes > 0) {
12622 memmove(dst.DataAddr(dst_offset_in_bytes),
12623 src.DataAddr(src_offset_in_bytes),
12624 length_in_bytes);
12625 }
12626 }
12627 }
12628
12629
12630 RawTypedData* TypedData::New(intptr_t class_id, 12608 RawTypedData* TypedData::New(intptr_t class_id,
12631 intptr_t len, 12609 intptr_t len,
12632 Heap::Space space) { 12610 Heap::Space space) {
12633 // TODO(asiva): Add a check for maximum elements. 12611 // TODO(asiva): Add a check for maximum elements.
12634 TypedData& result = TypedData::Handle(); 12612 TypedData& result = TypedData::Handle();
12635 { 12613 {
12636 // The len field has already been checked by the caller, we only assert 12614 // The len field has already been checked by the caller, we only assert
12637 // here that it is within a valid range. 12615 // here that it is within a valid range.
12638 ASSERT((len >= 0) && 12616 ASSERT((len >= 0) &&
12639 (len < (kSmiMax / TypedData::ElementSizeInBytes(class_id)))); 12617 (len < (kSmiMax / TypedData::ElementSizeInBytes(class_id))));
(...skipping 17 matching lines...) Expand all
12657 } 12635 }
12658 12636
12659 12637
12660 FinalizablePersistentHandle* ExternalTypedData::AddFinalizer( 12638 FinalizablePersistentHandle* ExternalTypedData::AddFinalizer(
12661 void* peer, Dart_WeakPersistentHandleFinalizer callback) const { 12639 void* peer, Dart_WeakPersistentHandleFinalizer callback) const {
12662 SetPeer(peer); 12640 SetPeer(peer);
12663 return dart::AddFinalizer(*this, peer, callback); 12641 return dart::AddFinalizer(*this, peer, callback);
12664 } 12642 }
12665 12643
12666 12644
12667 void ExternalTypedData::Copy(const ExternalTypedData& dst,
12668 intptr_t dst_offset_in_bytes,
12669 const ExternalTypedData& src,
12670 intptr_t src_offset_in_bytes,
12671 intptr_t length_in_bytes) {
12672 ASSERT(Utils::RangeCheck(src_offset_in_bytes,
12673 length_in_bytes,
12674 src.LengthInBytes()));
12675 ASSERT(Utils::RangeCheck(dst_offset_in_bytes,
12676 length_in_bytes,
12677 dst.LengthInBytes()));
12678 {
12679 NoGCScope no_gc;
12680 if (length_in_bytes > 0) {
12681 memmove(dst.DataAddr(dst_offset_in_bytes),
12682 src.DataAddr(src_offset_in_bytes),
12683 length_in_bytes);
12684 }
12685 }
12686 }
12687
12688
12689 RawExternalTypedData* ExternalTypedData::New(intptr_t class_id, 12645 RawExternalTypedData* ExternalTypedData::New(intptr_t class_id,
12690 uint8_t* data, 12646 uint8_t* data,
12691 intptr_t len, 12647 intptr_t len,
12692 Heap::Space space) { 12648 Heap::Space space) {
12693 ExternalTypedData& result = ExternalTypedData::Handle(); 12649 ExternalTypedData& result = ExternalTypedData::Handle();
12694 { 12650 {
12695 RawObject* raw = Object::Allocate(class_id, 12651 RawObject* raw = Object::Allocate(class_id,
12696 ExternalTypedData::InstanceSize(), 12652 ExternalTypedData::InstanceSize(),
12697 space); 12653 space);
12698 NoGCScope no_gc; 12654 NoGCScope no_gc;
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
13093 } 13049 }
13094 return result.raw(); 13050 return result.raw();
13095 } 13051 }
13096 13052
13097 13053
13098 const char* WeakProperty::ToCString() const { 13054 const char* WeakProperty::ToCString() const {
13099 return "_WeakProperty"; 13055 return "_WeakProperty";
13100 } 13056 }
13101 13057
13102 } // namespace dart 13058 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698