diff --git a/include/evmjit/JIT.h b/include/evmjit/JIT.h index 0a938fae9..fcb0db4e7 100644 --- a/include/evmjit/JIT.h +++ b/include/evmjit/JIT.h @@ -20,12 +20,13 @@ namespace evmjit using byte = uint8_t; using bytes_ref = std::tuple; +/// Representation of 256-bit hash value struct h256 { uint64_t words[4]; }; -inline bool operator==(h256 _h1, h256 _h2) +inline bool operator==(h256 const& _h1, h256 const& _h2) { return _h1.words[0] == _h2.words[0] && _h1.words[1] == _h2.words[1] && @@ -39,7 +40,7 @@ struct i256 uint64_t words[4]; i256() = default; - i256(h256 _h) { std::memcpy(this, &_h, sizeof(*this)); } + i256(h256 const& _h) { std::memcpy(this, &_h, sizeof(*this)); } }; // TODO: Merge with ExecutionContext @@ -68,6 +69,8 @@ struct RuntimeData ReturnDataSize = CallDataSize, ///< Return data size (set only in case of RETURN) }; + static size_t const numElements = CodeSize + 1; + int64_t gas = 0; int64_t gasPrice = 0; byte const* callData = nullptr; @@ -170,4 +173,3 @@ template<> struct hash }; }; } - diff --git a/libevmjit-cpp/JitVM.cpp b/libevmjit-cpp/JitVM.cpp index 169ce68ae..2fb2a0e67 100644 --- a/libevmjit-cpp/JitVM.cpp +++ b/libevmjit-cpp/JitVM.cpp @@ -50,6 +50,8 @@ bytesConstRef JitVM::execImpl(u256& io_gas, ExtVMFace& _ext, OnOpFunc const& _on m_data.codeSize = _ext.code.size(); m_data.codeHash = eth2jit(_ext.codeHash); + // Pass pointer to ExtVMFace casted to evmjit::Env* opaque type. + // JIT will do nothing with the pointer, just pass it to Env callback functions implemented in Env.cpp. m_context.init(m_data, reinterpret_cast(&_ext)); auto exitCode = evmjit::JIT::exec(m_context); switch (exitCode) diff --git a/libevmjit/Arith256.cpp b/libevmjit/Arith256.cpp index 066596e4c..76c53c78d 100644 --- a/libevmjit/Arith256.cpp +++ b/libevmjit/Arith256.cpp @@ -132,7 +132,7 @@ namespace llvm::Function* createUDivRemFunc(llvm::Type* _type, llvm::Module& _module, char const* _funcName) { // Based of "Improved shift divisor algorithm" from "Software Integer Division" by Microsoft Research - // The following algorithm also handles divisor of value 0 returning 0 for both quotient and reminder + // The following algorithm also handles divisor of value 0 returning 0 for both quotient and remainder auto retType = llvm::VectorType::get(_type, 2); auto func = llvm::Function::Create(llvm::FunctionType::get(retType, {_type, _type}, false), llvm::Function::PrivateLinkage, _funcName, &_module); @@ -327,7 +327,7 @@ llvm::Function* Arith256::getSDivRem256Func(llvm::Module& _module) auto qAbs = builder.CreateExtractElement(res, uint64_t(0)); auto rAbs = builder.CreateExtractElement(res, 1); - // the reminder has the same sign as dividend + // the remainder has the same sign as dividend auto rNeg = builder.CreateSub(Constant::get(0), rAbs); auto r = builder.CreateSelect(xIsNeg, rNeg, rAbs); diff --git a/libevmjit/Optimizer.cpp b/libevmjit/Optimizer.cpp index b097a2e3f..dea3ea2a0 100644 --- a/libevmjit/Optimizer.cpp +++ b/libevmjit/Optimizer.cpp @@ -32,7 +32,7 @@ bool optimize(llvm::Module& _module) namespace { -class LowerEVMPass : public llvm::BasicBlockPass +class LowerEVMPass: public llvm::BasicBlockPass { static char ID; diff --git a/libevmjit/RuntimeManager.h b/libevmjit/RuntimeManager.h index 98d5b3132..8c0728aaf 100644 --- a/libevmjit/RuntimeManager.h +++ b/libevmjit/RuntimeManager.h @@ -63,7 +63,7 @@ private: llvm::Value* m_memPtr = nullptr; llvm::Value* m_envPtr = nullptr; - std::array(RuntimeData::Index::CodeSize) + 1> m_dataElts; + std::array m_dataElts; llvm::Value* m_stackSize = nullptr; llvm::Function* m_checkStackLimit = nullptr;