Reduce max call stack size for debug.

This commit is contained in:
Stephen Chung 2020-10-08 23:00:01 +08:00
parent 1272eeb81a
commit d511aac7a4
5 changed files with 8 additions and 7 deletions

View File

@ -26,6 +26,7 @@ Enhancements
------------
* Many one-liners and few-liners are now marked `#[inline]` or `[inline(always)]`, just in case it helps when LTO is not turned on.
* Default call stack depth for `debug` builds is reduced to 12 (from 16).
Version 0.19.0

View File

@ -6,7 +6,7 @@ Maximum Call Stack Depth
Limit How Stack Usage by Scripts
-------------------------------
Rhai by default limits function calls to a maximum depth of 128 levels (16 levels in debug build).
Rhai by default limits function calls to a maximum depth of 128 levels (12 levels in debug build).
This limit may be changed via the `Engine::set_max_call_levels` method.

View File

@ -75,7 +75,7 @@ pub type Imports = Vec<(ImmutableString, Module)>;
#[cfg(not(feature = "unchecked"))]
#[cfg(debug_assertions)]
pub const MAX_CALL_STACK_DEPTH: usize = 16;
pub const MAX_CALL_STACK_DEPTH: usize = 12;
#[cfg(not(feature = "unchecked"))]
#[cfg(debug_assertions)]
pub const MAX_EXPR_DEPTH: usize = 32;

View File

@ -1,6 +1,6 @@
#![cfg(not(feature = "no_optimize"))]
use rhai::{Engine, EvalAltResult, OptimizationLevel, INT, RegisterFn};
use rhai::{Engine, EvalAltResult, OptimizationLevel, RegisterFn, INT};
#[test]
fn test_optimizer_run() -> Result<(), Box<EvalAltResult>> {

View File

@ -10,10 +10,10 @@ fn test_stack_overflow_fn_calls() -> Result<(), Box<EvalAltResult>> {
engine.eval::<INT>(
r"
fn foo(n) { if n <= 1 { 0 } else { n + foo(n-1) } }
foo(8)
foo(7)
",
)?,
35
27
);
#[cfg(not(feature = "unchecked"))]