mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-01 03:33:08 +02:00
Create configuration options specifically for JIT
This commit is contained in:
parent
67a19c8b5b
commit
c3b5623a3d
4 changed files with 61 additions and 19 deletions
|
@ -840,28 +840,38 @@ static void mriBindingExecute() {
|
||||||
ruby_init();
|
ruby_init();
|
||||||
rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding()));
|
rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding()));
|
||||||
|
|
||||||
std::vector<const char*> rubyArgsC{""};
|
std::vector<const char*> rubyArgsC{"mkxp-z"};
|
||||||
for(const auto& string : conf.rubyArgs)
|
rubyArgsC.push_back("-e ");
|
||||||
rubyArgsC.push_back(string.c_str());
|
void *node;
|
||||||
rubyArgsC.push_back("-e ");
|
if (conf.jit.enabled) {
|
||||||
|
std::string verboseLevel("--jit-verbose="); verboseLevel += std::to_string(conf.jit.verboseLevel);
|
||||||
void *node = ruby_process_options(rubyArgsC.size(), const_cast<char**>(rubyArgsC.data()));
|
std::string maxCache("--jit-max-cache="); maxCache += std::to_string(conf.jit.maxCache);
|
||||||
|
std::string minCalls("--jit-min-calls="); minCalls += std::to_string(conf.jit.minCalls);
|
||||||
|
rubyArgsC.push_back("--jit");
|
||||||
|
rubyArgsC.push_back(verboseLevel.c_str());
|
||||||
|
rubyArgsC.push_back(maxCache.c_str());
|
||||||
|
rubyArgsC.push_back(minCalls.c_str());
|
||||||
|
node = ruby_options(rubyArgsC.size(), const_cast<char**>(rubyArgsC.data()));
|
||||||
|
} else {
|
||||||
|
node = ruby_options(rubyArgsC.size(), const_cast<char**>(rubyArgsC.data()));
|
||||||
|
}
|
||||||
|
|
||||||
int state;
|
int state;
|
||||||
bool valid = ruby_executable_node(node, &state);
|
bool valid = ruby_executable_node(node, &state);
|
||||||
if (valid)
|
if (valid)
|
||||||
state = ruby_exec_node(node);
|
state = ruby_exec_node(node);
|
||||||
if (state || !valid) {
|
if (state || !valid) {
|
||||||
#if RAPI_FULL > 187
|
// The message is formatted for and automatically spits
|
||||||
|
// out to the terminal, so let's leave it that way for now
|
||||||
|
/*
|
||||||
VALUE exc = rb_errinfo();
|
VALUE exc = rb_errinfo();
|
||||||
#else
|
|
||||||
VALUE exc = rb_gv_get("$!");
|
|
||||||
#endif
|
|
||||||
#if RAPI_FULL >= 250
|
#if RAPI_FULL >= 250
|
||||||
VALUE msg = rb_funcall(exc, rb_intern("full_message"), 0);
|
VALUE msg = rb_funcall(exc, rb_intern("full_message"), 0);
|
||||||
#else
|
#else
|
||||||
VALUE msg = rb_funcall(exc, rb_intern("message"), 0);
|
VALUE msg = rb_funcall(exc, rb_intern("message"), 0);
|
||||||
#endif
|
#endif
|
||||||
showMsg(std::string("An argument passed to Ruby via 'rubyArg' is invalid:\n") + StringValueCStr(msg));
|
*/
|
||||||
|
showMsg("An error occurred while initializing Ruby. (Invalid JIT settings?)");
|
||||||
ruby_cleanup(state);
|
ruby_cleanup(state);
|
||||||
shState->rtData().rqTermAck.set();
|
shState->rtData().rqTermAck.set();
|
||||||
return;
|
return;
|
||||||
|
|
28
mkxp.json
28
mkxp.json
|
@ -284,11 +284,31 @@
|
||||||
// "rubyLoadpath": ["/usr/lib64/ruby/",
|
// "rubyLoadpath": ["/usr/lib64/ruby/",
|
||||||
// "/usr/local/share/ruby/site_ruby"],
|
// "/usr/local/share/ruby/site_ruby"],
|
||||||
|
|
||||||
// Commandline arguments to pass to Ruby, such as to enable JIT.
|
// Determines whether JIT is enabled. This probably
|
||||||
// Only supported for Ruby ≥2.
|
// won't work unless you also have the header file
|
||||||
// (default: none)
|
// that it needs. Only works with Ruby 2.6 or higher.
|
||||||
|
// (default: false)
|
||||||
//
|
//
|
||||||
// "rubyArg": ["--jit-verbose=1"],
|
// "JITEnable": false,
|
||||||
|
|
||||||
|
// Determines what level of verbosity to use when
|
||||||
|
// logging JIT events. Starts at 0, which is next
|
||||||
|
// to nothing. Set it higher to see more.
|
||||||
|
// (default: 0)
|
||||||
|
//
|
||||||
|
// "JITVerboseLevel": 0,
|
||||||
|
|
||||||
|
// Determines how many compiled methods that Ruby
|
||||||
|
// will keep in its cache.
|
||||||
|
// (default: 1000)
|
||||||
|
//
|
||||||
|
// "JITMaxCache": 1000,
|
||||||
|
|
||||||
|
// Determines how many times a function has to be
|
||||||
|
// called before it is compiled.
|
||||||
|
// (default: 5)
|
||||||
|
//
|
||||||
|
// "JITMinCalls": 5,
|
||||||
|
|
||||||
|
|
||||||
// SoundFont to use for midi playback (via fluidsynth)
|
// SoundFont to use for midi playback (via fluidsynth)
|
||||||
|
|
|
@ -91,7 +91,10 @@ void Config::read(int argc, char *argv[]) {
|
||||||
{"RTP", json::array({})},
|
{"RTP", json::array({})},
|
||||||
{"fontSub", json::array({})},
|
{"fontSub", json::array({})},
|
||||||
{"rubyLoadpath", json::array({})},
|
{"rubyLoadpath", json::array({})},
|
||||||
{"rubyArg", json::array({})}
|
{"JITEnable", false},
|
||||||
|
{"JITVerboseLevel", 0},
|
||||||
|
{"JITMaxCache", 1000},
|
||||||
|
{"JITMinCalls", 5}
|
||||||
}).as_object();
|
}).as_object();
|
||||||
|
|
||||||
#define GUARD(exp) \
|
#define GUARD(exp) \
|
||||||
|
@ -173,12 +176,15 @@ try { exp } catch (...) {}
|
||||||
SET_OPT(pathCache, boolean);
|
SET_OPT(pathCache, boolean);
|
||||||
SET_OPT(encryptedGraphics, boolean);
|
SET_OPT(encryptedGraphics, boolean);
|
||||||
SET_OPT(useScriptNames, boolean);
|
SET_OPT(useScriptNames, boolean);
|
||||||
|
SET_OPT_CUSTOMKEY(jit.enabled, JITEnable, boolean);
|
||||||
|
SET_OPT_CUSTOMKEY(jit.verboseLevel, JITVerboseLevel, integer);
|
||||||
|
SET_OPT_CUSTOMKEY(jit.maxCache, JITMaxCache, integer);
|
||||||
|
SET_OPT_CUSTOMKEY(jit.minCalls, JITMinCalls, integer);
|
||||||
|
|
||||||
fillStringVec(opts["preloadScript"], preloadScripts);
|
fillStringVec(opts["preloadScript"], preloadScripts);
|
||||||
fillStringVec(opts["RTP"], rtps);
|
fillStringVec(opts["RTP"], rtps);
|
||||||
fillStringVec(opts["fontSub"], fontSubs);
|
fillStringVec(opts["fontSub"], fontSubs);
|
||||||
fillStringVec(opts["rubyLoadpath"], rubyLoadpaths);
|
fillStringVec(opts["rubyLoadpath"], rubyLoadpaths);
|
||||||
fillStringVec(opts["rubyArg"], rubyArgs);
|
|
||||||
rgssVersion = clamp(rgssVersion, 0, 3);
|
rgssVersion = clamp(rgssVersion, 0, 3);
|
||||||
SE.sourceCount = clamp(SE.sourceCount, 1, 64);
|
SE.sourceCount = clamp(SE.sourceCount, 1, 64);
|
||||||
|
|
||||||
|
|
10
src/config.h
10
src/config.h
|
@ -86,8 +86,6 @@ struct Config {
|
||||||
|
|
||||||
std::vector<std::string> rubyLoadpaths;
|
std::vector<std::string> rubyLoadpaths;
|
||||||
|
|
||||||
std::vector<std::string> rubyArgs;
|
|
||||||
|
|
||||||
/* Editor flags */
|
/* Editor flags */
|
||||||
struct {
|
struct {
|
||||||
bool debug;
|
bool debug;
|
||||||
|
@ -99,6 +97,14 @@ struct Config {
|
||||||
std::string scripts;
|
std::string scripts;
|
||||||
std::string title;
|
std::string title;
|
||||||
} game;
|
} game;
|
||||||
|
|
||||||
|
// JIT Options
|
||||||
|
struct {
|
||||||
|
bool enabled;
|
||||||
|
int verboseLevel;
|
||||||
|
int maxCache;
|
||||||
|
int minCalls;
|
||||||
|
} jit;
|
||||||
|
|
||||||
/* Internal */
|
/* Internal */
|
||||||
std::string customDataPath;
|
std::string customDataPath;
|
||||||
|
|
Loading…
Add table
Reference in a new issue