if (length == 0) {
array->initialize_elements();
} else {
- isolate->heap()->RightTrimFixedArray<Heap::FROM_MUTATOR>(
+ isolate->heap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(
*backing_store, old_capacity - length);
}
} else {
if (size_difference > 0) {
Address address = proxy->address();
heap->CreateFillerObjectAt(address + map->instance_size(), size_difference);
- heap->AdjustLiveBytes(address, -size_difference, Heap::FROM_MUTATOR);
+ heap->AdjustLiveBytes(address, -size_difference,
+ Heap::CONCURRENT_TO_SWEEPER);
}
// Reset the map for the object.
void Heap::AdjustLiveBytes(Address address, int by, InvocationMode mode) {
if (incremental_marking()->IsMarking() &&
Marking::IsBlack(Marking::MarkBitFrom(address))) {
- if (mode == FROM_GC) {
+ if (mode == SEQUENTIAL_TO_SWEEPER) {
MemoryChunk::IncrementLiveBytesFromGC(address, by);
} else {
MemoryChunk::IncrementLiveBytesFromMutator(address, by);
// Maintain consistency of live bytes during incremental marking
marking()->TransferMark(object->address(), new_start);
- AdjustLiveBytes(new_start, -bytes_to_trim, Heap::FROM_MUTATOR);
+ AdjustLiveBytes(new_start, -bytes_to_trim, Heap::CONCURRENT_TO_SWEEPER);
// Notify the heap profiler of change in object layout.
OnMoveEvent(new_object, object, new_object->Size());
// Force instantiation of templatized method.
-template
-void Heap::RightTrimFixedArray<Heap::FROM_GC>(FixedArrayBase*, int);
-template
-void Heap::RightTrimFixedArray<Heap::FROM_MUTATOR>(FixedArrayBase*, int);
+template void Heap::RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(
+ FixedArrayBase*, int);
+template void Heap::RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(
+ FixedArrayBase*, int);
template<Heap::InvocationMode mode>
bool CanMoveObjectStart(HeapObject* object);
- // Indicates whether live bytes adjustment is triggered from within the GC
- // code or from mutator code.
- enum InvocationMode { FROM_GC, FROM_MUTATOR };
+ // Indicates whether live bytes adjustment is triggered
+ // - from within the GC code before sweeping started (SEQUENTIAL_TO_SWEEPER),
+ // - or from within GC (CONCURRENT_TO_SWEEPER),
+ // - or mutator code (CONCURRENT_TO_SWEEPER).
+ enum InvocationMode { SEQUENTIAL_TO_SWEEPER, CONCURRENT_TO_SWEEPER };
// Maintain consistency of live bytes during incremental marking.
void AdjustLiveBytes(Address address, int by, InvocationMode mode);
// Non-full-TransitionArray cases can never reach this point.
DCHECK(TransitionArray::IsFullTransitionArray(transitions));
TransitionArray* t = TransitionArray::cast(transitions);
- heap_->RightTrimFixedArray<Heap::FROM_GC>(
+ heap_->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(
t, trim * TransitionArray::kTransitionSize);
t->SetNumberOfTransitions(transition_index);
// The map still has a full transition array.
int to_trim = number_of_descriptors - number_of_own_descriptors;
if (to_trim == 0) return;
- heap_->RightTrimFixedArray<Heap::FROM_GC>(
+ heap_->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(
descriptors, to_trim * DescriptorArray::kDescriptorSize);
descriptors->SetNumberOfDescriptors(number_of_own_descriptors);
int to_trim = enum_cache->length() - live_enum;
if (to_trim <= 0) return;
- heap_->RightTrimFixedArray<Heap::FROM_GC>(descriptors->GetEnumCache(),
- to_trim);
+ heap_->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(
+ descriptors->GetEnumCache(), to_trim);
if (!descriptors->HasEnumIndicesCache()) return;
FixedArray* enum_indices_cache = descriptors->GetEnumIndicesCache();
- heap_->RightTrimFixedArray<Heap::FROM_GC>(enum_indices_cache, to_trim);
+ heap_->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(enum_indices_cache,
+ to_trim);
}
if (new_length == 0) {
heap()->set_detached_contexts(heap()->empty_fixed_array());
} else if (new_length < length) {
- heap()->RightTrimFixedArray<Heap::FROM_MUTATOR>(*detached_contexts,
- length - new_length);
+ heap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(
+ *detached_contexts, length - new_length);
}
}
if (current_length != array_length) {
DCHECK_LT(array_length, current_length);
int delta = current_length - array_length;
- heap->RightTrimFixedArray<Heap::FROM_GC>(this, delta);
+ heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(this, delta);
}
memset(DataPtr(), 0, DataSize());
LayoutDescriptor* layout_descriptor =
self->set_resource(resource);
if (is_internalized) self->Hash(); // Force regeneration of the hash value.
- heap->AdjustLiveBytes(this->address(), new_size - size, Heap::FROM_MUTATOR);
+ heap->AdjustLiveBytes(this->address(), new_size - size,
+ Heap::CONCURRENT_TO_SWEEPER);
return true;
}
self->set_resource(resource);
if (is_internalized) self->Hash(); // Force regeneration of the hash value.
- heap->AdjustLiveBytes(this->address(), new_size - size, Heap::FROM_MUTATOR);
+ heap->AdjustLiveBytes(this->address(), new_size - size,
+ Heap::CONCURRENT_TO_SWEEPER);
return true;
}
// If there are properties in the new backing store, trim it to the correct
// size and install the backing store into the object.
if (external > 0) {
- heap->RightTrimFixedArray<Heap::FROM_MUTATOR>(*array, inobject);
+ heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(*array, inobject);
object->set_properties(*array);
}
Address address = object->address();
heap->CreateFillerObjectAt(
address + new_instance_size, instance_size_delta);
- heap->AdjustLiveBytes(address, -instance_size_delta, Heap::FROM_MUTATOR);
+ heap->AdjustLiveBytes(address, -instance_size_delta,
+ Heap::CONCURRENT_TO_SWEEPER);
}
// We are storing the new map using release store after creating a filler for
heap->CreateFillerObjectAt(object->address() + new_instance_size,
instance_size_delta);
heap->AdjustLiveBytes(object->address(), -instance_size_delta,
- Heap::FROM_MUTATOR);
+ Heap::CONCURRENT_TO_SWEEPER);
}
// We are storing the new map using release store after creating a filler for
void FixedArray::Shrink(int new_length) {
DCHECK(0 <= new_length && new_length <= length());
if (new_length < length()) {
- GetHeap()->RightTrimFixedArray<Heap::FROM_MUTATOR>(
+ GetHeap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(
this, length() - new_length);
}
}
// that are a multiple of pointer size.
heap->CreateFillerObjectAt(start_of_string + new_size, delta);
}
- heap->AdjustLiveBytes(start_of_string, -delta, Heap::FROM_MUTATOR);
+ heap->AdjustLiveBytes(start_of_string, -delta, Heap::CONCURRENT_TO_SWEEPER);
// We are storing the new length using release store after creating a filler
// for the left-over space to avoid races with the sweeper thread.
}
if (dst != length) {
// Always trim even when array is cleared because of heap verifier.
- GetHeap()->RightTrimFixedArray<Heap::FROM_MUTATOR>(code_map, length - dst);
+ GetHeap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(code_map,
+ length - dst);
if (code_map->length() == kEntriesStart) ClearOptimizedCodeMap();
}
}
DCHECK(shrink_by % kEntryLength == 0);
DCHECK(shrink_by <= code_map->length() - kEntriesStart);
// Always trim even when array is cleared because of heap verifier.
- GetHeap()->RightTrimFixedArray<Heap::FROM_GC>(code_map, shrink_by);
+ GetHeap()->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(code_map,
+ shrink_by);
if (code_map->length() == kEntriesStart) {
ClearOptimizedCodeMap();
}
class BodyDescriptor : public FlexibleBodyDescriptor<kHeaderSize> {
public:
static inline int SizeOf(Map* map, HeapObject* object) {
- return SizeFor(reinterpret_cast<FixedArray*>(object)->length());
+ return SizeFor(
+ reinterpret_cast<FixedArray*>(object)->synchronized_length());
}
};
// thread can not get confused with the filler creation. No synchronization
// needed.
heap->CreateFillerObjectAt(end_of_string, delta);
- heap->AdjustLiveBytes(answer->address(), -delta, Heap::FROM_MUTATOR);
+ heap->AdjustLiveBytes(answer->address(), -delta, Heap::CONCURRENT_TO_SWEEPER);
return *answer;
}
Handle<FixedTypedArrayBase> array =
factory->NewFixedTypedArray(initial_length, type);
int old_size = array->size();
- heap->RightTrimFixedArray<Heap::FROM_MUTATOR>(*array, elements_to_trim);
+ heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(*array,
+ elements_to_trim);
// Check that free space filler is at the right place and did not smash the
// array header.