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

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

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

Context.setGenerateObserverCount介绍

[英]Turn on or off generation of code with callbacks to track the count of executed instructions. Currently only affects JVM byte code generation: this slows down the generated code, but code generated without the callbacks will not be counted toward instruction thresholds. Rhino's interpretive mode does instruction counting without inserting callbacks, so there is no requirement to compile code differently.
[中]启用或禁用带有回调的代码生成,以跟踪已执行指令的计数。目前只影响JVM字节码的生成:这会减慢生成的代码的速度,但在没有回调的情况下生成的代码不会计入指令阈值。Rhino的解释模式在不插入回调的情况下进行指令计数,因此不需要以不同的方式编译代码。

代码示例

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

/**
 * Set threshold of executed instructions counter that triggers call to
 * <code>observeInstructionCount()</code>.
 * When the threshold is zero, instruction counting is disabled,
 * otherwise each time the run-time executes at least the threshold value
 * of script instructions, <code>observeInstructionCount()</code> will
 * be called.<p/>
 * Note that the meaning of "instruction" is not guaranteed to be
 * consistent between compiled and interpretive modes: executing a given
 * script or function in the different modes will result in different
 * instruction counts against the threshold.
 * {@link #setGenerateObserverCount} is called with true if
 * <code>threshold</code> is greater than zero, false otherwise.
 * @param threshold The instruction threshold
 */
public final void setInstructionObserverThreshold(int threshold)
{
  if (sealed) onSealedMutation();
  if (threshold < 0) throw new IllegalArgumentException();
  instructionThreshold = threshold;
  setGenerateObserverCount(threshold > 0);
}

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

/**
 * Set threshold of executed instructions counter that triggers call to
 * <code>observeInstructionCount()</code>.
 * When the threshold is zero, instruction counting is disabled,
 * otherwise each time the run-time executes at least the threshold value
 * of script instructions, <code>observeInstructionCount()</code> will
 * be called.<p/>
 * Note that the meaning of "instruction" is not guaranteed to be
 * consistent between compiled and interpretive modes: executing a given
 * script or function in the different modes will result in different
 * instruction counts against the threshold.
 * {@link #setGenerateObserverCount} is called with true if
 * <code>threshold</code> is greater than zero, false otherwise.
 * @param threshold The instruction threshold
 */
public final void setInstructionObserverThreshold(int threshold)
{
  if (sealed) onSealedMutation();
  if (threshold < 0) throw new IllegalArgumentException();
  instructionThreshold = threshold;
  setGenerateObserverCount(threshold > 0);
}

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

/**
 * Set threshold of executed instructions counter that triggers call to
 * <code>observeInstructionCount()</code>.
 * When the threshold is zero, instruction counting is disabled,
 * otherwise each time the run-time executes at least the threshold value
 * of script instructions, <code>observeInstructionCount()</code> will
 * be called.<p/>
 * Note that the meaning of "instruction" is not guaranteed to be
 * consistent between compiled and interpretive modes: executing a given
 * script or function in the different modes will result in different
 * instruction counts against the threshold.
 * {@link #setGenerateObserverCount} is called with true if
 * <code>threshold</code> is greater than zero, false otherwise.
 * @param threshold The instruction threshold
 */
public final void setInstructionObserverThreshold(int threshold)
{
  if (sealed) onSealedMutation();
  if (threshold < 0) throw new IllegalArgumentException();
  instructionThreshold = threshold;
  setGenerateObserverCount(threshold > 0);
}

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

/**
 * Set threshold of executed instructions counter that triggers call to
 * <code>observeInstructionCount()</code>.
 * When the threshold is zero, instruction counting is disabled,
 * otherwise each time the run-time executes at least the threshold value
 * of script instructions, <code>observeInstructionCount()</code> will
 * be called.<p/>
 * Note that the meaning of "instruction" is not guaranteed to be
 * consistent between compiled and interpretive modes: executing a given
 * script or function in the different modes will result in different
 * instruction counts against the threshold.
 * {@link #setGenerateObserverCount} is called with true if
 * <code>threshold</code> is greater than zero, false otherwise.
 * @param threshold The instruction threshold
 */
public final void setInstructionObserverThreshold(int threshold)
{
  if (sealed) onSealedMutation();
  if (threshold < 0) throw new IllegalArgumentException();
  instructionThreshold = threshold;
  setGenerateObserverCount(threshold > 0);
}

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

/**
 * Set threshold of executed instructions counter that triggers call to
 * <code>observeInstructionCount()</code>.
 * When the threshold is zero, instruction counting is disabled,
 * otherwise each time the run-time executes at least the threshold value
 * of script instructions, <code>observeInstructionCount()</code> will
 * be called.<p/>
 * Note that the meaning of "instruction" is not guaranteed to be
 * consistent between compiled and interpretive modes: executing a given
 * script or function in the different modes will result in different
 * instruction counts against the threshold.
 * {@link #setGenerateObserverCount} is called with true if
 * <code>threshold</code> is greater than zero, false otherwise.
 * @param threshold The instruction threshold
 */
public final void setInstructionObserverThreshold(int threshold)
{
  if (sealed) onSealedMutation();
  if (threshold < 0) throw new IllegalArgumentException();
  instructionThreshold = threshold;
  setGenerateObserverCount(threshold > 0);
}

相关文章

微信公众号

Context类方法