 Chromium Code Reviews
 Chromium Code Reviews Issue 9365020:
  Convert fast smi-only to fast object in generated code for array push.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 9365020:
  Convert fast smi-only to fast object in generated code for array push.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| Index: src/arm/stub-cache-arm.cc | 
| diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc | 
| index 15c5f4edef1c3696a76259deaab6e868e2d10a00..f9231891386e53cdfb1587ba3e4178bc54842aea 100644 | 
| --- a/src/arm/stub-cache-arm.cc | 
| +++ b/src/arm/stub-cache-arm.cc | 
| @@ -1475,21 +1475,23 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall( | 
| __ Ret(); | 
| } else { | 
| Label call_builtin; | 
| - Register elements = r3; | 
| - Register end_elements = r5; | 
| - // Get the elements array of the object. | 
| - __ ldr(elements, FieldMemOperand(receiver, JSArray::kElementsOffset)); | 
| - | 
| - // Check that the elements are in fast mode and writable. | 
| - __ CheckMap(elements, | 
| - r0, | 
| - Heap::kFixedArrayMapRootIndex, | 
| - &call_builtin, | 
| - DONT_DO_SMI_CHECK); | 
| if (argc == 1) { // Otherwise fall through to call the builtin. | 
| Label attempt_to_grow_elements; | 
| + Register elements = r6; | 
| + Register end_elements = r5; | 
| + // Get the elements array of the object. | 
| + __ ldr(elements, FieldMemOperand(receiver, JSArray::kElementsOffset)); | 
| + | 
| + // Check that the elements are in fast mode and writable. | 
| + __ CheckMap(elements, | 
| + r0, | 
| + Heap::kFixedArrayMapRootIndex, | 
| + &call_builtin, | 
| + DONT_DO_SMI_CHECK); | 
| + | 
| + | 
| // Get the array's length into r0 and calculate new length. | 
| __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | 
| STATIC_ASSERT(kSmiTagSize == 1); | 
| @@ -1526,8 +1528,28 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall( | 
| __ bind(&with_write_barrier); | 
| - __ ldr(r6, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 
| - __ CheckFastObjectElements(r6, r6, &call_builtin); | 
| + __ ldr(r3, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 
| + | 
| + if (FLAG_smi_only_arrays && !FLAG_trace_elements_transitions) { | 
| + Label fast_object, not_fast_object; | 
| + __ CheckFastObjectElements(r3, r7, ¬_fast_object); | 
| + __ jmp(&fast_object); | 
| + // In case of fast smi-only, convert to fast object, otherwise bail out. | 
| + __ bind(¬_fast_object); | 
| + __ CheckFastSmiOnlyElements(r3, r7, &call_builtin); | 
| + // edx: receiver | 
| + // r3: map | 
| + __ LoadTransitionedArrayMapConditional(FAST_SMI_ONLY_ELEMENTS, | 
| + FAST_ELEMENTS, | 
| + r3, | 
| + r7, | 
| + &call_builtin); | 
| + __ mov(r2, r1); | 
| 
Jakob Kummerow
2012/02/08 16:24:55
nit: s/r1/receiver/
 | 
| + ElementsTransitionGenerator::GenerateSmiOnlyToObject(masm()); | 
| + __ bind(&fast_object); | 
| + } else { | 
| + __ CheckFastObjectElements(r3, r3, &call_builtin); | 
| + } | 
| // Save new length. | 
| __ str(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | 
| @@ -1578,25 +1600,25 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall( | 
| Operand(r0, LSL, kPointerSizeLog2 - kSmiTagSize)); | 
| __ add(end_elements, end_elements, Operand(kEndElementsOffset)); | 
| __ mov(r7, Operand(new_space_allocation_top)); | 
| - __ ldr(r6, MemOperand(r7)); | 
| - __ cmp(end_elements, r6); | 
| + __ ldr(r3, MemOperand(r7)); | 
| + __ cmp(end_elements, r3); | 
| __ b(ne, &call_builtin); | 
| __ mov(r9, Operand(new_space_allocation_limit)); | 
| __ ldr(r9, MemOperand(r9)); | 
| - __ add(r6, r6, Operand(kAllocationDelta * kPointerSize)); | 
| - __ cmp(r6, r9); | 
| + __ add(r3, r3, Operand(kAllocationDelta * kPointerSize)); | 
| + __ cmp(r3, r9); | 
| __ b(hi, &call_builtin); | 
| // We fit and could grow elements. | 
| // Update new_space_allocation_top. | 
| - __ str(r6, MemOperand(r7)); | 
| + __ str(r3, MemOperand(r7)); | 
| // Push the argument. | 
| __ str(r2, MemOperand(end_elements)); | 
| // Fill the rest with holes. | 
| - __ LoadRoot(r6, Heap::kTheHoleValueRootIndex); | 
| + __ LoadRoot(r3, Heap::kTheHoleValueRootIndex); | 
| for (int i = 1; i < kAllocationDelta; i++) { | 
| - __ str(r6, MemOperand(end_elements, i * kPointerSize)); | 
| + __ str(r3, MemOperand(end_elements, i * kPointerSize)); | 
| } | 
| // Update elements' and array's sizes. |