Expand statistics feature to cover all vm stats Block access to the choice point stack and trail stats unless the statistics feature is enabled for the VM. Change-Id: Ifb7baa1ddc1605c3324e0c1f5f802b1daf2b6f05
diff --git a/src/builtin/PRED_$statistics_2.java b/src/builtin/PRED_$statistics_2.java index 6d8b75c..e77864e 100644 --- a/src/builtin/PRED_$statistics_2.java +++ b/src/builtin/PRED_$statistics_2.java
@@ -28,12 +28,12 @@ Term result = null; a1 = a1.dereference(); + engine.requireFeature(Prolog.Feature.STATISTICS, this, a1); if (a1.isVariable()) { throw new PInstantiationException(this, 1); } else if (! a1.isSymbol()) { throw new IllegalTypeException(this, 1, "atom", a1); } else if (a1.equals(SYM_RUNTIME)) { - engine.requireFeature(Prolog.Feature.STATISTICS_RUNTIME, this, a1); long val1, val2; Term start, previous; val1 = System.currentTimeMillis() - engine.getStartRuntime(); @@ -61,7 +61,7 @@ } else { return engine.fail(); } - if (! a2.unify(result, engine.trail)) + if (! a2.unify(result, engine.trail)) return engine.fail(); return cont; }
diff --git a/src/lang/Prolog.java b/src/lang/Prolog.java index 231ab2c..205f71d 100644 --- a/src/lang/Prolog.java +++ b/src/lang/Prolog.java
@@ -90,7 +90,7 @@ IO, /** Track the running time of evaluations */ - STATISTICS_RUNTIME; + STATISTICS; } protected final EnumSet<Feature> features = EnumSet.noneOf(Feature.class); @@ -149,7 +149,7 @@ halt = 0; debug = "off"; exception = NONE; - startRuntime = features.contains(Feature.STATISTICS_RUNTIME) + startRuntime = features.contains(Feature.STATISTICS) ? System.currentTimeMillis() : 0; previousRuntime = 0;