Browse Source

Change namespace from `evmcc` to `dev::eth::jit`

[#80021262]
cl-refactor
Paweł Bylica 10 years ago
parent
commit
e33be3bbdb
  1. 9
      evmcc/BasicBlock.cpp
  2. 9
      evmcc/BasicBlock.h
  3. 9
      evmcc/Compiler.cpp
  4. 8
      evmcc/Compiler.h
  5. 12
      evmcc/ExecutionEngine.cpp
  6. 10
      evmcc/ExecutionEngine.h
  7. 11
      evmcc/Ext.cpp
  8. 11
      evmcc/Ext.h
  9. 9
      evmcc/GasMeter.cpp
  10. 9
      evmcc/GasMeter.h
  11. 15
      evmcc/Memory.cpp
  12. 10
      evmcc/Memory.h
  13. 10
      evmcc/Runtime.cpp
  14. 10
      evmcc/Runtime.h
  15. 9
      evmcc/Type.cpp
  16. 9
      evmcc/Type.h
  17. 10
      evmcc/Utils.cpp
  18. 10
      evmcc/Utils.h
  19. 10
      evmcc/evmcc.cpp

9
evmcc/BasicBlock.cpp

@ -6,7 +6,11 @@
#include "Type.h" #include "Type.h"
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
const char* BasicBlock::NamePrefix = "Instr."; const char* BasicBlock::NamePrefix = "Instr.";
@ -69,3 +73,6 @@ void BasicBlock::Stack::swap(size_t _index)
} }
} }
}
}

9
evmcc/BasicBlock.h

@ -3,7 +3,11 @@
#include <llvm/IR/BasicBlock.h> #include <llvm/IR/BasicBlock.h>
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
using ProgramCounter = uint64_t; // TODO: Rename using ProgramCounter = uint64_t; // TODO: Rename
@ -74,3 +78,6 @@ private:
}; };
} }
}
}

9
evmcc/Compiler.cpp

@ -16,7 +16,11 @@
#include "GasMeter.h" #include "GasMeter.h"
#include "Utils.h" #include "Utils.h"
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
using dev::eth::Instruction; using dev::eth::Instruction;
@ -945,3 +949,6 @@ void Compiler::linkBasicBlocks()
} }
} }
}
}

8
evmcc/Compiler.h

@ -7,7 +7,11 @@
#include "BasicBlock.h" #include "BasicBlock.h"
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
class Compiler class Compiler
@ -66,3 +70,5 @@ private:
}; };
} }
}
}

12
evmcc/ExecutionEngine.cpp

@ -21,7 +21,11 @@
#include "Memory.h" #include "Memory.h"
#include "Type.h" #include "Type.h"
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
ExecutionEngine::ExecutionEngine() ExecutionEngine::ExecutionEngine()
@ -91,7 +95,7 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module)
ext->currentBlock.gasLimit = 1008; ext->currentBlock.gasLimit = 1008;
std::string calldata = "Hello the Beautiful World of Ethereum!"; std::string calldata = "Hello the Beautiful World of Ethereum!";
ext->data = calldata; ext->data = calldata;
unsigned char fakecode[] = { 0x0d, 0x0e, 0x0a, 0x0d, 0x0b, 0x0e, 0xe, 0xf }; unsigned char fakecode[] = {0x0d, 0x0e, 0x0a, 0x0d, 0x0b, 0x0e, 0xe, 0xf};
ext->code = decltype(ext->code)(fakecode, 8); ext->code = decltype(ext->code)(fakecode, 8);
// Init runtime // Init runtime
@ -118,7 +122,7 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module)
returnCode = static_cast<ReturnCode>(r); returnCode = static_cast<ReturnCode>(r);
gas = static_cast<decltype(gas)>(Runtime::getGas()); gas = static_cast<decltype(gas)>(Runtime::getGas());
if (returnCode == ReturnCode::Return) if (returnCode == ReturnCode::Return)
{ {
auto&& returnData = Memory::getReturnData(); // TODO: It might be better to place is in Runtime interface auto&& returnData = Memory::getReturnData(); // TODO: It might be better to place is in Runtime interface
@ -134,3 +138,5 @@ int ExecutionEngine::run(std::unique_ptr<llvm::Module> _module)
} }
} }
}
}

