Commit c69b03ba authored by Daniel Clifford's avatar Daniel Clifford Committed by Commit Bot

Fix support for Builtin names for --gdbjit-full

Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: Ib76185e7b6bc893460b97b43cc385412485da20c
Reviewed-on: https://chromium-review.googlesource.com/956464
Commit-Queue: Daniel Clifford <danno@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52188}
parent 78c6bbd9
......@@ -6582,8 +6582,17 @@ struct JitCodeEvent {
// statement, and is used to indicate possible break locations.
enum PositionType { POSITION, STATEMENT_POSITION };
// There are two different kinds of JitCodeEvents, one for JIT code generated
// by the optimizing compiler, and one for byte code generated for the
// interpreter. For JIT_CODE events, the |code_start| member of the event
// points to the beginning of jitted assembly code, while for BYTE_CODE
// events, |code_start| points to the first bytecode of the interpreted
// function.
enum CodeType { BYTE_CODE, JIT_CODE };
// Type of event.
EventType type;
CodeType code_type;
// Start of the instructions.
void* code_start;
// Size of the instructions.
......
......@@ -62,6 +62,13 @@ CompilationInfo::CompilationInfo(Vector<const char> debug_name, Zone* zone,
if (code_kind == Code::BYTECODE_HANDLER && has_untrusted_code_mitigations()) {
SetFlag(CompilationInfo::kGenerateSpeculationPoisonOnEntry);
}
#if ENABLE_GDB_JIT_INTERFACE
#if DEBUG
if (code_kind == Code::BUILTIN || code_kind == Code::STUB) {
MarkAsSourcePositionsEnabled();
}
#endif
#endif
}
CompilationInfo::CompilationInfo(Vector<const char> debug_name,
......
......@@ -996,11 +996,7 @@ class CodeDescription BASE_EMBEDDED {
Script* script() { return Script::cast(shared_info_->script()); }
bool IsLineInfoAvailable() {
return has_script() && script()->source()->IsString() &&
script()->HasValidSource() && script()->name()->IsString() &&
lineinfo_ != nullptr;
}
bool IsLineInfoAvailable() { return lineinfo_ != nullptr; }
#if V8_TARGET_ARCH_X64
uintptr_t GetStackStateStartAddress(StackState state) const {
......@@ -1015,11 +1011,22 @@ class CodeDescription BASE_EMBEDDED {
#endif
std::unique_ptr<char[]> GetFilename() {
return String::cast(script()->name())->ToCString();
if (shared_info_ != nullptr) {
return String::cast(script()->name())->ToCString();
} else {
std::unique_ptr<char[]> result(new char[1]);
result[0] = 0;
return result;
}
}
int GetScriptLineNumber(int pos) { return script()->GetLineNumber(pos) + 1; }
int GetScriptLineNumber(int pos) {
if (shared_info_ != nullptr) {
return script()->GetLineNumber(pos) + 1;
} else {
return 0;
}
}
private:
const char* name_;
......@@ -2167,6 +2174,7 @@ static void AddCode(const char* name, Code* code, SharedFunctionInfo* shared,
void EventHandler(const v8::JitCodeEvent* event) {
if (!FLAG_gdbjit) return;
if (event->code_type != v8::JitCodeEvent::JIT_CODE) return;
base::LockGuard<base::Mutex> lock_guard(mutex.Pointer());
switch (event->type) {
case v8::JitCodeEvent::CODE_ADDED: {
......
......@@ -32,7 +32,7 @@ class Log {
static bool InitLogAtStart() {
return FLAG_log || FLAG_log_api || FLAG_log_code || FLAG_log_handles ||
FLAG_log_suspect || FLAG_ll_prof || FLAG_perf_basic_prof ||
FLAG_perf_prof || FLAG_log_source_code ||
FLAG_perf_prof || FLAG_log_source_code || FLAG_gdbjit ||
FLAG_log_internal_timer_events || FLAG_prof_cpp || FLAG_trace_ic ||
FLAG_log_function_events;
}
......
......@@ -505,6 +505,8 @@ void JitLogger::LogRecordedBuffer(AbstractCode* code,
memset(&event, 0, sizeof(event));
event.type = JitCodeEvent::CODE_ADDED;
event.code_start = code->instruction_start();
event.code_type =
code->IsCode() ? JitCodeEvent::JIT_CODE : JitCodeEvent::BYTE_CODE;
event.code_len = code->instruction_size();
Handle<SharedFunctionInfo> shared_function_handle;
if (shared && shared->script()->IsScript()) {
......@@ -521,6 +523,7 @@ void JitLogger::LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
JitCodeEvent event;
memset(&event, 0, sizeof(event));
event.type = JitCodeEvent::CODE_ADDED;
event.code_type = JitCodeEvent::JIT_CODE;
event.code_start = code->instructions().start();
event.code_len = code->instructions().length();
event.name.str = name;
......@@ -533,6 +536,8 @@ void JitLogger::CodeMoveEvent(AbstractCode* from, Address to) {
JitCodeEvent event;
event.type = JitCodeEvent::CODE_MOVED;
event.code_type =
from->IsCode() ? JitCodeEvent::JIT_CODE : JitCodeEvent::BYTE_CODE;
event.code_start = from->instruction_start();
event.code_len = from->instruction_size();
......
......@@ -163,6 +163,13 @@ Code* BuiltinDeserializer::DeserializeBuiltinRaw(int builtin_id) {
Code* code = Code::cast(o);
Assembler::FlushICache(code->instruction_start(), code->instruction_size());
PROFILE(isolate(), CodeCreateEvent(CodeEventListener::BUILTIN_TAG,
AbstractCode::cast(code),
Builtins::name(builtin_id)));
LOG_CODE_EVENT(isolate(),
CodeLinePosInfoRecordEvent(
code->instruction_start(),
ByteArray::cast(code->source_position_table())));
return code;
}
......@@ -187,6 +194,13 @@ Code* BuiltinDeserializer::DeserializeHandlerRaw(Bytecode bytecode,
Code* code = Code::cast(o);
Assembler::FlushICache(code->instruction_start(), code->instruction_size());
const char* handler_name =
isolate()->interpreter()->LookupNameOfBytecodeHandler(code);
if (handler_name == nullptr) {
handler_name = "UnknownBytecodeHadler";
}
PROFILE(isolate(), CodeCreateEvent(CodeEventListener::HANDLER_TAG,
AbstractCode::cast(code), handler_name));
return code;
}
......
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