OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 void MacroAssembler::TruncateX87TOSToI(Register result_reg) { | 236 void MacroAssembler::TruncateX87TOSToI(Register result_reg) { |
237 sub(esp, Immediate(kDoubleSize)); | 237 sub(esp, Immediate(kDoubleSize)); |
238 fst_d(MemOperand(esp, 0)); | 238 fst_d(MemOperand(esp, 0)); |
239 SlowTruncateToI(result_reg, esp, 0); | 239 SlowTruncateToI(result_reg, esp, 0); |
240 add(esp, Immediate(kDoubleSize)); | 240 add(esp, Immediate(kDoubleSize)); |
241 } | 241 } |
242 | 242 |
243 | 243 |
244 void MacroAssembler::X87TOSToI(Register result_reg, | 244 void MacroAssembler::X87TOSToI(Register result_reg, |
245 MinusZeroMode minus_zero_mode, | 245 MinusZeroMode minus_zero_mode, |
246 Label* conversion_failed, | 246 Label* lost_precision, Label* is_nan, |
247 Label::Distance dst) { | 247 Label* minus_zero, Label::Distance dst) { |
248 Label done; | 248 Label done; |
249 sub(esp, Immediate(kPointerSize)); | 249 sub(esp, Immediate(kPointerSize)); |
250 fld(0); | 250 fld(0); |
251 fist_s(MemOperand(esp, 0)); | 251 fist_s(MemOperand(esp, 0)); |
252 fild_s(MemOperand(esp, 0)); | 252 fild_s(MemOperand(esp, 0)); |
253 pop(result_reg); | 253 pop(result_reg); |
254 FCmp(); | 254 FCmp(); |
255 j(not_equal, conversion_failed, dst); | 255 j(not_equal, lost_precision, dst); |
256 j(parity_even, conversion_failed, dst); | 256 j(parity_even, is_nan, dst); |
257 if (minus_zero_mode == FAIL_ON_MINUS_ZERO) { | 257 if (minus_zero_mode == FAIL_ON_MINUS_ZERO) { |
258 test(result_reg, Operand(result_reg)); | 258 test(result_reg, Operand(result_reg)); |
259 j(not_zero, &done, Label::kNear); | 259 j(not_zero, &done, Label::kNear); |
260 // To check for minus zero, we load the value again as float, and check | 260 // To check for minus zero, we load the value again as float, and check |
261 // if that is still 0. | 261 // if that is still 0. |
262 sub(esp, Immediate(kPointerSize)); | 262 sub(esp, Immediate(kPointerSize)); |
263 fst_s(MemOperand(esp, 0)); | 263 fst_s(MemOperand(esp, 0)); |
264 pop(result_reg); | 264 pop(result_reg); |
265 test(result_reg, Operand(result_reg)); | 265 test(result_reg, Operand(result_reg)); |
266 j(not_zero, conversion_failed, dst); | 266 j(not_zero, minus_zero, dst); |
267 } | 267 } |
268 bind(&done); | 268 bind(&done); |
269 } | 269 } |
270 | 270 |
271 | 271 |
272 void MacroAssembler::TruncateHeapNumberToI(Register result_reg, | 272 void MacroAssembler::TruncateHeapNumberToI(Register result_reg, |
273 Register input_reg) { | 273 Register input_reg) { |
274 Label done, slow_case; | 274 Label done, slow_case; |
275 | 275 |
276 SlowTruncateToI(result_reg, input_reg); | 276 SlowTruncateToI(result_reg, input_reg); |
(...skipping 3069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3346 if (mag.shift > 0) sar(edx, mag.shift); | 3346 if (mag.shift > 0) sar(edx, mag.shift); |
3347 mov(eax, dividend); | 3347 mov(eax, dividend); |
3348 shr(eax, 31); | 3348 shr(eax, 31); |
3349 add(edx, eax); | 3349 add(edx, eax); |
3350 } | 3350 } |
3351 | 3351 |
3352 | 3352 |
3353 } } // namespace v8::internal | 3353 } } // namespace v8::internal |
3354 | 3354 |
3355 #endif // V8_TARGET_ARCH_X87 | 3355 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |