Commit 97f574a6 authored by Ng Zhi An's avatar Ng Zhi An Committed by V8 LUCI CQ

[cleanup][profiler] Rename CodeEventRecord::NONE to kNoEvent

Make it an enum class too, and fix all the enums to follow style guide.

Fixes a -Wshadow warning, NONE shadows PropertyAttributes::None.

Bug: v8:12244,v8:12245
Change-Id: I9a8181a35d5690a32a6ce58587f0d8704aa1ab40
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3291696
Auto-Submit: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78062}
parent 1efe967b
......@@ -190,7 +190,7 @@ void ProfilerEventsProcessor::StopSynchronously() {
bool ProfilerEventsProcessor::ProcessCodeEvent() {
CodeEventsContainer record;
if (events_buffer_.Dequeue(&record)) {
if (record.generic.type == CodeEventRecord::NATIVE_CONTEXT_MOVE) {
if (record.generic.type == CodeEventRecord::Type::kNativeContextMove) {
NativeContextMoveEventRecord& nc_record =
record.NativeContextMoveEventRecord_;
profiles_->UpdateNativeContextAddressForCurrentProfiles(
......@@ -207,14 +207,14 @@ bool ProfilerEventsProcessor::ProcessCodeEvent() {
void ProfilerEventsProcessor::CodeEventHandler(
const CodeEventsContainer& evt_rec) {
switch (evt_rec.generic.type) {
case CodeEventRecord::CODE_CREATION:
case CodeEventRecord::CODE_MOVE:
case CodeEventRecord::CODE_DISABLE_OPT:
case CodeEventRecord::CODE_DELETE:
case CodeEventRecord::NATIVE_CONTEXT_MOVE:
case CodeEventRecord::Type::kCodeCreation:
case CodeEventRecord::Type::kCodeMove:
case CodeEventRecord::Type::kCodeDisableOpt:
case CodeEventRecord::Type::kCodeDelete:
case CodeEventRecord::Type::kNativeContextMove:
Enqueue(evt_rec);
break;
case CodeEventRecord::CODE_DEOPT: {
case CodeEventRecord::Type::kCodeDeopt: {
const CodeDeoptEventRecord* rec = &evt_rec.CodeDeoptEventRecord_;
Address pc = rec->pc;
int fp_to_sp_delta = rec->fp_to_sp_delta;
......@@ -222,8 +222,8 @@ void ProfilerEventsProcessor::CodeEventHandler(
AddDeoptStack(pc, fp_to_sp_delta);
break;
}
case CodeEventRecord::NONE:
case CodeEventRecord::REPORT_BUILTIN:
case CodeEventRecord::Type::kNoEvent:
case CodeEventRecord::Type::kReportBuiltin:
UNREACHABLE();
}
}
......@@ -378,7 +378,7 @@ void ProfilerCodeObserver::CodeEventHandlerInternal(
CodeEventsContainer record = evt_rec;
switch (evt_rec.generic.type) {
#define PROFILER_TYPE_CASE(type, clss) \
case CodeEventRecord::type: \
case CodeEventRecord::Type::type: \
record.clss##_.UpdateCodeMap(&code_map_); \
break;
......@@ -408,7 +408,7 @@ void ProfilerCodeObserver::LogBuiltins() {
DCHECK(builtins->is_initialized());
for (Builtin builtin = Builtins::kFirst; builtin <= Builtins::kLast;
++builtin) {
CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kReportBuiltin);
ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_;
Code code = builtins->code(builtin);
rec->instruction_start = code.InstructionStart();
......
......@@ -29,22 +29,22 @@ class CpuProfilesCollection;
class Isolate;
class Symbolizer;
#define CODE_EVENTS_TYPE_LIST(V) \
V(CODE_CREATION, CodeCreateEventRecord) \
V(CODE_MOVE, CodeMoveEventRecord) \
V(CODE_DISABLE_OPT, CodeDisableOptEventRecord) \
V(CODE_DEOPT, CodeDeoptEventRecord) \
V(REPORT_BUILTIN, ReportBuiltinEventRecord) \
V(CODE_DELETE, CodeDeleteEventRecord)
#define CODE_EVENTS_TYPE_LIST(V) \
V(kCodeCreation, CodeCreateEventRecord) \
V(kCodeMove, CodeMoveEventRecord) \
V(kCodeDisableOpt, CodeDisableOptEventRecord) \
V(kCodeDeopt, CodeDeoptEventRecord) \
V(kReportBuiltin, ReportBuiltinEventRecord) \
V(kCodeDelete, CodeDeleteEventRecord)
#define VM_EVENTS_TYPE_LIST(V) \
CODE_EVENTS_TYPE_LIST(V) \
V(NATIVE_CONTEXT_MOVE, NativeContextMoveEventRecord)
V(kNativeContextMove, NativeContextMoveEventRecord)
class CodeEventRecord {
public:
#define DECLARE_TYPE(type, ignore) type,
enum Type { NONE = 0, VM_EVENTS_TYPE_LIST(DECLARE_TYPE) };
enum class Type { kNoEvent = 0, VM_EVENTS_TYPE_LIST(DECLARE_TYPE) };
#undef DECLARE_TYPE
Type type;
......@@ -135,7 +135,7 @@ class CodeDeleteEventRecord : public CodeEventRecord {
class CodeEventsContainer {
public:
explicit CodeEventsContainer(
CodeEventRecord::Type type = CodeEventRecord::NONE) {
CodeEventRecord::Type type = CodeEventRecord::Type::kNoEvent) {
generic.type = type;
}
union {
......
......@@ -43,7 +43,7 @@ ProfilerListener::~ProfilerListener() = default;
void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
const char* name) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = code->InstructionStart();
rec->entry =
......@@ -58,7 +58,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
Handle<Name> name) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = code->InstructionStart();
rec->entry =
......@@ -74,7 +74,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = code->InstructionStart();
rec->entry =
......@@ -111,7 +111,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line,
int column) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = abstract_code->InstructionStart();
std::unique_ptr<SourcePositionTable> line_table;
......@@ -235,7 +235,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
wasm::WasmName name,
const char* source_url, int code_offset,
int script_id) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = code->instruction_start();
rec->entry = code_entries_.Create(tag, GetName(name), GetName(source_url), 1,
......@@ -249,7 +249,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
#endif // V8_ENABLE_WEBASSEMBLY
void ProfilerListener::CallbackEvent(Handle<Name> name, Address entry_point) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = entry_point;
rec->entry =
......@@ -260,7 +260,7 @@ void ProfilerListener::CallbackEvent(Handle<Name> name, Address entry_point) {
void ProfilerListener::GetterCallbackEvent(Handle<Name> name,
Address entry_point) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = entry_point;
rec->entry = code_entries_.Create(CodeEventListener::CALLBACK_TAG,
......@@ -271,7 +271,7 @@ void ProfilerListener::GetterCallbackEvent(Handle<Name> name,
void ProfilerListener::SetterCallbackEvent(Handle<Name> name,
Address entry_point) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = entry_point;
rec->entry = code_entries_.Create(CodeEventListener::CALLBACK_TAG,
......@@ -282,7 +282,7 @@ void ProfilerListener::SetterCallbackEvent(Handle<Name> name,
void ProfilerListener::RegExpCodeCreateEvent(Handle<AbstractCode> code,
Handle<String> source) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = code->InstructionStart();
rec->entry = code_entries_.Create(
......@@ -296,7 +296,7 @@ void ProfilerListener::RegExpCodeCreateEvent(Handle<AbstractCode> code,
void ProfilerListener::CodeMoveEvent(AbstractCode from, AbstractCode to) {
DisallowGarbageCollection no_gc;
CodeEventsContainer evt_rec(CodeEventRecord::CODE_MOVE);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeMove);
CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_;
rec->from_instruction_start = from.InstructionStart();
rec->to_instruction_start = to.InstructionStart();
......@@ -304,7 +304,7 @@ void ProfilerListener::CodeMoveEvent(AbstractCode from, AbstractCode to) {
}
void ProfilerListener::NativeContextMoveEvent(Address from, Address to) {
CodeEventsContainer evt_rec(CodeEventRecord::NATIVE_CONTEXT_MOVE);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kNativeContextMove);
evt_rec.NativeContextMoveEventRecord_.from_address = from;
evt_rec.NativeContextMoveEventRecord_.to_address = to;
DispatchCodeEvent(evt_rec);
......@@ -312,7 +312,7 @@ void ProfilerListener::NativeContextMoveEvent(Address from, Address to) {
void ProfilerListener::CodeDisableOptEvent(Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_DISABLE_OPT);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeDisableOpt);
CodeDisableOptEventRecord* rec = &evt_rec.CodeDisableOptEventRecord_;
rec->instruction_start = code->InstructionStart();
rec->bailout_reason =
......@@ -325,7 +325,7 @@ void ProfilerListener::CodeDeoptEvent(Handle<Code> code, DeoptimizeKind kind,
bool reuse_code) {
// When reuse_code is true it is just a bailout and not an actual deopt.
if (reuse_code) return;
CodeEventsContainer evt_rec(CodeEventRecord::CODE_DEOPT);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeDeopt);
CodeDeoptEventRecord* rec = &evt_rec.CodeDeoptEventRecord_;
Deoptimizer::DeoptInfo info = Deoptimizer::GetDeoptInfo(*code, pc);
rec->instruction_start = code->InstructionStart();
......@@ -343,7 +343,7 @@ void ProfilerListener::CodeDeoptEvent(Handle<Code> code, DeoptimizeKind kind,
void ProfilerListener::WeakCodeClearEvent() { weak_code_registry_.Sweep(this); }
void ProfilerListener::OnHeapObjectDeletion(CodeEntry* entry) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_DELETE);
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeDelete);
evt_rec.CodeDeleteEventRecord_.entry = entry;
DispatchCodeEvent(evt_rec);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment