|
@@ -386,40 +386,40 @@ end
|
|
*)
|
|
*)
|
|
module InterferenceReport = struct
|
|
module InterferenceReport = struct
|
|
type interference_report = {
|
|
type interference_report = {
|
|
- ir_var_reads : (int,bool) Hashtbl.t;
|
|
|
|
- ir_var_writes : (int,bool) Hashtbl.t;
|
|
|
|
- ir_field_reads : (string,bool) Hashtbl.t;
|
|
|
|
- ir_field_writes : (string,bool) Hashtbl.t;
|
|
|
|
|
|
+ mutable ir_var_reads : bool IntMap.t;
|
|
|
|
+ mutable ir_var_writes : bool IntMap.t;
|
|
|
|
+ mutable ir_field_reads : bool StringMap.t;
|
|
|
|
+ mutable ir_field_writes : bool StringMap.t;
|
|
mutable ir_state_read : bool;
|
|
mutable ir_state_read : bool;
|
|
mutable ir_state_write : bool;
|
|
mutable ir_state_write : bool;
|
|
}
|
|
}
|
|
|
|
|
|
let create () = {
|
|
let create () = {
|
|
- ir_var_reads = Hashtbl.create 0;
|
|
|
|
- ir_var_writes = Hashtbl.create 0;
|
|
|
|
- ir_field_reads = Hashtbl.create 0;
|
|
|
|
- ir_field_writes = Hashtbl.create 0;
|
|
|
|
|
|
+ ir_var_reads = IntMap.empty;
|
|
|
|
+ ir_var_writes = IntMap.empty;
|
|
|
|
+ ir_field_reads = StringMap.empty;
|
|
|
|
+ ir_field_writes = StringMap.empty;
|
|
ir_state_read = false;
|
|
ir_state_read = false;
|
|
ir_state_write = false;
|
|
ir_state_write = false;
|
|
}
|
|
}
|
|
|
|
|
|
- let set_var_read ir v = Hashtbl.replace ir.ir_var_reads v.v_id true
|
|
|
|
- let set_var_write ir v = Hashtbl.replace ir.ir_var_writes v.v_id true
|
|
|
|
- let set_field_read ir s = Hashtbl.replace ir.ir_field_reads s true
|
|
|
|
- let set_field_write ir s = Hashtbl.replace ir.ir_field_writes s true
|
|
|
|
|
|
+ let set_var_read ir v = ir.ir_var_reads <- IntMap.add v.v_id true ir.ir_var_reads
|
|
|
|
+ let set_var_write ir v = ir.ir_var_writes <- IntMap.add v.v_id true ir.ir_var_writes
|
|
|
|
+ let set_field_read ir s = ir.ir_field_reads <- StringMap.add s true ir.ir_field_reads
|
|
|
|
+ let set_field_write ir s = ir.ir_field_writes <- StringMap.add s true ir.ir_field_writes
|
|
let set_state_read ir = ir.ir_state_read <- true
|
|
let set_state_read ir = ir.ir_state_read <- true
|
|
let set_state_write ir = ir.ir_state_write <- true
|
|
let set_state_write ir = ir.ir_state_write <- true
|
|
|
|
|
|
- let has_var_read ir v = Hashtbl.mem ir.ir_var_reads v.v_id
|
|
|
|
- let has_var_write ir v = Hashtbl.mem ir.ir_var_writes v.v_id
|
|
|
|
- let has_field_read ir s = Hashtbl.mem ir.ir_field_reads s
|
|
|
|
- let has_field_write ir s = Hashtbl.mem ir.ir_field_writes s
|
|
|
|
|
|
+ let has_var_read ir v = IntMap.mem v.v_id ir.ir_var_reads
|
|
|
|
+ let has_var_write ir v = IntMap.mem v.v_id ir.ir_var_writes
|
|
|
|
+ let has_field_read ir s = StringMap.mem s ir.ir_field_reads
|
|
|
|
+ let has_field_write ir s = StringMap.mem s ir.ir_field_writes
|
|
let has_state_read ir = ir.ir_state_read
|
|
let has_state_read ir = ir.ir_state_read
|
|
let has_state_write ir = ir.ir_state_write
|
|
let has_state_write ir = ir.ir_state_write
|
|
- let has_any_field_read ir = Hashtbl.length ir.ir_field_reads > 0
|
|
|
|
- let has_any_field_write ir = Hashtbl.length ir.ir_field_writes > 0
|
|
|
|
- let has_any_var_read ir = Hashtbl.length ir.ir_var_reads > 0
|
|
|
|
- let has_any_var_write ir = Hashtbl.length ir.ir_var_writes > 0
|
|
|
|
|
|
+ let has_any_field_read ir = not (StringMap.is_empty ir.ir_field_reads)
|
|
|
|
+ let has_any_field_write ir = not (StringMap.is_empty ir.ir_field_writes)
|
|
|
|
+ let has_any_var_read ir = not (IntMap.is_empty ir.ir_var_reads)
|
|
|
|
+ let has_any_var_write ir = not (IntMap.is_empty ir.ir_var_writes)
|
|
|
|
|
|
let from_texpr e =
|
|
let from_texpr e =
|
|
let ir = create () in
|
|
let ir = create () in
|
|
@@ -525,14 +525,17 @@ module InterferenceReport = struct
|
|
ir
|
|
ir
|
|
|
|
|
|
let to_string ir =
|
|
let to_string ir =
|
|
- let s_hashtbl f h =
|
|
|
|
- String.concat ", " (Hashtbl.fold (fun k _ acc -> (f k) :: acc) h [])
|
|
|
|
|
|
+ let s_intmap f h =
|
|
|
|
+ String.concat ", " (IntMap.fold (fun k _ acc -> (f k) :: acc) h [])
|
|
|
|
+ in
|
|
|
|
+ let s_stringmap f h =
|
|
|
|
+ String.concat ", " (StringMap.fold (fun k _ acc -> (f k) :: acc) h [])
|
|
in
|
|
in
|
|
Type.Printer.s_record_fields "" [
|
|
Type.Printer.s_record_fields "" [
|
|
- "ir_var_reads",s_hashtbl string_of_int ir.ir_var_reads;
|
|
|
|
- "ir_var_writes",s_hashtbl string_of_int ir.ir_var_writes;
|
|
|
|
- "ir_field_reads",s_hashtbl (fun x -> x) ir.ir_field_reads;
|
|
|
|
- "ir_field_writes",s_hashtbl (fun x -> x) ir.ir_field_writes;
|
|
|
|
|
|
+ "ir_var_reads",s_intmap string_of_int ir.ir_var_reads;
|
|
|
|
+ "ir_var_writes",s_intmap string_of_int ir.ir_var_writes;
|
|
|
|
+ "ir_field_reads",s_stringmap (fun x -> x) ir.ir_field_reads;
|
|
|
|
+ "ir_field_writes",s_stringmap (fun x -> x) ir.ir_field_writes;
|
|
"ir_state_read",string_of_bool ir.ir_state_read;
|
|
"ir_state_read",string_of_bool ir.ir_state_read;
|
|
"ir_state_write",string_of_bool ir.ir_state_write;
|
|
"ir_state_write",string_of_bool ir.ir_state_write;
|
|
]
|
|
]
|