10
evmcc/ExecutionEngine.h

@ -5,7 +5,11 @@
#include <libdevcore/Common.h> #include <libdevcore/Common.h>
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
class ExecutionEngine class ExecutionEngine
@ -16,4 +20,6 @@ public:
int run(std::unique_ptr<llvm::Module> module); int run(std::unique_ptr<llvm::Module> module);
}; };
} }
}
}

11
evmcc/Ext.cpp

@ -15,7 +15,11 @@ using Linkage = llvm::GlobalValue::LinkageTypes;
using dev::h256; using dev::h256;
using dev::u256; using dev::u256;
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
// TODO: Copy of dev::eth::fromAddress in VM.h // TODO: Copy of dev::eth::fromAddress in VM.h
@ -238,7 +242,7 @@ llvm::Value* Ext::codesizeAt(llvm::Value* _addr)
extern "C" extern "C"
{ {
using namespace evmcc; using namespace dev::eth::jit;
EXPORT void ext_init(ExtData* _extData) EXPORT void ext_init(ExtData* _extData)
{ {
@ -377,3 +381,6 @@ EXPORT void ext_codesizeAt(h256* _addr256, i256* _ret)
} }
} }
}
}

11
evmcc/Ext.h

@ -5,10 +5,12 @@
#include <libevm/ExtVMFace.h> #include <libevm/ExtVMFace.h>
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
class Ext class Ext
{ {
@ -80,3 +82,6 @@ private:
} }
}
}

9
evmcc/GasMeter.cpp

@ -12,7 +12,11 @@
#include "Utils.h" #include "Utils.h"
#include "Ext.h" #include "Ext.h"
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
using namespace dev::eth; // We should move all the JIT code into dev::eth namespace using namespace dev::eth; // We should move all the JIT code into dev::eth namespace
@ -193,3 +197,6 @@ llvm::Value* GasMeter::getGas()
} }
} }
}
}

9
evmcc/GasMeter.h

@ -5,7 +5,11 @@
#include <libevmface/Instruction.h> #include <libevmface/Instruction.h>
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
class GasMeter class GasMeter
@ -45,3 +49,6 @@ private:
}; };
} }
}
}

15
evmcc/Memory.cpp

@ -15,7 +15,11 @@
#include "Runtime.h" #include "Runtime.h"
#include "GasMeter.h" #include "GasMeter.h"
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
Memory::Memory(llvm::IRBuilder<>& _builder, llvm::Module* _module, GasMeter& _gasMeter): Memory::Memory(llvm::IRBuilder<>& _builder, llvm::Module* _module, GasMeter& _gasMeter):
@ -213,11 +217,14 @@ void Memory::dump(uint64_t _begin, uint64_t _end)
m_builder.CreateCall(m_memDump, llvm::ArrayRef<llvm::Value*>(args)); m_builder.CreateCall(m_memDump, llvm::ArrayRef<llvm::Value*>(args));
} }
} // namespace evmcc }
}
}
extern "C" extern "C"
{ {
using namespace evmcc; using namespace dev::eth::jit;
EXPORT i256 mem_returnDataOffset; EXPORT i256 mem_returnDataOffset;
EXPORT i256 mem_returnDataSize; EXPORT i256 mem_returnDataSize;
@ -256,7 +263,7 @@ EXPORT void evmccrt_memory_dump(uint64_t _begin, uint64_t _end)
} // extern "C" } // extern "C"
dev::bytesConstRef evmcc::Memory::getReturnData() dev::bytesConstRef dev::eth::jit::Memory::getReturnData()
{ {
// TODO: Handle large indexes // TODO: Handle large indexes
auto offset = static_cast<size_t>(llvm2eth(mem_returnDataOffset)); auto offset = static_cast<size_t>(llvm2eth(mem_returnDataOffset));

10
evmcc/Memory.h

@ -4,8 +4,13 @@
#include <libdevcore/Common.h> #include <libdevcore/Common.h>
namespace evmcc namespace dev
{ {
namespace eth
{
namespace jit
{
class GasMeter; class GasMeter;
class Memory class Memory
@ -58,3 +63,6 @@ private:
}; };
} }
}
}

10
evmcc/Runtime.cpp

@ -5,7 +5,11 @@
#include "Type.h" #include "Type.h"
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
static Runtime* g_runtime; static Runtime* g_runtime;
@ -48,4 +52,6 @@ dev::u256 Runtime::getGas()
return llvm2eth(gas); return llvm2eth(gas);
} }
} }
}
}

