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

Unified Diff: runtime/vm/intermediate_language_mips.cc

Issue 627103005: Unrolls array initialization loop for small arrays. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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 | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_mips.cc
===================================================================
--- runtime/vm/intermediate_language_mips.cc (revision 40940)
+++ runtime/vm/intermediate_language_mips.cc (working copy)
@@ -2025,6 +2025,7 @@
intptr_t num_elements,
Label* slow_path,
Label* done) {
+ const int kInlineArraySize = 12; // Same as kInlineInstanceSize.
const Register kLengthReg = A1;
const Register kElemTypeReg = A0;
const intptr_t instance_size = Array::InstanceSize(num_elements);
@@ -2054,14 +2055,22 @@
// data area to be initialized.
// T7: null.
if (num_elements > 0) {
+ const intptr_t array_size = instance_size - sizeof(RawArray);
__ LoadImmediate(T7, reinterpret_cast<int32_t>(Object::null()));
__ AddImmediate(T2, V0, sizeof(RawArray) - kHeapObjectTag);
-
- Label init_loop;
- __ Bind(&init_loop);
- __ sw(T7, Address(T2, 0));
- __ addiu(T2, T2, Immediate(kWordSize));
- __ BranchUnsignedLess(T2, T1, &init_loop);
+ if (array_size < (kInlineArraySize * kWordSize)) {
+ intptr_t current_offset = 0;
+ while (current_offset < array_size) {
+ __ sw(T7, Address(T2, current_offset));
+ current_offset += kWordSize;
+ }
+ } else {
+ Label init_loop;
+ __ Bind(&init_loop);
+ __ sw(T7, Address(T2, 0));
+ __ addiu(T2, T2, Immediate(kWordSize));
+ __ BranchUnsignedLess(T2, T1, &init_loop);
+ }
}
__ b(done);
}
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698