From 2aad6f0024c08cd0380f915b91c54ac4fb42660f Mon Sep 17 00:00:00 2001 From: "weiliang.lin@intel.com" Date: Tue, 15 Jul 2014 09:46:10 +0000 Subject: [PATCH] X87: Use register parameters in ElementsTransitionGenerator port r22384 original commit message: Use register parameters in ElementsTransitionGenerator x BUG= R=weiliang.lin@intel.com Review URL: https://codereview.chromium.org/395633010 Patch from Chunyang Dai . git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22402 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x87/codegen-x87.cc | 70 ++++++++++++++++++++-------------- src/x87/ic-x87.cc | 10 +++-- src/x87/macro-assembler-x87.cc | 34 +++++++++++++---- src/x87/macro-assembler-x87.h | 11 +++++- 4 files changed, 83 insertions(+), 42 deletions(-) diff --git a/src/x87/codegen-x87.cc b/src/x87/codegen-x87.cc index 334490a3c..68e22486c 100644 --- a/src/x87/codegen-x87.cc +++ b/src/x87/codegen-x87.cc @@ -199,40 +199,47 @@ MemMoveFunction CreateMemMoveFunction() { void ElementsTransitionGenerator::GenerateMapChangeElementsTransition( - MacroAssembler* masm, AllocationSiteMode mode, + MacroAssembler* masm, + Register receiver, + Register key, + Register value, + Register target_map, + AllocationSiteMode mode, Label* allocation_memento_found) { - // ----------- S t a t e ------------- - // -- eax : value - // -- ebx : target map - // -- ecx : key - // -- edx : receiver - // -- esp[0] : return address - // ----------------------------------- + Register scratch = edi; + ASSERT(!AreAliased(receiver, key, value, target_map, scratch)); + if (mode == TRACK_ALLOCATION_SITE) { ASSERT(allocation_memento_found != NULL); - __ JumpIfJSArrayHasAllocationMemento(edx, edi, allocation_memento_found); + __ JumpIfJSArrayHasAllocationMemento( + receiver, scratch, allocation_memento_found); } // Set transitioned map. - __ mov(FieldOperand(edx, HeapObject::kMapOffset), ebx); - __ RecordWriteField(edx, + __ mov(FieldOperand(receiver, HeapObject::kMapOffset), target_map); + __ RecordWriteField(receiver, HeapObject::kMapOffset, - ebx, - edi, + target_map, + scratch, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); } void ElementsTransitionGenerator::GenerateSmiToDouble( - MacroAssembler* masm, AllocationSiteMode mode, Label* fail) { - // ----------- S t a t e ------------- - // -- eax : value - // -- ebx : target map - // -- ecx : key - // -- edx : receiver - // -- esp[0] : return address - // ----------------------------------- + MacroAssembler* masm, + Register receiver, + Register key, + Register value, + Register target_map, + AllocationSiteMode mode, + Label* fail) { + // Return address is on the stack. + ASSERT(receiver.is(edx)); + ASSERT(key.is(ecx)); + ASSERT(value.is(eax)); + ASSERT(target_map.is(ebx)); + Label loop, entry, convert_hole, gc_required, only_change_map; if (mode == TRACK_ALLOCATION_SITE) { @@ -342,14 +349,19 @@ void ElementsTransitionGenerator::GenerateSmiToDouble( void ElementsTransitionGenerator::GenerateDoubleToObject( - MacroAssembler* masm, AllocationSiteMode mode, Label* fail) { - // ----------- S t a t e ------------- - // -- eax : value - // -- ebx : target map - // -- ecx : key - // -- edx : receiver - // -- esp[0] : return address - // ----------------------------------- + MacroAssembler* masm, + Register receiver, + Register key, + Register value, + Register target_map, + AllocationSiteMode mode, + Label* fail) { + // Return address is on the stack. + ASSERT(receiver.is(edx)); + ASSERT(key.is(ecx)); + ASSERT(value.is(eax)); + ASSERT(target_map.is(ebx)); + Label loop, entry, convert_hole, gc_required, only_change_map, success; if (mode == TRACK_ALLOCATION_SITE) { diff --git a/src/x87/ic-x87.cc b/src/x87/ic-x87.cc index 48c82c579..ed21d4d3d 100644 --- a/src/x87/ic-x87.cc +++ b/src/x87/ic-x87.cc @@ -804,7 +804,8 @@ static void KeyedStoreGenerateGenericHelper( slow); AllocationSiteMode mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_DOUBLE_ELEMENTS); - ElementsTransitionGenerator::GenerateSmiToDouble(masm, mode, slow); + ElementsTransitionGenerator::GenerateSmiToDouble( + masm, receiver, key, value, ebx, mode, slow); __ mov(ebx, FieldOperand(receiver, JSObject::kElementsOffset)); __ jmp(&fast_double_without_map_check); @@ -816,8 +817,8 @@ static void KeyedStoreGenerateGenericHelper( edi, slow); mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS); - ElementsTransitionGenerator::GenerateMapChangeElementsTransition(masm, mode, - slow); + ElementsTransitionGenerator::GenerateMapChangeElementsTransition( + masm, receiver, key, value, ebx, mode, slow); __ mov(ebx, FieldOperand(receiver, JSObject::kElementsOffset)); __ jmp(&finish_object_store); @@ -832,7 +833,8 @@ static void KeyedStoreGenerateGenericHelper( edi, slow); mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS); - ElementsTransitionGenerator::GenerateDoubleToObject(masm, mode, slow); + ElementsTransitionGenerator::GenerateDoubleToObject( + masm, receiver, key, value, ebx, mode, slow); __ mov(ebx, FieldOperand(receiver, JSObject::kElementsOffset)); __ jmp(&finish_object_store); } diff --git a/src/x87/macro-assembler-x87.cc b/src/x87/macro-assembler-x87.cc index 65682b855..ba93fbb38 100644 --- a/src/x87/macro-assembler-x87.cc +++ b/src/x87/macro-assembler-x87.cc @@ -2930,15 +2930,33 @@ void MacroAssembler::CallCFunction(Register function, } -bool AreAliased(Register r1, Register r2, Register r3, Register r4) { - if (r1.is(r2)) return true; - if (r1.is(r3)) return true; - if (r1.is(r4)) return true; - if (r2.is(r3)) return true; - if (r2.is(r4)) return true; - if (r3.is(r4)) return true; - return false; +#ifdef DEBUG +bool AreAliased(Register reg1, + Register reg2, + Register reg3, + Register reg4, + Register reg5, + Register reg6, + Register reg7, + Register reg8) { + int n_of_valid_regs = reg1.is_valid() + reg2.is_valid() + + reg3.is_valid() + reg4.is_valid() + reg5.is_valid() + reg6.is_valid() + + reg7.is_valid() + reg8.is_valid(); + + RegList regs = 0; + if (reg1.is_valid()) regs |= reg1.bit(); + if (reg2.is_valid()) regs |= reg2.bit(); + if (reg3.is_valid()) regs |= reg3.bit(); + if (reg4.is_valid()) regs |= reg4.bit(); + if (reg5.is_valid()) regs |= reg5.bit(); + if (reg6.is_valid()) regs |= reg6.bit(); + if (reg7.is_valid()) regs |= reg7.bit(); + if (reg8.is_valid()) regs |= reg8.bit(); + int n_of_non_aliasing_regs = NumRegs(regs); + + return n_of_valid_regs != n_of_non_aliasing_regs; } +#endif CodePatcher::CodePatcher(byte* address, int size) diff --git a/src/x87/macro-assembler-x87.h b/src/x87/macro-assembler-x87.h index 70770a662..4f161cb68 100644 --- a/src/x87/macro-assembler-x87.h +++ b/src/x87/macro-assembler-x87.h @@ -30,7 +30,16 @@ enum RegisterValueType { }; -bool AreAliased(Register r1, Register r2, Register r3, Register r4); +#ifdef DEBUG +bool AreAliased(Register reg1, + Register reg2, + Register reg3 = no_reg, + Register reg4 = no_reg, + Register reg5 = no_reg, + Register reg6 = no_reg, + Register reg7 = no_reg, + Register reg8 = no_reg); +#endif // MacroAssembler implements a collection of frequently used macros. -- 2.34.1