Commit e9df29e3 authored by QiuJi's avatar QiuJi Committed by V8 LUCI CQ

[riscv64] Make disassembler recognize illegal inst

Bug: 
Change-Id: If5cb112f838e73bcec5e9971a12e1f88ab41e996
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2874399Reviewed-by: 's avatarBrice Dobry <brice.dobry@futurewei.com>
Commit-Queue: Brice Dobry <brice.dobry@futurewei.com>
Cr-Commit-Position: refs/heads/master@{#74549}
parent 8b74fd45
...@@ -106,6 +106,9 @@ int FPURegisters::Number(const char* name) { ...@@ -106,6 +106,9 @@ int FPURegisters::Number(const char* name) {
} }
InstructionBase::Type InstructionBase::InstructionType() const { InstructionBase::Type InstructionBase::InstructionType() const {
if (IsIllegalInstruction()) {
return kUnsupported;
}
// RV64C Instruction // RV64C Instruction
if (FLAG_riscv_c_extension && IsShortInstruction()) { if (FLAG_riscv_c_extension && IsShortInstruction()) {
switch (InstructionBits() & kRvcOpcodeMask) { switch (InstructionBits() & kRvcOpcodeMask) {
......
...@@ -727,6 +727,11 @@ class InstructionBase { ...@@ -727,6 +727,11 @@ class InstructionBase {
kUnsupported = -1 kUnsupported = -1
}; };
inline bool IsIllegalInstruction() const {
uint8_t FirstHalfWord = *reinterpret_cast<const uint16_t*>(this);
return FirstHalfWord == 0;
}
inline bool IsShortInstruction() const { inline bool IsShortInstruction() const {
uint8_t FirstByte = *reinterpret_cast<const uint8_t*>(this); uint8_t FirstByte = *reinterpret_cast<const uint8_t*>(this);
return (FirstByte & 0x03) <= C2; return (FirstByte & 0x03) <= C2;
......
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