| 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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 NO_ALLOCATION_FLAGS); | 1586 NO_ALLOCATION_FLAGS); |
| 1587 | 1587 |
| 1588 Handle<Map> map = mode == MUTABLE | 1588 Handle<Map> map = mode == MUTABLE |
| 1589 ? isolate()->factory()->mutable_heap_number_map() | 1589 ? isolate()->factory()->mutable_heap_number_map() |
| 1590 : isolate()->factory()->heap_number_map(); | 1590 : isolate()->factory()->heap_number_map(); |
| 1591 | 1591 |
| 1592 // Set the map. | 1592 // Set the map. |
| 1593 mov(FieldOperand(result, HeapObject::kMapOffset), Immediate(map)); | 1593 mov(FieldOperand(result, HeapObject::kMapOffset), Immediate(map)); |
| 1594 } | 1594 } |
| 1595 | 1595 |
| 1596 | |
| 1597 void MacroAssembler::AllocateTwoByteString(Register result, | |
| 1598 Register length, | |
| 1599 Register scratch1, | |
| 1600 Register scratch2, | |
| 1601 Register scratch3, | |
| 1602 Label* gc_required) { | |
| 1603 // Calculate the number of bytes needed for the characters in the string while | |
| 1604 // observing object alignment. | |
| 1605 DCHECK((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); | |
| 1606 DCHECK(kShortSize == 2); | |
| 1607 // scratch1 = length * 2 + kObjectAlignmentMask. | |
| 1608 lea(scratch1, Operand(length, length, times_1, kObjectAlignmentMask)); | |
| 1609 and_(scratch1, Immediate(~kObjectAlignmentMask)); | |
| 1610 | |
| 1611 // Allocate two byte string in new space. | |
| 1612 Allocate(SeqTwoByteString::kHeaderSize, times_1, scratch1, | |
| 1613 REGISTER_VALUE_IS_INT32, result, scratch2, scratch3, gc_required, | |
| 1614 NO_ALLOCATION_FLAGS); | |
| 1615 | |
| 1616 // Set the map, length and hash field. | |
| 1617 mov(FieldOperand(result, HeapObject::kMapOffset), | |
| 1618 Immediate(isolate()->factory()->string_map())); | |
| 1619 mov(scratch1, length); | |
| 1620 SmiTag(scratch1); | |
| 1621 mov(FieldOperand(result, String::kLengthOffset), scratch1); | |
| 1622 mov(FieldOperand(result, String::kHashFieldOffset), | |
| 1623 Immediate(String::kEmptyHashField)); | |
| 1624 } | |
| 1625 | |
| 1626 | |
| 1627 void MacroAssembler::AllocateOneByteString(Register result, Register length, | |
| 1628 Register scratch1, Register scratch2, | |
| 1629 Register scratch3, | |
| 1630 Label* gc_required) { | |
| 1631 // Calculate the number of bytes needed for the characters in the string while | |
| 1632 // observing object alignment. | |
| 1633 DCHECK((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); | |
| 1634 mov(scratch1, length); | |
| 1635 DCHECK(kCharSize == 1); | |
| 1636 add(scratch1, Immediate(kObjectAlignmentMask)); | |
| 1637 and_(scratch1, Immediate(~kObjectAlignmentMask)); | |
| 1638 | |
| 1639 // Allocate one-byte string in new space. | |
| 1640 Allocate(SeqOneByteString::kHeaderSize, times_1, scratch1, | |
| 1641 REGISTER_VALUE_IS_INT32, result, scratch2, scratch3, gc_required, | |
| 1642 NO_ALLOCATION_FLAGS); | |
| 1643 | |
| 1644 // Set the map, length and hash field. | |
| 1645 mov(FieldOperand(result, HeapObject::kMapOffset), | |
| 1646 Immediate(isolate()->factory()->one_byte_string_map())); | |
| 1647 mov(scratch1, length); | |
| 1648 SmiTag(scratch1); | |
| 1649 mov(FieldOperand(result, String::kLengthOffset), scratch1); | |
| 1650 mov(FieldOperand(result, String::kHashFieldOffset), | |
| 1651 Immediate(String::kEmptyHashField)); | |
| 1652 } | |
| 1653 | |
| 1654 | |
| 1655 void MacroAssembler::AllocateOneByteString(Register result, int length, | |
| 1656 Register scratch1, Register scratch2, | |
| 1657 Label* gc_required) { | |
| 1658 DCHECK(length > 0); | |
| 1659 | |
| 1660 // Allocate one-byte string in new space. | |
| 1661 Allocate(SeqOneByteString::SizeFor(length), result, scratch1, scratch2, | |
| 1662 gc_required, NO_ALLOCATION_FLAGS); | |
| 1663 | |
| 1664 // Set the map, length and hash field. | |
| 1665 mov(FieldOperand(result, HeapObject::kMapOffset), | |
| 1666 Immediate(isolate()->factory()->one_byte_string_map())); | |
| 1667 mov(FieldOperand(result, String::kLengthOffset), | |
| 1668 Immediate(Smi::FromInt(length))); | |
| 1669 mov(FieldOperand(result, String::kHashFieldOffset), | |
| 1670 Immediate(String::kEmptyHashField)); | |
| 1671 } | |
| 1672 | |
| 1673 | |
| 1674 void MacroAssembler::AllocateTwoByteConsString(Register result, | |
| 1675 Register scratch1, | |
| 1676 Register scratch2, | |
| 1677 Label* gc_required) { | |
| 1678 // Allocate heap number in new space. | |
| 1679 Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required, | |
| 1680 NO_ALLOCATION_FLAGS); | |
| 1681 | |
| 1682 // Set the map. The other fields are left uninitialized. | |
| 1683 mov(FieldOperand(result, HeapObject::kMapOffset), | |
| 1684 Immediate(isolate()->factory()->cons_string_map())); | |
| 1685 } | |
| 1686 | |
| 1687 | |
| 1688 void MacroAssembler::AllocateOneByteConsString(Register result, | |
| 1689 Register scratch1, | |
| 1690 Register scratch2, | |
| 1691 Label* gc_required) { | |
| 1692 Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required, | |
| 1693 NO_ALLOCATION_FLAGS); | |
| 1694 | |
| 1695 // Set the map. The other fields are left uninitialized. | |
| 1696 mov(FieldOperand(result, HeapObject::kMapOffset), | |
| 1697 Immediate(isolate()->factory()->cons_one_byte_string_map())); | |
| 1698 } | |
| 1699 | |
| 1700 | |
| 1701 void MacroAssembler::AllocateTwoByteSlicedString(Register result, | |
| 1702 Register scratch1, | |
| 1703 Register scratch2, | |
| 1704 Label* gc_required) { | |
| 1705 // Allocate heap number in new space. | |
| 1706 Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, | |
| 1707 NO_ALLOCATION_FLAGS); | |
| 1708 | |
| 1709 // Set the map. The other fields are left uninitialized. | |
| 1710 mov(FieldOperand(result, HeapObject::kMapOffset), | |
| 1711 Immediate(isolate()->factory()->sliced_string_map())); | |
| 1712 } | |
| 1713 | |
| 1714 | |
| 1715 void MacroAssembler::AllocateOneByteSlicedString(Register result, | |
| 1716 Register scratch1, | |
| 1717 Register scratch2, | |
| 1718 Label* gc_required) { | |
| 1719 // Allocate heap number in new space. | |
| 1720 Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, | |
| 1721 NO_ALLOCATION_FLAGS); | |
| 1722 | |
| 1723 // Set the map. The other fields are left uninitialized. | |
| 1724 mov(FieldOperand(result, HeapObject::kMapOffset), | |
| 1725 Immediate(isolate()->factory()->sliced_one_byte_string_map())); | |
| 1726 } | |
| 1727 | |
| 1728 | |
| 1729 void MacroAssembler::AllocateJSValue(Register result, Register constructor, | 1596 void MacroAssembler::AllocateJSValue(Register result, Register constructor, |
| 1730 Register value, Register scratch, | 1597 Register value, Register scratch, |
| 1731 Label* gc_required) { | 1598 Label* gc_required) { |
| 1732 DCHECK(!result.is(constructor)); | 1599 DCHECK(!result.is(constructor)); |
| 1733 DCHECK(!result.is(scratch)); | 1600 DCHECK(!result.is(scratch)); |
| 1734 DCHECK(!result.is(value)); | 1601 DCHECK(!result.is(value)); |
| 1735 | 1602 |
| 1736 // Allocate JSValue in new space. | 1603 // Allocate JSValue in new space. |
| 1737 Allocate(JSValue::kSize, result, scratch, no_reg, gc_required, | 1604 Allocate(JSValue::kSize, result, scratch, no_reg, gc_required, |
| 1738 NO_ALLOCATION_FLAGS); | 1605 NO_ALLOCATION_FLAGS); |
| (...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2669 void MacroAssembler::LoadPowerOf2(XMMRegister dst, | 2536 void MacroAssembler::LoadPowerOf2(XMMRegister dst, |
| 2670 Register scratch, | 2537 Register scratch, |
| 2671 int power) { | 2538 int power) { |
| 2672 DCHECK(is_uintn(power + HeapNumber::kExponentBias, | 2539 DCHECK(is_uintn(power + HeapNumber::kExponentBias, |
| 2673 HeapNumber::kExponentBits)); | 2540 HeapNumber::kExponentBits)); |
| 2674 mov(scratch, Immediate(power + HeapNumber::kExponentBias)); | 2541 mov(scratch, Immediate(power + HeapNumber::kExponentBias)); |
| 2675 movd(dst, scratch); | 2542 movd(dst, scratch); |
| 2676 psllq(dst, HeapNumber::kMantissaBits); | 2543 psllq(dst, HeapNumber::kMantissaBits); |
| 2677 } | 2544 } |
| 2678 | 2545 |
| 2679 | |
| 2680 void MacroAssembler::JumpIfInstanceTypeIsNotSequentialOneByte( | |
| 2681 Register instance_type, Register scratch, Label* failure) { | |
| 2682 if (!scratch.is(instance_type)) { | |
| 2683 mov(scratch, instance_type); | |
| 2684 } | |
| 2685 and_(scratch, | |
| 2686 kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask); | |
| 2687 cmp(scratch, kStringTag | kSeqStringTag | kOneByteStringTag); | |
| 2688 j(not_equal, failure); | |
| 2689 } | |
| 2690 | |
| 2691 | |
| 2692 void MacroAssembler::JumpIfNotBothSequentialOneByteStrings(Register object1, | 2546 void MacroAssembler::JumpIfNotBothSequentialOneByteStrings(Register object1, |
| 2693 Register object2, | 2547 Register object2, |
| 2694 Register scratch1, | 2548 Register scratch1, |
| 2695 Register scratch2, | 2549 Register scratch2, |
| 2696 Label* failure) { | 2550 Label* failure) { |
| 2697 // Check that both objects are not smis. | 2551 // Check that both objects are not smis. |
| 2698 STATIC_ASSERT(kSmiTag == 0); | 2552 STATIC_ASSERT(kSmiTag == 0); |
| 2699 mov(scratch1, object1); | 2553 mov(scratch1, object1); |
| 2700 and_(scratch1, object2); | 2554 and_(scratch1, object2); |
| 2701 JumpIfSmi(scratch1, failure); | 2555 JumpIfSmi(scratch1, failure); |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3093 mov(eax, dividend); | 2947 mov(eax, dividend); |
| 3094 shr(eax, 31); | 2948 shr(eax, 31); |
| 3095 add(edx, eax); | 2949 add(edx, eax); |
| 3096 } | 2950 } |
| 3097 | 2951 |
| 3098 | 2952 |
| 3099 } // namespace internal | 2953 } // namespace internal |
| 3100 } // namespace v8 | 2954 } // namespace v8 |
| 3101 | 2955 |
| 3102 #endif // V8_TARGET_ARCH_IA32 | 2956 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |