Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index 880b1922ed9917279b1366d525eefb56c9080690..951599d0c268252490fb11187ab94f1626a25cee 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -18175,6 +18175,39 @@ RawArray* Array::MakeArray(const GrowableObjectArray& growable_array) { |
} |
+void Array::CopyFrom(intptr_t dst_start, |
Ivan Posva
2014/09/02 15:27:07
As discussed offline we will need to keep this as
Vyacheslav Egorov (Google)
2014/09/02 16:02:53
It is not completely clear how to implement this.
|
+ const Array& source, |
+ intptr_t src_start, |
+ intptr_t count) const { |
+ if (count < 0) { |
+ Exceptions::ThrowByType(Exceptions::kArgument, Object::empty_array()); |
+ } |
+ if (count == 0) { |
+ return; |
+ } |
+ if ((src_start < 0) || ((src_start + count) > source.Length())) { |
+ Exceptions::ThrowRangeError(Smi::Handle(Smi::New(src_start))); |
+ } |
+ if ((dst_start < 0) || ((dst_start + count) > Length())) { |
+ Exceptions::ThrowRangeError(Smi::Handle(Smi::New(dst_start))); |
+ } |
+ |
+ NoGCScope no_gc_scope; |
+ memmove(ObjectAddr(dst_start), |
+ source.ObjectAddr(src_start), |
+ count * kWordSize); |
+ // Instead of calling write-barrier for every single element be pessimistic: |
+ // put this object into store buffer if it is in the old space and there is |
+ // a possibility that it now contains pointers into new space. |
+ if (raw()->IsOldObject() && |
+ !raw()->IsRemembered() && |
+ (source.raw()->IsNewObject() || source.raw()->IsRemembered())) { |
+ raw()->SetRememberedBit(); |
+ Isolate::Current()->store_buffer()->AddObject(raw()); |
+ } |
+} |
+ |
+ |
bool Array::CheckAndCanonicalizeFields(const char** error_str) const { |
Object& obj = Object::Handle(); |
// Iterate over all elements, canonicalize numbers and strings, expect all |