summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>2004-06-16 15:41:59 +0000
committerDamien Doligez <damien.doligez-inria.fr>2004-06-16 15:41:59 +0000
commit477942df0ee5c54d182b4ad002b06b4dfbbdfb77 (patch)
treeca40d623a3b366a1c5505127c8998b9d33790d46
parent972259995212aba994b837f59f09825318901900 (diff)
PR#1928
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6414 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--tools/ocamlprof.ml15
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/ocamlprof.ml b/tools/ocamlprof.ml
index 8fb23b5b9..6ae04d3db 100644
--- a/tools/ocamlprof.ml
+++ b/tools/ocamlprof.ml
@@ -21,8 +21,9 @@ open Location
open Misc
open Parsetree
-(* User programs must not use identifiers that start with this prefix. *)
+(* User programs must not use identifiers that start with these prefixes. *)
let idprefix = "__ocaml_prof";;
+let modprefix = "OCAML__prof_";;
(* Errors specific to the profiler *)
@@ -87,8 +88,10 @@ let add_incr_counter modul (kind,pos) =
| Close -> fprintf !outchan ")";
| Open ->
fprintf !outchan
- "(%s_cnt_%s_.(%d) <- Pervasives.succ %s_cnt_%s_.(%d); "
- idprefix modul !prof_counter idprefix modul !prof_counter;
+ "(%sArray.set %s_cnt_%s %d \
+ (%sPervasives.succ (%sArray.get %s_cnt_%s %d)); "
+ modprefix idprefix modul !prof_counter
+ modprefix modprefix idprefix modul !prof_counter;
incr prof_counter;
;;
@@ -127,11 +130,13 @@ let pos_len = ref 0
let init_rewrite modes mod_name =
cur_point := 0;
if !instr_mode then begin
- fprintf !outchan "let %s_cnt_%s_ = Array.create 0000000" idprefix mod_name;
+ fprintf !outchan "module %sArray = Array;; " modprefix;
+ fprintf !outchan "module %sPervasives = Pervasives;; " modprefix;
+ fprintf !outchan "let %s_cnt_%s = Array.create 0000000" idprefix mod_name;
pos_len := pos_out !outchan;
fprintf !outchan
" 0;; Profiling.counters := \
- (\"%s\", (\"%s\", %s_cnt_%s_)) :: !Profiling.counters;; "
+ (\"%s\", (\"%s\", %s_cnt_%s)) :: !Profiling.counters;; "
mod_name modes idprefix mod_name
end