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

Side by Side Diff: src/heap/heap.cc

Issue 1075233002: Version 4.3.61.6 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.3
Patch Set: Created 5 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 | « include/v8-version.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 3504 matching lines...) Expand 10 before | Expand all | Expand 10 after
3515 MemoryChunk::IncrementLiveBytesFromGC(address, by); 3515 MemoryChunk::IncrementLiveBytesFromGC(address, by);
3516 } else { 3516 } else {
3517 MemoryChunk::IncrementLiveBytesFromMutator(address, by); 3517 MemoryChunk::IncrementLiveBytesFromMutator(address, by);
3518 } 3518 }
3519 } 3519 }
3520 } 3520 }
3521 3521
3522 3522
3523 FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object, 3523 FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object,
3524 int elements_to_trim) { 3524 int elements_to_trim) {
3525 DCHECK(!object->IsFixedTypedArrayBase());
3525 const int element_size = object->IsFixedArray() ? kPointerSize : kDoubleSize; 3526 const int element_size = object->IsFixedArray() ? kPointerSize : kDoubleSize;
3526 const int bytes_to_trim = elements_to_trim * element_size; 3527 const int bytes_to_trim = elements_to_trim * element_size;
3527 Map* map = object->map(); 3528 Map* map = object->map();
3528 3529
3529 // For now this trick is only applied to objects in new and paged space. 3530 // For now this trick is only applied to objects in new and paged space.
3530 // In large object space the object's start must coincide with chunk 3531 // In large object space the object's start must coincide with chunk
3531 // and thus the trick is just not applicable. 3532 // and thus the trick is just not applicable.
3532 DCHECK(!lo_space()->Contains(object)); 3533 DCHECK(!lo_space()->Contains(object));
3533 DCHECK(object->map() != fixed_cow_array_map()); 3534 DCHECK(object->map() != fixed_cow_array_map());
3534 3535
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3570 3571
3571 // Force instantiation of templatized method. 3572 // Force instantiation of templatized method.
3572 template 3573 template
3573 void Heap::RightTrimFixedArray<Heap::FROM_GC>(FixedArrayBase*, int); 3574 void Heap::RightTrimFixedArray<Heap::FROM_GC>(FixedArrayBase*, int);
3574 template 3575 template
3575 void Heap::RightTrimFixedArray<Heap::FROM_MUTATOR>(FixedArrayBase*, int); 3576 void Heap::RightTrimFixedArray<Heap::FROM_MUTATOR>(FixedArrayBase*, int);
3576 3577
3577 3578
3578 template<Heap::InvocationMode mode> 3579 template<Heap::InvocationMode mode>
3579 void Heap::RightTrimFixedArray(FixedArrayBase* object, int elements_to_trim) { 3580 void Heap::RightTrimFixedArray(FixedArrayBase* object, int elements_to_trim) {
3580 const int element_size = object->IsFixedArray() ? kPointerSize : kDoubleSize; 3581 const int len = object->length();
3581 const int bytes_to_trim = elements_to_trim * element_size; 3582 DCHECK(elements_to_trim < len);
3583
3584 int bytes_to_trim;
3585 if (object->IsFixedTypedArrayBase()) {
3586 InstanceType type = object->map()->instance_type();
3587 bytes_to_trim =
3588 FixedTypedArrayBase::TypedArraySize(type, len) -
3589 FixedTypedArrayBase::TypedArraySize(type, len - elements_to_trim);
3590 } else {
3591 const int element_size =
3592 object->IsFixedArray() ? kPointerSize : kDoubleSize;
3593 bytes_to_trim = elements_to_trim * element_size;
3594 }
3582 3595
3583 // For now this trick is only applied to objects in new and paged space. 3596 // For now this trick is only applied to objects in new and paged space.
3584 DCHECK(object->map() != fixed_cow_array_map()); 3597 DCHECK(object->map() != fixed_cow_array_map());
3585 3598
3586 const int len = object->length(); 3599 if (bytes_to_trim == 0) {
3587 DCHECK(elements_to_trim < len); 3600 // No need to create filler and update live bytes counters, just initialize
3601 // header of the trimmed array.
3602 object->synchronized_set_length(len - elements_to_trim);
3603 return;
3604 }
3588 3605
3589 // Calculate location of new array end. 3606 // Calculate location of new array end.
3590 Address new_end = object->address() + object->Size() - bytes_to_trim; 3607 Address new_end = object->address() + object->Size() - bytes_to_trim;
3591 3608
3592 // Technically in new space this write might be omitted (except for 3609 // Technically in new space this write might be omitted (except for
3593 // debug mode which iterates through the heap), but to play safer 3610 // debug mode which iterates through the heap), but to play safer
3594 // we still do it. 3611 // we still do it.
3595 // We do not create a filler for objects in large object space. 3612 // We do not create a filler for objects in large object space.
3596 // TODO(hpayer): We should shrink the large object page if the size 3613 // TODO(hpayer): We should shrink the large object page if the size
3597 // of the object changed significantly. 3614 // of the object changed significantly.
(...skipping 2797 matching lines...) Expand 10 before | Expand all | Expand 10 after
6395 static_cast<int>(object_sizes_last_time_[index])); 6412 static_cast<int>(object_sizes_last_time_[index]));
6396 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6413 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6397 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6414 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6398 6415
6399 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6416 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6400 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6417 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6401 ClearObjectStats(); 6418 ClearObjectStats();
6402 } 6419 }
6403 } 6420 }
6404 } // namespace v8::internal 6421 } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8-version.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698