Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: src/ia32/macro-assembler-ia32-inl.h

Issue 7032005: Unify markbits for old and new spaces. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 50
51 template<typename LabelType> 51 template<typename LabelType>
52 void MacroAssembler::InOldSpaceIsBlack(Register object, 52 void MacroAssembler::InOldSpaceIsBlack(Register object,
53 Register scratch0, 53 Register scratch0,
54 Register scratch1, 54 Register scratch1,
55 LabelType* is_black) { 55 LabelType* is_black) {
56 HasColour(object, scratch0, scratch1, 56 HasColour(object, scratch0, scratch1,
57 is_black, 57 is_black,
58 Page::kPageAlignmentMask, 58 1, 0); // kBlackBitPattern.
59 MemoryChunk::kHeaderSize,
60 1, 0, // kBlackBitPattern.
61 false); // In old space.
62 ASSERT(strcmp(IncrementalMarking::kBlackBitPattern, "10") == 0); 59 ASSERT(strcmp(IncrementalMarking::kBlackBitPattern, "10") == 0);
63 } 60 }
64 61
65 62
66 template<typename LabelType> 63 template<typename LabelType>
67 void MacroAssembler::InNewSpaceIsBlack(Register object, 64 void MacroAssembler::InNewSpaceIsBlack(Register object,
68 Register scratch0, 65 Register scratch0,
69 Register scratch1, 66 Register scratch1,
70 LabelType* is_black) { 67 LabelType* is_black) {
71 HasColour(object, scratch0, scratch1, 68 HasColour(object, scratch0, scratch1,
72 is_black, 69 is_black,
73 ~HEAP->new_space()->mask(), 70 1, 0); // kBlackBitPattern.
74 0,
75 1, 0, // kBlackBitPattern.
76 true); // In new space.
77 ASSERT(strcmp(IncrementalMarking::kBlackBitPattern, "10") == 0); 71 ASSERT(strcmp(IncrementalMarking::kBlackBitPattern, "10") == 0);
78 } 72 }
79 73
80 74
81 template<typename LabelType> 75 template<typename LabelType>
82 void MacroAssembler::HasColour(Register object, 76 void MacroAssembler::HasColour(Register object,
83 Register bitmap_scratch, 77 Register bitmap_scratch,
84 Register mask_scratch, 78 Register mask_scratch,
85 LabelType* has_colour, 79 LabelType* has_colour,
86 uint32_t mask,
87 int header_size,
88 int first_bit, 80 int first_bit,
89 int second_bit, 81 int second_bit) {
90 bool in_new_space) {
91 ASSERT(!Aliasing(object, bitmap_scratch, mask_scratch, ecx)); 82 ASSERT(!Aliasing(object, bitmap_scratch, mask_scratch, ecx));
92 int32_t high_mask = ~mask;
93 83
94 MarkBits(object, bitmap_scratch, mask_scratch, high_mask, in_new_space); 84 MarkBits(object, bitmap_scratch, mask_scratch);
95 85
96 NearLabel other_colour, word_boundary; 86 NearLabel other_colour, word_boundary;
97 test(mask_scratch, Operand(bitmap_scratch, header_size)); 87 test(mask_scratch, Operand(bitmap_scratch, MemoryChunk::kHeaderSize));
98 j(first_bit == 1 ? zero : not_zero, &other_colour); 88 j(first_bit == 1 ? zero : not_zero, &other_colour);
99 add(mask_scratch, Operand(mask_scratch)); // Shift left 1 by adding. 89 add(mask_scratch, Operand(mask_scratch)); // Shift left 1 by adding.
100 j(zero, &word_boundary); 90 j(zero, &word_boundary);
101 test(mask_scratch, Operand(bitmap_scratch, header_size)); 91 test(mask_scratch, Operand(bitmap_scratch, MemoryChunk::kHeaderSize));
102 j(second_bit == 1 ? not_zero : zero, has_colour); 92 j(second_bit == 1 ? not_zero : zero, has_colour);
103 jmp(&other_colour); 93 jmp(&other_colour);
104 94
105 bind(&word_boundary); 95 bind(&word_boundary);
106 test_b(Operand(bitmap_scratch, header_size + kPointerSize), 1); 96 test_b(Operand(bitmap_scratch, MemoryChunk::kHeaderSize + kPointerSize), 1);
107 97
108 j(second_bit == 1 ? not_zero : zero, has_colour); 98 j(second_bit == 1 ? not_zero : zero, has_colour);
109 bind(&other_colour); 99 bind(&other_colour);
110 } 100 }
111 101
112 102
113 template<typename LabelType> 103 template<typename LabelType>
114 void MacroAssembler::IsDataObject(Register value, 104 void MacroAssembler::IsDataObject(Register value,
115 Register scratch, 105 Register scratch,
116 LabelType* not_data_object, 106 LabelType* not_data_object,
(...skipping 18 matching lines...) Expand all
135 test_b(Operand(scratch, MemoryChunk::kFlagsOffset), 125 test_b(Operand(scratch, MemoryChunk::kFlagsOffset),
136 1 << MemoryChunk::CONTAINS_ONLY_DATA); 126 1 << MemoryChunk::CONTAINS_ONLY_DATA);
137 // Jump if we need to mark it grey and push it. 127 // Jump if we need to mark it grey and push it.
138 j(zero, not_data_object); 128 j(zero, not_data_object);
139 } 129 }
140 } 130 }
141 131
142 132
143 void MacroAssembler::MarkBits(Register addr_reg, 133 void MacroAssembler::MarkBits(Register addr_reg,
144 Register bitmap_reg, 134 Register bitmap_reg,
145 Register mask_reg, 135 Register mask_reg) {
146 int32_t high_mask,
147 bool in_new_space) {
148 ASSERT(!Aliasing(addr_reg, bitmap_reg, mask_reg, ecx)); 136 ASSERT(!Aliasing(addr_reg, bitmap_reg, mask_reg, ecx));
149 if (in_new_space) { 137 mov(bitmap_reg, Operand(addr_reg));
150 mov(bitmap_reg, 138 and_(bitmap_reg, ~Page::kPageAlignmentMask);
151 Immediate(ExternalReference::new_space_mark_bits(isolate())));
152 } else {
153 mov(bitmap_reg, Operand(addr_reg));
154 and_(bitmap_reg, high_mask);
155 }
156 mov(ecx, Operand(addr_reg)); 139 mov(ecx, Operand(addr_reg));
157 static const int kBitsPerCellLog2 = 140 shr(ecx, Bitmap::kBitsPerCellLog2);
158 Bitmap<MemoryChunk::BitmapStorageDescriptor>::kBitsPerCellLog2; 141 and_(ecx,
159 shr(ecx, kBitsPerCellLog2); 142 (Page::kPageAlignmentMask >> Bitmap::kBitsPerCellLog2) &
160 and_(ecx, ~((high_mask >> kBitsPerCellLog2) | (kPointerSize - 1))); 143 ~(kPointerSize - 1));
161 144
162 add(bitmap_reg, Operand(ecx)); 145 add(bitmap_reg, Operand(ecx));
163 mov(ecx, Operand(addr_reg)); 146 mov(ecx, Operand(addr_reg));
164 shr(ecx, kPointerSizeLog2); 147 shr(ecx, kPointerSizeLog2);
165 and_(ecx, (1 << kBitsPerCellLog2) - 1); 148 and_(ecx, (1 << Bitmap::kBitsPerCellLog2) - 1);
166 mov(mask_reg, Immediate(1)); 149 mov(mask_reg, Immediate(1));
167 shl_cl(mask_reg); 150 shl_cl(mask_reg);
168 } 151 }
169 152
170 153
171 template<typename LabelType> 154 template<typename LabelType>
172 void MacroAssembler::EnsureNotWhite( 155 void MacroAssembler::EnsureNotWhite(
173 Register value, 156 Register value,
174 Register bitmap_scratch, 157 Register bitmap_scratch,
175 Register mask_scratch, 158 Register mask_scratch,
176 LabelType* value_is_white_and_not_data, 159 LabelType* value_is_white_and_not_data,
177 bool in_new_space) { 160 bool in_new_space) {
178 ASSERT(!Aliasing(value, bitmap_scratch, mask_scratch, ecx)); 161 ASSERT(!Aliasing(value, bitmap_scratch, mask_scratch, ecx));
179 int32_t high_mask = in_new_space ? 162 MarkBits(value, bitmap_scratch, mask_scratch);
180 HEAP->new_space()->mask() :
181 ~Page::kPageAlignmentMask;
182 int header_size = in_new_space ? 0 : MemoryChunk::kHeaderSize;
183 MarkBits(value, bitmap_scratch, mask_scratch, high_mask, in_new_space);
184 163
185 // If the value is black or grey we don't need to do anything. 164 // If the value is black or grey we don't need to do anything.
186 ASSERT(strcmp(IncrementalMarking::kWhiteBitPattern, "00") == 0); 165 ASSERT(strcmp(IncrementalMarking::kWhiteBitPattern, "00") == 0);
187 ASSERT(strcmp(IncrementalMarking::kBlackBitPattern, "10") == 0); 166 ASSERT(strcmp(IncrementalMarking::kBlackBitPattern, "10") == 0);
188 ASSERT(strcmp(IncrementalMarking::kGreyBitPattern, "11") == 0); 167 ASSERT(strcmp(IncrementalMarking::kGreyBitPattern, "11") == 0);
189 ASSERT(strcmp(IncrementalMarking::kImpossibleBitPattern, "01") == 0); 168 ASSERT(strcmp(IncrementalMarking::kImpossibleBitPattern, "01") == 0);
190 169
191 NearLabel done; 170 NearLabel done;
192 171
193 // Since both black and grey have a 1 in the first position and white does 172 // Since both black and grey have a 1 in the first position and white does
194 // not have a 1 there we only need to check one bit. 173 // not have a 1 there we only need to check one bit.
195 test(mask_scratch, Operand(bitmap_scratch, header_size)); 174 test(mask_scratch, Operand(bitmap_scratch, MemoryChunk::kHeaderSize));
196 j(not_zero, &done); 175 j(not_zero, &done);
197 176
198 if (FLAG_debug_code) { 177 if (FLAG_debug_code) {
199 // Check for impossible bit pattern. 178 // Check for impossible bit pattern.
200 NearLabel ok; 179 NearLabel ok;
201 push(mask_scratch); 180 push(mask_scratch);
202 // shl. May overflow making the check conservative. 181 // shl. May overflow making the check conservative.
203 add(mask_scratch, Operand(mask_scratch)); 182 add(mask_scratch, Operand(mask_scratch));
204 test(mask_scratch, Operand(bitmap_scratch, header_size)); 183 test(mask_scratch, Operand(bitmap_scratch, MemoryChunk::kHeaderSize));
205 j(zero, &ok); 184 j(zero, &ok);
206 int3(); 185 int3();
207 bind(&ok); 186 bind(&ok);
208 pop(mask_scratch); 187 pop(mask_scratch);
209 } 188 }
210 189
211 // Value is white. We check whether it is data that doesn't need scanning. 190 // Value is white. We check whether it is data that doesn't need scanning.
212 IsDataObject(value, ecx, value_is_white_and_not_data, in_new_space); 191 IsDataObject(value, ecx, value_is_white_and_not_data, in_new_space);
213 192
214 // Value is a data object, and it is white. Mark it black. Since we know 193 // Value is a data object, and it is white. Mark it black. Since we know
215 // that the object is white we can make it black by flipping one bit. 194 // that the object is white we can make it black by flipping one bit.
216 or_(Operand(bitmap_scratch, header_size), mask_scratch); 195 or_(Operand(bitmap_scratch, MemoryChunk::kHeaderSize), mask_scratch);
217 bind(&done); 196 bind(&done);
218 } 197 }
219 198
220 } } // namespace v8::internal 199 } } // namespace v8::internal
221 200
222 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_INL_H_ 201 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_INL_H_
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/incremental-marking.cc » ('j') | src/serialize.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698