org.mozilla.javascript.Context.getMaximumInterpreterStackDepth()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 JavaScript  
字(2.1k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中org.mozilla.javascript.Context.getMaximumInterpreterStackDepth()方法的一些代码示例,展示了Context.getMaximumInterpreterStackDepth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getMaximumInterpreterStackDepth()方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:getMaximumInterpreterStackDepth

Context.getMaximumInterpreterStackDepth介绍

[英]Returns the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter. If the set depth would be exceeded, the interpreter will throw an EvaluatorException in the script. Defaults to Integer.MAX_VALUE. The setting only has effect for interpreted functions (those compiled with optimization level set to -1). As the interpreter doesn't use the Java stack but rather manages its own stack in the heap memory, a runaway recursion in interpreted code would eventually consume all available memory and cause OutOfMemoryError instead of a StackOverflowError limited to only a single thread. This setting helps prevent such situations.
[中]返回单个解释器调用中允许的最大堆栈深度(以调用帧的数量表示)。如果超过设置的深度,解释器将在脚本中抛出EvaluatorException。默认为整数。最大值。该设置仅对已解释的函数(在优化级别设置为-1的情况下编译的函数)有效。由于解释器不使用Java堆栈,而是在堆内存中管理自己的堆栈,因此解释代码中的失控递归最终将消耗所有可用内存,并导致OutOfMemoryError,而不是仅限于单个线程的StackOverflowerError。此设置有助于防止此类情况。

代码示例

代码示例来源:origin: geogebra/geogebra

frame.frameIndex = (parentFrame == null)
          ? 0 : parentFrame.frameIndex + 1;
if(frame.frameIndex > cx.getMaximumInterpreterStackDepth())

代码示例来源:origin: io.apigee/rhino

frame.frameIndex = (parentFrame == null)
          ? 0 : parentFrame.frameIndex + 1;
if(frame.frameIndex > cx.getMaximumInterpreterStackDepth())

代码示例来源:origin: com.github.tntim96/rhino

frame.frameIndex = (parentFrame == null)
          ? 0 : parentFrame.frameIndex + 1;
if(frame.frameIndex > cx.getMaximumInterpreterStackDepth())

代码示例来源:origin: ro.isdc.wro4j/rhino

frame.frameIndex = (parentFrame == null)
          ? 0 : parentFrame.frameIndex + 1;
if(frame.frameIndex > cx.getMaximumInterpreterStackDepth())

代码示例来源:origin: rhino/js

frame.frameIndex = (parentFrame == null)
          ? 0 : parentFrame.frameIndex + 1;
if(frame.frameIndex > cx.getMaximumInterpreterStackDepth())

代码示例来源:origin: com.sun.phobos/phobos-rhino

frame.frameIndex = (parentFrame == null)
          ? 0 : parentFrame.frameIndex + 1;
if(frame.frameIndex > cx.getMaximumInterpreterStackDepth())

相关文章

微信公众号

Context类方法