11cb0ef41Sopenharmony_ci// Copyright 2017 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_HEAP_STRESS_SCAVENGE_OBSERVER_H_
61cb0ef41Sopenharmony_ci#define V8_HEAP_STRESS_SCAVENGE_OBSERVER_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/heap/heap.h"
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_cinamespace v8 {
111cb0ef41Sopenharmony_cinamespace internal {
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciclass StressScavengeObserver : public AllocationObserver {
141cb0ef41Sopenharmony_ci public:
151cb0ef41Sopenharmony_ci  explicit StressScavengeObserver(Heap* heap);
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  void Step(int bytes_allocated, Address soon_object, size_t size) override;
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci  bool HasRequestedGC() const;
201cb0ef41Sopenharmony_ci  void RequestedGCDone();
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci  // The maximum percent of the newspace capacity reached. This is tracked when
231cb0ef41Sopenharmony_ci  // specyfing --fuzzer-gc-analysis.
241cb0ef41Sopenharmony_ci  double MaxNewSpaceSizeReached() const;
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci private:
271cb0ef41Sopenharmony_ci  Heap* heap_;
281cb0ef41Sopenharmony_ci  int limit_percentage_;
291cb0ef41Sopenharmony_ci  bool has_requested_gc_;
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci  double max_new_space_size_reached_;
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci  int NextLimit(int min = 0);
341cb0ef41Sopenharmony_ci};
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci}  // namespace internal
371cb0ef41Sopenharmony_ci}  // namespace v8
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ci#endif  // V8_HEAP_STRESS_SCAVENGE_OBSERVER_H_
40