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

Side by Side Diff: src/elements.cc

Issue 9663002: Use CopyElements for SetFastDoubleElementsCapacityAndLength (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix bugs Created 8 years, 9 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 125
126 static Failure* ThrowArrayLengthRangeError(Heap* heap) { 126 static Failure* ThrowArrayLengthRangeError(Heap* heap) {
127 HandleScope scope(heap->isolate()); 127 HandleScope scope(heap->isolate());
128 return heap->isolate()->Throw( 128 return heap->isolate()->Throw(
129 *heap->isolate()->factory()->NewRangeError("invalid_array_length", 129 *heap->isolate()->factory()->NewRangeError("invalid_array_length",
130 HandleVector<Object>(NULL, 0))); 130 HandleVector<Object>(NULL, 0)));
131 } 131 }
132 132
133 133
134 void CopyObjectToObjectElements(AssertNoAllocation* no_gc, 134 void CopyObjectToObjectElements(FixedArray* from,
135 FixedArray* from_obj,
136 ElementsKind from_kind, 135 ElementsKind from_kind,
137 uint32_t from_start, 136 uint32_t from_start,
138 FixedArray* to_obj, 137 FixedArray* to,
139 ElementsKind to_kind, 138 ElementsKind to_kind,
140 uint32_t to_start, 139 uint32_t to_start,
141 int copy_size) { 140 int raw_copy_size,
142 ASSERT(to_obj->map() != HEAP->fixed_cow_array_map()); 141 WriteBarrierMode mode) {
142 ASSERT(to->map() != HEAP->fixed_cow_array_map());
143 ASSERT(from_kind == FAST_ELEMENTS || from_kind == FAST_SMI_ONLY_ELEMENTS); 143 ASSERT(from_kind == FAST_ELEMENTS || from_kind == FAST_SMI_ONLY_ELEMENTS);
144 ASSERT(to_kind == FAST_ELEMENTS || to_kind == FAST_SMI_ONLY_ELEMENTS); 144 ASSERT(to_kind == FAST_ELEMENTS || to_kind == FAST_SMI_ONLY_ELEMENTS);
145 if (copy_size == -1) { 145 int copy_size = raw_copy_size;
146 copy_size = Min(from_obj->length() - from_start, 146 if (raw_copy_size < 0) {
147 to_obj->length() - to_start); 147 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd ||
148 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole);
149 copy_size = Min(from->length() - from_start,
150 to->length() - to_start);
151 #if DEBUG
Jakob Kummerow 2012/03/12 15:33:28 s/#if/#ifdef/ Again below.
danno 2012/03/12 20:35:03 Done.
152 // FAST_ELEMENT arrays cannot be uninitialized. Ensure they are already
153 // marked with the hole.
154 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
155 Object* hole = from->GetHeap()->the_hole_value();
156 for (int i = to_start + copy_size; i < to->length(); ++i) {
157 ASSERT(to->get(i) == hole);
Jakob Kummerow 2012/03/12 15:33:28 ASSERT(to->is_the_hole(i))?
danno 2012/03/12 20:35:03 Done.
158 }
159 }
160 #endif
148 } 161 }
149 ASSERT(((copy_size + static_cast<int>(to_start)) <= to_obj->length() && 162 ASSERT(((copy_size + static_cast<int>(to_start)) <= to->length() &&
Jakob Kummerow 2012/03/12 15:33:28 nit: you can remove at least one pair of parenthes
danno 2012/03/12 20:35:03 Done.
150 (copy_size + static_cast<int>(from_start)) <= from_obj->length())); 163 (copy_size + static_cast<int>(from_start)) <= from->length()));
151 if (copy_size == 0) return; 164 if (copy_size == 0) return;
152 Address to = to_obj->address() + FixedArray::kHeaderSize; 165 Address to_address = to->address() + FixedArray::kHeaderSize;
153 Address from = from_obj->address() + FixedArray::kHeaderSize; 166 Address from_address = from->address() + FixedArray::kHeaderSize;
154 CopyWords(reinterpret_cast<Object**>(to) + to_start, 167 CopyWords(reinterpret_cast<Object**>(to_address) + to_start,
155 reinterpret_cast<Object**>(from) + from_start, 168 reinterpret_cast<Object**>(from_address) + from_start,
156 copy_size); 169 copy_size);
157 if (from_kind == FAST_ELEMENTS && to_kind == FAST_ELEMENTS) { 170 if (from_kind == FAST_ELEMENTS && to_kind == FAST_ELEMENTS &&
158 Heap* heap = from_obj->GetHeap(); 171 mode == UPDATE_WRITE_BARRIER) {
159 WriteBarrierMode mode = to_obj->GetWriteBarrierMode(*no_gc); 172 Heap* heap = from->GetHeap();
160 if (mode == UPDATE_WRITE_BARRIER) { 173 if (!heap->InNewSpace(to)) {
161 heap->RecordWrites(to_obj->address(), 174 heap->RecordWrites(to->address(),
162 to_obj->OffsetOfElementAt(to_start), 175 to->OffsetOfElementAt(to_start),
163 copy_size); 176 copy_size);
164 } 177 }
165 heap->incremental_marking()->RecordWrites(to_obj); 178 heap->incremental_marking()->RecordWrites(to);
166 } 179 }
167 } 180 }
168 181
169 182
170
171
172 static void CopyDictionaryToObjectElements(SeededNumberDictionary* from, 183 static void CopyDictionaryToObjectElements(SeededNumberDictionary* from,
173 uint32_t from_start, 184 uint32_t from_start,
174 FixedArray* to, 185 FixedArray* to,
175 ElementsKind to_kind, 186 ElementsKind to_kind,
176 uint32_t to_start, 187 uint32_t to_start,
177 int copy_size) { 188 int raw_copy_size,
189 WriteBarrierMode mode) {
190 int copy_size = raw_copy_size;
191 Heap* heap = from->GetHeap();
192 Object* hole = heap->the_hole_value();
193 if (raw_copy_size < 0) {
194 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd ||
195 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole);
196 copy_size = from->max_number_key() + 1 - from_start;
197 #if DEBUG
198 // FAST_ELEMENT arrays cannot be uninitialized. Ensure they are already
199 // marked with the hole.
200 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
201 for (int i = to_start + copy_size; i < to->length(); ++i) {
202 ASSERT(to->get(i) == hole);
Jakob Kummerow 2012/03/12 15:33:28 ASSERT(to->is_the_hole(i))?
danno 2012/03/12 20:35:03 Done.
203 }
204 }
205 #endif
206 }
207 ASSERT((copy_size + static_cast<int>(to_start)) <= to->length());
178 ASSERT(to != from); 208 ASSERT(to != from);
179 ASSERT(to_kind == FAST_ELEMENTS || to_kind == FAST_SMI_ONLY_ELEMENTS); 209 ASSERT(to_kind == FAST_ELEMENTS || to_kind == FAST_SMI_ONLY_ELEMENTS);
180 ASSERT(copy_size == -1 || 210 ASSERT(copy_size > 0 || copy_size == ElementsAccessor::kCopyToEnd ||
Jakob Kummerow 2012/03/12 15:33:28 I don't see how copy_size can ever be < 0 at this
danno 2012/03/12 20:35:03 Done.
181 (copy_size + static_cast<int>(to_start)) <= to->length()); 211 copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole);
182 WriteBarrierMode mode = to_kind == FAST_ELEMENTS 212 ASSERT(copy_size + static_cast<int>(to_start) <= to->length());
Jakob Kummerow 2012/03/12 15:33:28 Duplicate assertion (see line 207).
danno 2012/03/12 20:35:03 Done.
183 ? UPDATE_WRITE_BARRIER 213 if (copy_size == 0) return;
184 : SKIP_WRITE_BARRIER; 214 for (int i = 0; i < copy_size; i++) {
185 uint32_t copy_limit = (copy_size == -1) 215 int entry = from->FindEntry(i + from_start);
186 ? to->length() 216 if (entry != SeededNumberDictionary::kNotFound) {
187 : Min(to_start + copy_size, static_cast<uint32_t>(to->length())); 217 Object* value = from->ValueAt(entry);
188 for (int i = 0; i < from->Capacity(); ++i) { 218 ASSERT(!value->IsTheHole());
189 Object* key = from->KeyAt(i); 219 to->set(i + to_start, value, SKIP_WRITE_BARRIER);
190 if (key->IsNumber()) { 220 } else {
191 uint32_t entry = static_cast<uint32_t>(key->Number()); 221 to->set(i + to_start, hole, SKIP_WRITE_BARRIER);
Jakob Kummerow 2012/03/12 15:33:28 to->set_the_hole(i + to_start)?
danno 2012/03/12 20:35:03 Done.
192 if (entry >= to_start && entry < copy_limit) {
193 Object* value = from->ValueAt(i);
194 ASSERT(to_kind == FAST_ELEMENTS || value->IsSmi());
195 to->set(entry, value, mode);
196 }
197 } 222 }
198 } 223 }
224 if (to_kind == FAST_ELEMENTS) {
225 if (!heap->InNewSpace(to)) {
226 heap->RecordWrites(to->address(),
227 to->OffsetOfElementAt(to_start),
228 copy_size);
229 }
230 heap->incremental_marking()->RecordWrites(to);
231 }
199 } 232 }
200 233
201 234
202 MUST_USE_RESULT static MaybeObject* CopyDoubleToObjectElements( 235 MUST_USE_RESULT static MaybeObject* CopyDoubleToObjectElements(
203 FixedDoubleArray* from_obj, 236 FixedDoubleArray* from,
204 uint32_t from_start, 237 uint32_t from_start,
205 FixedArray* to_obj, 238 FixedArray* to,
206 ElementsKind to_kind, 239 ElementsKind to_kind,
207 uint32_t to_start, 240 uint32_t to_start,
208 int copy_size) { 241 int raw_copy_size) {
209 ASSERT(to_kind == FAST_ELEMENTS || to_kind == FAST_SMI_ONLY_ELEMENTS); 242 ASSERT(to_kind == FAST_ELEMENTS || to_kind == FAST_SMI_ONLY_ELEMENTS);
210 if (copy_size == -1) { 243 int copy_size = raw_copy_size;
211 copy_size = Min(from_obj->length() - from_start, 244 if (raw_copy_size < 0) {
212 to_obj->length() - to_start); 245 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd ||
246 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole);
247 copy_size = Min(from->length() - from_start,
248 to->length() - to_start);
249 #if DEBUG
250 // FAST_ELEMENT arrays cannot be uninitialized. Ensure they are already
251 // marked with the hole.
252 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
253 Object* hole = from->GetHeap()->the_hole_value();
254 for (int i = to_start + copy_size; i < to->length(); ++i) {
255 ASSERT(to->get(i) == hole);
Jakob Kummerow 2012/03/12 15:33:28 ASSERT(to->is_the_hole(i))?
danno 2012/03/12 20:35:03 Done.
256 }
257 }
258 #endif
213 } 259 }
214 ASSERT(((copy_size + static_cast<int>(to_start)) <= to_obj->length() && 260 ASSERT(((copy_size + static_cast<int>(to_start)) <= to->length() &&
Jakob Kummerow 2012/03/12 15:33:28 nit: you can remove at least one pair of parenthes
danno 2012/03/12 20:35:03 Done.
215 (copy_size + static_cast<int>(from_start)) <= from_obj->length())); 261 (copy_size + static_cast<int>(from_start)) <= from->length()));
216 if (copy_size == 0) return from_obj; 262 if (copy_size == 0) return from;
217 for (int i = 0; i < copy_size; ++i) { 263 for (int i = 0; i < copy_size; ++i) {
218 if (to_kind == FAST_SMI_ONLY_ELEMENTS) { 264 if (to_kind == FAST_SMI_ONLY_ELEMENTS) {
219 UNIMPLEMENTED(); 265 UNIMPLEMENTED();
220 return Failure::Exception(); 266 return Failure::Exception();
221 } else { 267 } else {
222 MaybeObject* maybe_value = from_obj->get(i + from_start); 268 MaybeObject* maybe_value = from->get(i + from_start);
223 Object* value; 269 Object* value;
224 ASSERT(to_kind == FAST_ELEMENTS); 270 ASSERT(to_kind == FAST_ELEMENTS);
225 // Because FAST_DOUBLE_ELEMENTS -> FAST_ELEMENT allocate HeapObjects 271 // Because FAST_DOUBLE_ELEMENTS -> FAST_ELEMENT allocate HeapObjects
226 // iteratively, the allocate must succeed within a single GC cycle, 272 // iteratively, the allocate must succeed within a single GC cycle,
227 // otherwise the retry after the GC will also fail. In order to ensure 273 // otherwise the retry after the GC will also fail. In order to ensure
228 // that no GC is triggered, allocate HeapNumbers from old space if they 274 // that no GC is triggered, allocate HeapNumbers from old space if they
229 // can't be taken from new space. 275 // can't be taken from new space.
230 if (!maybe_value->ToObject(&value)) { 276 if (!maybe_value->ToObject(&value)) {
231 ASSERT(maybe_value->IsRetryAfterGC() || maybe_value->IsOutOfMemory()); 277 ASSERT(maybe_value->IsRetryAfterGC() || maybe_value->IsOutOfMemory());
232 Heap* heap = from_obj->GetHeap(); 278 Heap* heap = from->GetHeap();
233 MaybeObject* maybe_value_object = 279 MaybeObject* maybe_value_object =
234 heap->AllocateHeapNumber(from_obj->get_scalar(i + from_start), 280 heap->AllocateHeapNumber(from->get_scalar(i + from_start),
235 TENURED); 281 TENURED);
236 if (!maybe_value_object->ToObject(&value)) return maybe_value_object; 282 if (!maybe_value_object->ToObject(&value)) return maybe_value_object;
237 } 283 }
238 to_obj->set(i + to_start, value, UPDATE_WRITE_BARRIER); 284 to->set(i + to_start, value, UPDATE_WRITE_BARRIER);
239 } 285 }
240 } 286 }
241 return to_obj; 287 return to;
242 } 288 }
243 289
244 290
245 static void CopyDoubleToDoubleElements(FixedDoubleArray* from_obj, 291 static void CopyDoubleToDoubleElements(FixedDoubleArray* from,
246 uint32_t from_start, 292 uint32_t from_start,
247 FixedDoubleArray* to_obj, 293 FixedDoubleArray* to,
248 uint32_t to_start, 294 uint32_t to_start,
249 int copy_size) { 295 int raw_copy_size) {
250 if (copy_size == -1) { 296 int copy_size = raw_copy_size;
251 copy_size = Min(from_obj->length() - from_start, 297 if (raw_copy_size < 0) {
252 to_obj->length() - to_start); 298 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd ||
299 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole);
300 copy_size = Min(from->length() - from_start,
301 to->length() - to_start);
302 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
303 for (int i = to_start + copy_size; i < to->length(); ++i) {
304 to->set_the_hole(i);
305 }
306 }
253 } 307 }
254 ASSERT(((copy_size + static_cast<int>(to_start)) <= to_obj->length() && 308 ASSERT(((copy_size + static_cast<int>(to_start)) <= to->length() &&
255 (copy_size + static_cast<int>(from_start)) <= from_obj->length())); 309 (copy_size + static_cast<int>(from_start)) <= from->length()));
256 if (copy_size == 0) return; 310 if (copy_size == 0) return;
257 Address to = to_obj->address() + FixedDoubleArray::kHeaderSize; 311 Address to_address = to->address() + FixedDoubleArray::kHeaderSize;
258 Address from = from_obj->address() + FixedDoubleArray::kHeaderSize; 312 Address from_address = from->address() + FixedDoubleArray::kHeaderSize;
259 to += kDoubleSize * to_start; 313 to_address += kDoubleSize * to_start;
260 from += kDoubleSize * from_start; 314 from_address += kDoubleSize * from_start;
261 int words_per_double = (kDoubleSize / kPointerSize); 315 int words_per_double = (kDoubleSize / kPointerSize);
262 CopyWords(reinterpret_cast<Object**>(to), 316 CopyWords(reinterpret_cast<Object**>(to_address),
263 reinterpret_cast<Object**>(from), 317 reinterpret_cast<Object**>(from_address),
264 words_per_double * copy_size); 318 words_per_double * copy_size);
265 } 319 }
266 320
267 321
322 static void CopyObjectToDoubleElements(FixedArray* from,
323 uint32_t from_start,
324 FixedDoubleArray* to,
325 uint32_t to_start,
326 int raw_copy_size) {
327 int copy_size = raw_copy_size;
328 if (raw_copy_size < 0) {
329 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd ||
330 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole);
331 copy_size = from->length() - from_start;
332 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
333 for (int i = to_start + copy_size; i < to->length(); ++i) {
334 to->set_the_hole(i);
335 }
336 }
337 }
338 ASSERT(((copy_size + static_cast<int>(to_start)) <= to->length() &&
Jakob Kummerow 2012/03/12 15:33:28 nit: you can remove at least one pair of parenthes
danno 2012/03/12 20:35:03 Done.
339 (copy_size + static_cast<int>(from_start)) <= from->length()));
340 if (copy_size == 0) return;
341 for (int i = 0; i < copy_size; i++) {
342 Object* hole_or_object = from->get(i + from_start);
343 if (hole_or_object->IsTheHole()) {
344 to->set_the_hole(i + to_start);
345 } else {
346 to->set(i + to_start, hole_or_object->Number());
347 }
348 }
349 }
350
351
352 static void CopyDictionaryToDoubleElements(SeededNumberDictionary* from,
353 uint32_t from_start,
354 FixedDoubleArray* to,
355 uint32_t to_start,
356 int raw_copy_size) {
357 int copy_size = raw_copy_size;
358 if (copy_size < 0) {
359 ASSERT(copy_size == ElementsAccessor::kCopyToEnd ||
360 copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole);
361 copy_size = from->max_number_key() + 1 - from_start;
362 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
363 for (int i = to_start + copy_size; i < to->length(); ++i) {
364 to->set_the_hole(i);
365 }
366 }
367 }
368 ASSERT(copy_size + static_cast<int>(to_start) <= to->length());
369 if (copy_size == 0) return;
370 for (int i = 0; i < copy_size; i++) {
371 int entry = from->FindEntry(i + from_start);
372 if (entry != SeededNumberDictionary::kNotFound) {
373 to->set(i + to_start, from->ValueAt(entry)->Number());
374 } else {
375 to->set_the_hole(i + to_start);
376 }
377 }
378 }
379
380
268 // Base class for element handler implementations. Contains the 381 // Base class for element handler implementations. Contains the
269 // the common logic for objects with different ElementsKinds. 382 // the common logic for objects with different ElementsKinds.
270 // Subclasses must specialize method for which the element 383 // Subclasses must specialize method for which the element
271 // implementation differs from the base class implementation. 384 // implementation differs from the base class implementation.
272 // 385 //
273 // This class is intended to be used in the following way: 386 // This class is intended to be used in the following way:
274 // 387 //
275 // class SomeElementsAccessor : 388 // class SomeElementsAccessor :
276 // public ElementsAccessorBase<SomeElementsAccessor, 389 // public ElementsAccessorBase<SomeElementsAccessor,
277 // BackingStoreClass> { 390 // BackingStoreClass> {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 475
363 virtual MaybeObject* Delete(JSObject* obj, 476 virtual MaybeObject* Delete(JSObject* obj,
364 uint32_t key, 477 uint32_t key,
365 JSReceiver::DeleteMode mode) = 0; 478 JSReceiver::DeleteMode mode) = 0;
366 479
367 static MaybeObject* CopyElementsImpl(FixedArrayBase* from, 480 static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
368 uint32_t from_start, 481 uint32_t from_start,
369 FixedArrayBase* to, 482 FixedArrayBase* to,
370 ElementsKind to_kind, 483 ElementsKind to_kind,
371 uint32_t to_start, 484 uint32_t to_start,
372 int copy_size) { 485 int copy_size,
486 WriteBarrierMode mode) {
373 UNREACHABLE(); 487 UNREACHABLE();
374 return NULL; 488 return NULL;
375 } 489 }
376 490
377 virtual MaybeObject* CopyElements(JSObject* from_holder, 491 virtual MaybeObject* CopyElements(JSObject* from_holder,
378 uint32_t from_start, 492 uint32_t from_start,
379 FixedArrayBase* to, 493 FixedArrayBase* to,
380 ElementsKind to_kind, 494 ElementsKind to_kind,
381 uint32_t to_start, 495 uint32_t to_start,
382 int copy_size, 496 int copy_size,
497 WriteBarrierMode mode,
383 FixedArrayBase* from) { 498 FixedArrayBase* from) {
384 if (from == NULL) { 499 if (from == NULL) {
385 from = from_holder->elements(); 500 from = from_holder->elements();
386 } 501 }
502 if (from->length() == 0) {
503 return from;
504 }
387 return ElementsAccessorSubclass::CopyElementsImpl( 505 return ElementsAccessorSubclass::CopyElementsImpl(
388 from, from_start, to, to_kind, to_start, copy_size); 506 from, from_start, to, to_kind, to_start, copy_size, mode);
389 } 507 }
390 508
391 virtual MaybeObject* AddElementsToFixedArray(Object* receiver, 509 virtual MaybeObject* AddElementsToFixedArray(Object* receiver,
392 JSObject* holder, 510 JSObject* holder,
393 FixedArray* to, 511 FixedArray* to,
394 FixedArrayBase* from) { 512 FixedArrayBase* from) {
395 int len0 = to->length(); 513 int len0 = to->length();
396 #ifdef DEBUG 514 #ifdef DEBUG
397 if (FLAG_enable_slow_asserts) { 515 if (FLAG_enable_slow_asserts) {
398 for (int i = 0; i < len0; i++) { 516 for (int i = 0; i < len0; i++) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 } 733 }
616 } 734 }
617 return heap->true_value(); 735 return heap->true_value();
618 } 736 }
619 737
620 static MaybeObject* CopyElementsImpl(FixedArrayBase* from, 738 static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
621 uint32_t from_start, 739 uint32_t from_start,
622 FixedArrayBase* to, 740 FixedArrayBase* to,
623 ElementsKind to_kind, 741 ElementsKind to_kind,
624 uint32_t to_start, 742 uint32_t to_start,
625 int copy_size) { 743 int copy_size,
744 WriteBarrierMode mode) {
626 switch (to_kind) { 745 switch (to_kind) {
627 case FAST_SMI_ONLY_ELEMENTS: 746 case FAST_SMI_ONLY_ELEMENTS:
628 case FAST_ELEMENTS: { 747 case FAST_ELEMENTS: {
629 AssertNoAllocation no_gc;
630 CopyObjectToObjectElements( 748 CopyObjectToObjectElements(
631 &no_gc, FixedArray::cast(from), ElementsTraits::Kind, from_start, 749 FixedArray::cast(from), ElementsTraits::Kind, from_start,
632 FixedArray::cast(to), to_kind, to_start, copy_size); 750 FixedArray::cast(to), to_kind, to_start, copy_size, mode);
633 return from; 751 return from;
634 } 752 }
753 case FAST_DOUBLE_ELEMENTS:
754 CopyObjectToDoubleElements(
755 FixedArray::cast(from), from_start,
756 FixedDoubleArray::cast(to), to_start, copy_size);
757 return from;
635 default: 758 default:
636 UNREACHABLE(); 759 UNREACHABLE();
637 } 760 }
638 return to->GetHeap()->undefined_value(); 761 return to->GetHeap()->undefined_value();
639 } 762 }
640 763
641 764
642 static MaybeObject* SetFastElementsCapacityAndLength(JSObject* obj, 765 static MaybeObject* SetFastElementsCapacityAndLength(JSObject* obj,
643 uint32_t capacity, 766 uint32_t capacity,
644 uint32_t length) { 767 uint32_t length) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 ElementsKindTraits<FAST_DOUBLE_ELEMENTS> >; 808 ElementsKindTraits<FAST_DOUBLE_ELEMENTS> >;
686 friend class FastElementsAccessor<FastDoubleElementsAccessor, 809 friend class FastElementsAccessor<FastDoubleElementsAccessor,
687 ElementsKindTraits<FAST_DOUBLE_ELEMENTS>, 810 ElementsKindTraits<FAST_DOUBLE_ELEMENTS>,
688 kDoubleSize>; 811 kDoubleSize>;
689 812
690 static MaybeObject* CopyElementsImpl(FixedArrayBase* from, 813 static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
691 uint32_t from_start, 814 uint32_t from_start,
692 FixedArrayBase* to, 815 FixedArrayBase* to,
693 ElementsKind to_kind, 816 ElementsKind to_kind,
694 uint32_t to_start, 817 uint32_t to_start,
695 int copy_size) { 818 int copy_size,
819 WriteBarrierMode mode) {
696 switch (to_kind) { 820 switch (to_kind) {
697 case FAST_SMI_ONLY_ELEMENTS: 821 case FAST_SMI_ONLY_ELEMENTS:
698 case FAST_ELEMENTS: 822 case FAST_ELEMENTS:
699 return CopyDoubleToObjectElements( 823 return CopyDoubleToObjectElements(
700 FixedDoubleArray::cast(from), from_start, FixedArray::cast(to), 824 FixedDoubleArray::cast(from), from_start, FixedArray::cast(to),
701 to_kind, to_start, copy_size); 825 to_kind, to_start, copy_size);
702 case FAST_DOUBLE_ELEMENTS: 826 case FAST_DOUBLE_ELEMENTS:
703 CopyDoubleToDoubleElements(FixedDoubleArray::cast(from), from_start, 827 CopyDoubleToDoubleElements(FixedDoubleArray::cast(from), from_start,
704 FixedDoubleArray::cast(to), 828 FixedDoubleArray::cast(to),
705 to_start, copy_size); 829 to_start, copy_size);
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 } 1106 }
983 } 1107 }
984 return heap->true_value(); 1108 return heap->true_value();
985 } 1109 }
986 1110
987 static MaybeObject* CopyElementsImpl(FixedArrayBase* from, 1111 static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
988 uint32_t from_start, 1112 uint32_t from_start,
989 FixedArrayBase* to, 1113 FixedArrayBase* to,
990 ElementsKind to_kind, 1114 ElementsKind to_kind,
991 uint32_t to_start, 1115 uint32_t to_start,
992 int copy_size) { 1116 int copy_size,
1117 WriteBarrierMode mode) {
993 switch (to_kind) { 1118 switch (to_kind) {
994 case FAST_SMI_ONLY_ELEMENTS: 1119 case FAST_SMI_ONLY_ELEMENTS:
995 case FAST_ELEMENTS: 1120 case FAST_ELEMENTS:
996 CopyDictionaryToObjectElements( 1121 CopyDictionaryToObjectElements(
997 SeededNumberDictionary::cast(from), from_start, 1122 SeededNumberDictionary::cast(from), from_start,
998 FixedArray::cast(to), to_kind, to_start, copy_size); 1123 FixedArray::cast(to), to_kind, to_start, copy_size, mode);
1124 return from;
1125 case FAST_DOUBLE_ELEMENTS:
1126 CopyDictionaryToDoubleElements(
1127 SeededNumberDictionary::cast(from), from_start,
1128 FixedDoubleArray::cast(to), to_start, copy_size);
999 return from; 1129 return from;
1000 default: 1130 default:
1001 UNREACHABLE(); 1131 UNREACHABLE();
1002 } 1132 }
1003 return to->GetHeap()->undefined_value(); 1133 return to->GetHeap()->undefined_value();
1004 } 1134 }
1005 1135
1006 1136
1007 protected: 1137 protected:
1008 friend class ElementsAccessorBase<DictionaryElementsAccessor, 1138 friend class ElementsAccessorBase<DictionaryElementsAccessor,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 } 1251 }
1122 } 1252 }
1123 return obj->GetHeap()->true_value(); 1253 return obj->GetHeap()->true_value();
1124 } 1254 }
1125 1255
1126 static MaybeObject* CopyElementsImpl(FixedArrayBase* from, 1256 static MaybeObject* CopyElementsImpl(FixedArrayBase* from,
1127 uint32_t from_start, 1257 uint32_t from_start,
1128 FixedArrayBase* to, 1258 FixedArrayBase* to,
1129 ElementsKind to_kind, 1259 ElementsKind to_kind,
1130 uint32_t to_start, 1260 uint32_t to_start,
1131 int copy_size) { 1261 int copy_size,
1262 WriteBarrierMode mode) {
1132 FixedArray* parameter_map = FixedArray::cast(from); 1263 FixedArray* parameter_map = FixedArray::cast(from);
1133 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); 1264 FixedArray* arguments = FixedArray::cast(parameter_map->get(1));
1134 ElementsAccessor* accessor = ElementsAccessor::ForArray(arguments); 1265 ElementsAccessor* accessor = ElementsAccessor::ForArray(arguments);
1135 return accessor->CopyElements(NULL, from_start, to, to_kind, 1266 return accessor->CopyElements(NULL, from_start, to, to_kind,
1136 to_start, copy_size, arguments); 1267 to_start, copy_size, mode, arguments);
1137 } 1268 }
1138 1269
1139 static uint32_t GetCapacityImpl(FixedArray* parameter_map) { 1270 static uint32_t GetCapacityImpl(FixedArray* parameter_map) {
1140 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); 1271 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1));
1141 return Max(static_cast<uint32_t>(parameter_map->length() - 2), 1272 return Max(static_cast<uint32_t>(parameter_map->length() - 2),
1142 ForArray(arguments)->GetCapacity(arguments)); 1273 ForArray(arguments)->GetCapacity(arguments));
1143 } 1274 }
1144 1275
1145 static uint32_t GetKeyForIndexImpl(FixedArray* dict, 1276 static uint32_t GetKeyForIndexImpl(FixedArray* dict,
1146 uint32_t index) { 1277 uint32_t index) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; 1418 if (!maybe_obj->To(&new_backing_store)) return maybe_obj;
1288 new_backing_store->set(0, length); 1419 new_backing_store->set(0, length);
1289 { MaybeObject* result = array->SetContent(new_backing_store); 1420 { MaybeObject* result = array->SetContent(new_backing_store);
1290 if (result->IsFailure()) return result; 1421 if (result->IsFailure()) return result;
1291 } 1422 }
1292 return array; 1423 return array;
1293 } 1424 }
1294 1425
1295 1426
1296 } } // namespace v8::internal 1427 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698