Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 public: | 553 public: |
| 554 enum ConvertUndefined { | 554 enum ConvertUndefined { |
| 555 CONVERT_UNDEFINED_TO_ZERO, | 555 CONVERT_UNDEFINED_TO_ZERO, |
| 556 BAILOUT_ON_UNDEFINED | 556 BAILOUT_ON_UNDEFINED |
| 557 }; | 557 }; |
| 558 // Load the operands from rdx and rax into xmm0 and xmm1, as doubles. | 558 // Load the operands from rdx and rax into xmm0 and xmm1, as doubles. |
| 559 // If the operands are not both numbers, jump to not_numbers. | 559 // If the operands are not both numbers, jump to not_numbers. |
| 560 // Leaves rdx and rax unchanged. SmiOperands assumes both are smis. | 560 // Leaves rdx and rax unchanged. SmiOperands assumes both are smis. |
| 561 // NumberOperands assumes both are smis or heap numbers. | 561 // NumberOperands assumes both are smis or heap numbers. |
| 562 static void LoadSSE2SmiOperands(MacroAssembler* masm); | 562 static void LoadSSE2SmiOperands(MacroAssembler* masm); |
| 563 static void LoadSSE2NumberOperands(MacroAssembler* masm); | |
| 564 static void LoadSSE2UnknownOperands(MacroAssembler* masm, | 563 static void LoadSSE2UnknownOperands(MacroAssembler* masm, |
| 565 Label* not_numbers); | 564 Label* not_numbers); |
| 566 | 565 |
| 567 // Takes the operands in rdx and rax and loads them as integers in rax | 566 // Takes the operands in rdx and rax and loads them as integers in rax |
| 568 // and rcx. | 567 // and rcx. |
| 569 static void LoadAsIntegers(MacroAssembler* masm, | 568 static void LoadAsIntegers(MacroAssembler* masm, |
| 570 Label* operand_conversion_failure, | 569 Label* operand_conversion_failure, |
| 571 Register heap_number_map); | 570 Register heap_number_map); |
| 572 // As above, but we know the operands to be numbers. In that case, | |
| 573 // conversion can't fail. | |
| 574 static void LoadNumbersAsIntegers(MacroAssembler* masm); | |
| 575 | 571 |
| 576 // Tries to convert two values to smis losslessly. | 572 // Tries to convert two values to smis losslessly. |
| 577 // This fails if either argument is not a Smi nor a HeapNumber, | 573 // This fails if either argument is not a Smi nor a HeapNumber, |
| 578 // or if it's a HeapNumber with a value that can't be converted | 574 // or if it's a HeapNumber with a value that can't be converted |
| 579 // losslessly to a Smi. In that case, control transitions to the | 575 // losslessly to a Smi. In that case, control transitions to the |
| 580 // on_not_smis label. | 576 // on_not_smis label. |
| 581 // On success, either control goes to the on_success label (if one is | 577 // On success, either control goes to the on_success label (if one is |
| 582 // provided), or it falls through at the end of the code (if on_success | 578 // provided), or it falls through at the end of the code (if on_success |
| 583 // is NULL). | 579 // is NULL). |
| 584 // On success, both first and second holds Smi tagged values. | 580 // On success, both first and second holds Smi tagged values. |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1541 ASSERT(type == TranscendentalCache::LOG); | 1537 ASSERT(type == TranscendentalCache::LOG); |
| 1542 __ fldln2(); | 1538 __ fldln2(); |
| 1543 __ fxch(); | 1539 __ fxch(); |
| 1544 __ fyl2x(); | 1540 __ fyl2x(); |
| 1545 } | 1541 } |
| 1546 } | 1542 } |
| 1547 | 1543 |
| 1548 | 1544 |
| 1549 // Input: rdx, rax are the left and right objects of a bit op. | 1545 // Input: rdx, rax are the left and right objects of a bit op. |
| 1550 // Output: rax, rcx are left and right integers for a bit op. | 1546 // Output: rax, rcx are left and right integers for a bit op. |
| 1551 void FloatingPointHelper::LoadNumbersAsIntegers(MacroAssembler* masm) { | |
| 1552 // Check float operands. | |
| 1553 Label done; | |
| 1554 Label rax_is_smi; | |
| 1555 Label rax_is_object; | |
| 1556 Label rdx_is_object; | |
| 1557 | |
| 1558 __ JumpIfNotSmi(rdx, &rdx_is_object); | |
| 1559 __ SmiToInteger32(rdx, rdx); | |
| 1560 __ JumpIfSmi(rax, &rax_is_smi); | |
| 1561 | |
| 1562 __ bind(&rax_is_object); | |
| 1563 DoubleToIStub stub1(rax, rcx, HeapNumber::kValueOffset - kHeapObjectTag, | |
| 1564 true); | |
| 1565 __ call(stub1.GetCode(masm->isolate()), RelocInfo::CODE_TARGET); | |
| 1566 | |
| 1567 __ jmp(&done); | |
| 1568 | |
| 1569 __ bind(&rdx_is_object); | |
| 1570 DoubleToIStub stub2(rdx, rdx, HeapNumber::kValueOffset - kHeapObjectTag, | |
| 1571 true); | |
| 1572 __ call(stub1.GetCode(masm->isolate()), RelocInfo::CODE_TARGET); | |
|
Jakob Kummerow
2013/08/23 08:31:48
This was actually a bug: should have read "stub2".
| |
| 1573 __ JumpIfNotSmi(rax, &rax_is_object); | |
| 1574 | |
| 1575 __ bind(&rax_is_smi); | |
| 1576 __ SmiToInteger32(rcx, rax); | |
| 1577 | |
| 1578 __ bind(&done); | |
| 1579 __ movl(rax, rdx); | |
| 1580 } | |
| 1581 | |
| 1582 | |
| 1583 // Input: rdx, rax are the left and right objects of a bit op. | |
| 1584 // Output: rax, rcx are left and right integers for a bit op. | |
| 1585 // Jump to conversion_failure: rdx and rax are unchanged. | 1547 // Jump to conversion_failure: rdx and rax are unchanged. |
| 1586 void FloatingPointHelper::LoadAsIntegers(MacroAssembler* masm, | 1548 void FloatingPointHelper::LoadAsIntegers(MacroAssembler* masm, |
| 1587 Label* conversion_failure, | 1549 Label* conversion_failure, |
| 1588 Register heap_number_map) { | 1550 Register heap_number_map) { |
| 1589 // Check float operands. | 1551 // Check float operands. |
| 1590 Label arg1_is_object, check_undefined_arg1; | 1552 Label arg1_is_object, check_undefined_arg1; |
| 1591 Label arg2_is_object, check_undefined_arg2; | 1553 Label arg2_is_object, check_undefined_arg2; |
| 1592 Label load_arg2, done; | 1554 Label load_arg2, done; |
| 1593 | 1555 |
| 1594 __ JumpIfNotSmi(rdx, &arg1_is_object); | 1556 __ JumpIfNotSmi(rdx, &arg1_is_object); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1638 | 1600 |
| 1639 | 1601 |
| 1640 void FloatingPointHelper::LoadSSE2SmiOperands(MacroAssembler* masm) { | 1602 void FloatingPointHelper::LoadSSE2SmiOperands(MacroAssembler* masm) { |
| 1641 __ SmiToInteger32(kScratchRegister, rdx); | 1603 __ SmiToInteger32(kScratchRegister, rdx); |
| 1642 __ cvtlsi2sd(xmm0, kScratchRegister); | 1604 __ cvtlsi2sd(xmm0, kScratchRegister); |
| 1643 __ SmiToInteger32(kScratchRegister, rax); | 1605 __ SmiToInteger32(kScratchRegister, rax); |
| 1644 __ cvtlsi2sd(xmm1, kScratchRegister); | 1606 __ cvtlsi2sd(xmm1, kScratchRegister); |
| 1645 } | 1607 } |
| 1646 | 1608 |
| 1647 | 1609 |
| 1648 void FloatingPointHelper::LoadSSE2NumberOperands(MacroAssembler* masm) { | |
| 1649 Label load_smi_rdx, load_nonsmi_rax, load_smi_rax, done; | |
| 1650 // Load operand in rdx into xmm0. | |
| 1651 __ JumpIfSmi(rdx, &load_smi_rdx); | |
| 1652 __ movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset)); | |
| 1653 // Load operand in rax into xmm1. | |
| 1654 __ JumpIfSmi(rax, &load_smi_rax); | |
| 1655 __ bind(&load_nonsmi_rax); | |
| 1656 __ movsd(xmm1, FieldOperand(rax, HeapNumber::kValueOffset)); | |
| 1657 __ jmp(&done); | |
| 1658 | |
| 1659 __ bind(&load_smi_rdx); | |
| 1660 __ SmiToInteger32(kScratchRegister, rdx); | |
| 1661 __ cvtlsi2sd(xmm0, kScratchRegister); | |
| 1662 __ JumpIfNotSmi(rax, &load_nonsmi_rax); | |
| 1663 | |
| 1664 __ bind(&load_smi_rax); | |
| 1665 __ SmiToInteger32(kScratchRegister, rax); | |
| 1666 __ cvtlsi2sd(xmm1, kScratchRegister); | |
| 1667 | |
| 1668 __ bind(&done); | |
| 1669 } | |
| 1670 | |
| 1671 | |
| 1672 void FloatingPointHelper::LoadSSE2UnknownOperands(MacroAssembler* masm, | 1610 void FloatingPointHelper::LoadSSE2UnknownOperands(MacroAssembler* masm, |
| 1673 Label* not_numbers) { | 1611 Label* not_numbers) { |
| 1674 Label load_smi_rdx, load_nonsmi_rax, load_smi_rax, load_float_rax, done; | 1612 Label load_smi_rdx, load_nonsmi_rax, load_smi_rax, load_float_rax, done; |
| 1675 // Load operand in rdx into xmm0, or branch to not_numbers. | 1613 // Load operand in rdx into xmm0, or branch to not_numbers. |
| 1676 __ LoadRoot(rcx, Heap::kHeapNumberMapRootIndex); | 1614 __ LoadRoot(rcx, Heap::kHeapNumberMapRootIndex); |
| 1677 __ JumpIfSmi(rdx, &load_smi_rdx); | 1615 __ JumpIfSmi(rdx, &load_smi_rdx); |
| 1678 __ cmpq(FieldOperand(rdx, HeapObject::kMapOffset), rcx); | 1616 __ cmpq(FieldOperand(rdx, HeapObject::kMapOffset), rcx); |
| 1679 __ j(not_equal, not_numbers); // Argument in rdx is not a number. | 1617 __ j(not_equal, not_numbers); // Argument in rdx is not a number. |
| 1680 __ movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset)); | 1618 __ movsd(xmm0, FieldOperand(rdx, HeapNumber::kValueOffset)); |
| 1681 // Load operand in rax into xmm1, or branch to not_numbers. | 1619 // Load operand in rax into xmm1, or branch to not_numbers. |
| (...skipping 5118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6800 __ bind(&fast_elements_case); | 6738 __ bind(&fast_elements_case); |
| 6801 GenerateCase(masm, FAST_ELEMENTS); | 6739 GenerateCase(masm, FAST_ELEMENTS); |
| 6802 } | 6740 } |
| 6803 | 6741 |
| 6804 | 6742 |
| 6805 #undef __ | 6743 #undef __ |
| 6806 | 6744 |
| 6807 } } // namespace v8::internal | 6745 } } // namespace v8::internal |
| 6808 | 6746 |
| 6809 #endif // V8_TARGET_ARCH_X64 | 6747 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |