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 namespace v8 { 11 namespace internal { 12 13 class LocalHeap; 14 15 // This method generates a tick. Also makes the current thread to enter a 16 // safepoint iff it was required to do so. The tick is used as a deterministic 17 // correlate of time to detect performance or divergence bugs in Turbofan. 18 // TickAndMaybeEnterSafepoint() should be called frequently thoughout the 19 // compilation. 20 class TickCounter { 21 public: 22 void TickAndMaybeEnterSafepoint(); 23 void AttachLocalHeap(LocalHeap* local_heap); 24 void DetachLocalHeap(); CurrentTicks()25 size_t CurrentTicks() const { return ticks_; } 26 27 private: 28 size_t ticks_ = 0; 29 LocalHeap* local_heap_ = nullptr; 30 }; 31 32 } // namespace internal 33 } // namespace v8 34 35 #endif // V8_CODEGEN_TICK_COUNTER_H_ 36