From 892c7904ca97b4bf7adfb53a7fe617426eea2b98 Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Thu, 17 Oct 2019 13:50:31 -0500 Subject: [PATCH] merge fastmem --- CMakeLists.txt | 2 +- include/dynarmic/A32/config.h | 6 +++++ src/CMakeLists.txt | 32 +++++++++++++++++++++++++++ src/frontend/ir/location_descriptor.h | 10 ++++----- tests/A32/fuzz_arm.cpp | 8 +++++++ tests/CMakeLists.txt | 1 + 6 files changed, 52 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 524ce238..7156e3fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.8) -project(dynarmic CXX) +project(dynarmic C CXX) # Determine if we're built as a subproject (using add_subdirectory) # or if this is the master project. diff --git a/include/dynarmic/A32/config.h b/include/dynarmic/A32/config.h index ee96c197..c115be77 100644 --- a/include/dynarmic/A32/config.h +++ b/include/dynarmic/A32/config.h @@ -101,6 +101,12 @@ struct UserConfig { /// This can be avoided by carefully allocating the memory region. bool absolute_offset_page_table = false; + // Fastmem Pointer + // This should point to the beginning of a 4GB address space which is in arranged just like + // what you wish for emulated memory to be. If the host page faults on an address, the JIT + // will fallback to calling the MemoryRead*/MemoryWrite* callbacks. + void* fastmem_pointer = nullptr; + // Coprocessors std::array, 16> coprocessors{}; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 93092b35..b43e0e2a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -261,6 +261,36 @@ if (ARCHITECTURE_x86_64) if (WIN32) target_sources(dynarmic PRIVATE backend/x64/exception_handler_windows.cpp) + elseif (APPLE) + find_path(MACH_EXC_DEFS_DIR "mach/mach_exc.defs") + if (NOT MACH_EXC_DEFS_DIR) + message(WARNING "macOS fastmem disabled: unable to find mach/mach_exc.defs") + target_sources(dynarmic PRIVATE backend/x64/exception_handler_generic.cpp) + else() + message(STATUS "mach/mach_exc.defs location: ${MACH_EXC_DEFS_DIR}") + execute_process( + COMMAND + mkdir -p "${CMAKE_CURRENT_SOURCE_DIR}/backend/x64/mig" + COMMAND + mig + -arch x86_64 + -user "${CMAKE_CURRENT_SOURCE_DIR}/backend/x64/mig/mach_exc_user.c" + -header "${CMAKE_CURRENT_SOURCE_DIR}/backend/x64/mig/mach_exc_user.h" + -server "${CMAKE_CURRENT_SOURCE_DIR}/backend/x64/mig/mach_exc_server.c" + -sheader "${CMAKE_CURRENT_SOURCE_DIR}/backend/x64/mig/mach_exc_server.h" + "${MACH_EXC_DEFS_DIR}/mach/mach_exc.defs" + ) + target_sources(dynarmic PRIVATE + backend/x64/exception_handler_macos.cpp + backend/x64/mig/mach_exc_server.c + backend/x64/mig/mach_exc_server.h + ) + endif() + elseif (UNIX) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(dynarmic PUBLIC rt) + endif() + target_sources(dynarmic PRIVATE backend/x64/exception_handler_posix.cpp) else() target_sources(dynarmic PRIVATE backend/x64/exception_handler_generic.cpp) endif() @@ -352,3 +382,5 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") endif() # Disable this as it relies on a non-standard feature target_compile_definitions(dynarmic PRIVATE FMT_USE_USER_DEFINED_LITERALS=0) + +#export(TARGETS dynarmic boost fmt xbyak FILE "dynarmic-config.cmake") diff --git a/src/frontend/ir/location_descriptor.h b/src/frontend/ir/location_descriptor.h index 89d06db3..82fc67c6 100644 --- a/src/frontend/ir/location_descriptor.h +++ b/src/frontend/ir/location_descriptor.h @@ -25,6 +25,10 @@ public: return !operator==(o); } + bool operator < (const LocationDescriptor& o) const { + return value < o.Value(); + } + u64 Value() const { return value; } private: @@ -37,12 +41,6 @@ std::ostream& operator<<(std::ostream& o, const LocationDescriptor& descriptor); namespace std { template <> -struct less { - bool operator()(const Dynarmic::IR::LocationDescriptor& x, const Dynarmic::IR::LocationDescriptor& y) const noexcept { - return x.Value() < y.Value(); - } -}; -template <> struct hash { size_t operator()(const Dynarmic::IR::LocationDescriptor& x) const noexcept { return std::hash()(x.Value()); diff --git a/tests/A32/fuzz_arm.cpp b/tests/A32/fuzz_arm.cpp index 25ebacb1..4eeee8e9 100644 --- a/tests/A32/fuzz_arm.cpp +++ b/tests/A32/fuzz_arm.cpp @@ -34,6 +34,14 @@ #include #include +static Dynarmic::A32::UserConfig GetUserConfig(ArmTestEnv* testenv) { + Dynarmic::A32::UserConfig user_config; + user_config.enable_fast_dispatch = false; + user_config.callbacks = testenv; + user_config.fastmem_pointer = reinterpret_cast(0xFFFFFDDE00000000); + return user_config; +} + namespace { using namespace Dynarmic; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1712848d..c1652d1d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -63,6 +63,7 @@ endif() target_include_directories(dynarmic_tests PRIVATE . ../src) target_compile_options(dynarmic_tests PRIVATE ${DYNARMIC_CXX_FLAGS}) target_compile_definitions(dynarmic_tests PRIVATE FMT_USE_USER_DEFINED_LITERALS=0) +target_compile_options(dynarmic_tests PRIVATE -DCATCH_CONFIG_NO_WINDOWS_SEH -DCATCH_CONFIG_NO_POSIX_SIGNALS) target_link_libraries(dynarmic_print_info PRIVATE dynarmic boost catch fmt mp) target_include_directories(dynarmic_print_info PRIVATE . ../src)