Skip to content

Commit

Permalink
Use the new EnableJIT setting to conditionaly enable JIT
Browse files Browse the repository at this point in the history
  • Loading branch information
WSSDude committed Oct 29, 2023
1 parent 974ffc4 commit e204a6d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/CET.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ CET::CET()
, m_bindings(m_paths, m_options)
, m_window(&m_bindings, &m_d3d12)
, m_d3d12(m_window, m_paths, m_options)
, m_vm(m_paths, m_bindings, m_d3d12)
, m_vm(m_paths, m_options, m_bindings, m_d3d12)
, m_overlay(m_bindings, m_options, m_persistentState, m_vm)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/LuaVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct TDBIDLookupEntry
struct Image;
struct LuaVM
{
LuaVM(const Paths& aPaths, VKBindings& aBindings, D3D12& aD3D12);
LuaVM(const Paths& aPaths, const Options& aOptions, VKBindings& aBindings, D3D12& aD3D12);
~LuaVM() = default;

[[nodiscard]] const VKBind* GetBind(const VKModBind& acModBind) const;
Expand Down
4 changes: 2 additions & 2 deletions src/scripting/LuaVM_Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ void LuaVM::HookLogChannel(RED4ext::IScriptable*, RED4ext::CStackFrame* apStack,
}
}

LuaVM::LuaVM(const Paths& aPaths, VKBindings& aBindings, D3D12& aD3D12)
: m_scripting(aPaths, aBindings, aD3D12)
LuaVM::LuaVM(const Paths& aPaths, const Options& aOptions, VKBindings& aBindings, D3D12& aD3D12)
: m_scripting(aPaths, aOptions, aBindings, aD3D12)
, m_d3d12(aD3D12)
{
Hook();
Expand Down
9 changes: 7 additions & 2 deletions src/scripting/Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ static constexpr bool s_cThrowLuaErrors = true;
static RTTILocator s_stringType{RED4ext::FNV1a64("String")};
static RTTILocator s_resRefType{RED4ext::FNV1a64("redResourceReferenceScriptToken")};

Scripting::Scripting(const Paths& aPaths, VKBindings& aBindings, D3D12& aD3D12)
Scripting::Scripting(const Paths& aPaths, const Options& aOptions, VKBindings& aBindings, D3D12& aD3D12)
: m_sandbox(this, aBindings)
, m_mapper(m_lua.AsRef(), m_sandbox)
, m_store(m_sandbox, aPaths, aBindings)
, m_override(this)
, m_paths(aPaths)
, m_options(aOptions)
, m_d3d12(aD3D12)
{
CreateLogger(aPaths.CETRoot() / "scripting.log", "scripting");
Expand All @@ -49,7 +50,11 @@ void Scripting::Initialize()
auto lua = m_lua.Lock();
auto& luaVm = lua.Get();

luaVm.open_libraries(sol::lib::base, sol::lib::string, sol::lib::io, sol::lib::math, sol::lib::package, sol::lib::os, sol::lib::table, sol::lib::bit32, sol::lib::jit);
luaVm.open_libraries(sol::lib::base, sol::lib::string, sol::lib::io, sol::lib::math, sol::lib::package, sol::lib::os, sol::lib::table, sol::lib::bit32);

if (m_options.Developer.EnableJIT)
luaVm.open_libraries(sol::lib::jit);

luaVm.require("sqlite3", luaopen_lsqlite3);

// make sure to set package path to current directory scope
Expand Down
3 changes: 2 additions & 1 deletion src/scripting/Scripting.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct Scripting
{
using LockedState = TiltedPhoques::Locked<sol::state, std::recursive_mutex>;

Scripting(const Paths& aPaths, VKBindings& aBindings, D3D12& aD3D12);
Scripting(const Paths& aPaths, const Options& aOptions, VKBindings& aBindings, D3D12& aD3D12);
~Scripting() = default;

void Initialize();
Expand Down Expand Up @@ -61,5 +61,6 @@ struct Scripting
ScriptStore m_store;
FunctionOverride m_override;
const Paths& m_paths;
const Options& m_options;
D3D12& m_d3d12;
};

0 comments on commit e204a6d

Please sign in to comment.