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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 247 |
248 void MacroAssembler::TruncateHeapNumberToI(Register result_reg, | 248 void MacroAssembler::TruncateHeapNumberToI(Register result_reg, |
249 Register input_reg) { | 249 Register input_reg) { |
250 Label done, slow_case; | 250 Label done, slow_case; |
251 | 251 |
252 SlowTruncateToI(result_reg, input_reg); | 252 SlowTruncateToI(result_reg, input_reg); |
253 bind(&done); | 253 bind(&done); |
254 } | 254 } |
255 | 255 |
256 | 256 |
257 void MacroAssembler::TaggedToI(Register result_reg, | |
258 Register input_reg, | |
259 MinusZeroMode minus_zero_mode, | |
260 Label* lost_precision) { | |
261 Label done; | |
262 | |
263 cmp(FieldOperand(input_reg, HeapObject::kMapOffset), | |
264 isolate()->factory()->heap_number_map()); | |
265 j(not_equal, lost_precision, Label::kNear); | |
266 | |
267 // TODO(olivf) Converting a number on the fpu is actually quite slow. We | |
268 // should first try a fast conversion and then bailout to this slow case. | |
269 Label lost_precision_pop, zero_check; | |
270 Label* lost_precision_int = (minus_zero_mode == FAIL_ON_MINUS_ZERO) | |
271 ? &lost_precision_pop : lost_precision; | |
272 sub(esp, Immediate(kPointerSize)); | |
273 fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset)); | |
274 if (minus_zero_mode == FAIL_ON_MINUS_ZERO) fld(0); | |
275 fist_s(MemOperand(esp, 0)); | |
276 fild_s(MemOperand(esp, 0)); | |
277 FCmp(); | |
278 pop(result_reg); | |
279 j(not_equal, lost_precision_int, Label::kNear); | |
280 j(parity_even, lost_precision_int, Label::kNear); // NaN. | |
281 if (minus_zero_mode == FAIL_ON_MINUS_ZERO) { | |
282 test(result_reg, Operand(result_reg)); | |
283 j(zero, &zero_check, Label::kNear); | |
284 fstp(0); | |
285 jmp(&done, Label::kNear); | |
286 bind(&zero_check); | |
287 // To check for minus zero, we load the value again as float, and check | |
288 // if that is still 0. | |
289 sub(esp, Immediate(kPointerSize)); | |
290 fstp_s(Operand(esp, 0)); | |
291 pop(result_reg); | |
292 test(result_reg, Operand(result_reg)); | |
293 j(zero, &done, Label::kNear); | |
294 jmp(lost_precision, Label::kNear); | |
295 | |
296 bind(&lost_precision_pop); | |
297 fstp(0); | |
298 jmp(lost_precision, Label::kNear); | |
299 } | |
300 bind(&done); | |
301 } | |
302 | |
303 | |
304 void MacroAssembler::LoadUint32NoSSE2(Register src) { | 257 void MacroAssembler::LoadUint32NoSSE2(Register src) { |
305 Label done; | 258 Label done; |
306 push(src); | 259 push(src); |
307 fild_s(Operand(esp, 0)); | 260 fild_s(Operand(esp, 0)); |
308 cmp(src, Immediate(0)); | 261 cmp(src, Immediate(0)); |
309 j(not_sign, &done, Label::kNear); | 262 j(not_sign, &done, Label::kNear); |
310 ExternalReference uint32_bias = | 263 ExternalReference uint32_bias = |
311 ExternalReference::address_of_uint32_bias(); | 264 ExternalReference::address_of_uint32_bias(); |
312 fld_d(Operand::StaticVariable(uint32_bias)); | 265 fld_d(Operand::StaticVariable(uint32_bias)); |
313 faddp(1); | 266 faddp(1); |
(...skipping 3001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3315 if (mag.shift > 0) sar(edx, mag.shift); | 3268 if (mag.shift > 0) sar(edx, mag.shift); |
3316 mov(eax, dividend); | 3269 mov(eax, dividend); |
3317 shr(eax, 31); | 3270 shr(eax, 31); |
3318 add(edx, eax); | 3271 add(edx, eax); |
3319 } | 3272 } |
3320 | 3273 |
3321 | 3274 |
3322 } } // namespace v8::internal | 3275 } } // namespace v8::internal |
3323 | 3276 |
3324 #endif // V8_TARGET_ARCH_X87 | 3277 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |