Commit 5e24ffaa authored by antonm@chromium.org's avatar antonm@chromium.org

Slightly faster variant of Array.push.

Review URL: http://codereview.chromium.org/1265003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4279 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f45c35eb
...@@ -1251,8 +1251,7 @@ Object* CallStubCompiler::CompileArrayPushCall(Object* object, ...@@ -1251,8 +1251,7 @@ Object* CallStubCompiler::CompileArrayPushCall(Object* object,
__ j(not_equal, &miss); __ j(not_equal, &miss);
if (argc == 1) { // Otherwise fall through to call builtin. if (argc == 1) { // Otherwise fall through to call builtin.
Label call_builtin, exit, with_rset_update, Label call_builtin, exit, with_rset_update, attempt_to_grow_elements;
attempt_to_grow_elements, finish_push;
// Get the array's length into eax and calculate new length. // Get the array's length into eax and calculate new length.
__ mov(eax, FieldOperand(edx, JSArray::kLengthOffset)); __ mov(eax, FieldOperand(edx, JSArray::kLengthOffset));
...@@ -1278,8 +1277,6 @@ Object* CallStubCompiler::CompileArrayPushCall(Object* object, ...@@ -1278,8 +1277,6 @@ Object* CallStubCompiler::CompileArrayPushCall(Object* object,
__ mov(ecx, Operand(esp, argc * kPointerSize)); __ mov(ecx, Operand(esp, argc * kPointerSize));
__ mov(Operand(edx, 0), ecx); __ mov(Operand(edx, 0), ecx);
__ bind(&finish_push);
// Check if value is a smi. // Check if value is a smi.
__ test(ecx, Immediate(kSmiTagMask)); __ test(ecx, Immediate(kSmiTagMask));
__ j(not_zero, &with_rset_update); __ j(not_zero, &with_rset_update);
...@@ -1318,10 +1315,13 @@ Object* CallStubCompiler::CompileArrayPushCall(Object* object, ...@@ -1318,10 +1315,13 @@ Object* CallStubCompiler::CompileArrayPushCall(Object* object,
// We fit and could grow elements. // We fit and could grow elements.
__ mov(Operand::StaticVariable(new_space_allocation_top), ecx); __ mov(Operand::StaticVariable(new_space_allocation_top), ecx);
__ mov(ecx, Operand(esp, argc * kPointerSize)); __ mov(ecx, Operand(esp, argc * kPointerSize));
// Push the argument...
__ mov(Operand(edx, 0), ecx); __ mov(Operand(edx, 0), ecx);
// ... and fill the rest with holes.
for (int i = 1; i < kAllocationDelta; i++) { for (int i = 1; i < kAllocationDelta; i++) {
__ mov(Operand(edx, i * kPointerSize), __ mov(Operand(edx, i * kPointerSize),
Immediate(Factory::undefined_value())); Immediate(Factory::the_hole_value()));
} }
// Restore receiver to edx as finish sequence assumes it's here. // Restore receiver to edx as finish sequence assumes it's here.
...@@ -1332,7 +1332,8 @@ Object* CallStubCompiler::CompileArrayPushCall(Object* object, ...@@ -1332,7 +1332,8 @@ Object* CallStubCompiler::CompileArrayPushCall(Object* object,
Immediate(kAllocationDelta)); Immediate(kAllocationDelta));
__ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax);
__ jmp(&finish_push); // Elements are in new space, so no remembered set updates are necessary.
__ ret((argc + 1) * kPointerSize);
__ bind(&call_builtin); __ bind(&call_builtin);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment