From 01b6974a18ad93924bdace7e25161a9ff3c529bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 30 Oct 2014 19:22:01 +0100 Subject: [PATCH] Use readPushData() in instruction compilation --- libevmjit/Compiler.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libevmjit/Compiler.cpp b/libevmjit/Compiler.cpp index c63418753..92357e8d8 100644 --- a/libevmjit/Compiler.cpp +++ b/libevmjit/Compiler.cpp @@ -554,15 +554,11 @@ void Compiler::compileBasicBlock(BasicBlock& basicBlock, bytesConstRef bytecode, case Instruction::ANY_PUSH: { - const auto numBytes = static_cast(inst) - static_cast(Instruction::PUSH1) + 1; - auto value = llvm::APInt(256, 0); - for (auto lastPC = currentPC + numBytes; currentPC < lastPC;) - { - value <<= 8; - value |= bytecode[++currentPC]; - } + auto curr = bytecode.begin() + currentPC; // TODO: replace currentPC with iterator + auto value = readPushData(curr, bytecode.end()); + currentPC = curr - bytecode.begin(); - stack.push(m_builder.getInt(value)); + stack.push(Constant::get(value)); break; }