| OLD | NEW |
| 1 | 1 |
| 2 // Copyright 2012 the V8 project authors. All rights reserved. | 2 // Copyright 2012 the V8 project authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 #include <limits.h> // For LONG_MIN, LONG_MAX. | 6 #include <limits.h> // For LONG_MIN, LONG_MAX. |
| 7 | 7 |
| 8 #if V8_TARGET_ARCH_MIPS | 8 #if V8_TARGET_ARCH_MIPS |
| 9 | 9 |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3004 return false; | 3004 return false; |
| 3005 } | 3005 } |
| 3006 | 3006 |
| 3007 | 3007 |
| 3008 void MacroAssembler::Jump(Register target, | 3008 void MacroAssembler::Jump(Register target, |
| 3009 Condition cond, | 3009 Condition cond, |
| 3010 Register rs, | 3010 Register rs, |
| 3011 const Operand& rt, | 3011 const Operand& rt, |
| 3012 BranchDelaySlot bd) { | 3012 BranchDelaySlot bd) { |
| 3013 BlockTrampolinePoolScope block_trampoline_pool(this); | 3013 BlockTrampolinePoolScope block_trampoline_pool(this); |
| 3014 if (cond == cc_always) { | 3014 if (IsMipsArchVariant(kMips32r6) && bd == PROTECT) { |
| 3015 jr(target); | 3015 if (cond == cc_always) { |
| 3016 jic(target, 0); |
| 3017 } else { |
| 3018 BRANCH_ARGS_CHECK(cond, rs, rt); |
| 3019 Branch(2, NegateCondition(cond), rs, rt); |
| 3020 jic(target, 0); |
| 3021 } |
| 3016 } else { | 3022 } else { |
| 3017 BRANCH_ARGS_CHECK(cond, rs, rt); | 3023 if (cond == cc_always) { |
| 3018 Branch(2, NegateCondition(cond), rs, rt); | 3024 jr(target); |
| 3019 jr(target); | 3025 } else { |
| 3026 BRANCH_ARGS_CHECK(cond, rs, rt); |
| 3027 Branch(2, NegateCondition(cond), rs, rt); |
| 3028 jr(target); |
| 3029 } |
| 3030 // Emit a nop in the branch delay slot if required. |
| 3031 if (bd == PROTECT) nop(); |
| 3020 } | 3032 } |
| 3021 // Emit a nop in the branch delay slot if required. | |
| 3022 if (bd == PROTECT) | |
| 3023 nop(); | |
| 3024 } | 3033 } |
| 3025 | 3034 |
| 3026 | 3035 |
| 3027 void MacroAssembler::Jump(intptr_t target, | 3036 void MacroAssembler::Jump(intptr_t target, |
| 3028 RelocInfo::Mode rmode, | 3037 RelocInfo::Mode rmode, |
| 3029 Condition cond, | 3038 Condition cond, |
| 3030 Register rs, | 3039 Register rs, |
| 3031 const Operand& rt, | 3040 const Operand& rt, |
| 3032 BranchDelaySlot bd) { | 3041 BranchDelaySlot bd) { |
| 3033 Label skip; | 3042 Label skip; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3071 const Operand& rt, | 3080 const Operand& rt, |
| 3072 BranchDelaySlot bd) { | 3081 BranchDelaySlot bd) { |
| 3073 int size = 0; | 3082 int size = 0; |
| 3074 | 3083 |
| 3075 if (cond == cc_always) { | 3084 if (cond == cc_always) { |
| 3076 size += 1; | 3085 size += 1; |
| 3077 } else { | 3086 } else { |
| 3078 size += 3; | 3087 size += 3; |
| 3079 } | 3088 } |
| 3080 | 3089 |
| 3081 if (bd == PROTECT) | 3090 if (bd == PROTECT && !IsMipsArchVariant(kMips32r6)) size += 1; |
| 3082 size += 1; | |
| 3083 | 3091 |
| 3084 return size * kInstrSize; | 3092 return size * kInstrSize; |
| 3085 } | 3093 } |
| 3086 | 3094 |
| 3087 | 3095 |
| 3088 // Note: To call gcc-compiled C code on mips, you must call thru t9. | 3096 // Note: To call gcc-compiled C code on mips, you must call thru t9. |
| 3089 void MacroAssembler::Call(Register target, | 3097 void MacroAssembler::Call(Register target, |
| 3090 Condition cond, | 3098 Condition cond, |
| 3091 Register rs, | 3099 Register rs, |
| 3092 const Operand& rt, | 3100 const Operand& rt, |
| 3093 BranchDelaySlot bd) { | 3101 BranchDelaySlot bd) { |
| 3094 #ifdef DEBUG | 3102 #ifdef DEBUG |
| 3095 int size = IsPrevInstrCompactBranch() ? kInstrSize : 0; | 3103 int size = IsPrevInstrCompactBranch() ? kInstrSize : 0; |
| 3096 #endif | 3104 #endif |
| 3097 | 3105 |
| 3098 BlockTrampolinePoolScope block_trampoline_pool(this); | 3106 BlockTrampolinePoolScope block_trampoline_pool(this); |
| 3099 Label start; | 3107 Label start; |
| 3100 bind(&start); | 3108 bind(&start); |
| 3101 if (cond == cc_always) { | 3109 if (IsMipsArchVariant(kMips32r6) && bd == PROTECT) { |
| 3102 jalr(target); | 3110 if (cond == cc_always) { |
| 3111 jialc(target, 0); |
| 3112 } else { |
| 3113 BRANCH_ARGS_CHECK(cond, rs, rt); |
| 3114 Branch(1, NegateCondition(cond), rs, rt); |
| 3115 jialc(target, 0); |
| 3116 } |
| 3103 } else { | 3117 } else { |
| 3104 BRANCH_ARGS_CHECK(cond, rs, rt); | 3118 if (cond == cc_always) { |
| 3105 Branch(2, NegateCondition(cond), rs, rt); | 3119 jalr(target); |
| 3106 jalr(target); | 3120 } else { |
| 3121 BRANCH_ARGS_CHECK(cond, rs, rt); |
| 3122 Branch(2, NegateCondition(cond), rs, rt); |
| 3123 jalr(target); |
| 3124 } |
| 3125 // Emit a nop in the branch delay slot if required. |
| 3126 if (bd == PROTECT) nop(); |
| 3107 } | 3127 } |
| 3108 // Emit a nop in the branch delay slot if required. | |
| 3109 if (bd == PROTECT) | |
| 3110 nop(); | |
| 3111 | 3128 |
| 3112 #ifdef DEBUG | 3129 #ifdef DEBUG |
| 3113 CHECK_EQ(size + CallSize(target, cond, rs, rt, bd), | 3130 CHECK_EQ(size + CallSize(target, cond, rs, rt, bd), |
| 3114 SizeOfCodeGeneratedSince(&start)); | 3131 SizeOfCodeGeneratedSince(&start)); |
| 3115 #endif | 3132 #endif |
| 3116 } | 3133 } |
| 3117 | 3134 |
| 3118 | 3135 |
| 3119 int MacroAssembler::CallSize(Address target, | 3136 int MacroAssembler::CallSize(Address target, |
| 3120 RelocInfo::Mode rmode, | 3137 RelocInfo::Mode rmode, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3191 | 3208 |
| 3192 | 3209 |
| 3193 void MacroAssembler::BranchLong(Label* L, BranchDelaySlot bdslot) { | 3210 void MacroAssembler::BranchLong(Label* L, BranchDelaySlot bdslot) { |
| 3194 if (IsMipsArchVariant(kMips32r6) && bdslot == PROTECT && | 3211 if (IsMipsArchVariant(kMips32r6) && bdslot == PROTECT && |
| 3195 (!L->is_bound() || is_near_r6(L))) { | 3212 (!L->is_bound() || is_near_r6(L))) { |
| 3196 BranchShortHelperR6(0, L); | 3213 BranchShortHelperR6(0, L); |
| 3197 } else { | 3214 } else { |
| 3198 BlockTrampolinePoolScope block_trampoline_pool(this); | 3215 BlockTrampolinePoolScope block_trampoline_pool(this); |
| 3199 uint32_t imm32; | 3216 uint32_t imm32; |
| 3200 imm32 = jump_address(L); | 3217 imm32 = jump_address(L); |
| 3201 if (IsMipsArchVariant(kMips32r6) && bdslot != USE_DELAY_SLOT) { | 3218 if (IsMipsArchVariant(kMips32r6) && bdslot == PROTECT) { |
| 3202 uint32_t lui_offset, jic_offset; | 3219 uint32_t lui_offset, jic_offset; |
| 3203 UnpackTargetAddressUnsigned(imm32, lui_offset, jic_offset); | 3220 UnpackTargetAddressUnsigned(imm32, lui_offset, jic_offset); |
| 3204 { | 3221 { |
| 3205 BlockGrowBufferScope block_buf_growth(this); | 3222 BlockGrowBufferScope block_buf_growth(this); |
| 3206 // Buffer growth (and relocation) must be blocked for internal | 3223 // Buffer growth (and relocation) must be blocked for internal |
| 3207 // references until associated instructions are emitted and | 3224 // references until associated instructions are emitted and |
| 3208 // available to be patched. | 3225 // available to be patched. |
| 3209 RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); | 3226 RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); |
| 3210 lui(at, lui_offset); | 3227 lui(at, lui_offset); |
| 3211 jic(at, jic_offset); | 3228 jic(at, jic_offset); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3232 | 3249 |
| 3233 | 3250 |
| 3234 void MacroAssembler::BranchAndLinkLong(Label* L, BranchDelaySlot bdslot) { | 3251 void MacroAssembler::BranchAndLinkLong(Label* L, BranchDelaySlot bdslot) { |
| 3235 if (IsMipsArchVariant(kMips32r6) && bdslot == PROTECT && | 3252 if (IsMipsArchVariant(kMips32r6) && bdslot == PROTECT && |
| 3236 (!L->is_bound() || is_near_r6(L))) { | 3253 (!L->is_bound() || is_near_r6(L))) { |
| 3237 BranchAndLinkShortHelperR6(0, L); | 3254 BranchAndLinkShortHelperR6(0, L); |
| 3238 } else { | 3255 } else { |
| 3239 BlockTrampolinePoolScope block_trampoline_pool(this); | 3256 BlockTrampolinePoolScope block_trampoline_pool(this); |
| 3240 uint32_t imm32; | 3257 uint32_t imm32; |
| 3241 imm32 = jump_address(L); | 3258 imm32 = jump_address(L); |
| 3242 if (IsMipsArchVariant(kMips32r6) && bdslot != USE_DELAY_SLOT) { | 3259 if (IsMipsArchVariant(kMips32r6) && bdslot == PROTECT) { |
| 3243 uint32_t lui_offset, jic_offset; | 3260 uint32_t lui_offset, jic_offset; |
| 3244 UnpackTargetAddressUnsigned(imm32, lui_offset, jic_offset); | 3261 UnpackTargetAddressUnsigned(imm32, lui_offset, jic_offset); |
| 3245 { | 3262 { |
| 3246 BlockGrowBufferScope block_buf_growth(this); | 3263 BlockGrowBufferScope block_buf_growth(this); |
| 3247 // Buffer growth (and relocation) must be blocked for internal | 3264 // Buffer growth (and relocation) must be blocked for internal |
| 3248 // references until associated instructions are emitted and | 3265 // references until associated instructions are emitted and |
| 3249 // available to be patched. | 3266 // available to be patched. |
| 3250 RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); | 3267 RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); |
| 3251 lui(at, lui_offset); | 3268 lui(at, lui_offset); |
| 3252 jialc(at, jic_offset); | 3269 jialc(at, jic_offset); |
| 3253 } | 3270 } |
| 3254 CheckBuffer(); | 3271 CheckBuffer(); |
| 3255 } else { | 3272 } else { |
| 3256 { | 3273 { |
| 3257 BlockGrowBufferScope block_buf_growth(this); | 3274 BlockGrowBufferScope block_buf_growth(this); |
| 3258 // Buffer growth (and relocation) must be blocked for internal | 3275 // Buffer growth (and relocation) must be blocked for internal |
| 3259 // references | 3276 // references |
| 3260 // until associated instructions are emitted and available to be | 3277 // until associated instructions are emitted and available to be |
| 3261 // patched. | 3278 // patched. |
| 3262 RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); | 3279 RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); |
| 3263 lui(at, (imm32 & kHiMask) >> kLuiShift); | 3280 lui(at, (imm32 & kHiMask) >> kLuiShift); |
| 3264 ori(at, at, (imm32 & kImm16Mask)); | 3281 ori(at, at, (imm32 & kImm16Mask)); |
| 3265 } | 3282 } |
| 3283 CheckBuffer(); |
| 3266 jalr(at); | 3284 jalr(at); |
| 3267 // Emit a nop in the branch delay slot if required. | 3285 // Emit a nop in the branch delay slot if required. |
| 3268 if (bdslot == PROTECT) nop(); | 3286 if (bdslot == PROTECT) nop(); |
| 3269 } | 3287 } |
| 3270 } | 3288 } |
| 3271 } | 3289 } |
| 3272 | 3290 |
| 3273 | 3291 |
| 3274 void MacroAssembler::DropAndRet(int drop) { | 3292 void MacroAssembler::DropAndRet(int drop) { |
| 3275 DCHECK(is_int16(drop * kPointerSize)); | 3293 DCHECK(is_int16(drop * kPointerSize)); |
| (...skipping 2637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5913 if (mag.shift > 0) sra(result, result, mag.shift); | 5931 if (mag.shift > 0) sra(result, result, mag.shift); |
| 5914 srl(at, dividend, 31); | 5932 srl(at, dividend, 31); |
| 5915 Addu(result, result, Operand(at)); | 5933 Addu(result, result, Operand(at)); |
| 5916 } | 5934 } |
| 5917 | 5935 |
| 5918 | 5936 |
| 5919 } // namespace internal | 5937 } // namespace internal |
| 5920 } // namespace v8 | 5938 } // namespace v8 |
| 5921 | 5939 |
| 5922 #endif // V8_TARGET_ARCH_MIPS | 5940 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |