Browse Source

Windows fixes: DLL exports and cmake options

cl-refactor
Paweł Bylica 10 years ago
parent
commit
064c129afc
  1. 2
      evmjit/CMakeLists.txt
  2. 2
      evmjit/libevmjit/CMakeLists.txt
  3. 7
      evmjit/libevmjit/Common.h
  4. 2
      evmjit/libevmjit/ExecutionEngine.h
  5. 98
      evmjit/libevmjit/Runtime.h
  6. 11
      evmjit/libevmjit/interface.cpp

2
evmjit/CMakeLists.txt

@ -4,7 +4,7 @@ project(evmjit)
set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
else() else()
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-unknown-pragmas -Wextra -fPIC") set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-unknown-pragmas -Wextra -fPIC")
endif() endif()

2
evmjit/libevmjit/CMakeLists.txt

@ -20,5 +20,5 @@ target_link_libraries(${TARGET_NAME} PRIVATE ${LLVM_LIBS})
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION lib) install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
#install(FILES ${INTERFACE_HEADERS} DESTINATION include/${TARGET_NAME}) #install(FILES ${INTERFACE_HEADERS} DESTINATION include/${TARGET_NAME})

7
evmjit/libevmjit/Common.h

@ -2,6 +2,13 @@
#include <vector> #include <vector>
#include <tuple> #include <tuple>
#include <cstdint>
#ifdef _MSC_VER
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
namespace dev namespace dev
{ {

2
evmjit/libevmjit/ExecutionEngine.h

@ -16,7 +16,7 @@ public:
ExecutionEngine(ExecutionEngine const&) = delete; ExecutionEngine(ExecutionEngine const&) = delete;
void operator=(ExecutionEngine) = delete; void operator=(ExecutionEngine) = delete;
ReturnCode run(bytes const& _code, RuntimeData* _data, Env* _env); EXPORT ReturnCode run(bytes const& _code, RuntimeData* _data, Env* _env);
/// Reference to returned data (RETURN opcode used) /// Reference to returned data (RETURN opcode used)
bytes_ref returnData; bytes_ref returnData;

98
evmjit/libevmjit/Runtime.h

@ -1,52 +1,46 @@
#pragma once #pragma once
#include <csetjmp> #include <csetjmp>
#include "RuntimeData.h" #include "RuntimeData.h"
#ifdef _MSC_VER namespace dev
#define EXPORT __declspec(dllexport) {
#else namespace eth
#define EXPORT {
#endif namespace jit
{
namespace dev
{ using StackImpl = std::vector<i256>;
namespace eth using MemoryImpl = bytes;
{ using jmp_buf_ref = decltype(&std::jmp_buf{}[0]);
namespace jit
{ class Runtime
{
using StackImpl = std::vector<i256>; public:
using MemoryImpl = bytes; Runtime(RuntimeData* _data, Env* _env);
using jmp_buf_ref = decltype(&std::jmp_buf{}[0]);
Runtime(const Runtime&) = delete;
class Runtime Runtime& operator=(const Runtime&) = delete;
{
public: StackImpl& getStack() { return m_stack; }
Runtime(RuntimeData* _data, Env* _env); MemoryImpl& getMemory() { return m_memory; }
Env* getEnvPtr() { return &m_env; }
Runtime(const Runtime&) = delete;
Runtime& operator=(const Runtime&) = delete; bytes_ref getReturnData() const;
jmp_buf_ref getJmpBuf() { return m_jmpBuf; }
StackImpl& getStack() { return m_stack; }
MemoryImpl& getMemory() { return m_memory; } private:
Env* getEnvPtr() { return &m_env; } RuntimeData& m_data; ///< Pointer to data. Expected by compiled contract.
Env& m_env; ///< Pointer to environment proxy. Expected by compiled contract.
bytes_ref getReturnData() const; jmp_buf_ref m_currJmpBuf; ///< Pointer to jump buffer. Expected by compiled contract.
jmp_buf_ref getJmpBuf() { return m_jmpBuf; } byte* m_memoryData = nullptr;
i256 m_memorySize;
private: std::jmp_buf m_jmpBuf;
RuntimeData& m_data; ///< Pointer to data. Expected by compiled contract. StackImpl m_stack;
Env& m_env; ///< Pointer to environment proxy. Expected by compiled contract. MemoryImpl m_memory;
jmp_buf_ref m_currJmpBuf; ///< Pointer to jump buffer. Expected by compiled contract. };
byte* m_memoryData = nullptr;
i256 m_memorySize; }
std::jmp_buf m_jmpBuf; }
StackImpl m_stack; }
MemoryImpl m_memory;
};
}
}
}

11
evmjit/libevmjit/interface.cpp

@ -5,17 +5,22 @@ extern "C"
using namespace dev::eth::jit; using namespace dev::eth::jit;
void* evmjit_create() noexcept #ifdef _MSC_VER
#define _ALLOW_KEYWORD_MACROS
#define noexcept throw()
#endif
EXPORT void* evmjit_create() noexcept
{ {
return new(std::nothrow) ExecutionEngine; return new(std::nothrow) ExecutionEngine;
} }
void evmjit_destroy(ExecutionEngine* _engine) noexcept EXPORT void evmjit_destroy(ExecutionEngine* _engine) noexcept
{ {
delete _engine; delete _engine;
} }
int evmjit_run(ExecutionEngine* _engine, RuntimeData* _data, Env* _env) noexcept EXPORT int evmjit_run(ExecutionEngine* _engine, RuntimeData* _data, Env* _env) noexcept
{ {
try try
{ {

Loading…
Cancel
Save