Commits

Matthew Hammer committed e591d90

debugging info in the memo table is controlled by IFDEF flag

  • Participants
  • Parent commits 67a2466
  • Branches nominal

Comments (0)

Files changed (1)

File Source/AdaptonZoo/Adapton.ml

           | _ ->
               ()
         end;
-        (* DEBUGGING/LOGGING TODO: *)
-        (* XXX -- can't do this line: module R is not in scope here. *)
-        (* Log.log `ForceRet (fun _ -> Log.more (R.string value)); *)
         value
       end
 end
            incremental re-uses of the same key. *)
           struct
             type t = {
-              mutable caller : meta option ; (* DEBUGGING: last caller to update row. *)
-              mutable seqno  : int ; (* DEBUGGING: global sequence number *)
+              mutable caller : (meta option) ifdef_adapton_log  ; (* last caller to update row. *)
+              mutable seqno  : int ifdef_adapton_log ; (* global sequence number *)
               mutable arg    : A.t ;
               thunk          : R.t thunk }
           end in
 
-      let assert_no_memo_keyed_bug symbol key cur_arg row =
+      let assert_no_memo_keyed_bug symbol key cur_arg row = IFDEF ADAPTON_LOG THEN (
         let cur_caller = current_caller () in
         let diff_caller =
           begin match (row.Row.caller, cur_caller) with
                 row.Row.seqno (!global_seqno) (Key.string key) symbol row.Row.thunk.meta.id (A.string row.Row.arg) (A.string cur_arg) old_caller new_caller ;
               failwith "memo_keyed_bug(1)"
           | _ -> ()
-        end ;
+        end;
         (* BUG #2: Using the same key to create two different thunks. *)
         if (( row.Row.seqno >= !global_seqno ) && (not (A.equal cur_arg row.Row.arg))) then begin
           Printf.fprintf stderr "\nError: memo_keyed_bug-2: row_cycle=%d >= cur_cycle=%d, key=%s {symbol=%s, thunk=&%d, arg=%s}, cur_arg=%s\n%!"
             row.Row.seqno (!global_seqno) (Key.string key) symbol row.Row.thunk.meta.id (A.string row.Row.arg) (A.string cur_arg) ;
           failwith "memo_keyed_bug(2)"
         end
+      ) END
       in
 
       let _ = (fun _ -> ()) assert_no_memo_keyed_bug in (* silence useless unused variable warning. *)
         with
 	  | Some row -> begin
               (*( assert_no_memo_keyed_bug symbol key cur_arg row ) ;*)
-              row.Row.seqno  <- !global_seqno ;    (* DEBUG only *)
-              row.Row.caller <- current_caller () ; (* DEBUG only *)
               IFDEF ADAPTON_LOG THEN (
+                row.Row.seqno  <- !global_seqno ;
+                row.Row.caller <- current_caller () ;
                 Log.more ("Matched: &"^(string_of_int row.Row.thunk.meta.id)^".") ;
               ) END ;
               (* Found a matching row; *)
               and thunk = { meta  = make_meta_with (Some key) (Some symbol) ;
                             state = Thunk ( evaluate ) }
 
-              and row = { Row.caller = current_caller () ; (* DEBUG only *)
-                          Row.seqno  = !global_seqno ; (* DEBUG only *)
+              and row = { Row.caller = (IFDEF ADAPTON_LOG THEN current_caller () END);
+                          Row.seqno  = (IFDEF ADAPTON_LOG THEN !global_seqno END);
                           Row.arg    = cur_arg ;
                           Row.thunk  = thunk ; }
               in