Browse Source

Cleanups.

cl-refactor
Paweł Bylica 10 years ago
parent
commit
e4456e34fa
  1. 8
      include/evmjit/JIT.h
  2. 2
      libevmjit-cpp/JitVM.cpp
  3. 4
      libevmjit/Arith256.cpp
  4. 2
      libevmjit/Optimizer.cpp
  5. 2
      libevmjit/RuntimeManager.h

8
include/evmjit/JIT.h

@ -20,12 +20,13 @@ namespace evmjit
using byte = uint8_t;
using bytes_ref = std::tuple<byte const*, size_t>;
/// 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<dev::evmjit::h256>
};
};
}

2
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<evmjit::Env*>(&_ext));
auto exitCode = evmjit::JIT::exec(m_context);
switch (exitCode)

4
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);

2
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;

2
libevmjit/RuntimeManager.h

@ -63,7 +63,7 @@ private:
llvm::Value* m_memPtr = nullptr;
llvm::Value* m_envPtr = nullptr;
std::array<llvm::Value*, static_cast<size_t>(RuntimeData::Index::CodeSize) + 1> m_dataElts;
std::array<llvm::Value*, RuntimeData::numElements> m_dataElts;
llvm::Value* m_stackSize = nullptr;
llvm::Function* m_checkStackLimit = nullptr;

Loading…
Cancel
Save