| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2252 __ mov(tmp2, FieldOperand(input_reg, HeapNumber::kMantissaOffset)); | 2252 __ mov(tmp2, FieldOperand(input_reg, HeapNumber::kMantissaOffset)); |
| 2253 __ mov(FieldOperand(tmp, HeapNumber::kMantissaOffset), tmp2); | 2253 __ mov(FieldOperand(tmp, HeapNumber::kMantissaOffset), tmp2); |
| 2254 | 2254 |
| 2255 __ bind(&done); | 2255 __ bind(&done); |
| 2256 __ mov(Operand(esp, EspIndexForPushAll(input_reg) * kPointerSize), tmp); | 2256 __ mov(Operand(esp, EspIndexForPushAll(input_reg) * kPointerSize), tmp); |
| 2257 | 2257 |
| 2258 __ PopSafepointRegisters(); | 2258 __ PopSafepointRegisters(); |
| 2259 } | 2259 } |
| 2260 | 2260 |
| 2261 | 2261 |
| 2262 void LCodeGen::EmitIntegerMathAbs(LUnaryMathOperation* instr) { |
| 2263 Register input_reg = ToRegister(instr->InputAt(0)); |
| 2264 __ test(input_reg, Operand(input_reg)); |
| 2265 Label is_positive; |
| 2266 __ j(not_sign, &is_positive); |
| 2267 __ neg(input_reg); |
| 2268 __ test(input_reg, Operand(input_reg)); |
| 2269 DeoptimizeIf(negative, instr->environment()); |
| 2270 __ bind(&is_positive); |
| 2271 } |
| 2272 |
| 2273 |
| 2262 void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { | 2274 void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) { |
| 2263 // Class for deferred case. | 2275 // Class for deferred case. |
| 2264 class DeferredMathAbsTaggedHeapNumber: public LDeferredCode { | 2276 class DeferredMathAbsTaggedHeapNumber: public LDeferredCode { |
| 2265 public: | 2277 public: |
| 2266 DeferredMathAbsTaggedHeapNumber(LCodeGen* codegen, | 2278 DeferredMathAbsTaggedHeapNumber(LCodeGen* codegen, |
| 2267 LUnaryMathOperation* instr) | 2279 LUnaryMathOperation* instr) |
| 2268 : LDeferredCode(codegen), instr_(instr) { } | 2280 : LDeferredCode(codegen), instr_(instr) { } |
| 2269 virtual void Generate() { | 2281 virtual void Generate() { |
| 2270 codegen()->DoDeferredMathAbsTaggedHeapNumber(instr_); | 2282 codegen()->DoDeferredMathAbsTaggedHeapNumber(instr_); |
| 2271 } | 2283 } |
| 2272 private: | 2284 private: |
| 2273 LUnaryMathOperation* instr_; | 2285 LUnaryMathOperation* instr_; |
| 2274 }; | 2286 }; |
| 2275 | 2287 |
| 2276 ASSERT(instr->InputAt(0)->Equals(instr->result())); | 2288 ASSERT(instr->InputAt(0)->Equals(instr->result())); |
| 2277 Representation r = instr->hydrogen()->value()->representation(); | 2289 Representation r = instr->hydrogen()->value()->representation(); |
| 2278 | 2290 |
| 2279 if (r.IsDouble()) { | 2291 if (r.IsDouble()) { |
| 2280 XMMRegister scratch = xmm0; | 2292 XMMRegister scratch = xmm0; |
| 2281 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | 2293 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
| 2282 __ pxor(scratch, scratch); | 2294 __ pxor(scratch, scratch); |
| 2283 __ subsd(scratch, input_reg); | 2295 __ subsd(scratch, input_reg); |
| 2284 __ pand(input_reg, scratch); | 2296 __ pand(input_reg, scratch); |
| 2285 } else if (r.IsInteger32()) { | 2297 } else if (r.IsInteger32()) { |
| 2286 Register input_reg = ToRegister(instr->InputAt(0)); | 2298 EmitIntegerMathAbs(instr); |
| 2287 __ test(input_reg, Operand(input_reg)); | |
| 2288 Label is_positive; | |
| 2289 __ j(not_sign, &is_positive); | |
| 2290 __ neg(input_reg); | |
| 2291 __ test(input_reg, Operand(input_reg)); | |
| 2292 DeoptimizeIf(negative, instr->environment()); | |
| 2293 __ bind(&is_positive); | |
| 2294 } else { // Tagged case. | 2299 } else { // Tagged case. |
| 2295 DeferredMathAbsTaggedHeapNumber* deferred = | 2300 DeferredMathAbsTaggedHeapNumber* deferred = |
| 2296 new DeferredMathAbsTaggedHeapNumber(this, instr); | 2301 new DeferredMathAbsTaggedHeapNumber(this, instr); |
| 2297 Label not_smi; | |
| 2298 Register input_reg = ToRegister(instr->InputAt(0)); | 2302 Register input_reg = ToRegister(instr->InputAt(0)); |
| 2299 // Smi check. | 2303 // Smi check. |
| 2300 __ test(input_reg, Immediate(kSmiTagMask)); | 2304 __ test(input_reg, Immediate(kSmiTagMask)); |
| 2301 __ j(not_zero, deferred->entry()); | 2305 __ j(not_zero, deferred->entry()); |
| 2302 __ test(input_reg, Operand(input_reg)); | 2306 EmitIntegerMathAbs(instr); |
| 2303 Label is_positive; | |
| 2304 __ j(not_sign, &is_positive); | |
| 2305 __ neg(input_reg); | |
| 2306 | |
| 2307 __ test(input_reg, Operand(input_reg)); | |
| 2308 DeoptimizeIf(negative, instr->environment()); | |
| 2309 | |
| 2310 __ bind(&is_positive); | |
| 2311 __ bind(deferred->exit()); | 2307 __ bind(deferred->exit()); |
| 2312 } | 2308 } |
| 2313 } | 2309 } |
| 2314 | 2310 |
| 2315 | 2311 |
| 2316 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { | 2312 void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) { |
| 2317 XMMRegister xmm_scratch = xmm0; | 2313 XMMRegister xmm_scratch = xmm0; |
| 2318 Register output_reg = ToRegister(instr->result()); | 2314 Register output_reg = ToRegister(instr->result()); |
| 2319 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); | 2315 XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0)); |
| 2320 __ xorpd(xmm_scratch, xmm_scratch); // Zero the register. | 2316 __ xorpd(xmm_scratch, xmm_scratch); // Zero the register. |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3449 ASSERT(osr_pc_offset_ == -1); | 3445 ASSERT(osr_pc_offset_ == -1); |
| 3450 osr_pc_offset_ = masm()->pc_offset(); | 3446 osr_pc_offset_ = masm()->pc_offset(); |
| 3451 } | 3447 } |
| 3452 | 3448 |
| 3453 | 3449 |
| 3454 #undef __ | 3450 #undef __ |
| 3455 | 3451 |
| 3456 } } // namespace v8::internal | 3452 } } // namespace v8::internal |
| 3457 | 3453 |
| 3458 #endif // V8_TARGET_ARCH_IA32 | 3454 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |