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

Unified Diff: runtime/lib/array.cc

Issue 536043002: Merge array allocation and List._copyFromObjectArray to provide fast path for large arrays. (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
« no previous file with comments | « no previous file | runtime/lib/array.dart » ('j') | runtime/lib/array.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/array.cc
diff --git a/runtime/lib/array.cc b/runtime/lib/array.cc
index 7d9e076583483ae407786cab564af3ded01a1173..beac2f89461cfee863daeb75b74241c2ede631d1 100644
--- a/runtime/lib/array.cc
+++ b/runtime/lib/array.cc
@@ -51,46 +51,27 @@ DEFINE_NATIVE_ENTRY(List_getLength, 1) {
}
-// ObjectArray src, int srcStart, int dstStart, int count.
-DEFINE_NATIVE_ENTRY(List_copyFromObjectArray, 5) {
- const Array& dest = Array::CheckedHandle(arguments->NativeArgAt(0));
- GET_NON_NULL_NATIVE_ARGUMENT(Array, source, arguments->NativeArgAt(1));
- GET_NON_NULL_NATIVE_ARGUMENT(Smi, src_start, arguments->NativeArgAt(2));
- GET_NON_NULL_NATIVE_ARGUMENT(Smi, dst_start, arguments->NativeArgAt(3));
- GET_NON_NULL_NATIVE_ARGUMENT(Smi, count, arguments->NativeArgAt(4));
+// ObjectArray src, int start, int count, bool needTypeArgument.
+DEFINE_NATIVE_ENTRY(List_slice, 4) {
+ const Array& src = Array::CheckedHandle(arguments->NativeArgAt(0));
+ GET_NON_NULL_NATIVE_ARGUMENT(Smi, start, arguments->NativeArgAt(1));
+ GET_NON_NULL_NATIVE_ARGUMENT(Smi, count, arguments->NativeArgAt(2));
+ GET_NON_NULL_NATIVE_ARGUMENT(Bool, need_type_arg, arguments->NativeArgAt(3));
srdjan 2014/09/03 18:08:11 optional: needs_type_arg
Vyacheslav Egorov (Google) 2014/09/03 20:35:18 Done.
intptr_t icount = count.Value();
- if (icount < 0) {
+ if ((icount < 0) || (icount >= Array::kMaxElements)) {
Exceptions::ThrowByType(Exceptions::kArgument, Object::empty_array());
}
if (icount == 0) {
- return Object::null();
+ return Array::empty_array().raw();
Ivan Posva 2014/09/03 19:10:00 What if you need to return an empty array of T?
Vyacheslav Egorov (Google) 2014/09/03 20:35:18 Good catch! This case fortunately is never hit bec
}
- intptr_t isrc_start = src_start.Value();
- intptr_t idst_start = dst_start.Value();
- if ((isrc_start < 0) || ((isrc_start + icount) > source.Length())) {
+ intptr_t istart = start.Value();
+ if ((istart < 0) || ((istart + icount) > src.Length())) {
const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, src_start);
- Exceptions::ThrowByType(Exceptions::kRange, args);
- }
- if ((idst_start < 0) || ((idst_start + icount) > dest.Length())) {
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, dst_start);
+ args.SetAt(0, start);
Exceptions::ThrowByType(Exceptions::kRange, args);
}
- Object& src_obj = Object::Handle();
- if (isrc_start < idst_start) {
- for (intptr_t i = icount - 1; i >= 0; i--) {
- src_obj = source.At(isrc_start + i);
- dest.SetAt(idst_start + i, src_obj);
- }
- } else {
- for (intptr_t i = 0; i < icount; i++) {
- src_obj = source.At(isrc_start + i);
- dest.SetAt(idst_start + i, src_obj);
- }
- }
- return Object::null();
+ return src.Slice(istart, icount, need_type_arg.value());
}
« no previous file with comments | « no previous file | runtime/lib/array.dart » ('j') | runtime/lib/array.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698