Skip to content

Commit b275b3d

Browse files
author
Hongbo Zhang
committed
instrument debug info when setfield(floatfield)
1 parent 5e42620 commit b275b3d

File tree

11 files changed

+37
-28
lines changed

11 files changed

+37
-28
lines changed

asmcomp/closure.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ let prim_size prim args =
149149
| Psetglobal id -> 1
150150
| Pmakeblock(tag, _, mut) -> 5 + List.length args
151151
| Pfield _ -> 1
152-
| Psetfield(f, isptr) -> if isptr then 4 else 1
152+
| Psetfield(f, isptr,_) -> if isptr then 4 else 1
153153
| Pfloatfield _ -> 1
154-
| Psetfloatfield f -> 1
154+
| Psetfloatfield _ -> 1
155155
| Pduprecord _ -> 10 + List.length args
156156
| Pccall p -> (if p.prim_alloc then 10 else 4) + List.length args
157157
| Praise _ -> 4
@@ -924,11 +924,11 @@ let rec close fenv cenv = function
924924
let (ulam, approx) = close fenv cenv lam in
925925
check_constant_result lam (Uprim(field, [ulam], Debuginfo.none))
926926
(field_approx n approx)
927-
| Lprim(Psetfield(n, _), [Lprim(Pgetglobal id, []); lam]) ->
927+
| Lprim(Psetfield(n, _,dbg_info), [Lprim(Pgetglobal id, []); lam]) ->
928928
let (ulam, approx) = close fenv cenv lam in
929929
if approx <> Value_unknown then
930930
(!global_approx).(n) <- approx;
931-
(Uprim(Psetfield(n, false), [getglobal id; ulam], Debuginfo.none),
931+
(Uprim(Psetfield(n, false, dbg_info), [getglobal id; ulam], Debuginfo.none),
932932
Value_unknown)
933933
| Lprim(Praise k, [Levent(arg, ev)]) ->
934934
let (ulam, approx) = close fenv cenv arg in

asmcomp/cmmgen.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,13 +1660,13 @@ and transl_prim_1 p arg dbg =
16601660
and transl_prim_2 p arg1 arg2 dbg =
16611661
match p with
16621662
(* Heap operations *)
1663-
Psetfield(n, ptr) ->
1663+
Psetfield(n, ptr, _) ->
16641664
if ptr then
16651665
return_unit(Cop(Cextcall("caml_modify", typ_void, false,Debuginfo.none),
16661666
[field_address (transl arg1) n; transl arg2]))
16671667
else
16681668
return_unit(set_field (transl arg1) n (transl arg2))
1669-
| Psetfloatfield n ->
1669+
| Psetfloatfield (n,_) ->
16701670
let ptr = transl arg1 in
16711671
return_unit(
16721672
Cop(Cstore Double_u,

bytecomp/bytegen.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ let comp_primitive p args =
302302
| Pintcomp cmp -> Kintcomp cmp
303303
| Pmakeblock(tag, _, mut) -> Kmakeblock(List.length args, tag)
304304
| Pfield (n, _) -> Kgetfield n
305-
| Psetfield(n, ptr) -> Ksetfield n
305+
| Psetfield(n, ptr, _) -> Ksetfield n
306306
| Pfloatfield (n,_) -> Kgetfloatfield n
307-
| Psetfloatfield n -> Ksetfloatfield n
307+
| Psetfloatfield (n,_) -> Ksetfloatfield n
308308
| Pduprecord _ -> Kccall("caml_obj_dup", 1)
309309
| Pccall p -> Kccall(p.prim_name, p.prim_arity)
310310
| Pnegint -> Knegint

bytecomp/lambda.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ type field_dbg_info =
4444
| Fld_record of string
4545
| Fld_module of string
4646

47+
type set_field_dbg_info =
48+
| Fld_set_na
49+
| Fld_record_set of string
50+
4751
type primitive =
4852
| Pidentity
4953
| Pbytes_to_string
@@ -61,9 +65,9 @@ type primitive =
6165
(* Operations on heap blocks *)
6266
| Pmakeblock of int * tag_info * mutable_flag
6367
| Pfield of int * field_dbg_info
64-
| Psetfield of int * bool
68+
| Psetfield of int * bool * set_field_dbg_info
6569
| Pfloatfield of int * field_dbg_info
66-
| Psetfloatfield of int
70+
| Psetfloatfield of int * set_field_dbg_info
6771
| Pduprecord of Types.record_representation * int
6872
(* Force lazy values *)
6973
| Plazyforce

bytecomp/lambda.mli

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ type field_dbg_info =
4646
| Fld_record of string
4747
| Fld_module of string
4848

49+
type set_field_dbg_info =
50+
| Fld_set_na
51+
| Fld_record_set of string
52+
4953
type pointer_info =
5054
| NullConstructor of string
5155
| NullVariant of string
@@ -70,9 +74,10 @@ type primitive =
7074
(* Operations on heap blocks *)
7175
| Pmakeblock of int * tag_info * mutable_flag
7276
| Pfield of int * field_dbg_info
73-
| Psetfield of int * bool (* could have field info at least for record *)
77+
| Psetfield of int * bool * set_field_dbg_info
78+
(* could have field info at least for record *)
7479
| Pfloatfield of int * field_dbg_info
75-
| Psetfloatfield of int
80+
| Psetfloatfield of int * set_field_dbg_info
7681
| Pduprecord of Types.record_representation * int
7782
(* Force lazy values *)
7883
| Plazyforce

bytecomp/printlambda.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ let primitive ppf = function
110110
| Pmakeblock(tag, _, Immutable) -> fprintf ppf "makeblock %i" tag
111111
| Pmakeblock(tag, _, Mutable) -> fprintf ppf "makemutable %i" tag
112112
| Pfield (n,_) -> fprintf ppf "field %i" n
113-
| Psetfield(n, ptr) ->
113+
| Psetfield(n, ptr, _) ->
114114
let instr = if ptr then "setfield_ptr " else "setfield_imm " in
115115
fprintf ppf "%s%i" instr n
116116
| Pfloatfield (n,_) -> fprintf ppf "floatfield %i" n
117-
| Psetfloatfield n -> fprintf ppf "setfloatfield %i" n
117+
| Psetfloatfield (n,_) -> fprintf ppf "setfloatfield %i" n
118118
| Pduprecord (rep, size) -> fprintf ppf "duprecord %a %i" record_rep rep size
119119
| Plazyforce -> fprintf ppf "force"
120120
| Pccall p -> fprintf ppf "%s" p.prim_name
@@ -372,7 +372,7 @@ let lambda use_env env ppf v =
372372
| Lprim(Pfield (n,_), [ Lprim(Pgetglobal id,[])]) when use_env ->
373373
fprintf ppf "%s.%s/%d" id.name (get_string (id,n) env) n
374374

375-
| Lprim(Psetfield (n,_), [ Lprim(Pgetglobal id,[]) ; e ]) when use_env ->
375+
| Lprim(Psetfield (n,_,_), [ Lprim(Pgetglobal id,[]) ; e ]) when use_env ->
376376
fprintf ppf "@[<2>(%s.%s/%d <- %a)@]" id.name (get_string (id,n) env) n
377377
lam e
378378
| Lprim(prim, largs) ->

bytecomp/simplif.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ let rec eliminate_ref id = function
3737
eliminate_ref id e2)
3838
| Lprim(Pfield (0, _), [Lvar v]) when Ident.same v id ->
3939
Lvar id
40-
| Lprim(Psetfield(0, _), [Lvar v; e]) when Ident.same v id ->
40+
| Lprim(Psetfield(0, _, _), [Lvar v; e]) when Ident.same v id ->
4141
Lassign(id, eliminate_ref id e)
4242
| Lprim(Poffsetref delta, [Lvar v]) when Ident.same v id ->
4343
Lassign(id, Lprim(Poffsetint delta, [Lvar id]))

bytecomp/translclass.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ let transl_class ids cl_id pub_meths cl vflag =
777777
[Lvar tables; Lprim(Pmakeblock(0, Lambda.default_tag_info, Immutable), inh_keys)]),
778778
lam)
779779
and lset cached i lam =
780-
Lprim(Psetfield(i, true), [Lvar cached; lam])
780+
Lprim(Psetfield(i, true, Fld_set_na), [Lvar cached; lam])
781781
in
782782
let ldirect () =
783783
ltable cla

bytecomp/translcore.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ let primitives_table = create_hashtable 57 [
148148
"%ignore", Pignore;
149149
"%field0", Pfield (0, Fld_na);
150150
"%field1", Pfield (1, Fld_na);
151-
"%setfield0", Psetfield(0, true);
151+
"%setfield0", Psetfield(0, true, Fld_set_na);
152152
"%makeblock", Pmakeblock(0, Lambda.default_tag_info, Immutable);
153153
"%makemutable", Pmakeblock(0,Lambda.default_tag_info, Mutable);
154154
"%raise", Praise Raise_regular;
@@ -386,7 +386,7 @@ let transl_prim loc prim args =
386386
let p = find_primitive loc prim_name in
387387
(* Try strength reduction based on the type of the argument *)
388388
begin match (p, args) with
389-
(Psetfield(n, _), [arg1; arg2]) -> Psetfield(n, maybe_pointer arg2)
389+
(Psetfield(n, _, dbg_info), [arg1; arg2]) -> Psetfield(n, maybe_pointer arg2, dbg_info)
390390
| (Parraylength Pgenarray, [arg]) -> Parraylength(array_kind arg)
391391
| (Parrayrefu Pgenarray, arg1 :: _) -> Parrayrefu(array_kind arg1)
392392
| (Parraysetu Pgenarray, arg1 :: _) -> Parraysetu(array_kind arg1)
@@ -798,8 +798,8 @@ and transl_exp0 e =
798798
| Texp_setfield(arg, _, lbl, newval) ->
799799
let access =
800800
match lbl.lbl_repres with
801-
Record_regular -> Psetfield(lbl.lbl_pos, maybe_pointer newval)
802-
| Record_float -> Psetfloatfield lbl.lbl_pos in
801+
Record_regular -> Psetfield(lbl.lbl_pos, maybe_pointer newval, Fld_record_set lbl.lbl_name)
802+
| Record_float -> Psetfloatfield (lbl.lbl_pos, Fld_record_set lbl.lbl_name) in
803803
Lprim(access, [transl_exp arg; transl_exp newval])
804804
| Texp_array expr_list ->
805805
let kind = array_kind e in
@@ -1136,8 +1136,8 @@ and transl_record all_labels repres lbl_expr_list opt_init_expr =
11361136
let update_field (_, lbl, expr) cont =
11371137
let upd =
11381138
match lbl.lbl_repres with
1139-
Record_regular -> Psetfield(lbl.lbl_pos, maybe_pointer expr)
1140-
| Record_float -> Psetfloatfield lbl.lbl_pos in
1139+
Record_regular -> Psetfield(lbl.lbl_pos, maybe_pointer expr, Fld_record_set lbl.lbl_name)
1140+
| Record_float -> Psetfloatfield (lbl.lbl_pos, Fld_record_set lbl.lbl_name) in
11411141
Lsequence(Lprim(upd, [Lvar copy_id; transl_exp expr]), cont) in
11421142
begin match opt_init_expr with
11431143
None -> assert false

bytecomp/translmod.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ let transl_store_structure glob map prims str =
702702
try
703703
let (pos, cc) = Ident.find_same id map in
704704
let init_val = apply_coercion Alias cc (Lvar id) in
705-
Lprim(Psetfield(pos, false), [Lprim(Pgetglobal glob, []); init_val])
705+
Lprim(Psetfield(pos, false, Fld_set_na), [Lprim(Pgetglobal glob, []); init_val])
706706
with Not_found ->
707707
fatal_error("Translmod.store_ident: " ^ Ident.unique_name id)
708708

@@ -724,7 +724,7 @@ let transl_store_structure glob map prims str =
724724
List.fold_right (add_ident may_coerce) idlist subst
725725

726726
and store_primitive (pos, prim) cont =
727-
Lsequence(Lprim(Psetfield(pos, false),
727+
Lsequence(Lprim(Psetfield(pos, false, Fld_set_na),
728728
[Lprim(Pgetglobal glob, []);
729729
transl_primitive Location.none prim]),
730730
cont)
@@ -938,7 +938,7 @@ let transl_store_package component_names target_name coercion =
938938
(List.length component_names,
939939
make_sequence
940940
(fun pos id ->
941-
Lprim(Psetfield(pos, false),
941+
Lprim(Psetfield(pos, false, Fld_set_na),
942942
[Lprim(Pgetglobal target_name, []);
943943
get_component id]))
944944
0 component_names)
@@ -951,7 +951,7 @@ let transl_store_package component_names target_name coercion =
951951
Llet (Strict, blk, apply_coercion Strict coercion components,
952952
make_sequence
953953
(fun pos id ->
954-
Lprim(Psetfield(pos, false),
954+
Lprim(Psetfield(pos, false, Fld_set_na),
955955
[Lprim(Pgetglobal target_name, []);
956956
Lprim(Pfield (pos, Fld_na), [Lvar blk])]))
957957
0 pos_cc_list))

0 commit comments

Comments
 (0)