diff --git a/libevmjit/Cache.cpp b/libevmjit/Cache.cpp index 1265273f6..bbd2c95b8 100644 --- a/libevmjit/Cache.cpp +++ b/libevmjit/Cache.cpp @@ -10,42 +10,10 @@ namespace eth { namespace jit { -namespace -{ - using CacheMap = std::unordered_map; - - CacheMap& getCacheMap() - { - static CacheMap map; - return map; - } -} //#define LOG(...) std::cerr << "CACHE " #define LOG(...) std::ostream(nullptr) -ExecBundle& Cache::registerExec(Cache::Key _key, ExecBundle&& _exec) -{ - auto& map = getCacheMap(); - auto r = map.insert(std::make_pair(_key, std::move(_exec))); - assert(r.second && "Updating cached objects not supported"); - LOG() << "add\n"; - return r.first->second; // return exec, now owned by cache -} - -ExecBundle* Cache::findExec(Cache::Key _key) -{ - auto& map = getCacheMap(); - auto it = map.find(_key); - if (it != map.end()) - { - LOG() << "hit\n"; - return &it->second; - } - LOG() << "miss\n"; - return nullptr; -} - ObjectCache* Cache::getObjectCache() { static ObjectCache objectCache; diff --git a/libevmjit/Cache.h b/libevmjit/Cache.h index 377c1f6a2..80fe47ade 100644 --- a/libevmjit/Cache.h +++ b/libevmjit/Cache.h @@ -13,24 +13,6 @@ namespace eth namespace jit { -/// A bundle of objects and information needed for a contract execution -class ExecBundle -{ -public: - llvm::ExecutionEngine* engine = nullptr; - std::string mainFuncName; - - ExecBundle() = default; - ExecBundle(ExecBundle&& _other): - engine(std::move(_other.engine)), - mainFuncName(std::move(_other.mainFuncName)) - {} - - ExecBundle(ExecBundle const&) = delete; - void operator=(ExecBundle) = delete; -}; - - class ObjectCache : public llvm::ObjectCache { public: @@ -51,11 +33,6 @@ private: class Cache { public: - using Key = std::string; - - static ExecBundle& registerExec(Key _key, ExecBundle&& _exec); - static ExecBundle* findExec(Key _key); - static ObjectCache* getObjectCache(); }; diff --git a/libevmjit/ExecutionEngine.cpp b/libevmjit/ExecutionEngine.cpp index 354c6e151..2174df4eb 100644 --- a/libevmjit/ExecutionEngine.cpp +++ b/libevmjit/ExecutionEngine.cpp @@ -2,10 +2,6 @@ #include -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - -#include #include #include #include @@ -13,12 +9,8 @@ #include #include #include -#include -#include #include -#pragma GCC diagnostic pop - #include "Runtime.h" #include "Memory.h" #include "Stack.h" @@ -42,7 +34,6 @@ ReturnCode ExecutionEngine::run(bytes const& _code, RuntimeData* _data, Env* _en namespace { - typedef ReturnCode(*EntryFuncPtr)(Runtime*); ReturnCode runEntryFunc(EntryFuncPtr _mainFunc, Runtime* _runtime) @@ -59,7 +50,6 @@ ReturnCode runEntryFunc(EntryFuncPtr _mainFunc, Runtime* _runtime) return returnCode; } - } ReturnCode ExecutionEngine::run(std::unique_ptr _module, RuntimeData* _data, Env* _env, bytes const& _code) @@ -72,12 +62,8 @@ ReturnCode ExecutionEngine::run(std::unique_ptr _module, RuntimeDa static std::unique_ptr ee; // TODO: Use Managed Objects from LLVM? EntryFuncPtr entryFuncPtr{}; - - - - Runtime runtime(_data, _env); - auto&& mainFuncName = _module->getModuleIdentifier(); + Runtime runtime(_data, _env); // TODO: I don't know why but it must be created before getFunctionAddress() calls if (!ee) { @@ -118,22 +104,18 @@ ReturnCode ExecutionEngine::run(std::unique_ptr _module, RuntimeDa } assert(entryFuncPtr); - auto executionStartTime = std::chrono::high_resolution_clock::now(); - //auto mainFunc = (EntryFuncPtr)ee->getFunctionAddress(mainFuncName); + auto returnCode = runEntryFunc(entryFuncPtr, &runtime); if (returnCode == ReturnCode::Return) this->returnData = runtime.getReturnData(); auto executionEndTime = std::chrono::high_resolution_clock::now(); - clog(JIT) << " + " << std::chrono::duration_cast(executionEndTime - executionStartTime).count() << " ms "; - - clog(JIT) << "\n"; + clog(JIT) << " + " << std::chrono::duration_cast(executionEndTime - executionStartTime).count() << " ms\n"; return returnCode; } - } } }