diff --git a/libevmjit/ExecutionEngine.cpp b/libevmjit/ExecutionEngine.cpp index ee92a6ba9..2db125c2d 100644 --- a/libevmjit/ExecutionEngine.cpp +++ b/libevmjit/ExecutionEngine.cpp @@ -1,6 +1,7 @@ #include "ExecutionEngine.h" #include +#include // env options #include #include @@ -19,13 +20,6 @@ #include "Compiler.h" #include "Cache.h" -#if defined(NDEBUG) -#define DEBUG_ENV_OPTION(name) false -#else -#include -#define DEBUG_ENV_OPTION(name) (std::getenv(#name) != nullptr) -#endif - namespace dev { namespace eth @@ -67,13 +61,21 @@ std::string codeHash(bytes const& _code) return std::to_string(hash); } +bool getEnvOption(char const* _name, bool _default) +{ + auto var = std::getenv(_name); + if (!var) + return _default; + return std::strtol(var, nullptr, 10) != 0; +} + } ReturnCode ExecutionEngine::run(bytes const& _code, RuntimeData* _data, Env* _env) { static std::unique_ptr ee; // TODO: Use Managed Objects from LLVM? - static auto debugDumpModule = DEBUG_ENV_OPTION(EVMJIT_DUMP_MODULE); - static bool objectCacheEnabled = !DEBUG_ENV_OPTION(EVMJIT_CACHE_OFF); + static auto debugDumpModule = getEnvOption("EVMJIT_DUMP", false); + static auto objectCacheEnabled = getEnvOption("EVMJIT_CACHE", true); auto mainFuncName = codeHash(_code); EntryFuncPtr entryFuncPtr{};