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

Side by Side Diff: src/builtins.cc

Issue 1701008: Remove duplicate LeftTrimFixedArray function. (Closed)
Patch Set: Created 10 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 Heap::RecordWrites(dst->address(), dst->OffsetOfElementAt(dst_index), len); 293 Heap::RecordWrites(dst->address(), dst->OffsetOfElementAt(dst_index), len);
294 } 294 }
295 } 295 }
296 296
297 297
298 static void FillWithHoles(FixedArray* dst, int from, int to) { 298 static void FillWithHoles(FixedArray* dst, int from, int to) {
299 MemsetPointer(dst->data_start() + from, Heap::the_hole_value(), to - from); 299 MemsetPointer(dst->data_start() + from, Heap::the_hole_value(), to - from);
300 } 300 }
301 301
302 302
303 static FixedArray* LeftTrimFixedArray(FixedArray* elms) {
304 // For now this trick is only applied to fixed arrays in new space.
305 // In large object space the object's start must coincide with chunk
306 // and thus the trick is just not applicable.
307 // In old space we do not use this trick to avoid dealing with
308 // remembered sets.
309 ASSERT(Heap::new_space()->Contains(elms));
310
311 STATIC_ASSERT(FixedArray::kMapOffset == 0);
312 STATIC_ASSERT(FixedArray::kLengthOffset == kPointerSize);
313 STATIC_ASSERT(FixedArray::kHeaderSize == 2 * kPointerSize);
314
315 Object** former_start = HeapObject::RawField(elms, 0);
316
317 const int len = elms->length();
318
319 // Technically in new space this write might be omitted (except for
320 // debug mode which iterates through the heap), but to play safer
321 // we still do it.
322 former_start[0] = Heap::raw_unchecked_one_pointer_filler_map();
323
324 former_start[1] = Heap::fixed_array_map();
325 former_start[2] = reinterpret_cast<Object*>(len - 1);
326
327 ASSERT_EQ(elms->address() + kPointerSize, (elms + kPointerSize)->address());
328 return elms + kPointerSize;
329 }
330
331
332 static FixedArray* LeftTrimFixedArray(FixedArray* elms, int to_trim) { 303 static FixedArray* LeftTrimFixedArray(FixedArray* elms, int to_trim) {
333 // For now this trick is only applied to fixed arrays in new space. 304 // For now this trick is only applied to fixed arrays in new space.
334 // In large object space the object's start must coincide with chunk 305 // In large object space the object's start must coincide with chunk
335 // and thus the trick is just not applicable. 306 // and thus the trick is just not applicable.
336 // In old space we do not use this trick to avoid dealing with 307 // In old space we do not use this trick to avoid dealing with
337 // remembered sets. 308 // remembered sets.
338 ASSERT(Heap::new_space()->Contains(elms)); 309 ASSERT(Heap::new_space()->Contains(elms));
339 310
340 STATIC_ASSERT(FixedArray::kMapOffset == 0); 311 STATIC_ASSERT(FixedArray::kMapOffset == 0);
341 STATIC_ASSERT(FixedArray::kLengthOffset == kPointerSize); 312 STATIC_ASSERT(FixedArray::kLengthOffset == kPointerSize);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 491
521 // Get first element 492 // Get first element
522 Object* first = elms->get(0); 493 Object* first = elms->get(0);
523 if (first->IsTheHole()) { 494 if (first->IsTheHole()) {
524 first = Heap::undefined_value(); 495 first = Heap::undefined_value();
525 } 496 }
526 497
527 if (Heap::new_space()->Contains(elms)) { 498 if (Heap::new_space()->Contains(elms)) {
528 // As elms still in the same space they used to be (new space), 499 // As elms still in the same space they used to be (new space),
529 // there is no need to update remembered set. 500 // there is no need to update remembered set.
530 array->set_elements(LeftTrimFixedArray(elms), SKIP_WRITE_BARRIER); 501 array->set_elements(LeftTrimFixedArray(elms, 1), SKIP_WRITE_BARRIER);
531 } else { 502 } else {
532 // Shift the elements. 503 // Shift the elements.
533 AssertNoAllocation no_gc; 504 AssertNoAllocation no_gc;
534 MoveElements(&no_gc, elms, 0, elms, 1, len - 1); 505 MoveElements(&no_gc, elms, 0, elms, 1, len - 1);
535 elms->set(len - 1, Heap::the_hole_value()); 506 elms->set(len - 1, Heap::the_hole_value());
536 } 507 }
537 508
538 // Set the length. 509 // Set the length.
539 array->set_length(Smi::FromInt(len - 1)); 510 array->set_length(Smi::FromInt(len - 1));
540 511
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 if (entry->contains(pc)) { 1503 if (entry->contains(pc)) {
1533 return names_[i]; 1504 return names_[i];
1534 } 1505 }
1535 } 1506 }
1536 } 1507 }
1537 return NULL; 1508 return NULL;
1538 } 1509 }
1539 1510
1540 1511
1541 } } // namespace v8::internal 1512 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698