Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: syzygy/core/disassembler_util.cc

Issue 2543673002: Add support for more AVX instructions. (Closed)
Patch Set: Address nit. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | syzygy/core/disassembler_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: syzygy/core/disassembler_util.cc
diff --git a/syzygy/core/disassembler_util.cc b/syzygy/core/disassembler_util.cc
index c5cdac8d3a7ee7d6a0b1cc1d60f43b7d14bb67c4..7be5c8781853644f4d74abb1c39bed05a1411cca 100644
--- a/syzygy/core/disassembler_util.cc
+++ b/syzygy/core/disassembler_util.cc
@@ -14,6 +14,8 @@
#include "syzygy/core/disassembler_util.h"
+#include <algorithm>
+
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "mnemonics.h" // NOLINT
@@ -49,21 +51,19 @@ size_t Get3ByteVexEncodedInstructionSize(_CodeInfo* ci) {
DCHECK_EQ(0xC4, ci->code[0]);
// Switch case based on the opcode map used by this instruction.
switch (ci->code[1] & 0x1F) {
- case 0x01: {
- switch (ci->code[3]) {
- case 0x1D: return 5; // vpermd
- default: break;
- }
- break;
- }
case 0x02: {
switch (ci->code[3]) {
case 0x13: return 5; // vcvtps2ps
case 0x18: return 5; // vbroadcastss
case 0x36: return 5; // vpermd
+ case 0x58: return 6; // vpbroadcastd
case 0x5A: return 6; // vbroadcasti128
case 0x78: return 5; // vpbroadcastb
- default: break;
+ case 0x8C: return 5; // vpmaskmovd
+ case 0x8E: return 5; // vpmaskmovd
+ case 0x90: return 6; // vpgatherdd
+ default:
+ break;
}
break;
}
@@ -80,6 +80,21 @@ size_t Get3ByteVexEncodedInstructionSize(_CodeInfo* ci) {
default:
break;
}
+
+ // Print the instructions that we haven't been able to decompose in a format
+ // that can easily be pasted into ODA (https://onlinedisassembler.com/).
+ const int kMaxBytes = 10;
+ size_t byte_count = std::min(ci->codeLen, kMaxBytes);
+ std::string instruction_bytes;
+ for (size_t i = 0; i < byte_count; ++i) {
+ base::StringAppendF(&instruction_bytes, "%02X", ci->code[i]);
+ if (i != byte_count - 1)
+ instruction_bytes += " ";
+ }
+ if (ci->codeLen > kMaxBytes)
+ instruction_bytes += "...";
+ LOG(WARNING) << "Failed to decompose a VEX encoded instructions with the "
+ << "following bytes: " << instruction_bytes;
return 0;
}
« no previous file with comments | « no previous file | syzygy/core/disassembler_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698