| Index: runtime/vm/object.cc
|
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
|
| index 2d0fca9b2ed981a2c68ce1f317795d1ca31a7be8..c5c421cf4f9d80f4b8de89b5efe40fcee06301a9 100644
|
| --- a/runtime/vm/object.cc
|
| +++ b/runtime/vm/object.cc
|
| @@ -18097,6 +18097,32 @@ RawArray* Array::New(intptr_t class_id, intptr_t len, Heap::Space space) {
|
| }
|
|
|
|
|
| +RawArray* Array::Slice(intptr_t start,
|
| + intptr_t count,
|
| + bool with_type_argument) const {
|
| + // TODO(vegorov) introduce an array allocation method that fills newly
|
| + // allocated array with values from the given source array instead of
|
| + // null-initializing all elements.
|
| + Array& dest = Array::Handle(Array::New(count));
|
| + if (dest.raw()->IsNewObject()) {
|
| + NoGCScope no_gc_scope;
|
| + memmove(dest.ObjectAddr(0), ObjectAddr(start), count * kWordSize);
|
| + } else {
|
| + PassiveObject& obj = PassiveObject::Handle();
|
| + for (intptr_t i = 0; i < count; i++) {
|
| + obj = At(start + i);
|
| + dest.SetAt(i, obj);
|
| + }
|
| + }
|
| +
|
| + if (with_type_argument) {
|
| + dest.SetTypeArguments(TypeArguments::Handle(GetTypeArguments()));
|
| + }
|
| +
|
| + return dest.raw();
|
| +}
|
| +
|
| +
|
| void Array::MakeImmutable() const {
|
| NoGCScope no_gc;
|
| uword tags = raw_ptr()->tags_;
|
|
|