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

Unified Diff: src/ia32/builtins-ia32.cc

Issue 2082006: Use direct loop when filling small arrays. (Closed)
Patch Set: Named constant added Created 10 years, 7 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 | « src/ia32/assembler-ia32.cc ('k') | src/ia32/disasm-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/builtins-ia32.cc
diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc
index 2db21d58ef9efc282c18e832af2b77ec08df90cc..030688a6cdfbc78c3a65c9ab3bc08727e0dfc313 100644
--- a/src/ia32/builtins-ia32.cc
+++ b/src/ia32/builtins-ia32.cc
@@ -806,6 +806,7 @@ static void AllocateJSArray(MacroAssembler* masm,
Label* gc_required) {
ASSERT(scratch.is(edi)); // rep stos destination
ASSERT(!fill_with_hole || array_size.is(ecx)); // rep stos count
+ ASSERT(!fill_with_hole || !result.is(eax)); // result is never eax
// Load the initial map from the array function.
__ mov(elements_array,
@@ -863,15 +864,22 @@ static void AllocateJSArray(MacroAssembler* masm,
if (fill_with_hole) {
__ lea(edi, Operand(elements_array,
FixedArray::kHeaderSize - kHeapObjectTag));
-
- __ push(eax);
__ mov(eax, Factory::the_hole_value());
-
__ cld();
+ // Do not use rep stos when filling less than kRepStosThreshold
+ // words.
+ const int kRepStosThreshold = 16;
+ Label loop, entry, done;
+ __ cmp(ecx, kRepStosThreshold);
+ __ j(below, &loop); // Note: ecx > 0.
__ rep_stos();
-
- // Restore saved registers.
- __ pop(eax);
+ __ jmp(&done);
+ __ bind(&loop);
+ __ stos();
+ __ bind(&entry);
+ __ cmp(edi, Operand(elements_array_end));
+ __ j(below, &loop);
+ __ bind(&done);
}
}
@@ -970,13 +978,14 @@ static void ArrayNativeCode(MacroAssembler* masm,
AllocateJSArray(masm,
edi,
ecx,
- eax,
ebx,
+ eax,
edx,
edi,
true,
&prepare_generic_code_call);
__ IncrementCounter(&Counters::array_function_native, 1);
+ __ mov(eax, ebx);
__ pop(ebx);
if (construct_call) {
__ pop(edi);
« no previous file with comments | « src/ia32/assembler-ia32.cc ('k') | src/ia32/disasm-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698