summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-07 00:19:53 +0700
committerpolwex <polwex@sortug.com>2025-10-07 00:19:53 +0700
commitacf0d9d90795db6b028d7404a5cdc0a20d0225d9 (patch)
tree28ae2dea8eee85f73c35f386d81866c599820f3f
parent799007bbfee05ee706a9d24d399458c2229ad6af (diff)
added mugs to nock logs
-rw-r--r--ocaml/lib/nock.ml13
-rw-r--r--ocaml/test/test_two_stage_boot.ml4
2 files changed, 11 insertions, 6 deletions
diff --git a/ocaml/lib/nock.ml b/ocaml/lib/nock.ml
index 2d106b6..73e5407 100644
--- a/ocaml/lib/nock.ml
+++ b/ocaml/lib/nock.ml
@@ -24,12 +24,13 @@ open Noun
- depth: current recursion depth
- max_calls: how many calls to log (like C's limit)
- max_mug_depth: only compute mugs at shallow depths (expensive!)
+ - show_mugs: global flag to enable/disable mug logging
*)
let call_count = ref 0
let depth = ref 0
let max_calls = 100
-let max_mug_depth = -1 (* Disabled: even cached, initial mug of huge ivory pill is slow *)
-(* TODO: Enable selectively after verifying structural correctness *)
+let max_mug_depth = ref (-1) (* Can be set from outside *)
+let show_mugs = ref false (* Enable from test code to show mugs at every step *)
(* Helper to generate indentation based on depth *)
let indent () =
@@ -77,8 +78,8 @@ let rec nock_on bus fol =
| Cell { h = Cell _; _ } -> "CELL(dist)"
| _ -> "?"
in
- (* Only compute mugs at shallow depths to avoid performance penalty *)
- if !depth <= max_mug_depth then begin
+ (* Only compute mugs at shallow depths to avoid performance penalty, or if show_mugs is enabled *)
+ if !show_mugs || !depth <= !max_mug_depth then begin
let bus_mug = mug bus in
Printf.eprintf "%s>>> ENTER call #%d depth=%d opcode=%s bus=%s[mug=0x%lx]\n%!"
(indent ()) my_call !depth opcode_str
@@ -239,8 +240,8 @@ let rec nock_on bus fol =
(* Restore depth and log exit before returning *)
decr depth;
if should_log then begin
- (* Only compute mugs at shallow depths to avoid performance penalty *)
- if !depth <= max_mug_depth then begin
+ (* Only compute mugs at shallow depths to avoid performance penalty, or if show_mugs is enabled *)
+ if !show_mugs || !depth <= !max_mug_depth then begin
let result_mug = mug result in
Printf.eprintf "%s<<< EXIT call #%d depth=%d returns=%s[mug=0x%lx]\n%!"
(indent ()) my_call !depth
diff --git a/ocaml/test/test_two_stage_boot.ml b/ocaml/test/test_two_stage_boot.ml
index 17c72a8..863c3a1 100644
--- a/ocaml/test/test_two_stage_boot.ml
+++ b/ocaml/test/test_two_stage_boot.ml
@@ -54,6 +54,10 @@ let stage1_ivory_boot env =
Printf.printf "[5] Running u3v_life() on Arvo core...\n%!";
Printf.printf " Formula: [2 [0 3] [0 2]]\n";
Printf.printf " Subject: Arvo core (cell, mug: 0x%08lx)\n%!" core_mug;
+ Printf.printf " Enabling mug logging for all nock steps...\n%!";
+
+ (* Enable mug logging at every step *)
+ Nock.show_mugs := true;
begin try
let start = Unix.gettimeofday () in