diff options
Diffstat (limited to 'deps/v8/src/ppc/codegen-ppc.cc')
-rw-r--r-- | deps/v8/src/ppc/codegen-ppc.cc | 324 |
1 files changed, 10 insertions, 314 deletions
diff --git a/deps/v8/src/ppc/codegen-ppc.cc b/deps/v8/src/ppc/codegen-ppc.cc index 07853edc20..bb365b4e63 100644 --- a/deps/v8/src/ppc/codegen-ppc.cc +++ b/deps/v8/src/ppc/codegen-ppc.cc @@ -73,304 +73,6 @@ void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { #define __ ACCESS_MASM(masm) -void ElementsTransitionGenerator::GenerateMapChangeElementsTransition( - MacroAssembler* masm, Register receiver, Register key, Register value, - Register target_map, AllocationSiteMode mode, - Label* allocation_memento_found) { - Register scratch_elements = r7; - DCHECK(!AreAliased(receiver, key, value, target_map, scratch_elements)); - - if (mode == TRACK_ALLOCATION_SITE) { - DCHECK(allocation_memento_found != NULL); - __ JumpIfJSArrayHasAllocationMemento(receiver, scratch_elements, r11, - allocation_memento_found); - } - - // Set transitioned map. - __ StoreP(target_map, FieldMemOperand(receiver, HeapObject::kMapOffset), r0); - __ RecordWriteField(receiver, HeapObject::kMapOffset, target_map, r11, - kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, - OMIT_SMI_CHECK); -} - - -void ElementsTransitionGenerator::GenerateSmiToDouble( - MacroAssembler* masm, Register receiver, Register key, Register value, - Register target_map, AllocationSiteMode mode, Label* fail) { - // lr contains the return address - Label loop, entry, convert_hole, only_change_map, done; - Register elements = r7; - Register length = r8; - Register array = r9; - Register array_end = array; - - // target_map parameter can be clobbered. - Register scratch1 = target_map; - Register scratch2 = r10; - Register scratch3 = r11; - Register scratch4 = r14; - - // Verify input registers don't conflict with locals. - DCHECK(!AreAliased(receiver, key, value, target_map, elements, length, array, - scratch2)); - - if (mode == TRACK_ALLOCATION_SITE) { - __ JumpIfJSArrayHasAllocationMemento(receiver, elements, scratch3, fail); - } - - // Check for empty arrays, which only require a map transition and no changes - // to the backing store. - __ LoadP(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); - __ CompareRoot(elements, Heap::kEmptyFixedArrayRootIndex); - __ beq(&only_change_map); - - __ LoadP(length, FieldMemOperand(elements, FixedArray::kLengthOffset)); - // length: number of elements (smi-tagged) - - // Allocate new FixedDoubleArray. - __ SmiToDoubleArrayOffset(scratch3, length); - __ addi(scratch3, scratch3, Operand(FixedDoubleArray::kHeaderSize)); - __ Allocate(scratch3, array, scratch4, scratch2, fail, DOUBLE_ALIGNMENT); - __ subi(array, array, Operand(kHeapObjectTag)); - // array: destination FixedDoubleArray, not tagged as heap object. - // elements: source FixedArray. - - // Set destination FixedDoubleArray's length and map. - __ LoadRoot(scratch2, Heap::kFixedDoubleArrayMapRootIndex); - __ StoreP(length, MemOperand(array, FixedDoubleArray::kLengthOffset)); - // Update receiver's map. - __ StoreP(scratch2, MemOperand(array, HeapObject::kMapOffset)); - - __ StoreP(target_map, FieldMemOperand(receiver, HeapObject::kMapOffset), r0); - __ RecordWriteField(receiver, HeapObject::kMapOffset, target_map, scratch2, - kLRHasNotBeenSaved, kDontSaveFPRegs, OMIT_REMEMBERED_SET, - OMIT_SMI_CHECK); - // Replace receiver's backing store with newly created FixedDoubleArray. - __ addi(scratch1, array, Operand(kHeapObjectTag)); - __ StoreP(scratch1, FieldMemOperand(receiver, JSObject::kElementsOffset), r0); - __ RecordWriteField(receiver, JSObject::kElementsOffset, scratch1, scratch2, - kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, - OMIT_SMI_CHECK); - - // Prepare for conversion loop. - __ addi(scratch1, elements, - Operand(FixedArray::kHeaderSize - kHeapObjectTag)); - __ addi(scratch2, array, Operand(FixedDoubleArray::kHeaderSize)); - __ SmiToDoubleArrayOffset(array_end, length); - __ add(array_end, scratch2, array_end); -// Repurpose registers no longer in use. -#if V8_TARGET_ARCH_PPC64 - Register hole_int64 = elements; - __ mov(hole_int64, Operand(kHoleNanInt64)); -#else - Register hole_lower = elements; - Register hole_upper = length; - __ mov(hole_lower, Operand(kHoleNanLower32)); - __ mov(hole_upper, Operand(kHoleNanUpper32)); -#endif - // scratch1: begin of source FixedArray element fields, not tagged - // hole_lower: kHoleNanLower32 OR hol_int64 - // hole_upper: kHoleNanUpper32 - // array_end: end of destination FixedDoubleArray, not tagged - // scratch2: begin of FixedDoubleArray element fields, not tagged - - __ b(&entry); - - __ bind(&only_change_map); - __ StoreP(target_map, FieldMemOperand(receiver, HeapObject::kMapOffset), r0); - __ RecordWriteField(receiver, HeapObject::kMapOffset, target_map, scratch2, - kLRHasNotBeenSaved, kDontSaveFPRegs, OMIT_REMEMBERED_SET, - OMIT_SMI_CHECK); - __ b(&done); - - // Convert and copy elements. - __ bind(&loop); - __ LoadP(scratch3, MemOperand(scratch1)); - __ addi(scratch1, scratch1, Operand(kPointerSize)); - // scratch3: current element - __ UntagAndJumpIfNotSmi(scratch3, scratch3, &convert_hole); - - // Normal smi, convert to double and store. - __ ConvertIntToDouble(scratch3, d0); - __ stfd(d0, MemOperand(scratch2, 0)); - __ addi(scratch2, scratch2, Operand(8)); - __ b(&entry); - - // Hole found, store the-hole NaN. - __ bind(&convert_hole); - if (FLAG_debug_code) { - __ LoadP(scratch3, MemOperand(scratch1, -kPointerSize)); - __ CompareRoot(scratch3, Heap::kTheHoleValueRootIndex); - __ Assert(eq, kObjectFoundInSmiOnlyArray); - } -#if V8_TARGET_ARCH_PPC64 - __ std(hole_int64, MemOperand(scratch2, 0)); -#else - __ stw(hole_upper, MemOperand(scratch2, Register::kExponentOffset)); - __ stw(hole_lower, MemOperand(scratch2, Register::kMantissaOffset)); -#endif - __ addi(scratch2, scratch2, Operand(8)); - - __ bind(&entry); - __ cmp(scratch2, array_end); - __ blt(&loop); - - __ bind(&done); -} - - -void ElementsTransitionGenerator::GenerateDoubleToObject( - MacroAssembler* masm, Register receiver, Register key, Register value, - Register target_map, AllocationSiteMode mode, Label* fail) { - // Register lr contains the return address. - Label loop, convert_hole, gc_required, only_change_map; - Register elements = r7; - Register array = r9; - Register length = r8; - Register scratch = r10; - Register scratch3 = r11; - Register hole_value = r14; - - // Verify input registers don't conflict with locals. - DCHECK(!AreAliased(receiver, key, value, target_map, elements, array, length, - scratch)); - - if (mode == TRACK_ALLOCATION_SITE) { - __ JumpIfJSArrayHasAllocationMemento(receiver, elements, scratch3, fail); - } - - // Check for empty arrays, which only require a map transition and no changes - // to the backing store. - __ LoadP(elements, FieldMemOperand(receiver, JSObject::kElementsOffset)); - __ CompareRoot(elements, Heap::kEmptyFixedArrayRootIndex); - __ beq(&only_change_map); - - __ Push(target_map, receiver, key, value); - __ LoadP(length, FieldMemOperand(elements, FixedArray::kLengthOffset)); - // elements: source FixedDoubleArray - // length: number of elements (smi-tagged) - - // Allocate new FixedArray. - // Re-use value and target_map registers, as they have been saved on the - // stack. - Register array_size = value; - Register allocate_scratch = target_map; - __ li(array_size, Operand(FixedDoubleArray::kHeaderSize)); - __ SmiToPtrArrayOffset(r0, length); - __ add(array_size, array_size, r0); - __ Allocate(array_size, array, allocate_scratch, scratch, &gc_required, - NO_ALLOCATION_FLAGS); - // array: destination FixedArray, tagged as heap object - // Set destination FixedDoubleArray's length and map. - __ LoadRoot(scratch, Heap::kFixedArrayMapRootIndex); - __ StoreP(length, FieldMemOperand(array, - FixedDoubleArray::kLengthOffset), r0); - __ StoreP(scratch, FieldMemOperand(array, HeapObject::kMapOffset), r0); - - // Prepare for conversion loop. - Register src_elements = elements; - Register dst_elements = target_map; - Register dst_end = length; - Register heap_number_map = scratch; - __ addi(src_elements, elements, - Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag)); - __ SmiToPtrArrayOffset(length, length); - __ LoadRoot(hole_value, Heap::kTheHoleValueRootIndex); - - Label initialization_loop, loop_done; - __ ShiftRightImm(r0, length, Operand(kPointerSizeLog2), SetRC); - __ beq(&loop_done, cr0); - - // Allocating heap numbers in the loop below can fail and cause a jump to - // gc_required. We can't leave a partly initialized FixedArray behind, - // so pessimistically fill it with holes now. - __ mtctr(r0); - __ addi(dst_elements, array, - Operand(FixedArray::kHeaderSize - kHeapObjectTag - kPointerSize)); - __ bind(&initialization_loop); - __ StorePU(hole_value, MemOperand(dst_elements, kPointerSize)); - __ bdnz(&initialization_loop); - - __ addi(dst_elements, array, - Operand(FixedArray::kHeaderSize - kHeapObjectTag)); - __ add(dst_end, dst_elements, length); - __ LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); - // Using offsetted addresses in src_elements to fully take advantage of - // post-indexing. - // dst_elements: begin of destination FixedArray element fields, not tagged - // src_elements: begin of source FixedDoubleArray element fields, - // not tagged, +4 - // dst_end: end of destination FixedArray, not tagged - // array: destination FixedArray - // hole_value: the-hole pointer - // heap_number_map: heap number map - __ b(&loop); - - // Call into runtime if GC is required. - __ bind(&gc_required); - __ Pop(target_map, receiver, key, value); - __ b(fail); - - // Replace the-hole NaN with the-hole pointer. - __ bind(&convert_hole); - __ StoreP(hole_value, MemOperand(dst_elements)); - __ addi(dst_elements, dst_elements, Operand(kPointerSize)); - __ cmpl(dst_elements, dst_end); - __ bge(&loop_done); - - __ bind(&loop); - Register upper_bits = key; - __ lwz(upper_bits, MemOperand(src_elements, Register::kExponentOffset)); - __ addi(src_elements, src_elements, Operand(kDoubleSize)); - // upper_bits: current element's upper 32 bit - // src_elements: address of next element's upper 32 bit - __ Cmpi(upper_bits, Operand(kHoleNanUpper32), r0); - __ beq(&convert_hole); - - // Non-hole double, copy value into a heap number. - Register heap_number = receiver; - Register scratch2 = value; - __ AllocateHeapNumber(heap_number, scratch2, scratch3, heap_number_map, - &gc_required); - // heap_number: new heap number -#if V8_TARGET_ARCH_PPC64 - __ ld(scratch2, MemOperand(src_elements, -kDoubleSize)); - // subtract tag for std - __ addi(upper_bits, heap_number, Operand(-kHeapObjectTag)); - __ std(scratch2, MemOperand(upper_bits, HeapNumber::kValueOffset)); -#else - __ lwz(scratch2, - MemOperand(src_elements, Register::kMantissaOffset - kDoubleSize)); - __ lwz(upper_bits, - MemOperand(src_elements, Register::kExponentOffset - kDoubleSize)); - __ stw(scratch2, FieldMemOperand(heap_number, HeapNumber::kMantissaOffset)); - __ stw(upper_bits, FieldMemOperand(heap_number, HeapNumber::kExponentOffset)); -#endif - __ mr(scratch2, dst_elements); - __ StoreP(heap_number, MemOperand(dst_elements)); - __ addi(dst_elements, dst_elements, Operand(kPointerSize)); - __ RecordWrite(array, scratch2, heap_number, kLRHasNotBeenSaved, - kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); - __ cmpl(dst_elements, dst_end); - __ blt(&loop); - __ bind(&loop_done); - - __ Pop(target_map, receiver, key, value); - // Replace receiver's backing store with newly created and filled FixedArray. - __ StoreP(array, FieldMemOperand(receiver, JSObject::kElementsOffset), r0); - __ RecordWriteField(receiver, JSObject::kElementsOffset, array, scratch, - kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, - OMIT_SMI_CHECK); - - __ bind(&only_change_map); - // Update receiver's map. - __ StoreP(target_map, FieldMemOperand(receiver, HeapObject::kMapOffset), r0); - __ RecordWriteField(receiver, HeapObject::kMapOffset, target_map, scratch, - kLRHasNotBeenSaved, kDontSaveFPRegs, OMIT_REMEMBERED_SET, - OMIT_SMI_CHECK); -} - - // assume ip can be used as a scratch register below void StringCharLoadGenerator::Generate(MacroAssembler* masm, Register string, Register index, Register result, @@ -493,31 +195,25 @@ bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) { return result; } +Code::Age Code::GetCodeAge(Isolate* isolate, byte* sequence) { + if (IsYoungSequence(isolate, sequence)) return kNoAgeCodeAge; -void Code::GetCodeAgeAndParity(Isolate* isolate, byte* sequence, Age* age, - MarkingParity* parity) { - if (IsYoungSequence(isolate, sequence)) { - *age = kNoAgeCodeAge; - *parity = NO_MARKING_PARITY; - } else { - Code* code = NULL; - Address target_address = - Assembler::target_address_at(sequence + kCodeAgingTargetDelta, code); - Code* stub = GetCodeFromTargetAddress(target_address); - GetCodeAgeAndParity(stub, age, parity); - } + Code* code = NULL; + Address target_address = + Assembler::target_address_at(sequence + kCodeAgingTargetDelta, code); + Code* stub = GetCodeFromTargetAddress(target_address); + return GetAgeOfCodeAgeStub(stub); } - -void Code::PatchPlatformCodeAge(Isolate* isolate, byte* sequence, Code::Age age, - MarkingParity parity) { +void Code::PatchPlatformCodeAge(Isolate* isolate, byte* sequence, + Code::Age age) { uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); if (age == kNoAgeCodeAge) { isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); Assembler::FlushICache(isolate, sequence, young_length); } else { // FIXED_SEQUENCE - Code* stub = GetCodeAgeStub(isolate, age, parity); + Code* stub = GetCodeAgeStub(isolate, age); CodePatcher patcher(isolate, sequence, young_length / Assembler::kInstrSize); Assembler::BlockTrampolinePoolScope block_trampoline_pool(patcher.masm()); |