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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2807 | 2807 |
2808 add(bitmap_reg, ecx); | 2808 add(bitmap_reg, ecx); |
2809 mov(ecx, addr_reg); | 2809 mov(ecx, addr_reg); |
2810 shr(ecx, kPointerSizeLog2); | 2810 shr(ecx, kPointerSizeLog2); |
2811 and_(ecx, (1 << Bitmap::kBitsPerCellLog2) - 1); | 2811 and_(ecx, (1 << Bitmap::kBitsPerCellLog2) - 1); |
2812 mov(mask_reg, Immediate(1)); | 2812 mov(mask_reg, Immediate(1)); |
2813 shl_cl(mask_reg); | 2813 shl_cl(mask_reg); |
2814 } | 2814 } |
2815 | 2815 |
2816 | 2816 |
2817 void MacroAssembler::EnsureNotWhite( | 2817 void MacroAssembler::JumpIfWhite(Register value, Register bitmap_scratch, |
2818 Register value, | 2818 Register mask_scratch, Label* value_is_white, |
2819 Register bitmap_scratch, | 2819 Label::Distance distance) { |
2820 Register mask_scratch, | |
2821 Label* value_is_white_and_not_data, | |
2822 Label::Distance distance) { | |
2823 DCHECK(!AreAliased(value, bitmap_scratch, mask_scratch, ecx)); | 2820 DCHECK(!AreAliased(value, bitmap_scratch, mask_scratch, ecx)); |
2824 GetMarkBits(value, bitmap_scratch, mask_scratch); | 2821 GetMarkBits(value, bitmap_scratch, mask_scratch); |
2825 | 2822 |
2826 // If the value is black or grey we don't need to do anything. | 2823 // If the value is black or grey we don't need to do anything. |
2827 DCHECK(strcmp(Marking::kWhiteBitPattern, "00") == 0); | 2824 DCHECK(strcmp(Marking::kWhiteBitPattern, "00") == 0); |
2828 DCHECK(strcmp(Marking::kBlackBitPattern, "10") == 0); | 2825 DCHECK(strcmp(Marking::kBlackBitPattern, "10") == 0); |
2829 DCHECK(strcmp(Marking::kGreyBitPattern, "11") == 0); | 2826 DCHECK(strcmp(Marking::kGreyBitPattern, "11") == 0); |
2830 DCHECK(strcmp(Marking::kImpossibleBitPattern, "01") == 0); | 2827 DCHECK(strcmp(Marking::kImpossibleBitPattern, "01") == 0); |
2831 | 2828 |
2832 Label done; | |
2833 | |
2834 // Since both black and grey have a 1 in the first position and white does | 2829 // Since both black and grey have a 1 in the first position and white does |
2835 // not have a 1 there we only need to check one bit. | 2830 // not have a 1 there we only need to check one bit. |
2836 test(mask_scratch, Operand(bitmap_scratch, MemoryChunk::kHeaderSize)); | 2831 test(mask_scratch, Operand(bitmap_scratch, MemoryChunk::kHeaderSize)); |
2837 j(not_zero, &done, Label::kNear); | 2832 j(zero, &value_is_white, Label::kNear); |
2838 | |
2839 if (emit_debug_code()) { | |
2840 // Check for impossible bit pattern. | |
2841 Label ok; | |
2842 push(mask_scratch); | |
2843 // shl. May overflow making the check conservative. | |
2844 add(mask_scratch, mask_scratch); | |
2845 test(mask_scratch, Operand(bitmap_scratch, MemoryChunk::kHeaderSize)); | |
2846 j(zero, &ok, Label::kNear); | |
2847 int3(); | |
2848 bind(&ok); | |
2849 pop(mask_scratch); | |
2850 } | |
2851 | |
2852 // Value is white. We check whether it is data that doesn't need scanning. | |
2853 // Currently only checks for HeapNumber and non-cons strings. | |
2854 Register map = ecx; // Holds map while checking type. | |
2855 Register length = ecx; // Holds length of object after checking type. | |
2856 Label not_heap_number; | |
2857 Label is_data_object; | |
2858 | |
2859 // Check for heap-number | |
2860 mov(map, FieldOperand(value, HeapObject::kMapOffset)); | |
2861 cmp(map, isolate()->factory()->heap_number_map()); | |
2862 j(not_equal, ¬_heap_number, Label::kNear); | |
2863 mov(length, Immediate(HeapNumber::kSize)); | |
2864 jmp(&is_data_object, Label::kNear); | |
2865 | |
2866 bind(¬_heap_number); | |
2867 // Check for strings. | |
2868 DCHECK(kIsIndirectStringTag == 1 && kIsIndirectStringMask == 1); | |
2869 DCHECK(kNotStringTag == 0x80 && kIsNotStringMask == 0x80); | |
2870 // If it's a string and it's not a cons string then it's an object containing | |
2871 // no GC pointers. | |
2872 Register instance_type = ecx; | |
2873 movzx_b(instance_type, FieldOperand(map, Map::kInstanceTypeOffset)); | |
2874 test_b(instance_type, kIsIndirectStringMask | kIsNotStringMask); | |
2875 j(not_zero, value_is_white_and_not_data); | |
2876 // It's a non-indirect (non-cons and non-slice) string. | |
2877 // If it's external, the length is just ExternalString::kSize. | |
2878 // Otherwise it's String::kHeaderSize + string->length() * (1 or 2). | |
2879 Label not_external; | |
2880 // External strings are the only ones with the kExternalStringTag bit | |
2881 // set. | |
2882 DCHECK_EQ(0, kSeqStringTag & kExternalStringTag); | |
2883 DCHECK_EQ(0, kConsStringTag & kExternalStringTag); | |
2884 test_b(instance_type, kExternalStringTag); | |
2885 j(zero, ¬_external, Label::kNear); | |
2886 mov(length, Immediate(ExternalString::kSize)); | |
2887 jmp(&is_data_object, Label::kNear); | |
2888 | |
2889 bind(¬_external); | |
2890 // Sequential string, either Latin1 or UC16. | |
2891 DCHECK(kOneByteStringTag == 0x04); | |
2892 and_(length, Immediate(kStringEncodingMask)); | |
2893 xor_(length, Immediate(kStringEncodingMask)); | |
2894 add(length, Immediate(0x04)); | |
2895 // Value now either 4 (if Latin1) or 8 (if UC16), i.e., char-size shifted | |
2896 // by 2. If we multiply the string length as smi by this, it still | |
2897 // won't overflow a 32-bit value. | |
2898 DCHECK_EQ(SeqOneByteString::kMaxSize, SeqTwoByteString::kMaxSize); | |
2899 DCHECK(SeqOneByteString::kMaxSize <= | |
2900 static_cast<int>(0xffffffffu >> (2 + kSmiTagSize))); | |
2901 imul(length, FieldOperand(value, String::kLengthOffset)); | |
2902 shr(length, 2 + kSmiTagSize + kSmiShiftSize); | |
2903 add(length, Immediate(SeqString::kHeaderSize + kObjectAlignmentMask)); | |
2904 and_(length, Immediate(~kObjectAlignmentMask)); | |
2905 | |
2906 bind(&is_data_object); | |
2907 // Value is a data object, and it is white. Mark it black. Since we know | |
2908 // that the object is white we can make it black by flipping one bit. | |
2909 or_(Operand(bitmap_scratch, MemoryChunk::kHeaderSize), mask_scratch); | |
2910 | |
2911 and_(bitmap_scratch, Immediate(~Page::kPageAlignmentMask)); | |
2912 add(Operand(bitmap_scratch, MemoryChunk::kLiveBytesOffset), | |
2913 length); | |
2914 if (emit_debug_code()) { | |
2915 mov(length, Operand(bitmap_scratch, MemoryChunk::kLiveBytesOffset)); | |
2916 cmp(length, Operand(bitmap_scratch, MemoryChunk::kSizeOffset)); | |
2917 Check(less_equal, kLiveBytesCountOverflowChunkSize); | |
2918 } | |
2919 | |
2920 bind(&done); | |
2921 } | 2833 } |
2922 | 2834 |
2923 | 2835 |
2924 void MacroAssembler::EnumLength(Register dst, Register map) { | 2836 void MacroAssembler::EnumLength(Register dst, Register map) { |
2925 STATIC_ASSERT(Map::EnumLengthBits::kShift == 0); | 2837 STATIC_ASSERT(Map::EnumLengthBits::kShift == 0); |
2926 mov(dst, FieldOperand(map, Map::kBitField3Offset)); | 2838 mov(dst, FieldOperand(map, Map::kBitField3Offset)); |
2927 and_(dst, Immediate(Map::EnumLengthBits::kMask)); | 2839 and_(dst, Immediate(Map::EnumLengthBits::kMask)); |
2928 SmiTag(dst); | 2840 SmiTag(dst); |
2929 } | 2841 } |
2930 | 2842 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3041 mov(eax, dividend); | 2953 mov(eax, dividend); |
3042 shr(eax, 31); | 2954 shr(eax, 31); |
3043 add(edx, eax); | 2955 add(edx, eax); |
3044 } | 2956 } |
3045 | 2957 |
3046 | 2958 |
3047 } // namespace internal | 2959 } // namespace internal |
3048 } // namespace v8 | 2960 } // namespace v8 |
3049 | 2961 |
3050 #endif // V8_TARGET_ARCH_X87 | 2962 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |