v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
tick-counter.h
Go to the documentation of this file.
1// Copyright 2019 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_CODEGEN_TICK_COUNTER_H_
6#define V8_CODEGEN_TICK_COUNTER_H_
7
8#include <cstddef>
9
10#include "src/base/macros.h"
11#include "src/heap/local-heap.h"
12
13namespace v8 {
14namespace internal {
15
16class LocalHeap;
17
18// This method generates a tick. Also makes the current thread to enter a
19// safepoint iff it was required to do so. The tick is used as a deterministic
20// correlate of time to detect performance or divergence bugs in Turbofan.
21// TickAndMaybeEnterSafepoint() should be called frequently thoughout the
22// compilation.
24 public:
26 ++ticks_;
27 // Magical number to detect performance bugs or compiler divergence.
28 // Selected as being roughly 10x of what's needed frequently.
29 constexpr size_t kMaxTicks = 100000000;
30 USE(kMaxTicks);
31 DCHECK_LT(ticks_, kMaxTicks);
32
34 }
35 void AttachLocalHeap(LocalHeap* local_heap);
36 void DetachLocalHeap();
37 size_t CurrentTicks() const { return ticks_; }
38
39 private:
40 size_t ticks_ = 0;
42};
43
44} // namespace internal
45} // namespace v8
46
47#endif // V8_CODEGEN_TICK_COUNTER_H_
size_t CurrentTicks() const
void AttachLocalHeap(LocalHeap *local_heap)
#define DCHECK_LT(v1, v2)
Definition logging.h:489
#define USE(...)
Definition macros.h:293