Commit c436429c authored by Michal Majewski's avatar Michal Majewski Committed by Commit Bot

[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: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49907}
parent a743b2c9
...@@ -1690,6 +1690,8 @@ v8_source_set("v8_base") { ...@@ -1690,6 +1690,8 @@ v8_source_set("v8_base") {
"src/heap/spaces.h", "src/heap/spaces.h",
"src/heap/store-buffer.cc", "src/heap/store-buffer.cc",
"src/heap/store-buffer.h", "src/heap/store-buffer.h",
"src/heap/stress-marking-observer.cc",
"src/heap/stress-marking-observer.h",
"src/heap/sweeper.cc", "src/heap/sweeper.cc",
"src/heap/sweeper.h", "src/heap/sweeper.h",
"src/heap/worklist.h", "src/heap/worklist.h",
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "src/heap/scavenge-job.h" #include "src/heap/scavenge-job.h"
#include "src/heap/scavenger-inl.h" #include "src/heap/scavenger-inl.h"
#include "src/heap/store-buffer.h" #include "src/heap/store-buffer.h"
#include "src/heap/stress-marking-observer.h"
#include "src/heap/sweeper.h" #include "src/heap/sweeper.h"
#include "src/interpreter/interpreter.h" #include "src/interpreter/interpreter.h"
#include "src/objects/object-macros.h" #include "src/objects/object-macros.h"
...@@ -172,6 +173,7 @@ Heap::Heap() ...@@ -172,6 +173,7 @@ Heap::Heap()
gc_post_processing_depth_(0), gc_post_processing_depth_(0),
allocations_count_(0), allocations_count_(0),
raw_allocations_hash_(0), raw_allocations_hash_(0),
stress_marking_observer_(nullptr),
ms_count_(0), ms_count_(0),
gc_count_(0), gc_count_(0),
mmap_region_base_(0), mmap_region_base_(0),
...@@ -5658,6 +5660,10 @@ bool Heap::SetUp() { ...@@ -5658,6 +5660,10 @@ bool Heap::SetUp() {
if (FLAG_stress_marking > 0) { if (FLAG_stress_marking > 0) {
stress_marking_percentage_ = NextStressMarkingLimit(); 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; write_protect_code_memory_ = FLAG_write_protect_code_memory;
...@@ -5768,6 +5774,13 @@ void Heap::TearDown() { ...@@ -5768,6 +5774,13 @@ void Heap::TearDown() {
delete idle_scavenge_observer_; delete idle_scavenge_observer_;
idle_scavenge_observer_ = nullptr; 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) { if (mark_compact_collector_ != nullptr) {
mark_compact_collector_->TearDown(); mark_compact_collector_->TearDown();
delete mark_compact_collector_; delete mark_compact_collector_;
......
...@@ -2403,6 +2403,10 @@ class Heap { ...@@ -2403,6 +2403,10 @@ class Heap {
// is reached. // is reached.
int stress_marking_percentage_; 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. // How many mark-sweep collections happened.
unsigned int ms_count_; unsigned int ms_count_;
......
// 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
// 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
...@@ -1044,6 +1044,8 @@ ...@@ -1044,6 +1044,8 @@
'heap/spaces.h', 'heap/spaces.h',
'heap/store-buffer.cc', 'heap/store-buffer.cc',
'heap/store-buffer.h', 'heap/store-buffer.h',
'heap/stress-marking-observer.cc',
'heap/stress-marking-observer.h',
'heap/sweeper.cc', 'heap/sweeper.cc',
'heap/sweeper.h', 'heap/sweeper.h',
'heap/worklist.h', 'heap/worklist.h',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment