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

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

Issue 6824078: Move most of the incremental marking write barrier to generated code. (Closed) Base URL: http://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
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27
28 #ifndef V8_IA32_MACRO_ASSEMBLER_IA32_INL_H_
29 #define V8_IA32_MACRO_ASSEMBLER_IA32_INL_H_
30
31 #include "macro-assembler.h"
32
33 namespace v8 {
34 namespace internal {
35
36 template<typename LabelType>
37 void MacroAssembler::HasScanOnScavenge(Register object,
38 Register scratch,
39 LabelType* scan_on_scavenge) {
40 Move(scratch, object);
41 and_(scratch, ~Page::kPageAlignmentMask);
42 cmpb(Operand(scratch, MemoryChunk::kScanOnScavengeOffset), 0);
43 j(not_equal, scan_on_scavenge);
44 }
45
46
47 template<typename LabelType>
48 void MacroAssembler::InOldSpaceIsBlack(Register object,
49 Register scratch0,
50 Register scratch1,
51 LabelType* is_black) {
52 HasColour(object, scratch0, scratch1,
53 is_black,
54 Page::kPageAlignmentMask,
55 MemoryChunk::kHeaderSize,
56 1, 0, // kBlackBitPattern.
57 false); // In old space.
58 ASSERT(strcmp(IncrementalMarking::kBlackBitPattern, "10") == 0);
59 }
60
61
62 template<typename LabelType>
63 void MacroAssembler::InNewSpaceIsBlack(Register object,
64 Register scratch0,
65 Register scratch1,
66 LabelType* is_black) {
67 HasColour(object, scratch0, scratch1,
68 is_black,
69 ~HEAP->new_space()->mask(),
70 0,
71 1, 0, // kBlackBitPattern.
72 true); // In new space.
73 ASSERT(strcmp(IncrementalMarking::kBlackBitPattern, "10") == 0);
74 }
75
76
77 template<typename LabelType>
78 void MacroAssembler::HasColour(Register object,
79 Register bitmap_scratch,
80 Register mask_scratch,
81 LabelType* has_colour,
82 uint32_t mask,
83 int header_size,
84 int first_bit,
85 int second_bit,
86 bool in_new_space) {
87 ASSERT(!Aliasing(object, bitmap_scratch, mask_scratch, ecx));
88 int32_t high_mask = ~mask;
89
90 MarkBits(object, bitmap_scratch, mask_scratch, high_mask, in_new_space);
91
92 NearLabel other_colour, word_boundary;
93 test(mask_scratch, Operand(bitmap_scratch, header_size));
94 j(first_bit == 1 ? zero : not_zero, &other_colour);
95 add(mask_scratch, Operand(mask_scratch)); // Shift left 1 by adding.
96 j(zero, &word_boundary);
97 test(mask_scratch, Operand(bitmap_scratch, header_size));
98 j(second_bit == 1 ? not_zero : zero, has_colour);
99 jmp(&other_colour);
100
101 bind(&word_boundary);
102 test_b(Operand(bitmap_scratch, header_size + kPointerSize), 1);
103
104 j(second_bit == 1 ? not_zero : zero, has_colour);
105 bind(&other_colour);
106 }
107
108
109 template<typename LabelType>
110 void MacroAssembler::IsDataObject(Register value,
111 Register scratch,
112 LabelType* not_data_object,
113 bool in_new_space) {
114 if (in_new_space) {
115 NearLabel is_data_object;
116 mov(scratch, FieldOperand(value, HeapObject::kMapOffset));
117 cmp(scratch, FACTORY->heap_number_map());
118 j(equal, &is_data_object);
119 ASSERT(kConsStringTag == 1 && kIsConsStringMask == 1);
120 ASSERT(kNotStringTag == 0x80 && kIsNotStringMask == 0x80);
121 // If it's a string and it's not a cons string then it's an object that
122 // doesn't need scanning.
123 test_b(FieldOperand(scratch, Map::kInstanceTypeOffset),
124 kIsConsStringMask | kIsNotStringMask);
125 // Jump if we need to mark it grey and push it.
126 j(not_zero, not_data_object);
127 bind(&is_data_object);
128 } else {
129 mov(scratch, Operand(value));
130 and_(scratch, ~Page::kPageAlignmentMask);
131 test_b(Operand(scratch, MemoryChunk::kFlagsOffset),
132 1 << MemoryChunk::CONTAINS_ONLY_DATA);
133 // Jump if we need to mark it grey and push it.
134 j(zero, not_data_object);
135 }
136 }
137
138
139 void MacroAssembler::MarkBits(Register addr_reg,
140 Register bitmap_reg,
141 Register mask_reg,
142 int32_t high_mask,
143 bool in_new_space) {
144 ASSERT(!Aliasing(addr_reg, bitmap_reg, mask_reg, ecx));
145 if (in_new_space) {
146 mov(bitmap_reg, Immediate(ExternalReference::new_space_mark_bits()));
147 } else {
148 mov(bitmap_reg, Operand(addr_reg));
149 and_(bitmap_reg, high_mask);
150 }
151 mov(ecx, Operand(addr_reg));
152 static const int kBitsPerCellLog2 =
153 Bitmap<MemoryChunk::BitmapStorageDescriptor>::kBitsPerCellLog2;
154 shr(ecx, kBitsPerCellLog2);
155 and_(ecx, ~((high_mask >> kBitsPerCellLog2) | (kPointerSize - 1)));
156
157 add(bitmap_reg, Operand(ecx));
158 mov(ecx, Operand(addr_reg));
159 shr(ecx, kPointerSizeLog2);
160 and_(ecx, (1 << kBitsPerCellLog2) - 1);
161 mov(mask_reg, Immediate(1));
162 shl_cl(mask_reg);
163 }
164
165
166 template<typename LabelType>
167 void MacroAssembler::EnsureNotWhite(
168 Register value,
169 Register bitmap_scratch,
170 Register mask_scratch,
171 LabelType* value_is_white_and_not_data,
172 bool in_new_space) {
173 ASSERT(!Aliasing(value, bitmap_scratch, mask_scratch, ecx));
174 int32_t high_mask = in_new_space ?
175 HEAP->new_space()->mask() :
176 ~Page::kPageAlignmentMask;
177 int header_size = in_new_space ? 0 : MemoryChunk::kHeaderSize;
178 MarkBits(value, bitmap_scratch, mask_scratch, high_mask, in_new_space);
179
180 // If the value is black or grey we don't need to do anything.
181 ASSERT(strcmp(IncrementalMarking::kWhiteBitPattern, "00") == 0);
182 ASSERT(strcmp(IncrementalMarking::kBlackBitPattern, "10") == 0);
183 ASSERT(strcmp(IncrementalMarking::kGreyBitPattern, "11") == 0);
184 ASSERT(strcmp(IncrementalMarking::kImpossibleBitPattern, "01") == 0);
185
186 NearLabel done;
187
188 // Since both black and grey have a 1 in the first position and white does
189 // not have a 1 there we only need to check one bit.
190 test(mask_scratch, Operand(bitmap_scratch, header_size));
191 j(not_zero, &done);
192
193 if (FLAG_debug_code) {
194 // Check for impossible bit pattern.
195 NearLabel ok;
196 push(mask_scratch);
197 // shl. May overflow making the check conservative.
198 add(mask_scratch, Operand(mask_scratch));
199 test(mask_scratch, Operand(bitmap_scratch, header_size));
200 j(zero, &ok);
201 int3();
202 bind(&ok);
203 pop(mask_scratch);
204 }
205
206 // Value is white. We check whether it is data that doesn't need scanning.
207 IsDataObject(value, ecx, value_is_white_and_not_data, in_new_space);
208
209 // Value is a data object, and it is white. Mark it black. Since we know
210 // that the object is white we can make it black by flipping one bit.
211 or_(Operand(bitmap_scratch, header_size), mask_scratch);
212 bind(&done);
213 }
214
215 } } // namespace v8::internal
216
217 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_INL_H_
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698