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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #if defined(V8_TARGET_ARCH_IA32) | 30 #if V8_TARGET_ARCH_IA32 |
31 | 31 |
32 #include "ia32/lithium-gap-resolver-ia32.h" | 32 #include "ia32/lithium-gap-resolver-ia32.h" |
33 #include "ia32/lithium-codegen-ia32.h" | 33 #include "ia32/lithium-codegen-ia32.h" |
34 | 34 |
35 namespace v8 { | 35 namespace v8 { |
36 namespace internal { | 36 namespace internal { |
37 | 37 |
38 LGapResolver::LGapResolver(LCodeGen* owner) | 38 LGapResolver::LGapResolver(LCodeGen* owner) |
39 : cgen_(owner), | 39 : cgen_(owner), |
40 moves_(32, owner->zone()), | 40 moves_(32, owner->zone()), |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 LConstantOperand* constant_source = LConstantOperand::cast(source); | 306 LConstantOperand* constant_source = LConstantOperand::cast(source); |
307 if (destination->IsRegister()) { | 307 if (destination->IsRegister()) { |
308 Register dst = cgen_->ToRegister(destination); | 308 Register dst = cgen_->ToRegister(destination); |
309 if (cgen_->IsSmi(constant_source)) { | 309 if (cgen_->IsSmi(constant_source)) { |
310 __ Set(dst, cgen_->ToSmiImmediate(constant_source)); | 310 __ Set(dst, cgen_->ToSmiImmediate(constant_source)); |
311 } else if (cgen_->IsInteger32(constant_source)) { | 311 } else if (cgen_->IsInteger32(constant_source)) { |
312 __ Set(dst, cgen_->ToInteger32Immediate(constant_source)); | 312 __ Set(dst, cgen_->ToInteger32Immediate(constant_source)); |
313 } else { | 313 } else { |
314 __ LoadObject(dst, cgen_->ToHandle(constant_source)); | 314 __ LoadObject(dst, cgen_->ToHandle(constant_source)); |
315 } | 315 } |
| 316 } else if (destination->IsDoubleRegister()) { |
| 317 double v = cgen_->ToDouble(constant_source); |
| 318 uint64_t int_val = BitCast<uint64_t, double>(v); |
| 319 int32_t lower = static_cast<int32_t>(int_val); |
| 320 int32_t upper = static_cast<int32_t>(int_val >> kBitsPerInt); |
| 321 if (CpuFeatures::IsSupported(SSE2)) { |
| 322 CpuFeatureScope scope(cgen_->masm(), SSE2); |
| 323 XMMRegister dst = cgen_->ToDoubleRegister(destination); |
| 324 if (int_val == 0) { |
| 325 __ xorps(dst, dst); |
| 326 } else { |
| 327 __ push(Immediate(upper)); |
| 328 __ push(Immediate(lower)); |
| 329 __ movdbl(dst, Operand(esp, 0)); |
| 330 __ add(esp, Immediate(kDoubleSize)); |
| 331 } |
| 332 } else { |
| 333 __ push(Immediate(upper)); |
| 334 __ push(Immediate(lower)); |
| 335 if (cgen_->X87StackNonEmpty()) { |
| 336 cgen_->PopX87(); |
| 337 } |
| 338 cgen_->PushX87DoubleOperand(MemOperand(esp, 0)); |
| 339 __ add(esp, Immediate(kDoubleSize)); |
| 340 } |
316 } else { | 341 } else { |
317 ASSERT(destination->IsStackSlot()); | 342 ASSERT(destination->IsStackSlot()); |
318 Operand dst = cgen_->ToOperand(destination); | 343 Operand dst = cgen_->ToOperand(destination); |
319 if (cgen_->IsSmi(constant_source)) { | 344 if (cgen_->IsSmi(constant_source)) { |
320 __ Set(dst, cgen_->ToSmiImmediate(constant_source)); | 345 __ Set(dst, cgen_->ToSmiImmediate(constant_source)); |
321 } else if (cgen_->IsInteger32(constant_source)) { | 346 } else if (cgen_->IsInteger32(constant_source)) { |
322 __ Set(dst, cgen_->ToInteger32Immediate(constant_source)); | 347 __ Set(dst, cgen_->ToInteger32Immediate(constant_source)); |
323 } else { | 348 } else { |
324 Register tmp = EnsureTempRegister(); | 349 Register tmp = EnsureTempRegister(); |
325 __ LoadObject(tmp, cgen_->ToHandle(constant_source)); | 350 __ LoadObject(tmp, cgen_->ToHandle(constant_source)); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 } else if (destination->IsRegister()) { | 544 } else if (destination->IsRegister()) { |
520 source_uses_[destination->index()] = CountSourceUses(destination); | 545 source_uses_[destination->index()] = CountSourceUses(destination); |
521 } | 546 } |
522 } | 547 } |
523 | 548 |
524 #undef __ | 549 #undef __ |
525 | 550 |
526 } } // namespace v8::internal | 551 } } // namespace v8::internal |
527 | 552 |
528 #endif // V8_TARGET_ARCH_IA32 | 553 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |