forked from OctaForge/libcubescript
per-thread rundepth instead of per-state
parent
d584bc3ca6
commit
f87de11b19
|
@ -2625,14 +2625,15 @@ cleanup:
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr int MaxRunDepth = 255;
|
static constexpr int MaxRunDepth = 255;
|
||||||
|
static thread_local int rundepth = 0;
|
||||||
|
|
||||||
static ostd::Uint32 const *runcode(CsState &cs, ostd::Uint32 const *code, TaggedValue &result) {
|
static ostd::Uint32 const *runcode(CsState &cs, ostd::Uint32 const *code, TaggedValue &result) {
|
||||||
result.set_null();
|
result.set_null();
|
||||||
if (cs.rundepth >= MaxRunDepth) {
|
if (rundepth >= MaxRunDepth) {
|
||||||
cs_debug_code(cs, "exceeded recursion limit");
|
cs_debug_code(cs, "exceeded recursion limit");
|
||||||
return skipcode(code, (&result == &no_ret) ? nullptr : &result);
|
return skipcode(code, (&result == &no_ret) ? nullptr : &result);
|
||||||
}
|
}
|
||||||
++cs.rundepth;
|
++rundepth;
|
||||||
int numargs = 0;
|
int numargs = 0;
|
||||||
TaggedValue args[MaxArguments + MaxResults], *prevret = cs.result;
|
TaggedValue args[MaxArguments + MaxResults], *prevret = cs.result;
|
||||||
cs.result = &result;
|
cs.result = &result;
|
||||||
|
@ -3322,7 +3323,7 @@ noid:
|
||||||
}
|
}
|
||||||
exit:
|
exit:
|
||||||
cs.result = prevret;
|
cs.result = prevret;
|
||||||
--cs.rundepth;
|
--rundepth;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -372,7 +372,6 @@ struct OSTD_EXPORT CsState {
|
||||||
int nodebug = 0;
|
int nodebug = 0;
|
||||||
int numargs = 0;
|
int numargs = 0;
|
||||||
int dbgalias = 4;
|
int dbgalias = 4;
|
||||||
int rundepth = 0;
|
|
||||||
|
|
||||||
CsState();
|
CsState();
|
||||||
~CsState();
|
~CsState();
|
||||||
|
|
Loading…
Reference in New Issue