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

Unified Diff: runtime/vm/object.h

Issue 189443004: Fix performance of setRange by avoiding going to Lists.copy (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intrinsifier.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 33497)
+++ runtime/vm/object.h (working copy)
@@ -6076,7 +6076,6 @@
static void Copy(const DstType& dst, intptr_t dst_offset_in_bytes,
const SrcType& src, intptr_t src_offset_in_bytes,
intptr_t length_in_bytes) {
- ASSERT(dst.ElementType() == src.ElementType());
ASSERT(Utils::RangeCheck(src_offset_in_bytes,
length_in_bytes,
src.LengthInBytes()));
@@ -6093,6 +6092,35 @@
}
}
+
+ template <typename DstType, typename SrcType>
+ static void ClampedCopy(const DstType& dst, intptr_t dst_offset_in_bytes,
+ const SrcType& src, intptr_t src_offset_in_bytes,
+ intptr_t length_in_bytes) {
+ ASSERT(Utils::RangeCheck(src_offset_in_bytes,
+ length_in_bytes,
+ src.LengthInBytes()));
+ ASSERT(Utils::RangeCheck(dst_offset_in_bytes,
+ length_in_bytes,
+ dst.LengthInBytes()));
+ {
+ NoGCScope no_gc;
+ if (length_in_bytes > 0) {
+ uint8_t* dst_data =
+ reinterpret_cast<uint8_t*>(dst.DataAddr(dst_offset_in_bytes));
+ int8_t* src_data =
+ reinterpret_cast<int8_t*>(src.DataAddr(src_offset_in_bytes));
+ for (intptr_t ix = 0; ix < length_in_bytes; ix++) {
+ int8_t v = *src_data;
+ if (v < 0) v = 0;
+ *dst_data = v;
+ src_data++;
+ dst_data++;
+ }
+ }
+ }
+ }
+
static bool IsTypedData(const Instance& obj) {
ASSERT(!obj.IsNull());
intptr_t cid = obj.raw()->GetClassId();
« no previous file with comments | « runtime/vm/intrinsifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698