Use register parameters in ElementsTransitionGenerator.

R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/389283002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22384 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6466ff39
This diff is collapsed.
...@@ -974,10 +974,10 @@ static void KeyedStoreGenerateGenericHelper( ...@@ -974,10 +974,10 @@ static void KeyedStoreGenerateGenericHelper(
receiver_map, receiver_map,
r4, r4,
slow); slow);
ASSERT(receiver_map.is(r3)); // Transition code expects map in r3
AllocationSiteMode mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, AllocationSiteMode mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS,
FAST_DOUBLE_ELEMENTS); FAST_DOUBLE_ELEMENTS);
ElementsTransitionGenerator::GenerateSmiToDouble(masm, mode, slow); ElementsTransitionGenerator::GenerateSmiToDouble(
masm, receiver, key, value, receiver_map, mode, slow);
__ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
__ jmp(&fast_double_without_map_check); __ jmp(&fast_double_without_map_check);
...@@ -988,10 +988,9 @@ static void KeyedStoreGenerateGenericHelper( ...@@ -988,10 +988,9 @@ static void KeyedStoreGenerateGenericHelper(
receiver_map, receiver_map,
r4, r4,
slow); slow);
ASSERT(receiver_map.is(r3)); // Transition code expects map in r3
mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS); mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS);
ElementsTransitionGenerator::GenerateMapChangeElementsTransition(masm, mode, ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
slow); masm, receiver, key, value, receiver_map, mode, slow);
__ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
__ jmp(&finish_object_store); __ jmp(&finish_object_store);
...@@ -1004,9 +1003,9 @@ static void KeyedStoreGenerateGenericHelper( ...@@ -1004,9 +1003,9 @@ static void KeyedStoreGenerateGenericHelper(
receiver_map, receiver_map,
r4, r4,
slow); slow);
ASSERT(receiver_map.is(r3)); // Transition code expects map in r3
mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS); mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS);
ElementsTransitionGenerator::GenerateDoubleToObject(masm, mode, slow); ElementsTransitionGenerator::GenerateDoubleToObject(
masm, receiver, key, value, receiver_map, mode, slow);
__ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
__ jmp(&finish_object_store); __ jmp(&finish_object_store);
} }
......
...@@ -4050,9 +4050,12 @@ bool AreAliased(Register reg1, ...@@ -4050,9 +4050,12 @@ bool AreAliased(Register reg1,
Register reg3, Register reg3,
Register reg4, Register reg4,
Register reg5, Register reg5,
Register reg6) { Register reg6,
Register reg7,
Register reg8) {
int n_of_valid_regs = reg1.is_valid() + reg2.is_valid() + int n_of_valid_regs = reg1.is_valid() + reg2.is_valid() +
reg3.is_valid() + reg4.is_valid() + reg5.is_valid() + reg6.is_valid(); reg3.is_valid() + reg4.is_valid() + reg5.is_valid() + reg6.is_valid() +
reg7.is_valid() + reg8.is_valid();
RegList regs = 0; RegList regs = 0;
if (reg1.is_valid()) regs |= reg1.bit(); if (reg1.is_valid()) regs |= reg1.bit();
...@@ -4061,6 +4064,8 @@ bool AreAliased(Register reg1, ...@@ -4061,6 +4064,8 @@ bool AreAliased(Register reg1,
if (reg4.is_valid()) regs |= reg4.bit(); if (reg4.is_valid()) regs |= reg4.bit();
if (reg5.is_valid()) regs |= reg5.bit(); if (reg5.is_valid()) regs |= reg5.bit();
if (reg6.is_valid()) regs |= reg6.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); int n_of_non_aliasing_regs = NumRegs(regs);
return n_of_valid_regs != n_of_non_aliasing_regs; return n_of_valid_regs != n_of_non_aliasing_regs;
......
...@@ -58,7 +58,9 @@ bool AreAliased(Register reg1, ...@@ -58,7 +58,9 @@ bool AreAliased(Register reg1,
Register reg3 = no_reg, Register reg3 = no_reg,
Register reg4 = no_reg, Register reg4 = no_reg,
Register reg5 = no_reg, Register reg5 = no_reg,
Register reg6 = no_reg); Register reg6 = no_reg,
Register reg7 = no_reg,
Register reg8 = no_reg);
#endif #endif
......
...@@ -102,14 +102,16 @@ void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { ...@@ -102,14 +102,16 @@ void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const {
// Code generators // Code generators
void ElementsTransitionGenerator::GenerateMapChangeElementsTransition( void ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
MacroAssembler* masm, AllocationSiteMode mode, MacroAssembler* masm,
Register receiver,
Register key,
Register value,
Register target_map,
AllocationSiteMode mode,
Label* allocation_memento_found) { Label* allocation_memento_found) {
// ----------- S t a t e ------------- ASM_LOCATION(
// -- x2 : receiver "ElementsTransitionGenerator::GenerateMapChangeElementsTransition");
// -- x3 : target map ASSERT(!AreAliased(receiver, key, value, target_map));
// -----------------------------------
Register receiver = x2;
Register map = x3;
if (mode == TRACK_ALLOCATION_SITE) { if (mode == TRACK_ALLOCATION_SITE) {
ASSERT(allocation_memento_found != NULL); ASSERT(allocation_memento_found != NULL);
...@@ -118,10 +120,10 @@ void ElementsTransitionGenerator::GenerateMapChangeElementsTransition( ...@@ -118,10 +120,10 @@ void ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
} }
// Set transitioned map. // Set transitioned map.
__ Str(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); __ Str(target_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ RecordWriteField(receiver, __ RecordWriteField(receiver,
HeapObject::kMapOffset, HeapObject::kMapOffset,
map, target_map,
x10, x10,
kLRHasNotBeenSaved, kLRHasNotBeenSaved,
kDontSaveFPRegs, kDontSaveFPRegs,
...@@ -131,19 +133,25 @@ void ElementsTransitionGenerator::GenerateMapChangeElementsTransition( ...@@ -131,19 +133,25 @@ void ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
void ElementsTransitionGenerator::GenerateSmiToDouble( void ElementsTransitionGenerator::GenerateSmiToDouble(
MacroAssembler* masm, AllocationSiteMode mode, Label* fail) { MacroAssembler* masm,
Register receiver,
Register key,
Register value,
Register target_map,
AllocationSiteMode mode,
Label* fail) {
ASM_LOCATION("ElementsTransitionGenerator::GenerateSmiToDouble"); ASM_LOCATION("ElementsTransitionGenerator::GenerateSmiToDouble");
// ----------- S t a t e -------------
// -- lr : return address
// -- x0 : value
// -- x1 : key
// -- x2 : receiver
// -- x3 : target map, scratch for subsequent call
// -----------------------------------
Register receiver = x2;
Register target_map = x3;
Label gc_required, only_change_map; Label gc_required, only_change_map;
Register elements = x4;
Register length = x5;
Register array_size = x6;
Register array = x7;
Register scratch = x6;
// Verify input registers don't conflict with locals.
ASSERT(!AreAliased(receiver, key, value, target_map,
elements, length, array_size, array));
if (mode == TRACK_ALLOCATION_SITE) { if (mode == TRACK_ALLOCATION_SITE) {
__ JumpIfJSArrayHasAllocationMemento(receiver, x10, x11, fail); __ JumpIfJSArrayHasAllocationMemento(receiver, x10, x11, fail);
...@@ -151,32 +159,28 @@ void ElementsTransitionGenerator::GenerateSmiToDouble( ...@@ -151,32 +159,28 @@ void ElementsTransitionGenerator::GenerateSmiToDouble(
// Check for empty arrays, which only require a map transition and no changes // Check for empty arrays, which only require a map transition and no changes
// to the backing store. // to the backing store.
Register elements = x4;
__ Ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); __ Ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
__ JumpIfRoot(elements, Heap::kEmptyFixedArrayRootIndex, &only_change_map); __ JumpIfRoot(elements, Heap::kEmptyFixedArrayRootIndex, &only_change_map);
__ Push(lr); __ Push(lr);
Register length = x5;
__ Ldrsw(length, UntagSmiFieldMemOperand(elements, __ Ldrsw(length, UntagSmiFieldMemOperand(elements,
FixedArray::kLengthOffset)); FixedArray::kLengthOffset));
// Allocate new FixedDoubleArray. // Allocate new FixedDoubleArray.
Register array_size = x6;
Register array = x7;
__ Lsl(array_size, length, kDoubleSizeLog2); __ Lsl(array_size, length, kDoubleSizeLog2);
__ Add(array_size, array_size, FixedDoubleArray::kHeaderSize); __ Add(array_size, array_size, FixedDoubleArray::kHeaderSize);
__ Allocate(array_size, array, x10, x11, &gc_required, DOUBLE_ALIGNMENT); __ Allocate(array_size, array, x10, x11, &gc_required, DOUBLE_ALIGNMENT);
// Register array is non-tagged heap object. // Register array is non-tagged heap object.
// Set the destination FixedDoubleArray's length and map. // Set the destination FixedDoubleArray's length and map.
Register map_root = x6; Register map_root = array_size;
__ LoadRoot(map_root, Heap::kFixedDoubleArrayMapRootIndex); __ LoadRoot(map_root, Heap::kFixedDoubleArrayMapRootIndex);
__ SmiTag(x11, length); __ SmiTag(x11, length);
__ Str(x11, MemOperand(array, FixedDoubleArray::kLengthOffset)); __ Str(x11, MemOperand(array, FixedDoubleArray::kLengthOffset));
__ Str(map_root, MemOperand(array, HeapObject::kMapOffset)); __ Str(map_root, MemOperand(array, HeapObject::kMapOffset));
__ Str(target_map, FieldMemOperand(receiver, HeapObject::kMapOffset)); __ Str(target_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ RecordWriteField(receiver, HeapObject::kMapOffset, target_map, x6, __ RecordWriteField(receiver, HeapObject::kMapOffset, target_map, scratch,
kLRHasBeenSaved, kDontSaveFPRegs, OMIT_REMEMBERED_SET, kLRHasBeenSaved, kDontSaveFPRegs, OMIT_REMEMBERED_SET,
OMIT_SMI_CHECK); OMIT_SMI_CHECK);
...@@ -184,7 +188,7 @@ void ElementsTransitionGenerator::GenerateSmiToDouble( ...@@ -184,7 +188,7 @@ void ElementsTransitionGenerator::GenerateSmiToDouble(
__ Add(x10, array, kHeapObjectTag); __ Add(x10, array, kHeapObjectTag);
__ Str(x10, FieldMemOperand(receiver, JSObject::kElementsOffset)); __ Str(x10, FieldMemOperand(receiver, JSObject::kElementsOffset));
__ RecordWriteField(receiver, JSObject::kElementsOffset, x10, __ RecordWriteField(receiver, JSObject::kElementsOffset, x10,
x6, kLRHasBeenSaved, kDontSaveFPRegs, scratch, kLRHasBeenSaved, kDontSaveFPRegs,
EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
// Prepare for conversion loop. // Prepare for conversion loop.
...@@ -203,7 +207,7 @@ void ElementsTransitionGenerator::GenerateSmiToDouble( ...@@ -203,7 +207,7 @@ void ElementsTransitionGenerator::GenerateSmiToDouble(
__ Bind(&only_change_map); __ Bind(&only_change_map);
__ Str(target_map, FieldMemOperand(receiver, HeapObject::kMapOffset)); __ Str(target_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
__ RecordWriteField(receiver, HeapObject::kMapOffset, target_map, x6, __ RecordWriteField(receiver, HeapObject::kMapOffset, target_map, scratch,
kLRHasNotBeenSaved, kDontSaveFPRegs, OMIT_REMEMBERED_SET, kLRHasNotBeenSaved, kDontSaveFPRegs, OMIT_REMEMBERED_SET,
OMIT_SMI_CHECK); OMIT_SMI_CHECK);
__ B(&done); __ B(&done);
...@@ -235,20 +239,22 @@ void ElementsTransitionGenerator::GenerateSmiToDouble( ...@@ -235,20 +239,22 @@ void ElementsTransitionGenerator::GenerateSmiToDouble(
void ElementsTransitionGenerator::GenerateDoubleToObject( void ElementsTransitionGenerator::GenerateDoubleToObject(
MacroAssembler* masm, AllocationSiteMode mode, Label* fail) { MacroAssembler* masm,
Register receiver,
Register key,
Register value,
Register target_map,
AllocationSiteMode mode,
Label* fail) {
ASM_LOCATION("ElementsTransitionGenerator::GenerateDoubleToObject"); ASM_LOCATION("ElementsTransitionGenerator::GenerateDoubleToObject");
// ----------- S t a t e ------------- Register elements = x4;
// -- x0 : value Register array_size = x6;
// -- x1 : key Register array = x7;
// -- x2 : receiver Register length = x5;
// -- lr : return address
// -- x3 : target map, scratch for subsequent call // Verify input registers don't conflict with locals.
// -- x4 : scratch (elements) ASSERT(!AreAliased(receiver, key, value, target_map,
// ----------------------------------- elements, array_size, array, length));
Register value = x0;
Register key = x1;
Register receiver = x2;
Register target_map = x3;
if (mode == TRACK_ALLOCATION_SITE) { if (mode == TRACK_ALLOCATION_SITE) {
__ JumpIfJSArrayHasAllocationMemento(receiver, x10, x11, fail); __ JumpIfJSArrayHasAllocationMemento(receiver, x10, x11, fail);
...@@ -257,7 +263,7 @@ void ElementsTransitionGenerator::GenerateDoubleToObject( ...@@ -257,7 +263,7 @@ void ElementsTransitionGenerator::GenerateDoubleToObject(
// Check for empty arrays, which only require a map transition and no changes // Check for empty arrays, which only require a map transition and no changes
// to the backing store. // to the backing store.
Label only_change_map; Label only_change_map;
Register elements = x4;
__ Ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); __ Ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
__ JumpIfRoot(elements, Heap::kEmptyFixedArrayRootIndex, &only_change_map); __ JumpIfRoot(elements, Heap::kEmptyFixedArrayRootIndex, &only_change_map);
...@@ -265,20 +271,16 @@ void ElementsTransitionGenerator::GenerateDoubleToObject( ...@@ -265,20 +271,16 @@ void ElementsTransitionGenerator::GenerateDoubleToObject(
// TODO(all): These registers may not need to be pushed. Examine // TODO(all): These registers may not need to be pushed. Examine
// RecordWriteStub and check whether it's needed. // RecordWriteStub and check whether it's needed.
__ Push(target_map, receiver, key, value); __ Push(target_map, receiver, key, value);
Register length = x5;
__ Ldrsw(length, UntagSmiFieldMemOperand(elements, __ Ldrsw(length, UntagSmiFieldMemOperand(elements,
FixedArray::kLengthOffset)); FixedArray::kLengthOffset));
// Allocate new FixedArray. // Allocate new FixedArray.
Register array_size = x6;
Register array = x7;
Label gc_required; Label gc_required;
__ Mov(array_size, FixedDoubleArray::kHeaderSize); __ Mov(array_size, FixedDoubleArray::kHeaderSize);
__ Add(array_size, array_size, Operand(length, LSL, kPointerSizeLog2)); __ Add(array_size, array_size, Operand(length, LSL, kPointerSizeLog2));
__ Allocate(array_size, array, x10, x11, &gc_required, NO_ALLOCATION_FLAGS); __ Allocate(array_size, array, x10, x11, &gc_required, NO_ALLOCATION_FLAGS);
// Set destination FixedDoubleArray's length and map. // Set destination FixedDoubleArray's length and map.
Register map_root = x6; Register map_root = array_size;
__ LoadRoot(map_root, Heap::kFixedArrayMapRootIndex); __ LoadRoot(map_root, Heap::kFixedArrayMapRootIndex);
__ SmiTag(x11, length); __ SmiTag(x11, length);
__ Str(x11, MemOperand(array, FixedDoubleArray::kLengthOffset)); __ Str(x11, MemOperand(array, FixedDoubleArray::kLengthOffset));
...@@ -316,8 +318,10 @@ void ElementsTransitionGenerator::GenerateDoubleToObject( ...@@ -316,8 +318,10 @@ void ElementsTransitionGenerator::GenerateDoubleToObject(
__ B(eq, &convert_hole); __ B(eq, &convert_hole);
// Non-hole double, copy value into a heap number. // Non-hole double, copy value into a heap number.
Register heap_num = x5; Register heap_num = length;
__ AllocateHeapNumber(heap_num, &gc_required, x6, x4, Register scratch = array_size;
Register scratch2 = elements;
__ AllocateHeapNumber(heap_num, &gc_required, scratch, scratch2,
x13, heap_num_map); x13, heap_num_map);
__ Mov(x13, dst_elements); __ Mov(x13, dst_elements);
__ Str(heap_num, MemOperand(dst_elements, kPointerSize, PostIndex)); __ Str(heap_num, MemOperand(dst_elements, kPointerSize, PostIndex));
......
...@@ -1013,10 +1013,10 @@ static void KeyedStoreGenerateGenericHelper( ...@@ -1013,10 +1013,10 @@ static void KeyedStoreGenerateGenericHelper(
x10, x10,
x11, x11,
slow); slow);
ASSERT(receiver_map.Is(x3)); // Transition code expects map in x3.
AllocationSiteMode mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, AllocationSiteMode mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS,
FAST_DOUBLE_ELEMENTS); FAST_DOUBLE_ELEMENTS);
ElementsTransitionGenerator::GenerateSmiToDouble(masm, mode, slow); ElementsTransitionGenerator::GenerateSmiToDouble(
masm, receiver, key, value, receiver_map, mode, slow);
__ Ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); __ Ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
__ B(&fast_double_without_map_check); __ B(&fast_double_without_map_check);
...@@ -1028,10 +1028,11 @@ static void KeyedStoreGenerateGenericHelper( ...@@ -1028,10 +1028,11 @@ static void KeyedStoreGenerateGenericHelper(
x10, x10,
x11, x11,
slow); slow);
ASSERT(receiver_map.Is(x3)); // Transition code expects map in x3.
mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS); mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS);
ElementsTransitionGenerator::GenerateMapChangeElementsTransition(masm, mode, ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
slow); masm, receiver, key, value, receiver_map, mode, slow);
__ Ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); __ Ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
__ B(&finish_store); __ B(&finish_store);
...@@ -1045,9 +1046,9 @@ static void KeyedStoreGenerateGenericHelper( ...@@ -1045,9 +1046,9 @@ static void KeyedStoreGenerateGenericHelper(
x10, x10,
x11, x11,
slow); slow);
ASSERT(receiver_map.Is(x3)); // Transition code expects map in x3.
mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS); mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS);
ElementsTransitionGenerator::GenerateDoubleToObject(masm, mode, slow); ElementsTransitionGenerator::GenerateDoubleToObject(
masm, receiver, key, value, receiver_map, mode, slow);
__ Ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); __ Ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
__ B(&finish_store); __ B(&finish_store);
} }
......
...@@ -117,13 +117,28 @@ class ElementsTransitionGenerator : public AllStatic { ...@@ -117,13 +117,28 @@ class ElementsTransitionGenerator : public AllStatic {
public: public:
// If |mode| is set to DONT_TRACK_ALLOCATION_SITE, // If |mode| is set to DONT_TRACK_ALLOCATION_SITE,
// |allocation_memento_found| may be NULL. // |allocation_memento_found| may be NULL.
static void GenerateMapChangeElementsTransition(MacroAssembler* masm, static void GenerateMapChangeElementsTransition(
MacroAssembler* masm,
Register receiver,
Register key,
Register value,
Register target_map,
AllocationSiteMode mode, AllocationSiteMode mode,
Label* allocation_memento_found); Label* allocation_memento_found);
static void GenerateSmiToDouble(MacroAssembler* masm, static void GenerateSmiToDouble(
MacroAssembler* masm,
Register receiver,
Register key,
Register value,
Register target_map,
AllocationSiteMode mode, AllocationSiteMode mode,
Label* fail); Label* fail);
static void GenerateDoubleToObject(MacroAssembler* masm, static void GenerateDoubleToObject(
MacroAssembler* masm,
Register receiver,
Register key,
Register value,
Register target_map,
AllocationSiteMode mode, AllocationSiteMode mode,
Label* fail); Label* fail);
......
...@@ -522,26 +522,28 @@ MemMoveFunction CreateMemMoveFunction() { ...@@ -522,26 +522,28 @@ MemMoveFunction CreateMemMoveFunction() {
void ElementsTransitionGenerator::GenerateMapChangeElementsTransition( void ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
MacroAssembler* masm, AllocationSiteMode mode, MacroAssembler* masm,
Register receiver,
Register key,
Register value,
Register target_map,
AllocationSiteMode mode,
Label* allocation_memento_found) { Label* allocation_memento_found) {
// ----------- S t a t e ------------- Register scratch = edi;
// -- eax : value ASSERT(!AreAliased(receiver, key, value, target_map, scratch));
// -- ebx : target map
// -- ecx : key
// -- edx : receiver
// -- esp[0] : return address
// -----------------------------------
if (mode == TRACK_ALLOCATION_SITE) { if (mode == TRACK_ALLOCATION_SITE) {
ASSERT(allocation_memento_found != NULL); ASSERT(allocation_memento_found != NULL);
__ JumpIfJSArrayHasAllocationMemento(edx, edi, allocation_memento_found); __ JumpIfJSArrayHasAllocationMemento(
receiver, scratch, allocation_memento_found);
} }
// Set transitioned map. // Set transitioned map.
__ mov(FieldOperand(edx, HeapObject::kMapOffset), ebx); __ mov(FieldOperand(receiver, HeapObject::kMapOffset), target_map);
__ RecordWriteField(edx, __ RecordWriteField(receiver,
HeapObject::kMapOffset, HeapObject::kMapOffset,
ebx, target_map,
edi, scratch,
kDontSaveFPRegs, kDontSaveFPRegs,
EMIT_REMEMBERED_SET, EMIT_REMEMBERED_SET,
OMIT_SMI_CHECK); OMIT_SMI_CHECK);
...@@ -549,14 +551,19 @@ void ElementsTransitionGenerator::GenerateMapChangeElementsTransition( ...@@ -549,14 +551,19 @@ void ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
void ElementsTransitionGenerator::GenerateSmiToDouble( void ElementsTransitionGenerator::GenerateSmiToDouble(
MacroAssembler* masm, AllocationSiteMode mode, Label* fail) { MacroAssembler* masm,
// ----------- S t a t e ------------- Register receiver,
// -- eax : value Register key,
// -- ebx : target map Register value,
// -- ecx : key Register target_map,
// -- edx : receiver AllocationSiteMode mode,
// -- esp[0] : return address 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; Label loop, entry, convert_hole, gc_required, only_change_map;
if (mode == TRACK_ALLOCATION_SITE) { if (mode == TRACK_ALLOCATION_SITE) {
...@@ -670,14 +677,19 @@ void ElementsTransitionGenerator::GenerateSmiToDouble( ...@@ -670,14 +677,19 @@ void ElementsTransitionGenerator::GenerateSmiToDouble(
void ElementsTransitionGenerator::GenerateDoubleToObject( void ElementsTransitionGenerator::GenerateDoubleToObject(
MacroAssembler* masm, AllocationSiteMode mode, Label* fail) { MacroAssembler* masm,
// ----------- S t a t e ------------- Register receiver,
// -- eax : value Register key,
// -- ebx : target map Register value,
// -- ecx : key Register target_map,
// -- edx : receiver AllocationSiteMode mode,
// -- esp[0] : return address 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; Label loop, entry, convert_hole, gc_required, only_change_map, success;
if (mode == TRACK_ALLOCATION_SITE) { if (mode == TRACK_ALLOCATION_SITE) {
......
...@@ -804,7 +804,8 @@ static void KeyedStoreGenerateGenericHelper( ...@@ -804,7 +804,8 @@ static void KeyedStoreGenerateGenericHelper(
slow); slow);
AllocationSiteMode mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, AllocationSiteMode mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS,
FAST_DOUBLE_ELEMENTS); FAST_DOUBLE_ELEMENTS);
ElementsTransitionGenerator::GenerateSmiToDouble(masm, mode, slow); ElementsTransitionGenerator::GenerateSmiToDouble(
masm, receiver, key, value, ebx, mode, slow);
__ mov(ebx, FieldOperand(receiver, JSObject::kElementsOffset)); __ mov(ebx, FieldOperand(receiver, JSObject::kElementsOffset));
__ jmp(&fast_double_without_map_check); __ jmp(&fast_double_without_map_check);
...@@ -816,8 +817,8 @@ static void KeyedStoreGenerateGenericHelper( ...@@ -816,8 +817,8 @@ static void KeyedStoreGenerateGenericHelper(
edi, edi,
slow); slow);
mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS); mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS);
ElementsTransitionGenerator::GenerateMapChangeElementsTransition(masm, mode, ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
slow); masm, receiver, key, value, ebx, mode, slow);
__ mov(ebx, FieldOperand(receiver, JSObject::kElementsOffset)); __ mov(ebx, FieldOperand(receiver, JSObject::kElementsOffset));
__ jmp(&finish_object_store); __ jmp(&finish_object_store);
...@@ -832,7 +833,8 @@ static void KeyedStoreGenerateGenericHelper( ...@@ -832,7 +833,8 @@ static void KeyedStoreGenerateGenericHelper(
edi, edi,
slow); slow);
mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS); 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)); __ mov(ebx, FieldOperand(receiver, JSObject::kElementsOffset));
__ jmp(&finish_object_store); __ jmp(&finish_object_store);
} }
......
...@@ -3043,15 +3043,33 @@ void MacroAssembler::CallCFunction(Register function, ...@@ -3043,15 +3043,33 @@ void MacroAssembler::CallCFunction(Register function,
} }
bool AreAliased(Register r1, Register r2, Register r3, Register r4) { #ifdef DEBUG
if (r1.is(r2)) return true; bool AreAliased(Register reg1,
if (r1.is(r3)) return true; Register reg2,
if (r1.is(r4)) return true; Register reg3,
if (r2.is(r3)) return true; Register reg4,
if (r2.is(r4)) return true; Register reg5,
if (r3.is(r4)) return true; Register reg6,
return false; 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) CodePatcher::CodePatcher(byte* address, int size)
......
...@@ -30,7 +30,16 @@ enum RegisterValueType { ...@@ -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. // MacroAssembler implements a collection of frequently used macros.
......
...@@ -184,26 +184,29 @@ ModuloFunction CreateModuloFunction() { ...@@ -184,26 +184,29 @@ ModuloFunction CreateModuloFunction() {
#define __ ACCESS_MASM(masm) #define __ ACCESS_MASM(masm)
void ElementsTransitionGenerator::GenerateMapChangeElementsTransition( void ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
MacroAssembler* masm, AllocationSiteMode mode, MacroAssembler* masm,
Register receiver,
Register key,
Register value,
Register target_map,
AllocationSiteMode mode,
Label* allocation_memento_found) { Label* allocation_memento_found) {
// ----------- S t a t e ------------- // Return address is on the stack.
// -- rax : value Register scratch = rdi;
// -- rbx : target map ASSERT(!AreAliased(receiver, key, value, target_map, scratch));
// -- rcx : key
// -- rdx : receiver
// -- rsp[0] : return address
// -----------------------------------
if (mode == TRACK_ALLOCATION_SITE) { if (mode == TRACK_ALLOCATION_SITE) {
ASSERT(allocation_memento_found != NULL); ASSERT(allocation_memento_found != NULL);
__ JumpIfJSArrayHasAllocationMemento(rdx, rdi, allocation_memento_found); __ JumpIfJSArrayHasAllocationMemento(
receiver, scratch, allocation_memento_found);
} }
// Set transitioned map. // Set transitioned map.
__ movp(FieldOperand(rdx, HeapObject::kMapOffset), rbx); __ movp(FieldOperand(receiver, HeapObject::kMapOffset), target_map);
__ RecordWriteField(rdx, __ RecordWriteField(receiver,
HeapObject::kMapOffset, HeapObject::kMapOffset,
rbx, target_map,
rdi, scratch,
kDontSaveFPRegs, kDontSaveFPRegs,
EMIT_REMEMBERED_SET, EMIT_REMEMBERED_SET,
OMIT_SMI_CHECK); OMIT_SMI_CHECK);
...@@ -211,14 +214,19 @@ void ElementsTransitionGenerator::GenerateMapChangeElementsTransition( ...@@ -211,14 +214,19 @@ void ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
void ElementsTransitionGenerator::GenerateSmiToDouble( void ElementsTransitionGenerator::GenerateSmiToDouble(
MacroAssembler* masm, AllocationSiteMode mode, Label* fail) { MacroAssembler* masm,
// ----------- S t a t e ------------- Register receiver,
// -- rax : value Register key,
// -- rbx : target map Register value,
// -- rcx : key Register target_map,
// -- rdx : receiver AllocationSiteMode mode,
// -- rsp[0] : return address Label* fail) {
// ----------------------------------- // Return address is on the stack.
ASSERT(receiver.is(rdx));
ASSERT(key.is(rcx));
ASSERT(value.is(rax));
ASSERT(target_map.is(rbx));
// The fail label is not actually used since we do not allocate. // The fail label is not actually used since we do not allocate.
Label allocated, new_backing_store, only_change_map, done; Label allocated, new_backing_store, only_change_map, done;
...@@ -345,14 +353,19 @@ void ElementsTransitionGenerator::GenerateSmiToDouble( ...@@ -345,14 +353,19 @@ void ElementsTransitionGenerator::GenerateSmiToDouble(
void ElementsTransitionGenerator::GenerateDoubleToObject( void ElementsTransitionGenerator::GenerateDoubleToObject(
MacroAssembler* masm, AllocationSiteMode mode, Label* fail) { MacroAssembler* masm,
// ----------- S t a t e ------------- Register receiver,
// -- rax : value Register key,
// -- rbx : target map Register value,
// -- rcx : key Register target_map,
// -- rdx : receiver AllocationSiteMode mode,
// -- rsp[0] : return address Label* fail) {
// ----------------------------------- // Return address is on the stack.
ASSERT(receiver.is(rdx));
ASSERT(key.is(rcx));
ASSERT(value.is(rax));
ASSERT(target_map.is(rbx));
Label loop, entry, convert_hole, gc_required, only_change_map; Label loop, entry, convert_hole, gc_required, only_change_map;
if (mode == TRACK_ALLOCATION_SITE) { if (mode == TRACK_ALLOCATION_SITE) {
......
...@@ -673,7 +673,8 @@ static void KeyedStoreGenerateGenericHelper( ...@@ -673,7 +673,8 @@ static void KeyedStoreGenerateGenericHelper(
slow); slow);
AllocationSiteMode mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, AllocationSiteMode mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS,
FAST_DOUBLE_ELEMENTS); FAST_DOUBLE_ELEMENTS);
ElementsTransitionGenerator::GenerateSmiToDouble(masm, mode, slow); ElementsTransitionGenerator::GenerateSmiToDouble(
masm, receiver, key, value, rbx, mode, slow);
__ movp(rbx, FieldOperand(receiver, JSObject::kElementsOffset)); __ movp(rbx, FieldOperand(receiver, JSObject::kElementsOffset));
__ jmp(&fast_double_without_map_check); __ jmp(&fast_double_without_map_check);
...@@ -685,8 +686,8 @@ static void KeyedStoreGenerateGenericHelper( ...@@ -685,8 +686,8 @@ static void KeyedStoreGenerateGenericHelper(
rdi, rdi,
slow); slow);
mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS); mode = AllocationSite::GetMode(FAST_SMI_ELEMENTS, FAST_ELEMENTS);
ElementsTransitionGenerator::GenerateMapChangeElementsTransition(masm, mode, ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
slow); masm, receiver, key, value, rbx, mode, slow);
__ movp(rbx, FieldOperand(receiver, JSObject::kElementsOffset)); __ movp(rbx, FieldOperand(receiver, JSObject::kElementsOffset));
__ jmp(&finish_object_store); __ jmp(&finish_object_store);
...@@ -701,7 +702,8 @@ static void KeyedStoreGenerateGenericHelper( ...@@ -701,7 +702,8 @@ static void KeyedStoreGenerateGenericHelper(
rdi, rdi,
slow); slow);
mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS); mode = AllocationSite::GetMode(FAST_DOUBLE_ELEMENTS, FAST_ELEMENTS);
ElementsTransitionGenerator::GenerateDoubleToObject(masm, mode, slow); ElementsTransitionGenerator::GenerateDoubleToObject(
masm, receiver, key, value, rbx, mode, slow);
__ movp(rbx, FieldOperand(receiver, JSObject::kElementsOffset)); __ movp(rbx, FieldOperand(receiver, JSObject::kElementsOffset));
__ jmp(&finish_object_store); __ jmp(&finish_object_store);
} }
......
...@@ -5020,15 +5020,33 @@ void MacroAssembler::CallCFunction(Register function, int num_arguments) { ...@@ -5020,15 +5020,33 @@ void MacroAssembler::CallCFunction(Register function, int num_arguments) {
} }
bool AreAliased(Register r1, Register r2, Register r3, Register r4) { #ifdef DEBUG
if (r1.is(r2)) return true; bool AreAliased(Register reg1,
if (r1.is(r3)) return true; Register reg2,
if (r1.is(r4)) return true; Register reg3,
if (r2.is(r3)) return true; Register reg4,
if (r2.is(r4)) return true; Register reg5,
if (r3.is(r4)) return true; Register reg6,
return false; 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) CodePatcher::CodePatcher(byte* address, int size)
......
...@@ -50,7 +50,16 @@ class SmiOperationExecutionMode : public EnumSet<SmiOperationConstraint, byte> { ...@@ -50,7 +50,16 @@ class SmiOperationExecutionMode : public EnumSet<SmiOperationConstraint, byte> {
: EnumSet<SmiOperationConstraint, byte>(bits) { } : EnumSet<SmiOperationConstraint, byte>(bits) { }
}; };
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
// Forward declaration. // Forward declaration.
class JumpTarget; class JumpTarget;
......
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