10
evmcc/Runtime.h

@ -14,7 +14,11 @@
#define EXPORT #define EXPORT
#endif #endif
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
using StackImpl = std::vector<i256>; using StackImpl = std::vector<i256>;
@ -40,4 +44,6 @@ private:
std::unique_ptr<dev::eth::ExtVMFace> m_ext; std::unique_ptr<dev::eth::ExtVMFace> m_ext;
}; };
} }
}
}

9
evmcc/Type.cpp

@ -3,7 +3,11 @@
#include <llvm/IR/DerivedTypes.h> #include <llvm/IR/DerivedTypes.h>
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
llvm::IntegerType* Type::i256; llvm::IntegerType* Type::i256;
@ -36,3 +40,6 @@ llvm::Constant* Constant::get(ReturnCode _returnCode)
} }
} }
}
}

9
evmcc/Type.h

@ -4,7 +4,11 @@
#include <llvm/IR/Type.h> #include <llvm/IR/Type.h>
#include <llvm/IR/Constants.h> #include <llvm/IR/Constants.h>
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
struct Type struct Type
@ -46,3 +50,6 @@ struct Constant
}; };
} }
}
}

10
evmcc/Utils.cpp

@ -1,7 +1,11 @@
#include "Utils.h" #include "Utils.h"
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
dev::u256 llvm2eth(i256 _i) dev::u256 llvm2eth(i256 _i)
@ -31,4 +35,6 @@ i256 eth2llvm(dev::u256 _u)
return i; return i;
} }
} }
}
}

10
evmcc/Utils.h

@ -5,7 +5,11 @@
#include <libdevcore/Common.h> #include <libdevcore/Common.h>
namespace evmcc namespace dev
{
namespace eth
{
namespace jit
{ {
/// Representation of 256-bit value binary compatible with LLVM i256 /// Representation of 256-bit value binary compatible with LLVM i256
@ -111,4 +115,6 @@ private:
case Instruction::SWAP15: \ case Instruction::SWAP15: \
case Instruction::SWAP16 case Instruction::SWAP16
} }
}
}

10
evmcc/evmcc.cpp

@ -15,8 +15,6 @@
#include "Compiler.h" #include "Compiler.h"
#include "ExecutionEngine.h" #include "ExecutionEngine.h"
using namespace dev;
void show_usage() void show_usage()
{ {
@ -74,6 +72,8 @@ int main(int argc, char** argv)
boost::algorithm::trim(src); boost::algorithm::trim(src);
using namespace dev;
bytes bytecode = fromHex(src); bytes bytecode = fromHex(src);
if (opt_show_bytes) if (opt_show_bytes)
@ -89,15 +89,15 @@ int main(int argc, char** argv)
if (opt_compile) if (opt_compile)
{ {
auto module = evmcc::Compiler().compile(bytecode); auto module = eth::jit::Compiler().compile(bytecode);
llvm::raw_os_ostream out(std::cout); llvm::raw_os_ostream out(std::cout);
module->print(out, nullptr); module->print(out, nullptr);
} }
if (opt_interpret) if (opt_interpret)
{ {
auto engine = evmcc::ExecutionEngine(); auto engine = eth::jit::ExecutionEngine();
auto module = evmcc::Compiler().compile(bytecode); auto module = eth::jit::Compiler().compile(bytecode);
module->dump(); module->dump();
auto result = engine.run(std::move(module)); auto result = engine.run(std::move(module));
return result; return result;

Loading…
Cancel
Save