Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Unified Diff: runtime/vm/object.cc

Issue 533483003: Cleanup throwing of the RangeError in the runtime to remove duplicated code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« runtime/vm/exceptions.cc ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« runtime/vm/exceptions.cc ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698