Refactoring (#95)

* Blake2Generator::getInt32 renamed to getUInt32 to avoid confusion
* isPowerOf2 renamed to isZeroOrPowerOf2 to avoid confusion
* added asserts to validate the input/output size of AES functions
* fixed possible overflow in JitCompilerX86::getCodeSize (unused function)
This commit is contained in:
tevador
2019-07-03 18:13:20 +02:00
committed by GitHub
parent 08f7a2c2f2
commit 89aba80925
9 changed files with 20 additions and 15 deletions
+2 -2
View File
@@ -197,7 +197,7 @@ namespace randomx {
static const uint8_t* NOPX[] = { NOP1, NOP2, NOP3, NOP4, NOP5, NOP6, NOP7, NOP8 };
size_t JitCompilerX86::getCodeSize() {
return codePos - prologueSize;
return codePos < prologueSize ? 0 : codePos - prologueSize;
}
JitCompilerX86::JitCompilerX86() {
@@ -580,7 +580,7 @@ namespace randomx {
void JitCompilerX86::h_IMUL_RCP(Instruction& instr, int i) {
uint64_t divisor = instr.getImm32();
if (!isPowerOf2(divisor)) {
if (!isZeroOrPowerOf2(divisor)) {
registerUsage[instr.dst] = i;
emit(MOV_RAX_I);
emit64(randomx_reciprocal_fast(divisor));