Skip to content

Commit

Permalink
Use prepared calls with Event
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Jun 20, 2024
1 parent 821c5f6 commit a53133c
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if (USE_MOLD)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=/usr/local/bin/mold")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld-18")
endif()

add_subdirectory(../ext ext)
Expand Down
2 changes: 1 addition & 1 deletion engine/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CC=$ENGINE_CC
# Build the game
mkdir -p build
pushd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DFLTO=ON -DSANITIZE=OFF -DRISCV_EXT_C=$CEXT
cmake .. -DCMAKE_BUILD_TYPE=Release -DSANITIZE=OFF -DRISCV_EXT_C=$CEXT
make -j4
popd

Expand Down
1 change: 1 addition & 0 deletions engine/libtcc1.a
6 changes: 3 additions & 3 deletions engine/src/script/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ struct Event
}

private:
riscv::PreparedCall<Script::MARCH, F> m_pcall;
riscv::PreparedCall<Script::MARCH, F, Script::MAX_CALL_INSTR> m_pcall;
};

template <typename F, EventUsagePattern Usage>
inline Event<F, Usage>::Event(Script& script, Script::gaddr_t address)
: m_pcall(script.machine(), address)
: m_pcall((Usage == SharedScript) ? script.machine() : script.get_fork().machine(), address)
{
}

Expand All @@ -77,7 +77,7 @@ template <typename... Args> inline auto Event<F, Usage>::call(Args&&... args)
using Ret = decltype((F*){}(args...));

auto& script = this->script();
if (auto res = script.template prepared_call<F, Args...>(m_pcall, std::forward<Args>(args)...)) {
if (auto res = script.template prepared_call<F, Args&&...>(m_pcall, std::forward<Args>(args)...)) {
if constexpr (std::is_same_v<void, Ret>)
return true;
else if constexpr (std::is_same_v<Script::gaddr_t, Ret>)
Expand Down
4 changes: 2 additions & 2 deletions engine/src/script/script.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ struct Script
/// @param args The arguments to pass to the function.
/// @return The optional integral return value.
template <typename F, typename... Args>
std::optional<Script::sgaddr_t> prepared_call(riscv::PreparedCall<MARCH, F>& pcall, Args&&... args);
std::optional<Script::sgaddr_t> prepared_call(riscv::PreparedCall<MARCH, F, MAX_CALL_INSTR>& pcall, Args&&... args);

// Create new Script instance from file
Script(
Expand Down Expand Up @@ -377,7 +377,7 @@ inline std::optional<Script::sgaddr_t> Script::call(const std::string& func, Arg
}

template <typename F, typename... Args>
inline std::optional<Script::sgaddr_t> Script::prepared_call(riscv::PreparedCall<MARCH, F>& pcall, Args&&... args)
inline std::optional<Script::sgaddr_t> Script::prepared_call(riscv::PreparedCall<MARCH, F, MAX_CALL_INSTR>& pcall, Args&&... args)
{
ScriptDepthMeter meter(this->m_call_depth);
try
Expand Down
2 changes: 1 addition & 1 deletion ext/libriscv
2 changes: 1 addition & 1 deletion tests/Catch2
Submodule Catch2 updated 319 files

0 comments on commit a53133c

Please sign in to comment.