Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 bind(&done); | 207 bind(&done); |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 void MacroAssembler::ClampDoubleToUint8(XMMRegister input_reg, | 212 void MacroAssembler::ClampDoubleToUint8(XMMRegister input_reg, |
| 213 XMMRegister scratch_reg, | 213 XMMRegister scratch_reg, |
| 214 Register result_reg) { | 214 Register result_reg) { |
| 215 Label done; | 215 Label done; |
| 216 Label conv_failure; | 216 Label conv_failure; |
| 217 pxor(scratch_reg, scratch_reg); | 217 xorps(scratch_reg, scratch_reg); |
| 218 cvtsd2si(result_reg, input_reg); | 218 cvtsd2si(result_reg, input_reg); |
| 219 test(result_reg, Immediate(0xFFFFFF00)); | 219 test(result_reg, Immediate(0xFFFFFF00)); |
| 220 j(zero, &done, Label::kNear); | 220 j(zero, &done, Label::kNear); |
| 221 cmp(result_reg, Immediate(0x80000000)); | 221 cmp(result_reg, Immediate(0x1)); |
| 222 j(equal, &conv_failure, Label::kNear); | 222 j(overflow, &conv_failure, Label::kNear); |
| 223 mov(result_reg, Immediate(0)); | 223 sar(result_reg, 31); |
| 224 setcc(above, result_reg); | 224 not_(result_reg); // safe not to zero extension |
|
Jakob Kummerow
2014/03/19 12:00:30
This comment doesn't make any sense, unless the re
| |
| 225 sub(result_reg, Immediate(1)); | |
| 226 and_(result_reg, Immediate(255)); | |
| 227 jmp(&done, Label::kNear); | 225 jmp(&done, Label::kNear); |
| 228 bind(&conv_failure); | 226 bind(&conv_failure); |
| 227 sar(result_reg, 31); | |
| 228 ucomisd(input_reg, scratch_reg); | |
| 229 j(above_equal, &done, Label::kNear); | |
| 229 Set(result_reg, Immediate(0)); | 230 Set(result_reg, Immediate(0)); |
| 230 ucomisd(input_reg, scratch_reg); | |
| 231 j(below, &done, Label::kNear); | |
| 232 Set(result_reg, Immediate(255)); | |
| 233 bind(&done); | 231 bind(&done); |
| 234 } | 232 } |
| 235 | 233 |
| 236 | 234 |
| 237 void MacroAssembler::ClampUint8(Register reg) { | 235 void MacroAssembler::ClampUint8(Register reg) { |
| 238 Label done; | 236 Label done; |
| 239 test(reg, Immediate(0xFFFFFF00)); | 237 test(reg, Immediate(0xFFFFFF00)); |
| 240 j(zero, &done, Label::kNear); | 238 j(zero, &done, Label::kNear); |
| 241 setcc(negative, reg); // 1 if negative, 0 if positive. | 239 sar(reg, 31); |
| 242 dec_b(reg); // 0 if negative, 255 if positive. | 240 not_(reg); // safe not to zero extension |
| 243 bind(&done); | 241 bind(&done); |
| 244 } | 242 } |
| 245 | 243 |
| 246 | 244 |
| 247 void MacroAssembler::SlowTruncateToI(Register result_reg, | 245 void MacroAssembler::SlowTruncateToI(Register result_reg, |
| 248 Register input_reg, | 246 Register input_reg, |
| 249 int offset) { | 247 int offset) { |
| 250 DoubleToIStub stub(input_reg, result_reg, offset, true); | 248 DoubleToIStub stub(input_reg, result_reg, offset, true); |
| 251 call(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); | 249 call(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); |
| 252 } | 250 } |
| 253 | 251 |
| 254 | 252 |
| 255 void MacroAssembler::TruncateDoubleToI(Register result_reg, | 253 void MacroAssembler::TruncateDoubleToI(Register result_reg, |
| 256 XMMRegister input_reg) { | 254 XMMRegister input_reg) { |
| 257 Label done; | 255 Label done; |
| 258 cvttsd2si(result_reg, Operand(input_reg)); | 256 cvttsd2si(result_reg, Operand(input_reg)); |
| 259 cmp(result_reg, 0x80000000u); | 257 cmp(result_reg, 0x1); |
| 260 j(not_equal, &done, Label::kNear); | 258 j(no_overflow, &done, Label::kNear); |
| 261 | 259 |
| 262 sub(esp, Immediate(kDoubleSize)); | 260 sub(esp, Immediate(kDoubleSize)); |
| 263 movsd(MemOperand(esp, 0), input_reg); | 261 movsd(MemOperand(esp, 0), input_reg); |
| 264 SlowTruncateToI(result_reg, esp, 0); | 262 SlowTruncateToI(result_reg, esp, 0); |
| 265 add(esp, Immediate(kDoubleSize)); | 263 add(esp, Immediate(kDoubleSize)); |
| 266 bind(&done); | 264 bind(&done); |
| 267 } | 265 } |
| 268 | 266 |
| 269 | 267 |
| 270 void MacroAssembler::TruncateX87TOSToI(Register result_reg) { | 268 void MacroAssembler::TruncateX87TOSToI(Register result_reg) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 SlowTruncateToI(result_reg, esp, 0); | 365 SlowTruncateToI(result_reg, esp, 0); |
| 368 add(esp, Immediate(kDoubleSize)); | 366 add(esp, Immediate(kDoubleSize)); |
| 369 } else { | 367 } else { |
| 370 fstp(0); | 368 fstp(0); |
| 371 SlowTruncateToI(result_reg, input_reg); | 369 SlowTruncateToI(result_reg, input_reg); |
| 372 } | 370 } |
| 373 } else if (CpuFeatures::IsSupported(SSE2)) { | 371 } else if (CpuFeatures::IsSupported(SSE2)) { |
| 374 CpuFeatureScope scope(this, SSE2); | 372 CpuFeatureScope scope(this, SSE2); |
| 375 movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); | 373 movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); |
| 376 cvttsd2si(result_reg, Operand(xmm0)); | 374 cvttsd2si(result_reg, Operand(xmm0)); |
| 377 cmp(result_reg, 0x80000000u); | 375 cmp(result_reg, 0x1); |
| 378 j(not_equal, &done, Label::kNear); | 376 j(no_overflow, &done, Label::kNear); |
| 379 // Check if the input was 0x8000000 (kMinInt). | 377 // Check if the input was 0x8000000 (kMinInt). |
| 380 // If no, then we got an overflow and we deoptimize. | 378 // If no, then we got an overflow and we deoptimize. |
| 381 ExternalReference min_int = ExternalReference::address_of_min_int(); | 379 ExternalReference min_int = ExternalReference::address_of_min_int(); |
| 382 ucomisd(xmm0, Operand::StaticVariable(min_int)); | 380 ucomisd(xmm0, Operand::StaticVariable(min_int)); |
| 383 j(not_equal, &slow_case, Label::kNear); | 381 j(not_equal, &slow_case, Label::kNear); |
| 384 j(parity_even, &slow_case, Label::kNear); // NaN. | 382 j(parity_even, &slow_case, Label::kNear); // NaN. |
| 385 jmp(&done, Label::kNear); | 383 jmp(&done, Label::kNear); |
| 386 | 384 |
| 387 // Slow case. | 385 // Slow case. |
| 388 bind(&slow_case); | 386 bind(&slow_case); |
| (...skipping 3232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3621 imul(dividend); | 3619 imul(dividend); |
| 3622 if (divisor > 0 && ms.multiplier() < 0) add(edx, dividend); | 3620 if (divisor > 0 && ms.multiplier() < 0) add(edx, dividend); |
| 3623 if (divisor < 0 && ms.multiplier() > 0) sub(edx, dividend); | 3621 if (divisor < 0 && ms.multiplier() > 0) sub(edx, dividend); |
| 3624 if (ms.shift() > 0) sar(edx, ms.shift()); | 3622 if (ms.shift() > 0) sar(edx, ms.shift()); |
| 3625 } | 3623 } |
| 3626 | 3624 |
| 3627 | 3625 |
| 3628 } } // namespace v8::internal | 3626 } } // namespace v8::internal |
| 3629 | 3627 |
| 3630 #endif // V8_TARGET_ARCH_IA32 | 3628 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |