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
13
namespace
v8
{
14
namespace
internal
{
15
16
class
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.
23
class
TickCounter
{
24
public
:
25
void
TickAndMaybeEnterSafepoint
() {
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
33
if
(
local_heap_
)
local_heap_
->
Safepoint
();
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;
41
LocalHeap
*
local_heap_
=
nullptr
;
42
};
43
44
}
// namespace internal
45
}
// namespace v8
46
47
#endif
// V8_CODEGEN_TICK_COUNTER_H_
v8::internal::LocalHeap
Definition
local-heap.h:50
v8::internal::LocalHeap::Safepoint
void Safepoint()
Definition
local-heap.h:61
v8::internal::TickCounter
Definition
tick-counter.h:23
v8::internal::TickCounter::TickAndMaybeEnterSafepoint
void TickAndMaybeEnterSafepoint()
Definition
tick-counter.h:25
v8::internal::TickCounter::CurrentTicks
size_t CurrentTicks() const
Definition
tick-counter.h:37
v8::internal::TickCounter::local_heap_
LocalHeap * local_heap_
Definition
tick-counter.h:41
v8::internal::TickCounter::AttachLocalHeap
void AttachLocalHeap(LocalHeap *local_heap)
Definition
tick-counter.cc:14
v8::internal::TickCounter::DetachLocalHeap
void DetachLocalHeap()
Definition
tick-counter.cc:20
v8::internal::TickCounter::ticks_
size_t ticks_
Definition
tick-counter.h:40
local-heap.h
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
DCHECK_LT
#define DCHECK_LT(v1, v2)
Definition
logging.h:489
macros.h
USE
#define USE(...)
Definition
macros.h:293
src
codegen
tick-counter.h
Generated on Sun Apr 6 2025 21:08:51 for v8 by
1.12.0