Commit ed6be498 authored by Camillo's avatar Camillo Committed by V8 LUCI CQ

[logging] Use short "JS:" prefix for function log events

"Function:" and "LazyCompile:" are confusing by now and use up too
much space.# Enter a description of the change.

This also changes the function names visible when using linux-perf

Change-Id: Ib2d4b7df39068c27b5b06db578fc550d2973ebb4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3693705
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81161}
parent a31c6b95
......@@ -1163,18 +1163,18 @@ struct HeapStatsUpdate {
uint32_t size; // New value of size field for the interval with this index.
};
#define CODE_EVENTS_LIST(V) \
V(Builtin) \
V(Callback) \
V(Eval) \
V(Function) \
V(InterpretedFunction) \
V(Handler) \
V(BytecodeHandler) \
V(LazyCompile) \
V(RegExp) \
V(Script) \
V(Stub) \
#define CODE_EVENTS_LIST(V) \
V(Builtin) \
V(Callback) \
V(Eval) \
V(Function) \
V(InterpretedFunction) \
V(Handler) \
V(BytecodeHandler) \
V(LazyCompile) /* Unused, use kFunction instead */ \
V(RegExp) \
V(Script) \
V(Stub) \
V(Relocation)
/**
......
......@@ -86,7 +86,7 @@ class BaselineCompilerTask {
}
if (shared_function_info_->script().IsScript()) {
Compiler::LogFunctionCompilation(
isolate, LogEventListener::FUNCTION_TAG,
isolate, LogEventListener::CodeTag::kFunction,
handle(Script::cast(shared_function_info_->script()), isolate),
shared_function_info_, Handle<FeedbackVector>(),
Handle<AbstractCode>::cast(code), CodeKind::BASELINE, time_taken_ms_);
......
......@@ -343,7 +343,7 @@ void Builtins::EmitCodeCreateEvents(Isolate* isolate) {
for (; i < ToInt(Builtin::kFirstBytecodeHandler); i++) {
Code builtin_code = FromCodeT(CodeT::cast(Object(builtins[i])));
Handle<AbstractCode> code(AbstractCode::cast(builtin_code), isolate);
PROFILE(isolate, CodeCreateEvent(LogEventListener::BUILTIN_TAG, code,
PROFILE(isolate, CodeCreateEvent(LogEventListener::CodeTag::kBuiltin, code,
Builtins::name(FromInt(i))));
}
......@@ -357,7 +357,7 @@ void Builtins::EmitCodeCreateEvents(Isolate* isolate) {
builtin_metadata[i].data.bytecode_and_scale.scale;
PROFILE(isolate,
CodeCreateEvent(
LogEventListener::BYTECODE_HANDLER_TAG, code,
LogEventListener::CodeTag::kBytecodeHandler, code,
interpreter::Bytecodes::ToString(bytecode, scale).c_str()));
}
}
......
......@@ -273,7 +273,7 @@ class CompilerTracer : public AllStatic {
// static
void Compiler::LogFunctionCompilation(Isolate* isolate,
LogEventListener::LogEventsAndTags tag,
LogEventListener::CodeTag code_type,
Handle<Script> script,
Handle<SharedFunctionInfo> shared,
Handle<FeedbackVector> vector,
......@@ -301,8 +301,8 @@ void Compiler::LogFunctionCompilation(Isolate* isolate,
? String::cast(script->name())
: ReadOnlyRoots(isolate).empty_string(),
isolate);
LogEventListener::LogEventsAndTags log_tag =
V8FileLogger::ToNativeByScript(tag, *script);
LogEventListener::CodeTag log_tag =
V8FileLogger::ToNativeByScript(code_type, *script);
PROFILE(isolate, CodeCreateEvent(log_tag, abstract_code, shared, script_name,
line_num, column_num));
if (!vector.is_null()) {
......@@ -327,16 +327,12 @@ void Compiler::LogFunctionCompilation(Isolate* isolate,
default:
UNREACHABLE();
}
switch (tag) {
case LogEventListener::EVAL_TAG:
switch (code_type) {
case LogEventListener::CodeTag::kEval:
name += "-eval";
break;
case LogEventListener::SCRIPT_TAG:
break;
case LogEventListener::LAZY_COMPILE_TAG:
name += "-lazy";
break;
case LogEventListener::FUNCTION_TAG:
case LogEventListener::CodeTag::kScript:
case LogEventListener::CodeTag::kFunction:
break;
default:
UNREACHABLE();
......@@ -415,7 +411,7 @@ CompilationJob::Status UnoptimizedCompilationJob::FinalizeJob(
namespace {
void RecordUnoptimizedFunctionCompilation(
Isolate* isolate, LogEventListener::LogEventsAndTags tag,
Isolate* isolate, LogEventListener::CodeTag code_type,
Handle<SharedFunctionInfo> shared, base::TimeDelta time_taken_to_execute,
base::TimeDelta time_taken_to_finalize) {
Handle<AbstractCode> abstract_code;
......@@ -437,8 +433,8 @@ void RecordUnoptimizedFunctionCompilation(
Handle<Script> script(Script::cast(shared->script()), isolate);
Compiler::LogFunctionCompilation(
isolate, tag, script, shared, Handle<FeedbackVector>(), abstract_code,
CodeKind::INTERPRETED_FUNCTION, time_taken_ms);
isolate, code_type, script, shared, Handle<FeedbackVector>(),
abstract_code, CodeKind::INTERPRETED_FUNCTION, time_taken_ms);
}
} // namespace
......@@ -561,7 +557,7 @@ void TurbofanCompilationJob::RecordCompilationStats(ConcurrencyMode mode,
}
void TurbofanCompilationJob::RecordFunctionCompilation(
LogEventListener::LogEventsAndTags tag, Isolate* isolate) const {
LogEventListener::CodeTag code_type, Isolate* isolate) const {
Handle<AbstractCode> abstract_code =
Handle<AbstractCode>::cast(compilation_info()->code());
......@@ -574,8 +570,9 @@ void TurbofanCompilationJob::RecordFunctionCompilation(
Handle<FeedbackVector> feedback_vector(
compilation_info()->closure()->feedback_vector(), isolate);
Compiler::LogFunctionCompilation(
isolate, tag, script, compilation_info()->shared_info(), feedback_vector,
abstract_code, compilation_info()->code_kind(), time_taken_ms);
isolate, code_type, script, compilation_info()->shared_info(),
feedback_vector, abstract_code, compilation_info()->code_kind(),
time_taken_ms);
}
// ----------------------------------------------------------------------------
......@@ -600,9 +597,9 @@ bool UseAsmWasm(FunctionLiteral* literal, bool asm_wasm_broken) {
}
#endif
void InstallInterpreterTrampolineCopy(
Isolate* isolate, Handle<SharedFunctionInfo> shared_info,
LogEventListener::LogEventsAndTags log_tag) {
void InstallInterpreterTrampolineCopy(Isolate* isolate,
Handle<SharedFunctionInfo> shared_info,
LogEventListener::CodeTag log_tag) {
DCHECK(FLAG_interpreted_frames_native_stack);
if (!shared_info->function_data(kAcquireLoad).IsBytecodeArray()) {
DCHECK(!shared_info->HasBytecodeArray());
......@@ -675,7 +672,7 @@ void InstallUnoptimizedCode(UnoptimizedCompilationInfo* compilation_info,
void LogUnoptimizedCompilation(Isolate* isolate,
Handle<SharedFunctionInfo> shared_info,
LogEventListener::LogEventsAndTags log_tag,
LogEventListener::CodeTag log_tag,
base::TimeDelta time_taken_to_execute,
base::TimeDelta time_taken_to_finalize) {
RecordUnoptimizedFunctionCompilation(isolate, log_tag, shared_info,
......@@ -1022,7 +1019,7 @@ bool CompileTurbofan_NotConcurrent(Isolate* isolate,
compilation_info->osr_offset(),
ToCodeT(*compilation_info->code()),
compilation_info->function_context_specializing());
job->RecordFunctionCompilation(LogEventListener::LAZY_COMPILE_TAG, isolate);
job->RecordFunctionCompilation(LogEventListener::CodeTag::kFunction, isolate);
return true;
}
......@@ -1149,8 +1146,8 @@ void RecordMaglevFunctionCompilation(Isolate* isolate,
double time_taken_ms = 0;
Compiler::LogFunctionCompilation(
isolate, LogEventListener::FUNCTION_TAG, script, shared, feedback_vector,
abstract_code, abstract_code->kind(), time_taken_ms);
isolate, LogEventListener::CodeTag::kFunction, script, shared,
feedback_vector, abstract_code, abstract_code->kind(), time_taken_ms);
}
#endif // V8_ENABLE_MAGLEV
......@@ -1365,13 +1362,12 @@ void FinalizeUnoptimizedCompilation(
if (need_source_positions) {
SharedFunctionInfo::EnsureSourcePositionsAvailable(isolate, shared_info);
}
LogEventListener::LogEventsAndTags log_tag;
LogEventListener::CodeTag log_tag;
if (shared_info->is_toplevel()) {
log_tag = flags.is_eval() ? LogEventListener::EVAL_TAG
: LogEventListener::SCRIPT_TAG;
log_tag = flags.is_eval() ? LogEventListener::CodeTag::kEval
: LogEventListener::CodeTag::kScript;
} else {
log_tag = flags.is_lazy_compile() ? LogEventListener::LAZY_COMPILE_TAG
: LogEventListener::FUNCTION_TAG;
log_tag = LogEventListener::CodeTag::kFunction;
}
log_tag = V8FileLogger::ToNativeByScript(log_tag, *script);
if (FLAG_interpreted_frames_native_stack) {
......@@ -2175,7 +2171,7 @@ bool Compiler::CompileSharedWithBaseline(Isolate* isolate,
CompilerTracer::TraceFinishBaselineCompile(isolate, shared, time_taken_ms);
if (shared->script().IsScript()) {
LogFunctionCompilation(isolate, LogEventListener::FUNCTION_TAG,
LogFunctionCompilation(isolate, LogEventListener::CodeTag::kFunction,
handle(Script::cast(shared->script()), isolate),
shared, Handle<FeedbackVector>(),
Handle<AbstractCode>::cast(code), CodeKind::BASELINE,
......@@ -3447,7 +3443,7 @@ bool Compiler::FinalizeTurbofanCompilationJob(TurbofanCompilationJob* job,
job->RetryOptimization(BailoutReason::kOptimizationDisabled);
} else if (job->FinalizeJob(isolate) == CompilationJob::SUCCEEDED) {
job->RecordCompilationStats(ConcurrencyMode::kConcurrent, isolate);
job->RecordFunctionCompilation(LogEventListener::LAZY_COMPILE_TAG,
job->RecordFunctionCompilation(LogEventListener::CodeTag::kFunction,
isolate);
if (V8_LIKELY(use_result)) {
ResetTieringState(*function, osr_offset);
......
......@@ -238,7 +238,7 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
IsolateT* isolate);
static void LogFunctionCompilation(Isolate* isolate,
LogEventListener::LogEventsAndTags tag,
LogEventListener::CodeTag code_type,
Handle<Script> script,
Handle<SharedFunctionInfo> shared,
Handle<FeedbackVector> vector,
......@@ -322,7 +322,7 @@ class UnoptimizedCompilationJob : public CompilationJob {
FinalizeJob(Handle<SharedFunctionInfo> shared_info, LocalIsolate* isolate);
void RecordCompilationStats(Isolate* isolate) const;
void RecordFunctionCompilation(LogEventListener::LogEventsAndTags tag,
void RecordFunctionCompilation(LogEventListener::CodeTag code_type,
Handle<SharedFunctionInfo> shared,
Isolate* isolate) const;
......@@ -423,7 +423,7 @@ class TurbofanCompilationJob : public OptimizedCompilationJob {
Status AbortOptimization(BailoutReason reason);
void RecordCompilationStats(ConcurrencyMode mode, Isolate* isolate) const;
void RecordFunctionCompilation(LogEventListener::LogEventsAndTags tag,
void RecordFunctionCompilation(LogEventListener::CodeTag code_type,
Isolate* isolate) const;
private:
......
......@@ -2745,7 +2745,7 @@ CompilationJob::Status WasmHeapStubCompilationJob::FinalizeJobImpl(
tracing_scope.stream(), isolate);
}
#endif
PROFILE(isolate, CodeCreateEvent(LogEventListener::STUB_TAG,
PROFILE(isolate, CodeCreateEvent(LogEventListener::CodeTag::kStub,
Handle<AbstractCode>::cast(code),
compilation_info()->GetDebugName().get()));
return SUCCEEDED;
......
......@@ -28,64 +28,56 @@ class WasmCode;
using WasmName = base::Vector<const char>;
} // namespace wasm
// clang-format off
#define LOG_EVENTS_LIST(V) \
V(CODE_CREATION_EVENT, code-creation) \
V(CODE_DISABLE_OPT_EVENT, code-disable-optimization) \
V(CODE_MOVE_EVENT, code-move) \
V(CODE_DELETE_EVENT, code-delete) \
V(CODE_MOVING_GC, code-moving-gc) \
V(SHARED_FUNC_MOVE_EVENT, sfi-move) \
V(SNAPSHOT_CODE_NAME_EVENT, snapshot-code-name) \
V(TICK_EVENT, tick)
// clang-format on
#define LOG_EVENT_LIST(V) \
V(kCodeCreation, "code-creation") \
V(kCodeDisableOpt, "code-disable-optimization") \
V(kCodeMove, "code-move") \
V(kCodeDeopt, "code-deopt") \
V(kCodeDelete, "code-delete") \
V(kCodeMovingGC, "code-moving-gc") \
V(kSharedFuncMove, "sfi-move") \
V(kSnapshotCodeName, "snapshot-code-name") \
V(kTick, "tick")
#define TAGS_LIST(V) \
V(BUILTIN_TAG, Builtin) \
V(CALLBACK_TAG, Callback) \
V(EVAL_TAG, Eval) \
V(FUNCTION_TAG, Function) \
V(HANDLER_TAG, Handler) \
V(BYTECODE_HANDLER_TAG, BytecodeHandler) \
V(LAZY_COMPILE_TAG, LazyCompile) \
V(REG_EXP_TAG, RegExp) \
V(SCRIPT_TAG, Script) \
V(STUB_TAG, Stub) \
V(NATIVE_FUNCTION_TAG, Function) \
V(NATIVE_LAZY_COMPILE_TAG, LazyCompile) \
V(NATIVE_SCRIPT_TAG, Script)
// Note that 'NATIVE_' cases for functions and scripts are mapped onto
#define CODE_TYPE_LIST(V) \
V(kBuiltin, Builtin) \
V(kCallback, Callback) \
V(kEval, Eval) \
V(kFunction, JS) \
V(kHandler, Handler) \
V(kBytecodeHandler, BytecodeHandler) \
V(kRegExp, RegExp) \
V(kScript, Script) \
V(kStub, Stub) \
V(kNativeFunction, JS) \
V(kNativeScript, Script)
// Note that 'Native' cases for functions and scripts are mapped onto
// original tags when writing to the log.
#define LOG_EVENTS_AND_TAGS_LIST(V) \
LOG_EVENTS_LIST(V) \
TAGS_LIST(V)
#define PROFILE(the_isolate, Call) (the_isolate)->logger()->Call;
class LogEventListener {
public:
#define DECLARE_ENUM(enum_item, _) enum_item,
enum LogEventsAndTags {
LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) NUMBER_OF_LOG_EVENTS
};
enum class Event : uint8_t { LOG_EVENT_LIST(DECLARE_ENUM) kLength };
enum class CodeTag : uint8_t { CODE_TYPE_LIST(DECLARE_ENUM) kLength };
#undef DECLARE_ENUM
virtual ~LogEventListener() = default;
virtual void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
virtual void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
const char* name) = 0;
virtual void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
virtual void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<Name> name) = 0;
virtual void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
virtual void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name) = 0;
virtual void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
virtual void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line,
int column) = 0;
#if V8_ENABLE_WEBASSEMBLY
virtual void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
virtual void CodeCreateEvent(CodeTag tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url,
int code_offset, int script_id) = 0;
#endif // V8_ENABLE_WEBASSEMBLY
......@@ -119,7 +111,8 @@ class LogEventListener {
// Dispatches code events to a set of registered listeners.
class Logger {
public:
using LogEventsAndTags = LogEventListener::LogEventsAndTags;
using Event = LogEventListener::Event;
using CodeTag = LogEventListener::CodeTag;
Logger() = default;
Logger(const Logger&) = delete;
......@@ -153,28 +146,28 @@ class Logger {
return _is_listening_to_code_events;
}
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
const char* comment) {
base::MutexGuard guard(&mutex_);
for (auto listener : listeners_) {
listener->CodeCreateEvent(tag, code, comment);
}
}
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<Name> name) {
base::MutexGuard guard(&mutex_);
for (auto listener : listeners_) {
listener->CodeCreateEvent(tag, code, name);
}
}
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared, Handle<Name> name) {
base::MutexGuard guard(&mutex_);
for (auto listener : listeners_) {
listener->CodeCreateEvent(tag, code, shared, name);
}
}
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared, Handle<Name> source,
int line, int column) {
base::MutexGuard guard(&mutex_);
......@@ -183,7 +176,7 @@ class Logger {
}
}
#if V8_ENABLE_WEBASSEMBLY
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
void CodeCreateEvent(CodeTag tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url,
int code_offset, int script_id) {
base::MutexGuard guard(&mutex_);
......
......@@ -13,16 +13,14 @@
namespace v8 {
namespace internal {
LogEventListener::LogEventsAndTags V8FileLogger::ToNativeByScript(
LogEventListener::LogEventsAndTags tag, Script script) {
LogEventListener::CodeTag V8FileLogger::ToNativeByScript(
LogEventListener::CodeTag tag, Script script) {
if (script.type() != Script::TYPE_NATIVE) return tag;
switch (tag) {
case LogEventListener::FUNCTION_TAG:
return LogEventListener::NATIVE_FUNCTION_TAG;
case LogEventListener::LAZY_COMPILE_TAG:
return LogEventListener::NATIVE_LAZY_COMPILE_TAG;
case LogEventListener::SCRIPT_TAG:
return LogEventListener::NATIVE_SCRIPT_TAG;
case LogEventListener::CodeTag::kFunction:
return LogEventListener::CodeTag::kNativeFunction;
case LogEventListener::CodeTag::kScript:
return LogEventListener::CodeTag::kNativeScript;
default:
return tag;
}
......
......@@ -30,6 +30,7 @@
#include "src/interpreter/bytecodes.h"
#include "src/interpreter/interpreter.h"
#include "src/libsampler/sampler.h"
#include "src/logging/code-events.h"
#include "src/logging/counters.h"
#include "src/logging/log-file.h"
#include "src/logging/log-inl.h"
......@@ -63,28 +64,55 @@
namespace v8 {
namespace internal {
static const char* kLogEventsNames[] = {
#define DECLARE_EVENT(ignore1, name) name,
LOG_EVENT_LIST(DECLARE_EVENT)
#undef DECLARE_EVENT
};
static const char* kCodeTagNames[] = {
#define DECLARE_EVENT(ignore1, name) #name,
static const char* kLogEventsNames[LogEventListener::NUMBER_OF_LOG_EVENTS] = {
LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT)};
CODE_TYPE_LIST(DECLARE_EVENT)
#undef DECLARE_EVENT
};
std::ostream& operator<<(std::ostream& os, LogEventListener::CodeTag tag) {
os << kCodeTagNames[static_cast<int>(tag)];
return os;
}
std::ostream& operator<<(std::ostream& os, LogEventListener::Event event) {
os << kLogEventsNames[static_cast<int>(event)];
return os;
}
static v8::CodeEventType GetCodeEventTypeForTag(
LogEventListener::LogEventsAndTags tag) {
static v8::CodeEventType GetCodeEventTypeForTag(LogEventListener::CodeTag tag) {
switch (tag) {
case LogEventListener::NUMBER_OF_LOG_EVENTS:
#define V(Event, _) case LogEventListener::Event:
LOG_EVENTS_LIST(V)
#undef V
return v8::CodeEventType::kUnknownType;
#define V(From, To) \
case LogEventListener::From: \
return v8::CodeEventType::k##To##Type;
TAGS_LIST(V)
#undef V
case LogEventListener::CodeTag::kLength:
// Manually create this switch, since v8::CodeEventType is API expose and
// cannot be easily modified.
case LogEventListener::CodeTag::kBuiltin:
return v8::CodeEventType::kBuiltinType;
case LogEventListener::CodeTag::kCallback:
return v8::CodeEventType::kCallbackType;
case LogEventListener::CodeTag::kEval:
return v8::CodeEventType::kEvalType;
case LogEventListener::CodeTag::kNativeFunction:
case LogEventListener::CodeTag::kFunction:
return v8::CodeEventType::kFunctionType;
case LogEventListener::CodeTag::kHandler:
return v8::CodeEventType::kHandlerType;
case LogEventListener::CodeTag::kBytecodeHandler:
return v8::CodeEventType::kBytecodeHandlerType;
case LogEventListener::CodeTag::kRegExp:
return v8::CodeEventType::kRegExpType;
case LogEventListener::CodeTag::kNativeScript:
case LogEventListener::CodeTag::kScript:
return v8::CodeEventType::kScriptType;
case LogEventListener::CodeTag::kStub:
return v8::CodeEventType::kStubType;
}
// The execution should never pass here
UNREACHABLE();
}
#define CALL_CODE_EVENT_HANDLER(Call) \
if (listener_) { \
listener_->Call; \
......@@ -126,9 +154,9 @@ class CodeEventLogger::NameBuffer {
void Reset() { utf8_pos_ = 0; }
void Init(LogEventsAndTags tag) {
void Init(CodeTag tag) {
Reset();
AppendBytes(kLogEventsNames[tag]);
AppendBytes(kCodeTagNames[static_cast<int>(tag)]);
AppendByte(':');
}
......@@ -210,8 +238,7 @@ CodeEventLogger::CodeEventLogger(Isolate* isolate)
CodeEventLogger::~CodeEventLogger() = default;
void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
void CodeEventLogger::CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
const char* comment) {
DCHECK(is_listening_to_code_events());
name_buffer_->Init(tag);
......@@ -220,8 +247,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
name_buffer_->get(), name_buffer_->size());
}
void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
void CodeEventLogger::CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<Name> name) {
DCHECK(is_listening_to_code_events());
name_buffer_->Init(tag);
......@@ -230,8 +256,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
name_buffer_->get(), name_buffer_->size());
}
void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
void CodeEventLogger::CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name) {
DCHECK(is_listening_to_code_events());
......@@ -242,8 +267,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size());
}
void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
void CodeEventLogger::CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line,
int column) {
......@@ -267,8 +291,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
}
#if V8_ENABLE_WEBASSEMBLY
void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
const wasm::WasmCode* code,
void CodeEventLogger::CodeCreateEvent(CodeTag tag, const wasm::WasmCode* code,
wasm::WasmName name,
const char* source_url,
int /*code_offset*/, int /*script_id*/) {
......@@ -291,7 +314,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
void CodeEventLogger::RegExpCodeCreateEvent(Handle<AbstractCode> code,
Handle<String> source) {
DCHECK(is_listening_to_code_events());
name_buffer_->Init(LogEventListener::REG_EXP_TAG);
name_buffer_->Init(LogEventListener::CodeTag::kRegExp);
name_buffer_->AppendString(*source);
LogRecordedBuffer(code, MaybeHandle<SharedFunctionInfo>(),
name_buffer_->get(), name_buffer_->size());
......@@ -444,7 +467,7 @@ void ExternalLogEventListener::StopListening() {
is_listening_ = false;
}
void ExternalLogEventListener::CodeCreateEvent(LogEventsAndTags tag,
void ExternalLogEventListener::CodeCreateEvent(CodeTag tag,
Handle<AbstractCode> code,
const char* comment) {
CodeEvent code_event;
......@@ -461,7 +484,7 @@ void ExternalLogEventListener::CodeCreateEvent(LogEventsAndTags tag,
code_event_handler_->Handle(reinterpret_cast<v8::CodeEvent*>(&code_event));
}
void ExternalLogEventListener::CodeCreateEvent(LogEventsAndTags tag,
void ExternalLogEventListener::CodeCreateEvent(CodeTag tag,
Handle<AbstractCode> code,
Handle<Name> name) {
Handle<String> name_string =
......@@ -482,8 +505,8 @@ void ExternalLogEventListener::CodeCreateEvent(LogEventsAndTags tag,
}
void ExternalLogEventListener::CodeCreateEvent(
LogEventsAndTags tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared, Handle<Name> name) {
CodeTag tag, Handle<AbstractCode> code, Handle<SharedFunctionInfo> shared,
Handle<Name> name) {
Handle<String> name_string =
Name::ToFunctionName(isolate_, name).ToHandleChecked();
......@@ -502,9 +525,8 @@ void ExternalLogEventListener::CodeCreateEvent(
}
void ExternalLogEventListener::CodeCreateEvent(
LogEventsAndTags tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared, Handle<Name> source, int line,
int column) {
CodeTag tag, Handle<AbstractCode> code, Handle<SharedFunctionInfo> shared,
Handle<Name> source, int line, int column) {
Handle<String> name_string =
Name::ToFunctionName(isolate_, handle(shared->Name(), isolate_))
.ToHandleChecked();
......@@ -526,7 +548,7 @@ void ExternalLogEventListener::CodeCreateEvent(
}
#if V8_ENABLE_WEBASSEMBLY
void ExternalLogEventListener::CodeCreateEvent(LogEventsAndTags tag,
void ExternalLogEventListener::CodeCreateEvent(CodeTag tag,
const wasm::WasmCode* code,
wasm::WasmName name,
const char* source_url,
......@@ -545,7 +567,8 @@ void ExternalLogEventListener::RegExpCodeCreateEvent(Handle<AbstractCode> code,
code_event.script_name = isolate_->factory()->empty_string();
code_event.script_line = 0;
code_event.script_column = 0;
code_event.code_type = GetCodeEventTypeForTag(LogEventListener::REG_EXP_TAG);
code_event.code_type =
GetCodeEventTypeForTag(LogEventListener::CodeTag::kRegExp);
code_event.comment = "";
code_event_handler_->Handle(reinterpret_cast<v8::CodeEvent*>(&code_event));
......@@ -1218,19 +1241,17 @@ void V8FileLogger::DeleteEvent(const char* name, void* object) {
namespace {
void AppendCodeCreateHeader(LogFile::MessageBuilder& msg,
LogEventListener::LogEventsAndTags tag,
CodeKind kind, uint8_t* address, int size,
uint64_t time) {
msg << kLogEventsNames[LogEventListener::CODE_CREATION_EVENT]
<< V8FileLogger::kNext << kLogEventsNames[tag] << V8FileLogger::kNext
<< static_cast<int>(kind) << V8FileLogger::kNext << time
<< V8FileLogger::kNext << reinterpret_cast<void*>(address)
LogEventListener::CodeTag tag, CodeKind kind,
uint8_t* address, int size, uint64_t time) {
msg << LogEventListener::Event::kCodeCreation << V8FileLogger::kNext << tag
<< V8FileLogger::kNext << static_cast<int>(kind) << V8FileLogger::kNext
<< time << V8FileLogger::kNext << reinterpret_cast<void*>(address)
<< V8FileLogger::kNext << size << V8FileLogger::kNext;
}
void AppendCodeCreateHeader(LogFile::MessageBuilder& msg,
LogEventListener::LogEventsAndTags tag,
AbstractCode code, uint64_t time) {
LogEventListener::CodeTag tag, AbstractCode code,
uint64_t time) {
AppendCodeCreateHeader(msg, tag, code.kind(),
reinterpret_cast<uint8_t*>(code.InstructionStart()),
code.InstructionSize(), time);
......@@ -1347,8 +1368,7 @@ void V8FileLogger::LogCodeDisassemble(Handle<AbstractCode> code) {
}
// Builtins and Bytecode handlers
void V8FileLogger::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
void V8FileLogger::CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
const char* name) {
if (!is_listening_to_code_events()) return;
if (!FLAG_log_code) return;
......@@ -1361,8 +1381,7 @@ void V8FileLogger::CodeCreateEvent(LogEventsAndTags tag,
LogCodeDisassemble(code);
}
void V8FileLogger::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
void V8FileLogger::CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<Name> name) {
if (!is_listening_to_code_events()) return;
if (!FLAG_log_code) return;
......@@ -1376,8 +1395,7 @@ void V8FileLogger::CodeCreateEvent(LogEventsAndTags tag,
}
// Scripts
void V8FileLogger::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
void V8FileLogger::CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name) {
if (!is_listening_to_code_events()) return;
......@@ -1426,8 +1444,7 @@ void V8FileLogger::FeedbackVectorEvent(FeedbackVector vector,
// Although, it is possible to extract source and line from
// the SharedFunctionInfo object, we left it to caller
// to leave logging functions free from heap allocations.
void V8FileLogger::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
void V8FileLogger::CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line,
int column) {
......@@ -1447,8 +1464,7 @@ void V8FileLogger::CodeCreateEvent(LogEventsAndTags tag,
}
#if V8_ENABLE_WEBASSEMBLY
void V8FileLogger::CodeCreateEvent(LogEventsAndTags tag,
const wasm::WasmCode* code,
void V8FileLogger::CodeCreateEvent(CodeTag tag, const wasm::WasmCode* code,
wasm::WasmName name,
const char* /*source_url*/,
int /*code_offset*/, int /*script_id*/) {
......@@ -1477,10 +1493,9 @@ void V8FileLogger::CallbackEventInternal(const char* prefix, Handle<Name> name,
Address entry_point) {
if (!FLAG_log_code) return;
MSG_BUILDER();
msg << kLogEventsNames[LogEventListener::CODE_CREATION_EVENT] << kNext
<< kLogEventsNames[LogEventListener::CALLBACK_TAG] << kNext << -2 << kNext
<< Time() << kNext << reinterpret_cast<void*>(entry_point) << kNext << 1
<< kNext << prefix << *name;
msg << Event::kCodeCreation << kNext << CodeTag::kCallback << kNext << -2
<< kNext << Time() << kNext << reinterpret_cast<void*>(entry_point)
<< kNext << 1 << kNext << prefix << *name;
msg.WriteToLogFile();
}
......@@ -1501,20 +1516,21 @@ void V8FileLogger::RegExpCodeCreateEvent(Handle<AbstractCode> code,
if (!is_listening_to_code_events()) return;
if (!FLAG_log_code) return;
MSG_BUILDER();
AppendCodeCreateHeader(msg, LogEventListener::REG_EXP_TAG, *code, Time());
AppendCodeCreateHeader(msg, LogEventListener::CodeTag::kRegExp, *code,
Time());
msg << *source;
msg.WriteToLogFile();
}
void V8FileLogger::CodeMoveEvent(AbstractCode from, AbstractCode to) {
if (!is_listening_to_code_events()) return;
MoveEventInternal(LogEventListener::CODE_MOVE_EVENT, from.InstructionStart(),
MoveEventInternal(Event::kCodeMove, from.InstructionStart(),
to.InstructionStart());
}
void V8FileLogger::SharedFunctionInfoMoveEvent(Address from, Address to) {
if (!is_listening_to_code_events()) return;
MoveEventInternal(LogEventListener::SHARED_FUNC_MOVE_EVENT, from, to);
MoveEventInternal(Event::kSharedFuncMove, from, to);
}
void V8FileLogger::CodeMovingGCEvent() {
......@@ -1528,17 +1544,16 @@ void V8FileLogger::CodeDisableOptEvent(Handle<AbstractCode> code,
if (!is_listening_to_code_events()) return;
if (!FLAG_log_code) return;
MSG_BUILDER();
msg << kLogEventsNames[LogEventListener::CODE_DISABLE_OPT_EVENT] << kNext
<< shared->DebugNameCStr().get() << kNext
<< GetBailoutReason(shared->disabled_optimization_reason());
msg << Event::kCodeDisableOpt << kNext << shared->DebugNameCStr().get()
<< kNext << GetBailoutReason(shared->disabled_optimization_reason());
msg.WriteToLogFile();
}
void V8FileLogger::ProcessDeoptEvent(Handle<Code> code, SourcePosition position,
const char* kind, const char* reason) {
MSG_BUILDER();
msg << "code-deopt" << kNext << Time() << kNext << code->CodeSize() << kNext
<< reinterpret_cast<void*>(code->InstructionStart());
msg << Event::kCodeDeopt << kNext << Time() << kNext << code->CodeSize()
<< kNext << reinterpret_cast<void*>(code->InstructionStart());
std::ostringstream deopt_location;
int inlining_id = -1;
......@@ -1615,17 +1630,15 @@ void V8FileLogger::CodeNameEvent(Address addr, int pos, const char* code_name) {
if (code_name == nullptr) return; // Not a code object.
if (!is_listening_to_code_events()) return;
MSG_BUILDER();
msg << kLogEventsNames[LogEventListener::SNAPSHOT_CODE_NAME_EVENT] << kNext
<< pos << kNext << code_name;
msg << Event::kSnapshotCodeName << kNext << pos << kNext << code_name;
msg.WriteToLogFile();
}
void V8FileLogger::MoveEventInternal(LogEventsAndTags event, Address from,
Address to) {
void V8FileLogger::MoveEventInternal(Event event, Address from, Address to) {
if (!FLAG_log_code) return;
MSG_BUILDER();
msg << kLogEventsNames[event] << kNext << reinterpret_cast<void*>(from)
<< kNext << reinterpret_cast<void*>(to);
msg << event << kNext << reinterpret_cast<void*>(from) << kNext
<< reinterpret_cast<void*>(to);
msg.WriteToLogFile();
}
......@@ -1780,8 +1793,8 @@ void V8FileLogger::TickEvent(TickSample* sample, bool overflow) {
RuntimeCallTimerEvent();
}
MSG_BUILDER();
msg << kLogEventsNames[LogEventListener::TICK_EVENT] << kNext
<< reinterpret_cast<void*>(sample->pc) << kNext << Time();
msg << Event::kTick << kNext << reinterpret_cast<void*>(sample->pc) << kNext
<< Time();
if (sample->has_external_callback) {
msg << kNext << 1 << kNext
<< reinterpret_cast<void*>(sample->external_callback_entry);
......@@ -2188,7 +2201,7 @@ void V8FileLogger::UpdateIsLogging(bool value) {
void ExistingCodeLogger::LogCodeObject(Object object) {
HandleScope scope(isolate_);
Handle<AbstractCode> abstract_code(AbstractCode::cast(object), isolate_);
LogEventListener::LogEventsAndTags tag = LogEventListener::STUB_TAG;
CodeTag tag = CodeTag::kStub;
const char* description = "Unknown code from before profiling";
switch (abstract_code->kind()) {
case CodeKind::INTERPRETED_FUNCTION:
......@@ -2198,16 +2211,16 @@ void ExistingCodeLogger::LogCodeObject(Object object) {
return; // We log this later using LogCompiledFunctions.
case CodeKind::FOR_TESTING:
description = "STUB code";
tag = LogEventListener::STUB_TAG;
tag = CodeTag::kStub;
break;
case CodeKind::REGEXP:
description = "Regular expression code";
tag = LogEventListener::REG_EXP_TAG;
tag = CodeTag::kRegExp;
break;
case CodeKind::BYTECODE_HANDLER:
description =
isolate_->builtins()->name(abstract_code->GetCode().builtin_id());
tag = LogEventListener::BYTECODE_HANDLER_TAG;
tag = CodeTag::kBytecodeHandler;
break;
case CodeKind::BUILTIN:
if (Code::cast(object).is_interpreter_trampoline_builtin() &&
......@@ -2217,31 +2230,31 @@ void ExistingCodeLogger::LogCodeObject(Object object) {
}
description =
isolate_->builtins()->name(abstract_code->GetCode().builtin_id());
tag = LogEventListener::BUILTIN_TAG;
tag = CodeTag::kBuiltin;
break;
case CodeKind::WASM_FUNCTION:
description = "A Wasm function";
tag = LogEventListener::FUNCTION_TAG;
tag = CodeTag::kFunction;
break;
case CodeKind::JS_TO_WASM_FUNCTION:
description = "A JavaScript to Wasm adapter";
tag = LogEventListener::STUB_TAG;
tag = CodeTag::kStub;
break;
case CodeKind::JS_TO_JS_FUNCTION:
description = "A WebAssembly.Function adapter";
tag = LogEventListener::STUB_TAG;
tag = CodeTag::kStub;
break;
case CodeKind::WASM_TO_CAPI_FUNCTION:
description = "A Wasm to C-API adapter";
tag = LogEventListener::STUB_TAG;
tag = CodeTag::kStub;
break;
case CodeKind::WASM_TO_JS_FUNCTION:
description = "A Wasm to JavaScript adapter";
tag = LogEventListener::STUB_TAG;
tag = CodeTag::kStub;
break;
case CodeKind::C_WASM_ENTRY:
description = "A C to Wasm entry stub";
tag = LogEventListener::STUB_TAG;
tag = CodeTag::kStub;
break;
}
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(tag, abstract_code, description))
......@@ -2311,9 +2324,9 @@ void ExistingCodeLogger::LogCompiledFunctions() {
#endif // V8_ENABLE_WEBASSEMBLY
}
void ExistingCodeLogger::LogExistingFunction(
Handle<SharedFunctionInfo> shared, Handle<AbstractCode> code,
LogEventListener::LogEventsAndTags tag) {
void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
Handle<AbstractCode> code,
CodeTag tag) {
if (shared->script().IsScript()) {
Handle<Script> script(Script::cast(shared->script()), isolate_);
int line_num = Script::GetLineNumber(script, shared->StartPosition()) + 1;
......@@ -2327,10 +2340,9 @@ void ExistingCodeLogger::LogExistingFunction(
shared, script_name, line_num, column_num))
} else {
// Can't distinguish eval and script here, so always use Script.
CALL_CODE_EVENT_HANDLER(
CodeCreateEvent(V8FileLogger::ToNativeByScript(
LogEventListener::SCRIPT_TAG, *script),
code, shared, script_name))
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(
V8FileLogger::ToNativeByScript(CodeTag::kScript, *script), code,
shared, script_name))
}
} else {
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(
......
......@@ -83,6 +83,7 @@ class Ticker;
class ExistingCodeLogger {
public:
using CodeTag = LogEventListener::CodeTag;
explicit ExistingCodeLogger(Isolate* isolate,
LogEventListener* listener = nullptr)
: isolate_(isolate), listener_(listener) {}
......@@ -93,7 +94,7 @@ class ExistingCodeLogger {
void LogCompiledFunctions();
void LogExistingFunction(
Handle<SharedFunctionInfo> shared, Handle<AbstractCode> code,
LogEventListener::LogEventsAndTags tag = LogEventListener::FUNCTION_TAG);
LogEventListener::CodeTag tag = LogEventListener::CodeTag::kFunction);
void LogCodeObject(Object object);
private:
......@@ -167,18 +168,18 @@ class V8FileLogger : public LogEventListener {
V8_EXPORT_PRIVATE void RemoveLogEventListener(LogEventListener* listener);
// LogEventListener implementation.
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
const char* name) override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<Name> name) override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name) override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line, int column) override;
#if V8_ENABLE_WEBASSEMBLY
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
void CodeCreateEvent(CodeTag tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url,
int code_offset, int script_id) override;
#endif // V8_ENABLE_WEBASSEMBLY
......@@ -283,8 +284,7 @@ class V8FileLogger : public LogEventListener {
void LogAllMaps();
// Converts tag to a corresponding NATIVE_... if the script is native.
V8_INLINE static LogEventListener::LogEventsAndTags ToNativeByScript(
LogEventListener::LogEventsAndTags, Script);
V8_INLINE static CodeTag ToNativeByScript(CodeTag tag, Script script);
private:
void UpdateIsLogging(bool value);
......@@ -297,11 +297,10 @@ class V8FileLogger : public LogEventListener {
Address entry_point);
// Internal configurable move event.
void MoveEventInternal(LogEventListener::LogEventsAndTags event, Address from,
Address to);
void MoveEventInternal(Event event, Address from, Address to);
// Helper method. It resets name_buffer_ and add tag name into it.
void InitNameBuffer(LogEventListener::LogEventsAndTags tag);
void InitNameBuffer(Event tag);
// Emits a profiler tick event. Used by the profiler thread.
void TickEvent(TickSample* sample, bool overflow);
......@@ -409,18 +408,18 @@ class V8_EXPORT_PRIVATE CodeEventLogger : public LogEventListener {
explicit CodeEventLogger(Isolate* isolate);
~CodeEventLogger() override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
const char* name) override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<Name> name) override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name) override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line, int column) override;
#if V8_ENABLE_WEBASSEMBLY
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
void CodeCreateEvent(CodeTag tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url,
int code_offset, int script_id) override;
#endif // V8_ENABLE_WEBASSEMBLY
......@@ -477,18 +476,18 @@ class ExternalLogEventListener : public LogEventListener {
explicit ExternalLogEventListener(Isolate* isolate);
~ExternalLogEventListener() override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
const char* comment) override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<Name> name) override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> name) override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared, Handle<Name> source,
int line, int column) override;
#if V8_ENABLE_WEBASSEMBLY
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
void CodeCreateEvent(CodeTag tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url,
int code_offset, int script_id) override;
#endif // V8_ENABLE_WEBASSEMBLY
......
......@@ -53,7 +53,7 @@ void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) {
if (builtin == Builtin::kGenericJSToWasmWrapper) {
// Make sure to add the generic js-to-wasm wrapper builtin, because that
// one is supposed to show up in profiles.
entry = code_map->code_entries().Create(LogEventListener::BUILTIN_TAG,
entry = code_map->code_entries().Create(LogEventListener::CodeTag::kBuiltin,
Builtins::name(builtin));
code_map->AddCode(instruction_start, entry, instruction_size);
}
......
......@@ -398,7 +398,7 @@ void ProfilerCodeObserver::CreateEntriesForRuntimeCallStats() {
for (int i = 0; i < RuntimeCallStats::kNumberOfCounters; ++i) {
RuntimeCallCounter* counter = rcs->GetCounter(i);
DCHECK(counter->name());
auto entry = code_entries_.Create(LogEventListener::FUNCTION_TAG,
auto entry = code_entries_.Create(LogEventListener::CodeTag::kFunction,
counter->name(), "native V8Runtime");
code_map_.AddCode(reinterpret_cast<Address>(counter), entry, 1);
}
......
......@@ -12,12 +12,12 @@
namespace v8 {
namespace internal {
CodeEntry::CodeEntry(LogEventListener::LogEventsAndTags tag, const char* name,
CodeEntry::CodeEntry(LogEventListener::CodeTag tag, const char* name,
const char* resource_name, int line_number,
int column_number,
std::unique_ptr<SourcePositionTable> line_info,
bool is_shared_cross_origin, CodeType code_type)
: bit_field_(TagField::encode(tag) |
: bit_field_(CodeTagField::encode(tag) |
BuiltinField::encode(Builtin::kIllegal) |
CodeTypeField::encode(code_type) |
SharedCrossOriginField::encode(is_shared_cross_origin)),
......
......@@ -91,7 +91,7 @@ const char* const CodeEntry::kRootEntryName = "(root)";
// static
CodeEntry* CodeEntry::program_entry() {
static base::LeakyObject<CodeEntry> kProgramEntry(
LogEventListener::FUNCTION_TAG, CodeEntry::kProgramEntryName,
LogEventListener::CodeTag::kFunction, CodeEntry::kProgramEntryName,
CodeEntry::kEmptyResourceName, v8::CpuProfileNode::kNoLineNumberInfo,
v8::CpuProfileNode::kNoColumnNumberInfo, nullptr, false,
CodeEntry::CodeType::OTHER);
......@@ -101,7 +101,7 @@ CodeEntry* CodeEntry::program_entry() {
// static
CodeEntry* CodeEntry::idle_entry() {
static base::LeakyObject<CodeEntry> kIdleEntry(
LogEventListener::FUNCTION_TAG, CodeEntry::kIdleEntryName,
LogEventListener::CodeTag::kFunction, CodeEntry::kIdleEntryName,
CodeEntry::kEmptyResourceName, v8::CpuProfileNode::kNoLineNumberInfo,
v8::CpuProfileNode::kNoColumnNumberInfo, nullptr, false,
CodeEntry::CodeType::OTHER);
......@@ -111,8 +111,9 @@ CodeEntry* CodeEntry::idle_entry() {
// static
CodeEntry* CodeEntry::gc_entry() {
static base::LeakyObject<CodeEntry> kGcEntry(
LogEventListener::BUILTIN_TAG, CodeEntry::kGarbageCollectorEntryName,
CodeEntry::kEmptyResourceName, v8::CpuProfileNode::kNoLineNumberInfo,
LogEventListener::CodeTag::kBuiltin,
CodeEntry::kGarbageCollectorEntryName, CodeEntry::kEmptyResourceName,
v8::CpuProfileNode::kNoLineNumberInfo,
v8::CpuProfileNode::kNoColumnNumberInfo, nullptr, false,
CodeEntry::CodeType::OTHER);
return kGcEntry.get();
......@@ -121,7 +122,7 @@ CodeEntry* CodeEntry::gc_entry() {
// static
CodeEntry* CodeEntry::unresolved_entry() {
static base::LeakyObject<CodeEntry> kUnresolvedEntry(
LogEventListener::FUNCTION_TAG, CodeEntry::kUnresolvedFunctionName,
LogEventListener::CodeTag::kFunction, CodeEntry::kUnresolvedFunctionName,
CodeEntry::kEmptyResourceName, v8::CpuProfileNode::kNoLineNumberInfo,
v8::CpuProfileNode::kNoColumnNumberInfo, nullptr, false,
CodeEntry::CodeType::OTHER);
......@@ -131,7 +132,7 @@ CodeEntry* CodeEntry::unresolved_entry() {
// static
CodeEntry* CodeEntry::root_entry() {
static base::LeakyObject<CodeEntry> kRootEntry(
LogEventListener::FUNCTION_TAG, CodeEntry::kRootEntryName,
LogEventListener::CodeTag::kFunction, CodeEntry::kRootEntryName,
CodeEntry::kEmptyResourceName, v8::CpuProfileNode::kNoLineNumberInfo,
v8::CpuProfileNode::kNoColumnNumberInfo, nullptr, false,
CodeEntry::CodeType::OTHER);
......@@ -163,7 +164,8 @@ bool CodeEntry::IsSameFunctionAs(const CodeEntry* entry) const {
}
void CodeEntry::SetBuiltinId(Builtin id) {
bit_field_ = TagField::update(bit_field_, LogEventListener::BUILTIN_TAG);
bit_field_ =
CodeTagField::update(bit_field_, LogEventListener::CodeTag::kBuiltin);
bit_field_ = BuiltinField::update(bit_field_, id);
}
......@@ -339,34 +341,26 @@ CpuProfileNode::SourceType ProfileNode::source_type() const {
return CpuProfileNode::kUnresolved;
// Otherwise, resolve based on logger tag.
switch (entry_->tag()) {
case LogEventListener::EVAL_TAG:
case LogEventListener::SCRIPT_TAG:
case LogEventListener::LAZY_COMPILE_TAG:
case LogEventListener::FUNCTION_TAG:
switch (entry_->code_tag()) {
case LogEventListener::CodeTag::kEval:
case LogEventListener::CodeTag::kScript:
case LogEventListener::CodeTag::kFunction:
return CpuProfileNode::kScript;
case LogEventListener::BUILTIN_TAG:
case LogEventListener::HANDLER_TAG:
case LogEventListener::BYTECODE_HANDLER_TAG:
case LogEventListener::NATIVE_FUNCTION_TAG:
case LogEventListener::NATIVE_SCRIPT_TAG:
case LogEventListener::NATIVE_LAZY_COMPILE_TAG:
case LogEventListener::CodeTag::kBuiltin:
case LogEventListener::CodeTag::kHandler:
case LogEventListener::CodeTag::kBytecodeHandler:
case LogEventListener::CodeTag::kNativeFunction:
case LogEventListener::CodeTag::kNativeScript:
return CpuProfileNode::kBuiltin;
case LogEventListener::CALLBACK_TAG:
case LogEventListener::CodeTag::kCallback:
return CpuProfileNode::kCallback;
case LogEventListener::REG_EXP_TAG:
case LogEventListener::STUB_TAG:
case LogEventListener::CODE_CREATION_EVENT:
case LogEventListener::CODE_DISABLE_OPT_EVENT:
case LogEventListener::CODE_MOVE_EVENT:
case LogEventListener::CODE_DELETE_EVENT:
case LogEventListener::CODE_MOVING_GC:
case LogEventListener::SHARED_FUNC_MOVE_EVENT:
case LogEventListener::SNAPSHOT_CODE_NAME_EVENT:
case LogEventListener::TICK_EVENT:
case LogEventListener::NUMBER_OF_LOG_EVENTS:
case LogEventListener::CodeTag::kRegExp:
case LogEventListener::CodeTag::kStub:
case LogEventListener::CodeTag::kLength:
return CpuProfileNode::kInternal;
}
return CpuProfileNode::kInternal;
UNREACHABLE();
}
void ProfileNode::CollectDeoptInfo(CodeEntry* entry) {
......
......@@ -65,7 +65,7 @@ class CodeEntry {
// CodeEntry may reference strings (|name|, |resource_name|) managed by a
// StringsStorage instance. These must be freed via ReleaseStrings.
inline CodeEntry(LogEventListener::LogEventsAndTags tag, const char* name,
inline CodeEntry(LogEventListener::CodeTag tag, const char* name,
const char* resource_name = CodeEntry::kEmptyResourceName,
int line_number = v8::CpuProfileNode::kNoLineNumberInfo,
int column_number = v8::CpuProfileNode::kNoColumnNumberInfo,
......@@ -164,8 +164,12 @@ class CodeEntry {
const std::vector<CodeEntryAndLineNumber>* GetInlineStack(
int pc_offset) const;
LogEventListener::LogEventsAndTags tag() const {
return TagField::decode(bit_field_);
LogEventListener::Event event() const {
return EventField::decode(bit_field_);
}
LogEventListener::CodeTag code_tag() const {
return CodeTagField::decode(bit_field_);
}
V8_EXPORT_PRIVATE static const char* const kEmptyResourceName;
......@@ -227,7 +231,8 @@ class CodeEntry {
return ref_count_;
}
using TagField = base::BitField<LogEventListener::LogEventsAndTags, 0, 8>;
using EventField = base::BitField<LogEventListener::Event, 0, 4>;
using CodeTagField = base::BitField<LogEventListener::CodeTag, 0, 4>;
using BuiltinField = base::BitField<Builtin, 8, 20>;
static_assert(Builtins::kBuiltinCount <= BuiltinField::kNumValues,
"builtin_count exceeds size of bitfield");
......
......@@ -40,8 +40,7 @@ ProfilerListener::ProfilerListener(Isolate* isolate,
ProfilerListener::~ProfilerListener() = default;
void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
void ProfilerListener::CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
const char* name) {
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
......@@ -55,8 +54,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
DispatchCodeEvent(evt_rec);
}
void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
void ProfilerListener::CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<Name> name) {
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
......@@ -70,8 +68,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
DispatchCodeEvent(evt_rec);
}
void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
Handle<AbstractCode> code,
void ProfilerListener::CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name) {
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
......@@ -106,7 +103,7 @@ CodeEntry* GetOrInsertCachedEntry(
} // namespace
void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
void ProfilerListener::CodeCreateEvent(CodeTag tag,
Handle<AbstractCode> abstract_code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line,
......@@ -230,8 +227,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
}
#if V8_ENABLE_WEBASSEMBLY
void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
const wasm::WasmCode* code,
void ProfilerListener::CodeCreateEvent(CodeTag tag, const wasm::WasmCode* code,
wasm::WasmName name,
const char* source_url, int code_offset,
int script_id) {
......@@ -252,8 +248,8 @@ void ProfilerListener::CallbackEvent(Handle<Name> name, Address entry_point) {
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = entry_point;
rec->entry =
code_entries_.Create(LogEventListener::CALLBACK_TAG, GetName(*name));
rec->entry = code_entries_.Create(LogEventListener::CodeTag::kCallback,
GetName(*name));
rec->instruction_size = 1;
DispatchCodeEvent(evt_rec);
}
......@@ -263,7 +259,7 @@ void ProfilerListener::GetterCallbackEvent(Handle<Name> name,
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = entry_point;
rec->entry = code_entries_.Create(LogEventListener::CALLBACK_TAG,
rec->entry = code_entries_.Create(LogEventListener::CodeTag::kCallback,
GetConsName("get ", *name));
rec->instruction_size = 1;
DispatchCodeEvent(evt_rec);
......@@ -274,7 +270,7 @@ void ProfilerListener::SetterCallbackEvent(Handle<Name> name,
CodeEventsContainer evt_rec(CodeEventRecord::Type::kCodeCreation);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = entry_point;
rec->entry = code_entries_.Create(LogEventListener::CALLBACK_TAG,
rec->entry = code_entries_.Create(LogEventListener::CodeTag::kCallback,
GetConsName("set ", *name));
rec->instruction_size = 1;
DispatchCodeEvent(evt_rec);
......@@ -286,7 +282,7 @@ void ProfilerListener::RegExpCodeCreateEvent(Handle<AbstractCode> code,
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
rec->instruction_start = code->InstructionStart();
rec->entry = code_entries_.Create(
LogEventListener::REG_EXP_TAG, GetConsName("RegExp: ", *source),
LogEventListener::CodeTag::kRegExp, GetConsName("RegExp: ", *source),
CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo,
CpuProfileNode::kNoColumnNumberInfo, nullptr);
rec->instruction_size = code->InstructionSize();
......
......@@ -35,18 +35,18 @@ class V8_EXPORT_PRIVATE ProfilerListener : public LogEventListener,
ProfilerListener(const ProfilerListener&) = delete;
ProfilerListener& operator=(const ProfilerListener&) = delete;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
const char* name) override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<Name> name) override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name) override;
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line, int column) override;
#if V8_ENABLE_WEBASSEMBLY
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
void CodeCreateEvent(CodeTag tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url,
int code_offset, int script_id) override;
#endif // V8_ENABLE_WEBASSEMBLY
......
......@@ -1547,19 +1547,19 @@ RUNTIME_FUNCTION(Runtime_EnableCodeLoggingForTesting) {
// {true} on {is_listening_to_code_events()}. Feel free to add assertions to
// any method to further test the code logging callbacks.
class NoopListener final : public LogEventListener {
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
const char* name) final {}
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<Name> name) final {}
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name) final {}
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
void CodeCreateEvent(CodeTag tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line, int column) final {
}
#if V8_ENABLE_WEBASSEMBLY
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
void CodeCreateEvent(CodeTag tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url,
int code_offset, int script_id) final {}
#endif // V8_ENABLE_WEBASSEMBLY
......
......@@ -314,8 +314,8 @@ void CreateInterpreterDataForDeserializedCode(Isolate* isolate,
int line_num = script->GetLineNumber(info->StartPosition()) + 1;
int column_num = script->GetColumnNumber(info->StartPosition()) + 1;
PROFILE(isolate,
CodeCreateEvent(LogEventListener::FUNCTION_TAG, abstract_code, info,
name_handle, line_num, column_num));
CodeCreateEvent(LogEventListener::CodeTag::kFunction, abstract_code,
info, name_handle, line_num, column_num));
}
}
#endif // V8_TARGET_ARCH_ARM
......@@ -397,13 +397,13 @@ void FinalizeDeserialization(Isolate* isolate,
script->GetLineNumber(shared_info->StartPosition()) + 1;
int column_num =
script->GetColumnNumber(shared_info->StartPosition()) + 1;
PROFILE(
isolate,
CodeCreateEvent(
shared_info->is_toplevel() ? LogEventListener::SCRIPT_TAG
: LogEventListener::FUNCTION_TAG,
handle(shared_info->abstract_code(isolate), isolate),
shared_info, name, line_num, column_num));
PROFILE(isolate,
CodeCreateEvent(
shared_info->is_toplevel()
? LogEventListener::CodeTag::kScript
: LogEventListener::CodeTag::kFunction,
handle(shared_info->abstract_code(isolate), isolate),
shared_info, name, line_num, column_num));
}
}
}
......
......@@ -248,7 +248,7 @@ Handle<CodeT> JSToWasmWrapperCompilationUnit::Finalize() {
isolate_->is_profiling()) {
Handle<String> name = isolate_->factory()->NewStringFromAsciiChecked(
job_->compilation_info()->GetDebugName().get());
PROFILE(isolate_, CodeCreateEvent(LogEventListener::STUB_TAG,
PROFILE(isolate_, CodeCreateEvent(LogEventListener::CodeTag::kStub,
Handle<AbstractCode>::cast(code), name));
}
return ToCodeT(code, isolate_);
......
......@@ -289,8 +289,8 @@ void WasmCode::LogCode(Isolate* isolate, const char* source_url,
}
int code_offset = module->functions[index_].code.offset();
PROFILE(isolate, CodeCreateEvent(LogEventListener::FUNCTION_TAG, this, name,
source_url, code_offset, script_id));
PROFILE(isolate, CodeCreateEvent(LogEventListener::CodeTag::kFunction, this,
name, source_url, code_offset, script_id));
}
void WasmCode::Validate() const {
......
......@@ -13542,13 +13542,9 @@ static int move_events = 0;
static bool FunctionNameIs(const char* expected,
const v8::JitCodeEvent* event) {
// Log lines for functions are of the general form:
// "LazyCompile:<type><function_name>" or Function:<type><function_name>,
// "JS:<type><function_name>" or Function:<type><function_name>,
// where the type is one of "*", "~" or "".
static const char* kPreamble = "Function:";
if (i::FLAG_lazy &&
event->code_type != v8::JitCodeEvent::CodeType::WASM_CODE) {
kPreamble = "LazyCompile:";
}
static const char* kPreamble = "JS:";
static size_t kPreambleLen = strlen(kPreamble);
if (event->name.len < kPreambleLen ||
......@@ -192,12 +192,12 @@ TEST(CodeEvents) {
// Enqueue code creation events.
const char* aaa_str = "aaa";
i::Handle<i::String> aaa_name = factory->NewStringFromAsciiChecked(aaa_str);
profiler_listener.CodeCreateEvent(i::V8FileLogger::FUNCTION_TAG, aaa_code,
aaa_name);
profiler_listener.CodeCreateEvent(i::V8FileLogger::BUILTIN_TAG, comment_code,
"comment");
profiler_listener.CodeCreateEvent(i::V8FileLogger::BUILTIN_TAG, comment2_code,
"comment2");
profiler_listener.CodeCreateEvent(i::LogEventListener::CodeTag::kFunction,
aaa_code, aaa_name);
profiler_listener.CodeCreateEvent(i::LogEventListener::CodeTag::kBuiltin,
comment_code, "comment");
profiler_listener.CodeCreateEvent(i::LogEventListener::CodeTag::kBuiltin,
comment2_code, "comment2");
profiler_listener.CodeMoveEvent(*comment2_code, *moved_code);
// Enqueue a tick event to enable code events processing.
......@@ -257,12 +257,12 @@ TEST(TickEvents) {
*code_observer->weak_code_registry());
isolate->v8_file_logger()->AddLogEventListener(&profiler_listener);
profiler_listener.CodeCreateEvent(i::V8FileLogger::BUILTIN_TAG, frame1_code,
"bbb");
profiler_listener.CodeCreateEvent(i::V8FileLogger::STUB_TAG, frame2_code,
"ccc");
profiler_listener.CodeCreateEvent(i::V8FileLogger::BUILTIN_TAG, frame3_code,
"ddd");
profiler_listener.CodeCreateEvent(i::LogEventListener::CodeTag::kBuiltin,
frame1_code, "bbb");
profiler_listener.CodeCreateEvent(i::LogEventListener::CodeTag::kStub,
frame2_code, "ccc");
profiler_listener.CodeCreateEvent(i::LogEventListener::CodeTag::kBuiltin,
frame3_code, "ddd");
EnqueueTickSampleEvent(processor, frame1_code->raw_instruction_start());
EnqueueTickSampleEvent(processor,
......@@ -418,7 +418,8 @@ TEST(Issue1398) {
*code_observer->code_entries(),
*code_observer->weak_code_registry());
profiler_listener.CodeCreateEvent(i::V8FileLogger::BUILTIN_TAG, code, "bbb");
profiler_listener.CodeCreateEvent(i::LogEventListener::CodeTag::kBuiltin,
code, "bbb");
v8::internal::TickSample sample;
sample.pc = reinterpret_cast<void*>(code->InstructionStart());
......@@ -1310,9 +1311,9 @@ static void TickLines(bool optimize) {
i::Handle<i::String> str = factory->NewStringFromAsciiChecked(func_name);
int line = 1;
int column = 1;
profiler_listener.CodeCreateEvent(i::V8FileLogger::FUNCTION_TAG, code,
handle(func->shared(), isolate), str, line,
column);
profiler_listener.CodeCreateEvent(i::LogEventListener::CodeTag::kFunction,
code, handle(func->shared(), isolate), str,
line, column);
// Enqueue a tick event to enable code events processing.
EnqueueTickSampleEvent(processor, code_address);
......
......@@ -48,17 +48,17 @@ TEST(ProfileNodeFindOrAddChild) {
CcTest::InitializeVM();
ProfileTree tree(CcTest::i_isolate());
ProfileNode* node = tree.root();
CodeEntry entry1(i::LogEventListener::FUNCTION_TAG, "aaa");
CodeEntry entry1(i::LogEventListener::CodeTag::kFunction, "aaa");
ProfileNode* childNode1 = node->FindOrAddChild(&entry1);
CHECK(childNode1);
CHECK_EQ(childNode1, node->FindOrAddChild(&entry1));
CodeEntry entry2(i::LogEventListener::FUNCTION_TAG, "bbb");
CodeEntry entry2(i::LogEventListener::CodeTag::kFunction, "bbb");
ProfileNode* childNode2 = node->FindOrAddChild(&entry2);
CHECK(childNode2);
CHECK_NE(childNode1, childNode2);
CHECK_EQ(childNode1, node->FindOrAddChild(&entry1));
CHECK_EQ(childNode2, node->FindOrAddChild(&entry2));
CodeEntry entry3(i::LogEventListener::FUNCTION_TAG, "ccc");
CodeEntry entry3(i::LogEventListener::CodeTag::kFunction, "ccc");
ProfileNode* childNode3 = node->FindOrAddChild(&entry3);
CHECK(childNode3);
CHECK_NE(childNode1, childNode3);
......@@ -72,13 +72,13 @@ TEST(ProfileNodeFindOrAddChildWithLineNumber) {
CcTest::InitializeVM();
ProfileTree tree(CcTest::i_isolate());
ProfileNode* root = tree.root();
CodeEntry a(i::LogEventListener::FUNCTION_TAG, "a");
CodeEntry a(i::LogEventListener::CodeTag::kFunction, "a");
ProfileNode* a_node = root->FindOrAddChild(&a, -1);
// a --(22)--> child1
// --(23)--> child1
CodeEntry child1(i::LogEventListener::FUNCTION_TAG, "child1");
CodeEntry child1(i::LogEventListener::CodeTag::kFunction, "child1");
ProfileNode* child1_node = a_node->FindOrAddChild(&child1, 22);
CHECK(child1_node);
CHECK_EQ(child1_node, a_node->FindOrAddChild(&child1, 22));
......@@ -93,15 +93,15 @@ TEST(ProfileNodeFindOrAddChildForSameFunction) {
const char* aaa = "aaa";
ProfileTree tree(CcTest::i_isolate());
ProfileNode* node = tree.root();
CodeEntry entry1(i::LogEventListener::FUNCTION_TAG, aaa);
CodeEntry entry1(i::LogEventListener::CodeTag::kFunction, aaa);
ProfileNode* childNode1 = node->FindOrAddChild(&entry1);
CHECK(childNode1);
CHECK_EQ(childNode1, node->FindOrAddChild(&entry1));
// The same function again.
CodeEntry entry2(i::LogEventListener::FUNCTION_TAG, aaa);
CodeEntry entry2(i::LogEventListener::CodeTag::kFunction, aaa);
CHECK_EQ(childNode1, node->FindOrAddChild(&entry2));
// Now with a different security token.
CodeEntry entry3(i::LogEventListener::FUNCTION_TAG, aaa);
CodeEntry entry3(i::LogEventListener::CodeTag::kFunction, aaa);
CHECK_EQ(childNode1, node->FindOrAddChild(&entry3));
}
......@@ -137,9 +137,9 @@ class ProfileTreeTestHelper {
TEST(ProfileTreeAddPathFromEnd) {
CcTest::InitializeVM();
CodeEntry entry1(i::LogEventListener::FUNCTION_TAG, "aaa");
CodeEntry entry2(i::LogEventListener::FUNCTION_TAG, "bbb");
CodeEntry entry3(i::LogEventListener::FUNCTION_TAG, "ccc");
CodeEntry entry1(i::LogEventListener::CodeTag::kFunction, "aaa");
CodeEntry entry2(i::LogEventListener::CodeTag::kFunction, "bbb");
CodeEntry entry3(i::LogEventListener::CodeTag::kFunction, "ccc");
ProfileTree tree(CcTest::i_isolate());
ProfileTreeTestHelper helper(&tree);
CHECK(!helper.Walk(&entry1));
......@@ -197,9 +197,9 @@ TEST(ProfileTreeAddPathFromEnd) {
TEST(ProfileTreeAddPathFromEndWithLineNumbers) {
CcTest::InitializeVM();
CodeEntry a(i::LogEventListener::FUNCTION_TAG, "a");
CodeEntry b(i::LogEventListener::FUNCTION_TAG, "b");
CodeEntry c(i::LogEventListener::FUNCTION_TAG, "c");
CodeEntry a(i::LogEventListener::CodeTag::kFunction, "a");
CodeEntry b(i::LogEventListener::CodeTag::kFunction, "b");
CodeEntry c(i::LogEventListener::CodeTag::kFunction, "c");
ProfileTree tree(CcTest::i_isolate());
ProfileTreeTestHelper helper(&tree);
......@@ -226,7 +226,7 @@ TEST(ProfileTreeCalculateTotalTicks) {
empty_tree.root()->IncrementSelfTicks();
CHECK_EQ(1u, empty_tree.root()->self_ticks());
CodeEntry entry1(i::LogEventListener::FUNCTION_TAG, "aaa");
CodeEntry entry1(i::LogEventListener::CodeTag::kFunction, "aaa");
CodeEntry* e1_path[] = {&entry1};
std::vector<CodeEntry*> e1_path_vec(e1_path, e1_path + arraysize(e1_path));
......@@ -240,7 +240,7 @@ TEST(ProfileTreeCalculateTotalTicks) {
CHECK_EQ(1u, single_child_tree.root()->self_ticks());
CHECK_EQ(1u, node1->self_ticks());
CodeEntry entry2(i::LogEventListener::FUNCTION_TAG, "bbb");
CodeEntry entry2(i::LogEventListener::CodeTag::kFunction, "bbb");
CodeEntry* e2_e1_path[] = {&entry2, &entry1};
std::vector<CodeEntry*> e2_e1_path_vec(e2_e1_path,
e2_e1_path + arraysize(e2_e1_path));
......@@ -266,7 +266,7 @@ TEST(ProfileTreeCalculateTotalTicks) {
CodeEntry* e2_path[] = {&entry2};
std::vector<CodeEntry*> e2_path_vec(e2_path, e2_path + arraysize(e2_path));
CodeEntry entry3(i::LogEventListener::FUNCTION_TAG, "ccc");
CodeEntry entry3(i::LogEventListener::CodeTag::kFunction, "ccc");
CodeEntry* e3_path[] = {&entry3};
std::vector<CodeEntry*> e3_path_vec(e3_path, e3_path + arraysize(e3_path));
......@@ -315,10 +315,14 @@ static inline void* ToPointer(int n) { return reinterpret_cast<void*>(n); }
TEST(CodeMapAddCode) {
CodeEntryStorage storage;
CodeMap code_map(storage);
CodeEntry* entry1 = storage.Create(i::LogEventListener::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = storage.Create(i::LogEventListener::FUNCTION_TAG, "bbb");
CodeEntry* entry3 = storage.Create(i::LogEventListener::FUNCTION_TAG, "ccc");
CodeEntry* entry4 = storage.Create(i::LogEventListener::FUNCTION_TAG, "ddd");
CodeEntry* entry1 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "aaa");
CodeEntry* entry2 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "bbb");
CodeEntry* entry3 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "ccc");
CodeEntry* entry4 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "ddd");
code_map.AddCode(ToAddress(0x1500), entry1, 0x200);
code_map.AddCode(ToAddress(0x1700), entry2, 0x100);
code_map.AddCode(ToAddress(0x1900), entry3, 0x50);
......@@ -345,8 +349,10 @@ TEST(CodeMapAddCode) {
TEST(CodeMapMoveAndDeleteCode) {
CodeEntryStorage storage;
CodeMap code_map(storage);
CodeEntry* entry1 = storage.Create(i::LogEventListener::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = storage.Create(i::LogEventListener::FUNCTION_TAG, "bbb");
CodeEntry* entry1 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "aaa");
CodeEntry* entry2 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "bbb");
code_map.AddCode(ToAddress(0x1500), entry1, 0x200);
code_map.AddCode(ToAddress(0x1700), entry2, 0x100);
CHECK_EQ(entry1, code_map.FindEntry(ToAddress(0x1500)));
......@@ -359,8 +365,10 @@ TEST(CodeMapMoveAndDeleteCode) {
TEST(CodeMapClear) {
CodeEntryStorage storage;
CodeMap code_map(storage);
CodeEntry* entry1 = storage.Create(i::LogEventListener::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = storage.Create(i::LogEventListener::FUNCTION_TAG, "bbb");
CodeEntry* entry1 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "aaa");
CodeEntry* entry2 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "bbb");
code_map.AddCode(ToAddress(0x1500), entry1, 0x200);
code_map.AddCode(ToAddress(0x1700), entry2, 0x100);
......@@ -396,9 +404,12 @@ TEST(SymbolizeTickSample) {
CodeEntryStorage storage;
CodeMap code_map(storage);
Symbolizer symbolizer(&code_map);
CodeEntry* entry1 = storage.Create(i::V8FileLogger::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = storage.Create(i::V8FileLogger::FUNCTION_TAG, "bbb");
CodeEntry* entry3 = storage.Create(i::V8FileLogger::FUNCTION_TAG, "ccc");
CodeEntry* entry1 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "aaa");
CodeEntry* entry2 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "bbb");
CodeEntry* entry3 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "ccc");
symbolizer.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
symbolizer.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100);
symbolizer.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50);
......@@ -466,9 +477,12 @@ TEST(SampleIds) {
CodeEntryStorage storage;
CodeMap code_map(storage);
Symbolizer symbolizer(&code_map);
CodeEntry* entry1 = storage.Create(i::V8FileLogger::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = storage.Create(i::V8FileLogger::FUNCTION_TAG, "bbb");
CodeEntry* entry3 = storage.Create(i::V8FileLogger::FUNCTION_TAG, "ccc");
CodeEntry* entry1 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "aaa");
CodeEntry* entry2 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "bbb");
CodeEntry* entry3 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "ccc");
symbolizer.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
symbolizer.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100);
symbolizer.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50);
......@@ -677,7 +691,8 @@ TEST(NoSamples) {
CodeEntryStorage storage;
CodeMap code_map(storage);
Symbolizer symbolizer(&code_map);
CodeEntry* entry1 = storage.Create(i::V8FileLogger::FUNCTION_TAG, "aaa");
CodeEntry* entry1 =
storage.Create(i::LogEventListener::CodeTag::kFunction, "aaa");
symbolizer.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
// We are building the following calls tree:
......@@ -937,15 +952,15 @@ TEST(BailoutReason) {
TEST(NodeSourceTypes) {
ProfileTree tree(CcTest::i_isolate());
CodeEntry function_entry(LogEventListener::FUNCTION_TAG, "function");
CodeEntry function_entry(LogEventListener::CodeTag::kFunction, "function");
tree.AddPathFromEnd({&function_entry});
CodeEntry builtin_entry(LogEventListener::BUILTIN_TAG, "builtin");
CodeEntry builtin_entry(LogEventListener::CodeTag::kBuiltin, "builtin");
tree.AddPathFromEnd({&builtin_entry});
CodeEntry callback_entry(LogEventListener::CALLBACK_TAG, "callback");
CodeEntry callback_entry(LogEventListener::CodeTag::kCallback, "callback");
tree.AddPathFromEnd({&callback_entry});
CodeEntry regex_entry(LogEventListener::REG_EXP_TAG, "regex");
CodeEntry regex_entry(LogEventListener::CodeTag::kRegExp, "regex");
tree.AddPathFromEnd({&regex_entry});
CodeEntry stub_entry(LogEventListener::STUB_TAG, "stub");
CodeEntry stub_entry(LogEventListener::CodeTag::kStub, "stub");
tree.AddPathFromEnd({&stub_entry});
tree.AddPathFromEnd({CodeEntry::gc_entry()});
......@@ -998,7 +1013,8 @@ TEST(CodeMapRemoveCode) {
CodeEntryStorage storage;
CodeMap code_map(storage);
CodeEntry* entry = storage.Create(i::LogEventListener::FUNCTION_TAG, "aaa");
CodeEntry* entry =
storage.Create(i::LogEventListener::CodeTag::kFunction, "aaa");
code_map.AddCode(ToAddress(0x1000), entry, 0x100);
CHECK(code_map.RemoveCode(entry));
CHECK(!code_map.FindEntry(ToAddress(0x1000)));
......@@ -1006,9 +1022,9 @@ TEST(CodeMapRemoveCode) {
// Test that when two entries share the same address, we remove only the
// entry that we desired to.
CodeEntry* colliding_entry1 =
storage.Create(i::LogEventListener::FUNCTION_TAG, "aaa");
storage.Create(i::LogEventListener::CodeTag::kFunction, "aaa");
CodeEntry* colliding_entry2 =
storage.Create(i::LogEventListener::FUNCTION_TAG, "aaa");
storage.Create(i::LogEventListener::CodeTag::kFunction, "aaa");
code_map.AddCode(ToAddress(0x1000), colliding_entry1, 0x100);
code_map.AddCode(ToAddress(0x1000), colliding_entry2, 0x100);
......@@ -1023,11 +1039,11 @@ TEST(CodeMapMoveOverlappingCode) {
CodeEntryStorage storage;
CodeMap code_map(storage);
CodeEntry* colliding_entry1 =
storage.Create(i::LogEventListener::FUNCTION_TAG, "aaa");
storage.Create(i::LogEventListener::CodeTag::kFunction, "aaa");
CodeEntry* colliding_entry2 =
storage.Create(i::LogEventListener::FUNCTION_TAG, "bbb");
storage.Create(i::LogEventListener::CodeTag::kFunction, "bbb");
CodeEntry* after_entry =
storage.Create(i::LogEventListener::FUNCTION_TAG, "ccc");
storage.Create(i::LogEventListener::CodeTag::kFunction, "ccc");
code_map.AddCode(ToAddress(0x1400), colliding_entry1, 0x200);
code_map.AddCode(ToAddress(0x1400), colliding_entry2, 0x200);
......
......@@ -541,7 +541,7 @@ TEST_F(LogAllTest, LogAll) {
CHECK(logger.ContainsLine({"timer-event-start", "V8.CompileCode"}));
CHECK(logger.ContainsLine({"timer-event-end", "V8.CompileCode"}));
CHECK(logger.ContainsLine({"code-creation,Script", ":1:1"}));
CHECK(logger.ContainsLine({"code-creation,LazyCompile,", "testAddFn"}));
CHECK(logger.ContainsLine({"code-creation,JS,", "testAddFn"}));
if (i::FLAG_turbofan && !i::FLAG_always_turbofan) {
CHECK(logger.ContainsLine({"code-deopt,", "not a Smi"}));
......@@ -573,8 +573,8 @@ TEST_F(LogInterpretedFramesNativeStackTest, LogInterpretedFramesNativeStack) {
logger.StopLogging();
CHECK(logger.ContainsLinesInOrder(
{{"LazyCompile", "testLogInterpretedFramesNativeStack"},
{"LazyCompile", "testLogInterpretedFramesNativeStack"}}));
{{"JS", "testLogInterpretedFramesNativeStack"},
{"JS", "testLogInterpretedFramesNativeStack"}}));
}
}
......@@ -656,7 +656,7 @@ TEST_F(LogInterpretedFramesNativeStackWithSerializationTest,
// Function is logged twice: once as interpreted, and once as the
// interpreter entry trampoline builtin.
CHECK(logger.ContainsLinesInOrder(
{{"Function", "eyecatcher"}, {"Function", "eyecatcher"}}));
{{"JS", "eyecatcher"}, {"JS", "eyecatcher"}}));
}
v8::Local<v8::Value> arg = Number::New(isolate, 3);
v8::Local<v8::Value> result =
......@@ -699,6 +699,7 @@ TEST_F(LogExternalLogEventListenerTest, ExternalLogEventListener) {
CHECK_EQ(code_event_handler.CountLines("Function",
"testLogEventListenerBeforeStart"),
0);
// We no longer log LazyCompile.
CHECK_EQ(code_event_handler.CountLines("LazyCompile",
"testLogEventListenerBeforeStart"),
0);
......@@ -714,9 +715,13 @@ TEST_F(LogExternalLogEventListenerTest, ExternalLogEventListener) {
"testLogEventListenerAfterStart('1', 1);";
RunJS(source_text_after_start);
CHECK_GE(code_event_handler.CountLines("LazyCompile",
CHECK_GE(code_event_handler.CountLines("Function",
"testLogEventListenerAfterStart"),
1);
// We no longer log LazyCompile.
CHECK_GE(code_event_handler.CountLines("LazyCompile",
"testLogEventListenerAfterStart"),
0);
}
}
......@@ -845,7 +850,7 @@ TEST_F(LogExternalInterpretedFramesNativeStackTest,
"testLogEventListenerAfterStart('1', 1);";
RunJS(source_text_after_start);
CHECK_GE(code_event_handler.CountLines("LazyCompile",
CHECK_GE(code_event_handler.CountLines("Function",
"testLogEventListenerAfterStart"),
2);
......@@ -1185,16 +1190,16 @@ TEST_F(LogFunctionEventsTest, LogFunctionEvents) {
// Step 4. - lazy parse, lazy compiling and execute skipped functions
// - execute eager functions.
{"function,parse-function,", ",lazyFunction"},
{"function,interpreter-lazy,", ",lazyFunction"},
{"function,interpreter,", ",lazyFunction"},
{"function,parse-function,", ",lazyInnerFunction"},
{"function,interpreter-lazy,", ",lazyInnerFunction"},
{"function,interpreter,", ",lazyInnerFunction"},
{"function,parse-function,", ",Foo"},
{"function,interpreter-lazy,", ",Foo"},
{"function,interpreter,", ",Foo"},
{"function,parse-function,", ",Foo.foo"},
{"function,interpreter-lazy,", ",Foo.foo"},
{"function,interpreter,", ",Foo.foo"},
};
CHECK(logger.ContainsLinesInOrder(lines));
}
......@@ -1214,7 +1219,7 @@ TEST_F(LogTest, BuiltinsNotLoggedAsLazyCompile) {
i_isolate);
v8::base::EmbeddedVector<char, 100> buffer;
// Should only be logged as "Builtin" with a name, never as "LazyCompile".
// Should only be logged as "Builtin" with a name, never as "Function".
v8::base::SNPrintF(buffer, ",0x%" V8PRIxPTR ",%d,BooleanConstructor",
builtin->InstructionStart(), builtin->InstructionSize());
CHECK(logger.ContainsLine(
......@@ -1223,7 +1228,7 @@ TEST_F(LogTest, BuiltinsNotLoggedAsLazyCompile) {
v8::base::SNPrintF(buffer, ",0x%" V8PRIxPTR ",%d,",
builtin->InstructionStart(), builtin->InstructionSize());
CHECK(!logger.ContainsLine(
{"code-creation,LazyCompile,2,", std::string(buffer.begin())}));
{"code-creation,JS,2,", std::string(buffer.begin())}));
}
}
} // namespace v8
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