Browse Source

Merge commit 'bb9df15d75281e9240b8ab5f21286948c00958d0' into evmjit

cl-refactor
Paweł Bylica 10 years ago
parent
commit
9e465b0d1b
  1. 9
      evmjit/README.md
  2. 10
      evmjit/libevmjit/BuildInfo.h.in
  3. 5
      evmjit/libevmjit/CMakeLists.txt
  4. 13
      evmjit/libevmjit/Compiler.cpp
  5. 13
      evmjit/libevmjit/ExecutionEngine.cpp

9
evmjit/README.md

@ -31,4 +31,13 @@ It can be used to substitute classic interpreter-like EVM Virtual Machine in Eth
Ask me.
## Options
Options to evmjit library can be passed by environmental variables, e.g. `EVMJIT_CACHE=0 testeth --jit`.
Option | Default value | Description
------------- | ------------- | ----------------------------------------------
EVMJIT_CACHE | 1 | Enables on disk cache for compiled EVM objects
EVMJIT_DUMP | 0 | Dumps generated LLVM module to standard output

10
evmjit/libevmjit/BuildInfo.h.in

@ -0,0 +1,10 @@
#define EVMJIT_VERSION "${EVMJIT_VERSION}"
#define EVMJIT_VERSION_MAJOR ${EVMJIT_VERSION_MAJOR}
#define EVMJIT_VERSION_MINOR ${EVMJIT_VERSION_MINOR}
#define EVMJIT_VERSION_PATCH ${EVMJIT_VERSION_PATCH}
#define EVMJIT_VERSION_PRERELEASE "${EVMJIT_VERSION_PRERELEASE}"
#define EVMJIT_VERSION_FULL "${EVMJIT_VERSION_FULL}"
#define LLVM_VERSION "${LLVM_PACKAGE_VERSION}"
#define LLVM_ASSERTIONS "${LLVM_ENABLE_ASSERTIONS}"

5
evmjit/libevmjit/CMakeLists.txt

@ -47,14 +47,17 @@ else()
set(EVMJIT_SOVERSION ${EVMJIT_VERSION_MAJOR})
endif()
configure_file(BuildInfo.h.in ${CMAKE_CURRENT_BINARY_DIR}/gen/BuildInfo.gen.h)
message(STATUS "EVM JIT version: ${EVMJIT_VERSION_MAJOR}.${EVMJIT_VERSION_MINOR}.${EVMJIT_VERSION_PATCH}-${EVMJIT_VERSION_PRERELEASE} (${EVMJIT_VERSION_FULL})")
add_library(${TARGET_NAME} SHARED ${SOURCES} ${HEADERS})
add_library(${TARGET_NAME} SHARED ${SOURCES} ${HEADERS} gen/BuildInfo.gen.h)
set_target_properties(${TARGET_NAME} PROPERTIES
VERSION ${EVMJIT_VERSION} SOVERSION ${EVMJIT_SOVERSION}
FOLDER "libs")
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/gen)
target_link_libraries(${TARGET_NAME} PRIVATE ${LLVM_LIBS})

13
evmjit/libevmjit/Compiler.cpp

@ -91,6 +91,7 @@ void Compiler::createBasicBlocks(code_iterator _codeBegin, code_iterator _codeEn
}
}
// TODO: Create Stop basic block on demand
m_stopBB = llvm::BasicBlock::Create(m_mainFunc->getContext(), "Stop", m_mainFunc);
}
@ -864,6 +865,18 @@ void Compiler::removeDeadBlocks()
}
}
while (sthErased);
if (m_jumpTableBlock && llvm::pred_begin(m_jumpTableBlock->llvm()) == llvm::pred_end(m_jumpTableBlock->llvm()))
{
m_jumpTableBlock->llvm()->eraseFromParent();
m_jumpTableBlock.reset();
}
if (m_badJumpBlock && llvm::pred_begin(m_badJumpBlock->llvm()) == llvm::pred_end(m_badJumpBlock->llvm()))
{
m_badJumpBlock->llvm()->eraseFromParent();
m_badJumpBlock.reset();
}
}
void Compiler::dumpCFGifRequired(std::string const& _dotfilePath)

13
evmjit/libevmjit/ExecutionEngine.cpp

@ -19,6 +19,7 @@
#include "Runtime.h"
#include "Compiler.h"
#include "Cache.h"
#include "BuildInfo.gen.h"
#include <iostream>
@ -72,6 +73,16 @@ bool getEnvOption(char const* _name, bool _default)
return std::strtol(var, nullptr, 10) != 0;
}
bool showInfo()
{
auto show = getEnvOption("EVMJIT_INFO", false);
if (show)
{
std::cout << "The Ethereum EVM JIT " EVMJIT_VERSION_FULL " LLVM " LLVM_VERSION << std::endl;
}
return show;
}
}
ReturnCode ExecutionEngine::run(RuntimeData* _data, Env* _env)
@ -79,6 +90,8 @@ ReturnCode ExecutionEngine::run(RuntimeData* _data, Env* _env)
static std::unique_ptr<llvm::ExecutionEngine> ee; // TODO: Use Managed Objects from LLVM?
static auto debugDumpModule = getEnvOption("EVMJIT_DUMP", false);
static auto objectCacheEnabled = getEnvOption("EVMJIT_CACHE", true);
static auto infoShown = showInfo();
(void) infoShown;
auto codeBegin = _data->code;
auto codeEnd = codeBegin + _data->codeSize;

Loading…
Cancel
Save