OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 <assert.h> // For assert | 5 #include <assert.h> // For assert |
6 #include <limits.h> // For LONG_MIN, LONG_MAX. | 6 #include <limits.h> // For LONG_MIN, LONG_MAX. |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #if V8_TARGET_ARCH_PPC | 10 #if V8_TARGET_ARCH_PPC |
(...skipping 3224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3235 | 3235 |
3236 dcbf(r0, scratch); | 3236 dcbf(r0, scratch); |
3237 sync(); | 3237 sync(); |
3238 icbi(r0, scratch); | 3238 icbi(r0, scratch); |
3239 isync(); | 3239 isync(); |
3240 | 3240 |
3241 bind(&done); | 3241 bind(&done); |
3242 } | 3242 } |
3243 | 3243 |
3244 | 3244 |
| 3245 void MacroAssembler::DecodeConstantPoolOffset(Register result, |
| 3246 Register location) { |
| 3247 Label overflow_access, done; |
| 3248 DCHECK(!AreAliased(result, location, r0)); |
| 3249 |
| 3250 // Determine constant pool access type |
| 3251 // Caller has already placed the instruction word at location in result. |
| 3252 ExtractBitRange(r0, result, 31, 26); |
| 3253 cmpi(r0, Operand(ADDIS >> 26)); |
| 3254 beq(&overflow_access); |
| 3255 |
| 3256 // Regular constant pool access |
| 3257 // extract the load offset |
| 3258 andi(result, result, Operand(kImm16Mask)); |
| 3259 b(&done); |
| 3260 |
| 3261 bind(&overflow_access); |
| 3262 // Overflow constant pool access |
| 3263 // shift addis immediate |
| 3264 slwi(r0, result, Operand(16)); |
| 3265 // sign-extend and add the load offset |
| 3266 lwz(result, MemOperand(location, kInstrSize)); |
| 3267 extsh(result, result); |
| 3268 add(result, r0, result); |
| 3269 |
| 3270 bind(&done); |
| 3271 } |
| 3272 |
| 3273 |
3245 void MacroAssembler::SetRelocatedValue(Register location, Register scratch, | 3274 void MacroAssembler::SetRelocatedValue(Register location, Register scratch, |
3246 Register new_value) { | 3275 Register new_value) { |
3247 lwz(scratch, MemOperand(location)); | 3276 lwz(scratch, MemOperand(location)); |
3248 | 3277 |
3249 if (FLAG_enable_embedded_constant_pool) { | 3278 if (FLAG_enable_embedded_constant_pool) { |
3250 if (emit_debug_code()) { | 3279 if (emit_debug_code()) { |
3251 // Check that the instruction sequence is a load from the constant pool | 3280 // Check that the instruction sequence is a load from the constant pool |
3252 ExtractBitMask(scratch, scratch, 0x1f * B16); | 3281 ExtractBitMask(scratch, scratch, 0x1f * B16); |
3253 cmpi(scratch, Operand(kConstantPoolRegister.code())); | 3282 cmpi(scratch, Operand(kConstantPoolRegister.code())); |
3254 Check(eq, kTheInstructionToPatchShouldBeALoadFromConstantPool); | 3283 Check(eq, kTheInstructionToPatchShouldBeALoadFromConstantPool); |
3255 // Scratch was clobbered. Restore it. | 3284 // Scratch was clobbered. Restore it. |
3256 lwz(scratch, MemOperand(location)); | 3285 lwz(scratch, MemOperand(location)); |
3257 } | 3286 } |
3258 // Get the address of the constant and patch it. | 3287 DecodeConstantPoolOffset(scratch, location); |
3259 andi(scratch, scratch, Operand(kImm16Mask)); | |
3260 StorePX(new_value, MemOperand(kConstantPoolRegister, scratch)); | 3288 StorePX(new_value, MemOperand(kConstantPoolRegister, scratch)); |
3261 return; | 3289 return; |
3262 } | 3290 } |
3263 | 3291 |
3264 // This code assumes a FIXED_SEQUENCE for lis/ori | 3292 // This code assumes a FIXED_SEQUENCE for lis/ori |
3265 | 3293 |
3266 // At this point scratch is a lis instruction. | 3294 // At this point scratch is a lis instruction. |
3267 if (emit_debug_code()) { | 3295 if (emit_debug_code()) { |
3268 And(scratch, scratch, Operand(kOpcodeMask | (0x1f * B16))); | 3296 And(scratch, scratch, Operand(kOpcodeMask | (0x1f * B16))); |
3269 Cmpi(scratch, Operand(ADDIS), r0); | 3297 Cmpi(scratch, Operand(ADDIS), r0); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3345 lwz(result, MemOperand(location)); | 3373 lwz(result, MemOperand(location)); |
3346 | 3374 |
3347 if (FLAG_enable_embedded_constant_pool) { | 3375 if (FLAG_enable_embedded_constant_pool) { |
3348 if (emit_debug_code()) { | 3376 if (emit_debug_code()) { |
3349 // Check that the instruction sequence is a load from the constant pool | 3377 // Check that the instruction sequence is a load from the constant pool |
3350 ExtractBitMask(result, result, 0x1f * B16); | 3378 ExtractBitMask(result, result, 0x1f * B16); |
3351 cmpi(result, Operand(kConstantPoolRegister.code())); | 3379 cmpi(result, Operand(kConstantPoolRegister.code())); |
3352 Check(eq, kTheInstructionToPatchShouldBeALoadFromConstantPool); | 3380 Check(eq, kTheInstructionToPatchShouldBeALoadFromConstantPool); |
3353 lwz(result, MemOperand(location)); | 3381 lwz(result, MemOperand(location)); |
3354 } | 3382 } |
3355 // Get the address of the constant and retrieve it. | 3383 DecodeConstantPoolOffset(result, location); |
3356 andi(result, result, Operand(kImm16Mask)); | |
3357 LoadPX(result, MemOperand(kConstantPoolRegister, result)); | 3384 LoadPX(result, MemOperand(kConstantPoolRegister, result)); |
3358 return; | 3385 return; |
3359 } | 3386 } |
3360 | 3387 |
3361 // This code assumes a FIXED_SEQUENCE for lis/ori | 3388 // This code assumes a FIXED_SEQUENCE for lis/ori |
3362 if (emit_debug_code()) { | 3389 if (emit_debug_code()) { |
3363 And(result, result, Operand(kOpcodeMask | (0x1f * B16))); | 3390 And(result, result, Operand(kOpcodeMask | (0x1f * B16))); |
3364 Cmpi(result, Operand(ADDIS), r0); | 3391 Cmpi(result, Operand(ADDIS), r0); |
3365 Check(eq, kTheInstructionShouldBeALis); | 3392 Check(eq, kTheInstructionShouldBeALis); |
3366 lwz(result, MemOperand(location)); | 3393 lwz(result, MemOperand(location)); |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4635 } | 4662 } |
4636 if (mag.shift > 0) srawi(result, result, mag.shift); | 4663 if (mag.shift > 0) srawi(result, result, mag.shift); |
4637 ExtractBit(r0, dividend, 31); | 4664 ExtractBit(r0, dividend, 31); |
4638 add(result, result, r0); | 4665 add(result, result, r0); |
4639 } | 4666 } |
4640 | 4667 |
4641 } // namespace internal | 4668 } // namespace internal |
4642 } // namespace v8 | 4669 } // namespace v8 |
4643 | 4670 |
4644 #endif // V8_TARGET_ARCH_PPC | 4671 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |