Index: runtime/lib/byte_array.cc |
=================================================================== |
--- runtime/lib/byte_array.cc (revision 3621) |
+++ runtime/lib/byte_array.cc (working copy) |
@@ -30,6 +30,36 @@ |
} |
+DEFINE_NATIVE_ENTRY(ByteArray_copyFromByteArray, 5) { |
+ ByteArray& dst = ByteArray::CheckedHandle(arguments->At(0)); |
+ GET_NATIVE_ARGUMENT(ByteArray, src, arguments->At(1)); |
+ GET_NATIVE_ARGUMENT(Smi, src_start, arguments->At(2)); |
+ GET_NATIVE_ARGUMENT(Smi, dst_start, arguments->At(3)); |
+ GET_NATIVE_ARGUMENT(Smi, count, arguments->At(4)); |
+ intptr_t icount = count.Value(); |
cshapiro
2012/01/27 23:00:04
I think the Value() calls are compiled away so you
Anders Johnsen
2012/01/27 23:42:39
Done.
|
+ if (icount < 0) { |
+ GrowableArray<const Object*> args; |
+ Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); |
+ } |
+ if (icount == 0) { |
+ return; |
+ } |
+ intptr_t isrc_start = src_start.Value(); |
+ intptr_t idst_start = dst_start.Value(); |
+ if ((isrc_start < 0) || ((isrc_start + icount) > src.Length())) { |
+ GrowableArray<const Object*> arguments; |
+ arguments.Add(&src_start); |
+ Exceptions::ThrowByType(Exceptions::kIndexOutOfRange, arguments); |
+ } |
+ if ((idst_start < 0) || ((idst_start + icount) > dst.Length())) { |
+ GrowableArray<const Object*> arguments; |
+ arguments.Add(&dst_start); |
+ Exceptions::ThrowByType(Exceptions::kIndexOutOfRange, arguments); |
+ } |
+ ByteArray::Copy(dst, idst_start, src, isrc_start, icount); |
+} |
+ |
+ |
static void RangeCheck(const ByteArray& array, const Smi& index, |
intptr_t num_bytes) { |
if ((index.Value() < 0) || ((index.Value() + num_bytes) > array.Length())) { |