From 015bd796f60325734de02e5f7ff161133374a70b Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Thu, 30 May 2013 04:13:59 +0300 Subject: [PATCH] Save/Restore host memory across UNSAFEREWINDs --- include/lua/unsaferewind.hpp | 3 ++- src/lua/lua.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/lua/unsaferewind.hpp b/include/lua/unsaferewind.hpp index f8cf109d..0199f031 100644 --- a/include/lua/unsaferewind.hpp +++ b/include/lua/unsaferewind.hpp @@ -10,6 +10,7 @@ struct lua_unsaferewind uint64_t secs; uint64_t ssecs; std::vector pollcounters; + std::vector hostmemory; }; -#endif \ No newline at end of file +#endif diff --git a/src/lua/lua.cpp b/src/lua/lua.cpp index 8acfe5c8..02443791 100644 --- a/src/lua/lua.cpp +++ b/src/lua/lua.cpp @@ -616,6 +616,7 @@ void lua_callback_do_unsafe_rewind(const std::vector& save, uint64_t secs, run_lua_cb(0); mainloop_restore_state(u2->state, u2->secs, u2->ssecs); mov.fast_load(u2->frame, u2->ptr, u2->lag, u2->pollcounters); + try { get_host_memory() = u2->hostmemory; } catch(...) {} if(callback_exists("on_post_rewind")) run_lua_cb(0); } catch(...) { @@ -628,6 +629,7 @@ void lua_callback_do_unsafe_rewind(const std::vector& save, uint64_t secs, u2->state = save; u2->secs = secs, u2->ssecs = ssecs; + u2->hostmemory = get_host_memory(); mov.fast_save(u2->frame, u2->ptr, u2->lag, u2->pollcounters); run_lua_cb(1); }