Browse Source

Change the name of a module to some hash (for caching)

cl-refactor
Paweł Bylica 10 years ago
parent
commit
2332595c9c
  1. 8
      libevmjit/Compiler.cpp

8
libevmjit/Compiler.cpp

@ -1,6 +1,7 @@
#include "Compiler.h"
#include <functional>
#include <fstream>
#include <chrono>
@ -153,8 +154,13 @@ void Compiler::createBasicBlocks(bytes const& _bytecode)
std::unique_ptr<llvm::Module> Compiler::compile(bytes const& _bytecode)
{
// TODO: Better hash of code needed, probably SHA3
std::string code{reinterpret_cast<char const*>(_bytecode.data()), _bytecode.size()};
auto hash = std::hash<std::string>{}(code);
auto strHash = std::to_string(hash);
auto compilationStartTime = std::chrono::high_resolution_clock::now();
auto module = std::unique_ptr<llvm::Module>(new llvm::Module("main", m_builder.getContext()));
auto module = std::unique_ptr<llvm::Module>(new llvm::Module(strHash, m_builder.getContext()));
// Create main function
auto mainFuncType = llvm::FunctionType::get(Type::MainReturn, Type::RuntimePtr, false);

Loading…
Cancel
Save