Chromium Code Reviews| Index: runtime/lib/byte_array.cc |
| =================================================================== |
| --- runtime/lib/byte_array.cc (revision 3627) |
| +++ runtime/lib/byte_array.cc (working copy) |
| @@ -30,6 +30,36 @@ |
| } |
| +DEFINE_NATIVE_ENTRY(ByteArray_setRange, 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)); |
| + if (count.Value() < 0) { |
| + GrowableArray<const Object*> args; |
| + Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); |
| + } |
| + if (count.Value() == 0) { |
|
cshapiro
2012/01/28 02:25:48
technically, this is not needed. your call.
Anders Johnsen
2012/01/30 21:15:28
Done.
|
| + return; |
| + } |
| + if ((src_start.Value() < 0) || |
|
cshapiro
2012/01/28 02:25:48
This check must be improved. Ensure all of the fo
Anders Johnsen
2012/01/30 21:15:28
Done.
|
| + ((src_start.Value() + count.Value()) > src.Length())) { |
| + GrowableArray<const Object*> arguments; |
| + arguments.Add(&src_start); |
| + Exceptions::ThrowByType(Exceptions::kIndexOutOfRange, arguments); |
| + } |
| + if ((dst_start.Value() < 0) || |
|
cshapiro
2012/01/28 02:25:48
Same here.
Anders Johnsen
2012/01/30 21:15:28
Done.
|
| + ((dst_start.Value() + count.Value()) > dst.Length())) { |
| + GrowableArray<const Object*> arguments; |
| + arguments.Add(&dst_start); |
| + Exceptions::ThrowByType(Exceptions::kIndexOutOfRange, arguments); |
| + } |
| + ByteArray::Copy( |
| + dst, dst_start.Value(), src, src_start.Value(), count.Value()); |
| +} |
| + |
| + |
| static void RangeCheck(const ByteArray& array, const Smi& index, |
| intptr_t num_bytes) { |
| if ((index.Value() < 0) || ((index.Value() + num_bytes) > array.Length())) { |