| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
| 8 | 8 |
| 9 #include "src/arm64/delayed-masm-arm64.h" | 9 #include "src/arm64/delayed-masm-arm64.h" |
| 10 #include "src/arm64/lithium-codegen-arm64.h" | 10 #include "src/arm64/lithium-codegen-arm64.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 #define __ ACCESS_MASM(masm_) | 15 #define __ ACCESS_MASM(masm_) |
| 16 | 16 |
| 17 | 17 |
| 18 void DelayedMasm::StackSlotMove(LOperand* src, LOperand* dst) { | 18 void DelayedMasm::StackSlotMove(LOperand* src, LOperand* dst) { |
| 19 ASSERT(src->IsStackSlot()); | 19 DCHECK(src->IsStackSlot()); |
| 20 ASSERT(dst->IsStackSlot()); | 20 DCHECK(dst->IsStackSlot()); |
| 21 MemOperand src_operand = cgen_->ToMemOperand(src); | 21 MemOperand src_operand = cgen_->ToMemOperand(src); |
| 22 MemOperand dst_operand = cgen_->ToMemOperand(dst); | 22 MemOperand dst_operand = cgen_->ToMemOperand(dst); |
| 23 if (pending_ == kStackSlotMove) { | 23 if (pending_ == kStackSlotMove) { |
| 24 ASSERT(pending_pc_ == masm_->pc_offset()); | 24 DCHECK(pending_pc_ == masm_->pc_offset()); |
| 25 UseScratchRegisterScope scope(masm_); | 25 UseScratchRegisterScope scope(masm_); |
| 26 DoubleRegister temp1 = scope.AcquireD(); | 26 DoubleRegister temp1 = scope.AcquireD(); |
| 27 DoubleRegister temp2 = scope.AcquireD(); | 27 DoubleRegister temp2 = scope.AcquireD(); |
| 28 switch (MemOperand::AreConsistentForPair(pending_address_src_, | 28 switch (MemOperand::AreConsistentForPair(pending_address_src_, |
| 29 src_operand)) { | 29 src_operand)) { |
| 30 case MemOperand::kNotPair: | 30 case MemOperand::kNotPair: |
| 31 __ Ldr(temp1, pending_address_src_); | 31 __ Ldr(temp1, pending_address_src_); |
| 32 __ Ldr(temp2, src_operand); | 32 __ Ldr(temp2, src_operand); |
| 33 break; | 33 break; |
| 34 case MemOperand::kPairAB: | 34 case MemOperand::kPairAB: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 59 pending_ = kStackSlotMove; | 59 pending_ = kStackSlotMove; |
| 60 pending_address_src_ = src_operand; | 60 pending_address_src_ = src_operand; |
| 61 pending_address_dst_ = dst_operand; | 61 pending_address_dst_ = dst_operand; |
| 62 #ifdef DEBUG | 62 #ifdef DEBUG |
| 63 pending_pc_ = masm_->pc_offset(); | 63 pending_pc_ = masm_->pc_offset(); |
| 64 #endif | 64 #endif |
| 65 } | 65 } |
| 66 | 66 |
| 67 | 67 |
| 68 void DelayedMasm::StoreConstant(uint64_t value, const MemOperand& operand) { | 68 void DelayedMasm::StoreConstant(uint64_t value, const MemOperand& operand) { |
| 69 ASSERT(!scratch_register_acquired_); | 69 DCHECK(!scratch_register_acquired_); |
| 70 if ((pending_ == kStoreConstant) && (value == pending_value_)) { | 70 if ((pending_ == kStoreConstant) && (value == pending_value_)) { |
| 71 MemOperand::PairResult result = | 71 MemOperand::PairResult result = |
| 72 MemOperand::AreConsistentForPair(pending_address_dst_, operand); | 72 MemOperand::AreConsistentForPair(pending_address_dst_, operand); |
| 73 if (result != MemOperand::kNotPair) { | 73 if (result != MemOperand::kNotPair) { |
| 74 const MemOperand& dst = | 74 const MemOperand& dst = |
| 75 (result == MemOperand::kPairAB) ? | 75 (result == MemOperand::kPairAB) ? |
| 76 pending_address_dst_ : | 76 pending_address_dst_ : |
| 77 operand; | 77 operand; |
| 78 ASSERT(pending_pc_ == masm_->pc_offset()); | 78 DCHECK(pending_pc_ == masm_->pc_offset()); |
| 79 if (pending_value_ == 0) { | 79 if (pending_value_ == 0) { |
| 80 __ Stp(xzr, xzr, dst); | 80 __ Stp(xzr, xzr, dst); |
| 81 } else { | 81 } else { |
| 82 SetSavedValue(pending_value_); | 82 SetSavedValue(pending_value_); |
| 83 __ Stp(ScratchRegister(), ScratchRegister(), dst); | 83 __ Stp(ScratchRegister(), ScratchRegister(), dst); |
| 84 } | 84 } |
| 85 ResetPending(); | 85 ResetPending(); |
| 86 return; | 86 return; |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 EmitPending(); | 90 EmitPending(); |
| 91 pending_ = kStoreConstant; | 91 pending_ = kStoreConstant; |
| 92 pending_address_dst_ = operand; | 92 pending_address_dst_ = operand; |
| 93 pending_value_ = value; | 93 pending_value_ = value; |
| 94 #ifdef DEBUG | 94 #ifdef DEBUG |
| 95 pending_pc_ = masm_->pc_offset(); | 95 pending_pc_ = masm_->pc_offset(); |
| 96 #endif | 96 #endif |
| 97 } | 97 } |
| 98 | 98 |
| 99 | 99 |
| 100 void DelayedMasm::Load(const CPURegister& rd, const MemOperand& operand) { | 100 void DelayedMasm::Load(const CPURegister& rd, const MemOperand& operand) { |
| 101 if ((pending_ == kLoad) && | 101 if ((pending_ == kLoad) && |
| 102 pending_register_.IsSameSizeAndType(rd)) { | 102 pending_register_.IsSameSizeAndType(rd)) { |
| 103 switch (MemOperand::AreConsistentForPair(pending_address_src_, operand)) { | 103 switch (MemOperand::AreConsistentForPair(pending_address_src_, operand)) { |
| 104 case MemOperand::kNotPair: | 104 case MemOperand::kNotPair: |
| 105 break; | 105 break; |
| 106 case MemOperand::kPairAB: | 106 case MemOperand::kPairAB: |
| 107 ASSERT(pending_pc_ == masm_->pc_offset()); | 107 DCHECK(pending_pc_ == masm_->pc_offset()); |
| 108 ASSERT(!IsScratchRegister(pending_register_) || | 108 DCHECK(!IsScratchRegister(pending_register_) || |
| 109 scratch_register_acquired_); | 109 scratch_register_acquired_); |
| 110 ASSERT(!IsScratchRegister(rd) || scratch_register_acquired_); | 110 DCHECK(!IsScratchRegister(rd) || scratch_register_acquired_); |
| 111 __ Ldp(pending_register_, rd, pending_address_src_); | 111 __ Ldp(pending_register_, rd, pending_address_src_); |
| 112 ResetPending(); | 112 ResetPending(); |
| 113 return; | 113 return; |
| 114 case MemOperand::kPairBA: | 114 case MemOperand::kPairBA: |
| 115 ASSERT(pending_pc_ == masm_->pc_offset()); | 115 DCHECK(pending_pc_ == masm_->pc_offset()); |
| 116 ASSERT(!IsScratchRegister(pending_register_) || | 116 DCHECK(!IsScratchRegister(pending_register_) || |
| 117 scratch_register_acquired_); | 117 scratch_register_acquired_); |
| 118 ASSERT(!IsScratchRegister(rd) || scratch_register_acquired_); | 118 DCHECK(!IsScratchRegister(rd) || scratch_register_acquired_); |
| 119 __ Ldp(rd, pending_register_, operand); | 119 __ Ldp(rd, pending_register_, operand); |
| 120 ResetPending(); | 120 ResetPending(); |
| 121 return; | 121 return; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 EmitPending(); | 125 EmitPending(); |
| 126 pending_ = kLoad; | 126 pending_ = kLoad; |
| 127 pending_register_ = rd; | 127 pending_register_ = rd; |
| 128 pending_address_src_ = operand; | 128 pending_address_src_ = operand; |
| 129 #ifdef DEBUG | 129 #ifdef DEBUG |
| 130 pending_pc_ = masm_->pc_offset(); | 130 pending_pc_ = masm_->pc_offset(); |
| 131 #endif | 131 #endif |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 void DelayedMasm::Store(const CPURegister& rd, const MemOperand& operand) { | 135 void DelayedMasm::Store(const CPURegister& rd, const MemOperand& operand) { |
| 136 if ((pending_ == kStore) && | 136 if ((pending_ == kStore) && |
| 137 pending_register_.IsSameSizeAndType(rd)) { | 137 pending_register_.IsSameSizeAndType(rd)) { |
| 138 switch (MemOperand::AreConsistentForPair(pending_address_dst_, operand)) { | 138 switch (MemOperand::AreConsistentForPair(pending_address_dst_, operand)) { |
| 139 case MemOperand::kNotPair: | 139 case MemOperand::kNotPair: |
| 140 break; | 140 break; |
| 141 case MemOperand::kPairAB: | 141 case MemOperand::kPairAB: |
| 142 ASSERT(pending_pc_ == masm_->pc_offset()); | 142 DCHECK(pending_pc_ == masm_->pc_offset()); |
| 143 __ Stp(pending_register_, rd, pending_address_dst_); | 143 __ Stp(pending_register_, rd, pending_address_dst_); |
| 144 ResetPending(); | 144 ResetPending(); |
| 145 return; | 145 return; |
| 146 case MemOperand::kPairBA: | 146 case MemOperand::kPairBA: |
| 147 ASSERT(pending_pc_ == masm_->pc_offset()); | 147 DCHECK(pending_pc_ == masm_->pc_offset()); |
| 148 __ Stp(rd, pending_register_, operand); | 148 __ Stp(rd, pending_register_, operand); |
| 149 ResetPending(); | 149 ResetPending(); |
| 150 return; | 150 return; |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 EmitPending(); | 154 EmitPending(); |
| 155 pending_ = kStore; | 155 pending_ = kStore; |
| 156 pending_register_ = rd; | 156 pending_register_ = rd; |
| 157 pending_address_dst_ = operand; | 157 pending_address_dst_ = operand; |
| 158 #ifdef DEBUG | 158 #ifdef DEBUG |
| 159 pending_pc_ = masm_->pc_offset(); | 159 pending_pc_ = masm_->pc_offset(); |
| 160 #endif | 160 #endif |
| 161 } | 161 } |
| 162 | 162 |
| 163 | 163 |
| 164 void DelayedMasm::EmitPending() { | 164 void DelayedMasm::EmitPending() { |
| 165 ASSERT((pending_ == kNone) || (pending_pc_ == masm_->pc_offset())); | 165 DCHECK((pending_ == kNone) || (pending_pc_ == masm_->pc_offset())); |
| 166 switch (pending_) { | 166 switch (pending_) { |
| 167 case kNone: | 167 case kNone: |
| 168 return; | 168 return; |
| 169 case kStoreConstant: | 169 case kStoreConstant: |
| 170 if (pending_value_ == 0) { | 170 if (pending_value_ == 0) { |
| 171 __ Str(xzr, pending_address_dst_); | 171 __ Str(xzr, pending_address_dst_); |
| 172 } else { | 172 } else { |
| 173 SetSavedValue(pending_value_); | 173 SetSavedValue(pending_value_); |
| 174 __ Str(ScratchRegister(), pending_address_dst_); | 174 __ Str(ScratchRegister(), pending_address_dst_); |
| 175 } | 175 } |
| 176 break; | 176 break; |
| 177 case kLoad: | 177 case kLoad: |
| 178 ASSERT(!IsScratchRegister(pending_register_) || | 178 DCHECK(!IsScratchRegister(pending_register_) || |
| 179 scratch_register_acquired_); | 179 scratch_register_acquired_); |
| 180 __ Ldr(pending_register_, pending_address_src_); | 180 __ Ldr(pending_register_, pending_address_src_); |
| 181 break; | 181 break; |
| 182 case kStore: | 182 case kStore: |
| 183 __ Str(pending_register_, pending_address_dst_); | 183 __ Str(pending_register_, pending_address_dst_); |
| 184 break; | 184 break; |
| 185 case kStackSlotMove: { | 185 case kStackSlotMove: { |
| 186 UseScratchRegisterScope scope(masm_); | 186 UseScratchRegisterScope scope(masm_); |
| 187 DoubleRegister temp = scope.AcquireD(); | 187 DoubleRegister temp = scope.AcquireD(); |
| 188 __ Ldr(temp, pending_address_src_); | 188 __ Ldr(temp, pending_address_src_); |
| 189 __ Str(temp, pending_address_dst_); | 189 __ Str(temp, pending_address_dst_); |
| 190 break; | 190 break; |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 ResetPending(); | 193 ResetPending(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 } } // namespace v8::internal | 196 } } // namespace v8::internal |
| 197 | 197 |
| 198 #endif // V8_TARGET_ARCH_ARM64 | 198 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |