Reviewers: Rico,
Message:
Please take a look.
Checking for smi before checking for non-smi array should make storing smi
values slightly faster.
Description:
Small refactor to KeyedStoreIC::GenerateGeneric to make it slightly faster.
Please review this at http://codereview.chromium.org/8008016/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/arm/ic-arm.cc
M src/ia32/ic-ia32.cc
Index: src/arm/ic-arm.cc
diff --git a/src/arm/ic-arm.cc b/src/arm/ic-arm.cc
index
9932125a719baedf5b1712fb22bf8e2e4099cbc2..cadddf3895da4a7679f7271616824bba69dd5273
100644
--- a/src/arm/ic-arm.cc
+++ b/src/arm/ic-arm.cc
@@ -1360,28 +1360,26 @@ 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.
__ ldr(scratch_value, FieldMemOperand(receiver,
HeapObject::kMapOffset));
- __ CheckFastSmiOnlyElements(scratch_value, scratch_value,
¬_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(¬_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 +1389,6 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler*
masm,
kDontSaveFPRegs,
EMIT_REMEMBERED_SET,
OMIT_SMI_CHECK);
-
__ Ret();
}
Index: src/ia32/ic-ia32.cc
diff --git a/src/ia32/ic-ia32.cc b/src/ia32/ic-ia32.cc
index
c2181e7134f3838a9d1dafc70d2c596f0c6635c1..50ea5416075670d7ee0dba1bd47efb3c7c251dd4
100644
--- a/src/ia32/ic-ia32.cc
+++ b/src/ia32/ic-ia32.cc
@@ -811,23 +811,23 @@ 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.
__ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset));
- __ CheckFastSmiOnlyElements(ebx, ¬_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(¬_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);
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev