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

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

Issue 12881006: Add the native intrinsic TypedData_setRange to optimize the setRange call when the destination and … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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') | 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) 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 12363 matching lines...) Expand 10 before | Expand all | Expand 10 after
12374 2, // kTypedDataUint16ArrayCid. 12374 2, // kTypedDataUint16ArrayCid.
12375 4, // kTypedDataInt32ArrayCid. 12375 4, // kTypedDataInt32ArrayCid.
12376 4, // kTypedDataUint32ArrayCid. 12376 4, // kTypedDataUint32ArrayCid.
12377 8, // kTypedDataInt64ArrayCid. 12377 8, // kTypedDataInt64ArrayCid.
12378 8, // kTypedDataUint64ArrayCid. 12378 8, // kTypedDataUint64ArrayCid.
12379 4, // kTypedDataFloat32ArrayCid. 12379 4, // kTypedDataFloat32ArrayCid.
12380 8, // kTypedDataFloat64ArrayCid. 12380 8, // kTypedDataFloat64ArrayCid.
12381 }; 12381 };
12382 12382
12383 12383
12384 void TypedData::Copy(const TypedData& dst,
12385 intptr_t dst_offset_in_bytes,
12386 const TypedData& src,
12387 intptr_t src_offset_in_bytes,
12388 intptr_t length_in_bytes) {
12389 ASSERT(Utils::RangeCheck(src_offset_in_bytes,
12390 length_in_bytes,
12391 src.LengthInBytes()));
12392 ASSERT(Utils::RangeCheck(dst_offset_in_bytes,
12393 length_in_bytes,
12394 dst.LengthInBytes()));
12395 {
12396 NoGCScope no_gc;
12397 if (length_in_bytes > 0) {
12398 memmove(dst.DataAddr(dst_offset_in_bytes),
12399 src.DataAddr(src_offset_in_bytes),
12400 length_in_bytes);
12401 }
12402 }
12403 }
12404
12405
12384 RawTypedData* TypedData::New(intptr_t class_id, 12406 RawTypedData* TypedData::New(intptr_t class_id,
12385 intptr_t len, 12407 intptr_t len,
12386 Heap::Space space) { 12408 Heap::Space space) {
12387 // TODO(asiva): Add a check for maximum elements. 12409 // TODO(asiva): Add a check for maximum elements.
12388 TypedData& result = TypedData::Handle(); 12410 TypedData& result = TypedData::Handle();
12389 { 12411 {
12390 // The len field has already been checked by the caller, we only assert 12412 // The len field has already been checked by the caller, we only assert
12391 // here that it is within a valid range. 12413 // here that it is within a valid range.
12392 ASSERT((len >= 0) && 12414 ASSERT((len >= 0) &&
12393 (len < (kSmiMax / TypedData::ElementSizeInBytes(class_id)))); 12415 (len < (kSmiMax / TypedData::ElementSizeInBytes(class_id))));
(...skipping 17 matching lines...) Expand all
12411 } 12433 }
12412 12434
12413 12435
12414 FinalizablePersistentHandle* ExternalTypedData::AddFinalizer( 12436 FinalizablePersistentHandle* ExternalTypedData::AddFinalizer(
12415 void* peer, Dart_WeakPersistentHandleFinalizer callback) const { 12437 void* peer, Dart_WeakPersistentHandleFinalizer callback) const {
12416 SetPeer(peer); 12438 SetPeer(peer);
12417 return dart::AddFinalizer(*this, peer, callback); 12439 return dart::AddFinalizer(*this, peer, callback);
12418 } 12440 }
12419 12441
12420 12442
12443 void ExternalTypedData::Copy(const ExternalTypedData& dst,
12444 intptr_t dst_offset_in_bytes,
12445 const ExternalTypedData& src,
12446 intptr_t src_offset_in_bytes,
12447 intptr_t length_in_bytes) {
12448 ASSERT(Utils::RangeCheck(src_offset_in_bytes,
12449 length_in_bytes,
12450 src.LengthInBytes()));
12451 ASSERT(Utils::RangeCheck(dst_offset_in_bytes,
12452 length_in_bytes,
12453 dst.LengthInBytes()));
12454 {
12455 NoGCScope no_gc;
12456 if (length_in_bytes > 0) {
12457 memmove(dst.DataAddr(dst_offset_in_bytes),
12458 src.DataAddr(src_offset_in_bytes),
12459 length_in_bytes);
12460 }
12461 }
12462 }
12463
12464
12421 RawExternalTypedData* ExternalTypedData::New(intptr_t class_id, 12465 RawExternalTypedData* ExternalTypedData::New(intptr_t class_id,
12422 uint8_t* data, 12466 uint8_t* data,
12423 intptr_t len, 12467 intptr_t len,
12424 Heap::Space space) { 12468 Heap::Space space) {
12425 ExternalTypedData& result = ExternalTypedData::Handle(); 12469 ExternalTypedData& result = ExternalTypedData::Handle();
12426 { 12470 {
12427 RawObject* raw = Object::Allocate(class_id, 12471 RawObject* raw = Object::Allocate(class_id,
12428 ExternalTypedData::InstanceSize(), 12472 ExternalTypedData::InstanceSize(),
12429 space); 12473 space);
12430 NoGCScope no_gc; 12474 NoGCScope no_gc;
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
13409 } 13453 }
13410 return result.raw(); 13454 return result.raw();
13411 } 13455 }
13412 13456
13413 13457
13414 const char* WeakProperty::ToCString() const { 13458 const char* WeakProperty::ToCString() const {
13415 return "_WeakProperty"; 13459 return "_WeakProperty";
13416 } 13460 }
13417 13461
13418 } // namespace dart 13462 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698