[test] AllocationObserver for stress marking.

Observer that increases frequency of checking if we reached
marking limit. Works only with --stress-marking.

Bug: v8:6972
Change-Id: I13544fdd8bb33738d78adbac96feb70222b5b634
Reviewed-on: https://chromium-review.googlesource.com/802434
Commit-Queue: Michał Majewski <majeski@google.com>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49907}
This commit is contained in:
Michal Majewski 2017-12-06 18:35:07 +01:00 committed by Commit Bot
parent a743b2c97e
commit c436429c0e
6 changed files with 68 additions and 0 deletions

View File

@ -1690,6 +1690,8 @@ v8_source_set("v8_base") {
"src/heap/spaces.h",
"src/heap/store-buffer.cc",
"src/heap/store-buffer.h",
"src/heap/stress-marking-observer.cc",
"src/heap/stress-marking-observer.h",
"src/heap/sweeper.cc",
"src/heap/sweeper.h",
"src/heap/worklist.h",

View File

@ -43,6 +43,7 @@
#include "src/heap/scavenge-job.h"
#include "src/heap/scavenger-inl.h"
#include "src/heap/store-buffer.h"
#include "src/heap/stress-marking-observer.h"
#include "src/heap/sweeper.h"
#include "src/interpreter/interpreter.h"
#include "src/objects/object-macros.h"
@ -172,6 +173,7 @@ Heap::Heap()
gc_post_processing_depth_(0),
allocations_count_(0),
raw_allocations_hash_(0),
stress_marking_observer_(nullptr),
ms_count_(0),
gc_count_(0),
mmap_region_base_(0),
@ -5658,6 +5660,10 @@ bool Heap::SetUp() {
if (FLAG_stress_marking > 0) {
stress_marking_percentage_ = NextStressMarkingLimit();
stress_marking_observer_ = new StressMarkingObserver(*this);
AddAllocationObserversToAllSpaces(stress_marking_observer_,
stress_marking_observer_);
}
write_protect_code_memory_ = FLAG_write_protect_code_memory;
@ -5768,6 +5774,13 @@ void Heap::TearDown() {
delete idle_scavenge_observer_;
idle_scavenge_observer_ = nullptr;
if (FLAG_stress_marking > 0) {
RemoveAllocationObserversFromAllSpaces(stress_marking_observer_,
stress_marking_observer_);
delete stress_marking_observer_;
stress_marking_observer_ = nullptr;
}
if (mark_compact_collector_ != nullptr) {
mark_compact_collector_->TearDown();
delete mark_compact_collector_;

View File

@ -2403,6 +2403,10 @@ class Heap {
// is reached.
int stress_marking_percentage_;
// Observer that causes more frequent checks for reached incremental marking
// limit.
AllocationObserver* stress_marking_observer_;
// How many mark-sweep collections happened.
unsigned int ms_count_;

View File

@ -0,0 +1,21 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/heap/stress-marking-observer.h"
namespace v8 {
namespace internal {
// TODO(majeski): meaningful step_size
StressMarkingObserver::StressMarkingObserver(Heap& heap)
: AllocationObserver(64), heap_(heap) {}
void StressMarkingObserver::Step(int bytes_allocated, Address soon_object,
size_t size) {
heap_.StartIncrementalMarkingIfAllocationLimitIsReached(Heap::kNoGCFlags,
kNoGCCallbackFlags);
}
} // namespace internal
} // namespace v8

View File

@ -0,0 +1,26 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_HEAP_STRESS_MARKING_OBSERVER_H_
#define V8_HEAP_STRESS_MARKING_OBSERVER_H_
#include "src/heap/heap.h"
namespace v8 {
namespace internal {
class StressMarkingObserver : public AllocationObserver {
public:
explicit StressMarkingObserver(Heap& heap);
void Step(int bytes_allocated, Address soon_object, size_t size) override;
private:
Heap& heap_;
};
} // namespace internal
} // namespace v8
#endif

View File

@ -1044,6 +1044,8 @@
'heap/spaces.h',
'heap/store-buffer.cc',
'heap/store-buffer.h',
'heap/stress-marking-observer.cc',
'heap/stress-marking-observer.h',
'heap/sweeper.cc',
'heap/sweeper.h',
'heap/worklist.h',