Chromium Code Reviews| Index: runtime/vm/object.cc |
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
| index 2d0fca9b2ed981a2c68ce1f317795d1ca31a7be8..8251533b27d70618420804471223d11063a5aa9c 100644 |
| --- a/runtime/vm/object.cc |
| +++ b/runtime/vm/object.cc |
| @@ -18097,6 +18097,29 @@ 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 { |
| + Array& dest = Array::Handle(Array::New(count)); |
|
Ivan Posva
2014/09/03 19:10:00
Please add a TODO to allocate new arrays, which wi
Vyacheslav Egorov (Google)
2014/09/03 20:35:18
Done.
|
| + 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_; |