Commit c6853493 authored by Lu Yahan's avatar Lu Yahan Committed by V8 LUCI CQ

[riscv64] Reduce the print of "call to builtin"

When run jalr and pc is contained in Builtin code range, sim will print "Call to builtin".
This cl reduces the print of "Call to builtin"  which only be printed when call builtin and return to builtin.

Change-Id: Ic84101e892ed661cf41ac4d8d83bfff1ef7b4d5f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3030382
Auto-Submit: Yahan Lu <yahan@iscas.ac.cn>
Commit-Queue: Ji Qiu <qiuji@iscas.ac.cn>
Reviewed-by: 's avatarJi Qiu <qiuji@iscas.ac.cn>
Cr-Commit-Position: refs/heads/master@{#75772}
parent e0036c55
......@@ -2826,6 +2826,14 @@ void Simulator::DecodeRVR4Type() {
}
}
Builtin Simulator::LookUp(Address pc) {
for (Builtin builtin = Builtins::kFirst; builtin <= Builtins::kLast;
++builtin) {
if (builtins_.code(builtin).contains(isolate_, pc)) return builtin;
}
return Builtin::kNoBuiltinId;
}
void Simulator::DecodeRVIType() {
switch (instr_.InstructionBits() & kITypeMask) {
case RO_JALR: {
......@@ -2834,29 +2842,34 @@ void Simulator::DecodeRVIType() {
int64_t next_pc = (rs1() + imm12()) & ~reg_t(1);
set_pc(next_pc);
if (::v8::internal::FLAG_trace_sim) {
if ((rs1_reg() != ra || imm12() != 0)) {
const char* name = builtins_.Lookup((Address)next_pc);
if (name != nullptr) {
int64_t arg0 = get_register(a0);
int64_t arg1 = get_register(a1);
int64_t arg2 = get_register(a2);
int64_t arg3 = get_register(a3);
int64_t arg4 = get_register(a4);
int64_t arg5 = get_register(a5);
int64_t arg6 = get_register(a6);
int64_t arg7 = get_register(a7);
int64_t* stack_pointer =
reinterpret_cast<int64_t*>(get_register(sp));
int64_t arg8 = stack_pointer[0];
int64_t arg9 = stack_pointer[1];
PrintF(
"Call to Builtin at %s "
"a0 %08" PRIx64 " ,a1 %08" PRIx64 " ,a2 %08" PRIx64
" ,a3 %08" PRIx64 " ,a4 %08" PRIx64 " ,a5 %08" PRIx64
" ,a6 %08" PRIx64 " ,a7 %08" PRIx64 " ,0(sp) %08" PRIx64
" ,8(sp) %08" PRIx64 " ,sp %08" PRIx64 ",fp %08" PRIx64 " \n",
name, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8,
arg9, get_register(sp), get_register(fp));
Builtin builtin = LookUp((Address)get_pc());
if (builtin != Builtin::kNoBuiltinId) {
auto code = builtins_.code(builtin);
if ((rs1_reg() != ra || imm12() != 0)) {
if ((Address)get_pc() == code.InstructionStart()) {
int64_t arg0 = get_register(a0);
int64_t arg1 = get_register(a1);
int64_t arg2 = get_register(a2);
int64_t arg3 = get_register(a3);
int64_t arg4 = get_register(a4);
int64_t arg5 = get_register(a5);
int64_t arg6 = get_register(a6);
int64_t arg7 = get_register(a7);
int64_t* stack_pointer =
reinterpret_cast<int64_t*>(get_register(sp));
int64_t arg8 = stack_pointer[0];
int64_t arg9 = stack_pointer[1];
PrintF(
"Call to Builtin at %s "
"a0 %08" PRIx64 " ,a1 %08" PRIx64 " ,a2 %08" PRIx64
" ,a3 %08" PRIx64 " ,a4 %08" PRIx64 " ,a5 %08" PRIx64
" ,a6 %08" PRIx64 " ,a7 %08" PRIx64 " ,0(sp) %08" PRIx64
" ,8(sp) %08" PRIx64 " ,sp %08" PRIx64 ",fp %08" PRIx64 " \n",
builtins_.name(builtin), arg0, arg1, arg2, arg3, arg4, arg5,
arg6, arg7, arg8, arg9, get_register(sp), get_register(fp));
}
} else if (rd_reg() == zero_reg) {
PrintF("Return to Builtin at %s \n", builtins_.name(builtin));
}
}
}
......@@ -3468,8 +3481,8 @@ void Simulator::InstructionDecode(Instruction* instr) {
}
if (::v8::internal::FLAG_trace_sim) {
PrintF(" 0x%012" PRIxPTR " %ld %-44s %s\n",
reinterpret_cast<intptr_t>(instr), icount_, buffer.begin(),
PrintF(" 0x%012" PRIxPTR " %-44s %s\n",
reinterpret_cast<intptr_t>(instr), buffer.begin(),
trace_buf_.begin());
}
......
......@@ -610,6 +610,7 @@ class Simulator : public SimulatorBase {
return alu_out;
}
Builtin LookUp(Address pc);
// RISCV decoding routine
void DecodeRVRType();
void DecodeRVR4Type();
......
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