per-thread rundepth instead of per-state

master
Daniel Kolesa 2016-07-23 01:08:58 +01:00
parent d584bc3ca6
commit f87de11b19
2 changed files with 4 additions and 4 deletions

View File

@ -2625,14 +2625,15 @@ cleanup:
}
static constexpr int MaxRunDepth = 255;
static thread_local int rundepth = 0;
static ostd::Uint32 const *runcode(CsState &cs, ostd::Uint32 const *code, TaggedValue &result) {
result.set_null();
if (cs.rundepth >= MaxRunDepth) {
if (rundepth >= MaxRunDepth) {
cs_debug_code(cs, "exceeded recursion limit");
return skipcode(code, (&result == &no_ret) ? nullptr : &result);
}
++cs.rundepth;
++rundepth;
int numargs = 0;
TaggedValue args[MaxArguments + MaxResults], *prevret = cs.result;
cs.result = &result;
@ -3322,7 +3323,7 @@ noid:
}
exit:
cs.result = prevret;
--cs.rundepth;
--rundepth;
return code;
}

View File

@ -372,7 +372,6 @@ struct OSTD_EXPORT CsState {
int nodebug = 0;
int numargs = 0;
int dbgalias = 4;
int rundepth = 0;
CsState();
~CsState();