Commit e6509e77 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Small refactor to KeyedStoreIC::GenerateGeneric to make it slightly faster.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9418 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d21902b2
......@@ -1360,28 +1360,25 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm,
__ bind(&fast);
Register scratch_value = r4;
Register address = r5;
Label non_smi_value;
__ JumpIfNotSmi(value, &non_smi_value);
// It's irrelevant whether array is smi-only or not when writing a smi.
__ add(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
__ add(address, address, Operand(key, LSL, kPointerSizeLog2 - kSmiTagSize));
__ str(value, MemOperand(address));
__ Ret();
__ bind(&non_smi_value);
if (FLAG_smi_only_arrays) {
Label not_smi_only;
// Make sure the elements are smi-only.
// Escape to slow case when writing non-smi into smi-only array.
__ ldr(scratch_value, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ CheckFastSmiOnlyElements(scratch_value, scratch_value, &not_smi_only);
// Non-smis need to call into the runtime if the array is smi only.
__ JumpIfNotSmi(value, &slow);
__ add(address, elements,
Operand(FixedArray::kHeaderSize - kHeapObjectTag));
__ add(address, address, Operand(key, LSL, kPointerSizeLog2 - kSmiTagSize));
__ str(value, MemOperand(address));
__ Ret();
__ bind(&not_smi_only);
__ CheckFastObjectElements(scratch_value, scratch_value, &slow);
}
// Fast case, store the value to the elements backing store.
// Fast elements array, store the value to the elements backing store.
__ add(address, elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
__ add(address, address, Operand(key, LSL, kPointerSizeLog2 - kSmiTagSize));
__ str(value, MemOperand(address));
// Skip write barrier if the written value is a smi.
__ tst(value, Operand(kSmiTagMask));
__ Ret(eq);
// Update write barrier for the elements array address.
__ mov(scratch_value, value); // Preserve the value which is returned.
__ RecordWrite(elements,
......@@ -1391,7 +1388,6 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm,
kDontSaveFPRegs,
EMIT_REMEMBERED_SET,
OMIT_SMI_CHECK);
__ Ret();
}
......
......@@ -811,23 +811,24 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm,
// edx: receiver
// edi: FixedArray receiver->elements
Label non_smi_value;
__ JumpIfNotSmi(eax, &non_smi_value);
// It's irrelevant whether array is smi-only or not when writing a smi.
__ mov(CodeGenerator::FixedArrayElementOperand(edi, ecx), eax);
__ ret(0);
__ bind(&non_smi_value);
if (FLAG_smi_only_arrays) {
Label not_smi_only;
// Make sure the elements are smi-only.
// Escape to slow case when writing non-smi into smi-only array.
__ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset));
__ CheckFastSmiOnlyElements(ebx, &not_smi_only, Label::kNear);
// Non-smis need to call into the runtime if the array is smi only.
__ JumpIfNotSmi(eax, &slow);
__ mov(CodeGenerator::FixedArrayElementOperand(edi, ecx), eax);
__ ret(0);
__ bind(&not_smi_only);
__ CheckFastObjectElements(ebx, &slow, Label::kNear);
}
// Fast elements array, store the value to the elements backing store.
__ mov(CodeGenerator::FixedArrayElementOperand(edi, ecx), eax);
// Update write barrier for the elements array address.
__ mov(edx, Operand(eax)); // Preserve the value which is returned.
__ RecordWriteArray(edi, edx, ecx, kDontSaveFPRegs);
__ RecordWriteArray(
edi, edx, ecx, kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
__ ret(0);
}
......
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