From 2332595c9c0d315dc9ecde22d236ae477b931863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 18 Dec 2014 13:01:45 +0100 Subject: [PATCH] Change the name of a module to some hash (for caching) --- libevmjit/Compiler.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libevmjit/Compiler.cpp b/libevmjit/Compiler.cpp index 80bd647add..20b17e9fe5 100644 --- a/libevmjit/Compiler.cpp +++ b/libevmjit/Compiler.cpp @@ -1,6 +1,7 @@ #include "Compiler.h" +#include #include #include @@ -153,8 +154,13 @@ void Compiler::createBasicBlocks(bytes const& _bytecode) std::unique_ptr Compiler::compile(bytes const& _bytecode) { + // TODO: Better hash of code needed, probably SHA3 + std::string code{reinterpret_cast(_bytecode.data()), _bytecode.size()}; + auto hash = std::hash{}(code); + auto strHash = std::to_string(hash); + auto compilationStartTime = std::chrono::high_resolution_clock::now(); - auto module = std::unique_ptr(new llvm::Module("main", m_builder.getContext())); + auto module = std::unique_ptr(new llvm::Module(strHash, m_builder.getContext())); // Create main function auto mainFuncType = llvm::FunctionType::get(Type::MainReturn, Type::RuntimePtr, false);