[serializer]: Fix DisableGCStats

This bug may lead to gc_stats tracing doesn't stop after chrome://tracing stop as expected.

Change-Id: Ibc2ece4c0ad536a99c4aece039ef546d152df10a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3709242
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Jianxiao Lu <jianxiao.lu@intel.com>
Cr-Commit-Position: refs/heads/main@{#81251}
This commit is contained in:
JianxiaoLuIntel 2022-06-17 11:14:41 +08:00 committed by V8 LUCI CQ
parent b84c7dbd7f
commit 6697ae1829

View File

@ -259,17 +259,13 @@ class Deserializer : public SerializerDeserializer {
class V8_NODISCARD DisableGCStats {
public:
explicit DisableGCStats() {
if (V8_LIKELY(!TracingFlags::is_gc_stats_enabled())) return;
was_enabled_ = true;
TracingFlags::gc_stats = false;
}
~DisableGCStats() {
if (V8_LIKELY(!was_enabled_)) return;
TracingFlags::gc_stats = true;
original_gc_stats_ = TracingFlags::gc_stats;
TracingFlags::gc_stats = 0;
}
~DisableGCStats() { TracingFlags::gc_stats = original_gc_stats_; }
private:
bool was_enabled_ = false;
unsigned int original_gc_stats_;
};
DisableGCStats no_gc_stats_;