Skip to content

Commit 8369d84

Browse files
committed
disable event generation from upstream
1 parent 7594631 commit 8369d84

25 files changed

+1186
-1194
lines changed

Diff for: jscomp/bin/bsdep.ml

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ val opaque : bool ref
169169
type mli_status = Mli_na | Mli_exists | Mli_non_exists
170170
val no_implicit_current_dir : bool ref
171171
val assume_no_mli : mli_status ref
172+
val record_event_when_debug : bool ref
172173

173174

174175
type color_setting = Auto | Always | Never
@@ -299,6 +300,7 @@ let unsafe_string = ref true;; (* -safe-string / -unsafe-string *)
299300
type mli_status = Mli_na | Mli_exists | Mli_non_exists
300301
let no_implicit_current_dir = ref false
301302
let assume_no_mli = ref Mli_na
303+
let record_event_when_debug = ref true (* turned off in BuckleScript*)
302304

303305

304306
type color_setting = Auto | Always | Never

Diff for: jscomp/bin/bspp.ml

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ val opaque : bool ref
106106
type mli_status = Mli_na | Mli_exists | Mli_non_exists
107107
val no_implicit_current_dir : bool ref
108108
val assume_no_mli : mli_status ref
109+
val record_event_when_debug : bool ref
109110

110111

111112
type color_setting = Auto | Always | Never
@@ -236,6 +237,7 @@ let unsafe_string = ref true;; (* -safe-string / -unsafe-string *)
236237
type mli_status = Mli_na | Mli_exists | Mli_non_exists
237238
let no_implicit_current_dir = ref false
238239
let assume_no_mli = ref Mli_na
240+
let record_event_when_debug = ref true (* turned off in BuckleScript*)
239241

240242

241243
type color_setting = Auto | Always | Never

Diff for: jscomp/bin/bsppx.ml

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ val opaque : bool ref
106106
type mli_status = Mli_na | Mli_exists | Mli_non_exists
107107
val no_implicit_current_dir : bool ref
108108
val assume_no_mli : mli_status ref
109+
val record_event_when_debug : bool ref
109110

110111

111112
type color_setting = Auto | Always | Never
@@ -236,6 +237,7 @@ let unsafe_string = ref true;; (* -safe-string / -unsafe-string *)
236237
type mli_status = Mli_na | Mli_exists | Mli_non_exists
237238
let no_implicit_current_dir = ref false
238239
let assume_no_mli = ref Mli_na
240+
let record_event_when_debug = ref true (* turned off in BuckleScript*)
239241

240242

241243
type color_setting = Auto | Always | Never

Diff for: jscomp/bin/whole_compiler.ml

+43-35
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ val opaque : bool ref
169169
type mli_status = Mli_na | Mli_exists | Mli_non_exists
170170
val no_implicit_current_dir : bool ref
171171
val assume_no_mli : mli_status ref
172+
val record_event_when_debug : bool ref
172173

173174

174175
type color_setting = Auto | Always | Never
@@ -299,6 +300,7 @@ let unsafe_string = ref true;; (* -safe-string / -unsafe-string *)
299300
type mli_status = Mli_na | Mli_exists | Mli_non_exists
300301
let no_implicit_current_dir = ref false
301302
let assume_no_mli = ref Mli_na
303+
let record_event_when_debug = ref true (* turned off in BuckleScript*)
302304

303305

304306
type color_setting = Auto | Always | Never
@@ -66835,23 +66837,25 @@ let convert exports lam : _ * _ =
6683566837
let lam = Lletrec (bindings, body) in
6683666838
scc bindings lam body
6683766839
(* inlining will affect how mututal recursive behave *)
66838-
| Lprim(Prevapply, [x ; f ], outer_loc) ->
66839-
let x = aux x in
66840-
let f = aux f in
66841-
begin match f with
66842-
| Lapply{fn;args;loc=inner_loc} ->
66843-
apply fn (args @[x]) outer_loc App_na
66844-
| _ ->
66845-
apply f [x] outer_loc App_na
66846-
end
66847-
| Lprim(Pdirapply, [f;x], outer_loc) ->
66848-
let f = aux f in
66849-
let x = aux x in
66850-
begin match f with
66851-
| Lapply{fn ; args }
66852-
->
66853-
apply fn (args @ [x]) outer_loc App_na
66854-
| _ -> apply f [x] outer_loc App_na
66840+
| Lprim(Prevapply, [x ; f ], outer_loc)
66841+
| Lprim(Pdirapply, [f ; x], outer_loc) ->
66842+
begin (*match f with
66843+
| Lapply(Lfunction(kind, params,Lprim(external_fn,inner_args,inner_loc)), args, outer_loc )
66844+
66845+
when Ext_list.for_all2_no_exn (fun x y -> match y with Lambda.Lvar y when Ident.same x y -> true | _ -> false ) params inner_args
66846+
&& Ext_list.same_length inner_args (args @ [x])
66847+
->
66848+
66849+
aux (Lprim(external_fn, args @ [x], outer_loc))
66850+
| _ -> *)
66851+
let x = aux x in
66852+
let f = aux f in
66853+
begin match f with
66854+
| Lapply{fn;args} ->
66855+
apply fn (args @[x]) outer_loc App_na
66856+
| _ ->
66857+
apply f [x] outer_loc App_na
66858+
end
6685566859
end
6685666860
| Lprim (Prevapply, _, _ ) -> assert false
6685766861
| Lprim(Pdirapply, _, _) -> assert false
@@ -66982,7 +66986,9 @@ let convert exports lam : _ * _ =
6698266986
(* Format.fprintf Format.err_formatter "weird: %d@." (Obj.tag (Obj.repr b)); *)
6698366987
Lsend(kind, aux a, b, List.map aux ls, loc )
6698466988
end
66985-
| Levent (e, event) -> aux e
66989+
| Levent (e, event) ->
66990+
(* disabled by upstream*)
66991+
assert false
6698666992
| Lifused (id, e) ->
6698766993
Lifused(id, aux e) (* TODO: remove it ASAP *)
6698866994
and aux_switch (s : Lambda.lambda_switch) : switch =
@@ -73157,20 +73163,19 @@ let lambda use_env env ppf v =
7315773163
let kind =
7315873164
if k = Self then "self" else if k = Cached then "cache" else "" in
7315973165
fprintf ppf "@[<2>(send%s@ %a@ %a%a)@]" kind lam obj lam met args largs
73160-
| Levent(expr, _ev) ->
73161-
lam ppf expr
73162-
(* let kind = *)
73163-
(* match ev.lev_kind with *)
73164-
(* | Lev_before -> "before" *)
73165-
(* | Lev_after _ -> "after" *)
73166-
(* | Lev_function -> "funct-body" in *)
73167-
(* fprintf ppf "@[<2>(%s %s(%i)%s:%i-%i@ %a)@]" kind *)
73168-
(* ev.lev_loc.Location.loc_start.Lexing.pos_fname *)
73169-
(* ev.lev_loc.Location.loc_start.Lexing.pos_lnum *)
73170-
(* (if ev.lev_loc.Location.loc_ghost then "<ghost>" else "") *)
73171-
(* ev.lev_loc.Location.loc_start.Lexing.pos_cnum *)
73172-
(* ev.lev_loc.Location.loc_end.Lexing.pos_cnum *)
73173-
(* lam expr *)
73166+
| Levent(expr, ev) ->
73167+
let kind =
73168+
match ev.lev_kind with
73169+
| Lev_before -> "before"
73170+
| Lev_after _ -> "after"
73171+
| Lev_function -> "funct-body" in
73172+
fprintf ppf "@[<2>(%s %s(%i)%s:%i-%i@ %a)@]" kind
73173+
ev.lev_loc.Location.loc_start.Lexing.pos_fname
73174+
ev.lev_loc.Location.loc_start.Lexing.pos_lnum
73175+
(if ev.lev_loc.Location.loc_ghost then "<ghost>" else "")
73176+
ev.lev_loc.Location.loc_start.Lexing.pos_cnum
73177+
ev.lev_loc.Location.loc_end.Lexing.pos_cnum
73178+
lam expr
7317473179
| Lifused(id, expr) ->
7317573180
fprintf ppf "@[<2>(ifused@ %a@ %a)@]" Ident.print id lam expr
7317673181

@@ -78451,23 +78456,23 @@ let rec push_defaults loc bindings cases partial =
7845178456
let event_before exp lam = match lam with
7845278457
| Lstaticraise (_,_) -> lam
7845378458
| _ ->
78454-
if !Clflags.debug
78459+
if !Clflags.record_event_when_debug && !Clflags.debug
7845578460
then Levent(lam, {lev_loc = exp.exp_loc;
7845678461
lev_kind = Lev_before;
7845778462
lev_repr = None;
7845878463
lev_env = Env.summary exp.exp_env})
7845978464
else lam
7846078465

7846178466
let event_after exp lam =
78462-
if !Clflags.debug
78467+
if !Clflags.record_event_when_debug && !Clflags.debug
7846378468
then Levent(lam, {lev_loc = exp.exp_loc;
7846478469
lev_kind = Lev_after exp.exp_type;
7846578470
lev_repr = None;
7846678471
lev_env = Env.summary exp.exp_env})
7846778472
else lam
7846878473

7846978474
let event_function exp lam =
78470-
if !Clflags.debug then
78475+
if !Clflags.record_event_when_debug && !Clflags.debug then
7847178476
let repr = Some (ref 0) in
7847278477
let (info, body) = lam repr in
7847378478
(info,
@@ -108367,8 +108372,11 @@ let buckle_script_flags =
108367108372

108368108373

108369108374
let _ =
108375+
(* Default configuraiton: sync up with
108376+
{!Jsoo_main} *)
108370108377
Clflags.unsafe_string := false;
108371108378
Clflags.debug := true;
108379+
Clflags.record_event_when_debug := false;
108372108380
Clflags.binary_annotations := true;
108373108381
Bs_conditional_initial.setup_env ();
108374108382
try

Diff for: jscomp/core/design.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,8 @@ let f xs =
6565
xs |> filter (fun x -> x > 2)
6666
```
6767

68-
Here whether the callback gets inlined to the call of `filter` will have an effect on how `Pjs_fn_make` gets cancelled.
68+
Here whether the callback gets inlined to the call of `filter` will have an effect on how `Pjs_fn_make` gets cancelled.
69+
70+
Note when we pattern match over the original lamba,`Levent` needs to be removed as early as possible. Due to the existence of `Levent`, we can not pattern match over nested original raw lambda.
71+
72+
We turned off event generation temporarily

Diff for: jscomp/core/js_main.ml

+3
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,11 @@ let buckle_script_flags =
253253

254254

255255
let _ =
256+
(* Default configuraiton: sync up with
257+
{!Jsoo_main} *)
256258
Clflags.unsafe_string := false;
257259
Clflags.debug := true;
260+
Clflags.record_event_when_debug := false;
258261
Clflags.binary_annotations := true;
259262
Bs_conditional_initial.setup_env ();
260263
try

Diff for: jscomp/core/jsoo_main.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ let () =
4242
Clflags.assume_no_mli := Clflags.Mli_non_exists;
4343
Bs_conditional_initial.setup_env ();
4444
Clflags.dont_write_files := true;
45-
Clflags.unsafe_string := false
45+
Clflags.unsafe_string := false;
46+
Clflags.record_event_when_debug := false
4647

4748
let implementation impl ppf str =
4849
let modulename = "Test" in

Diff for: jscomp/core/lam.ml

+22-18
Original file line numberDiff line numberDiff line change
@@ -1688,23 +1688,25 @@ let convert exports lam : _ * _ =
16881688
let lam = Lletrec (bindings, body) in
16891689
scc bindings lam body
16901690
(* inlining will affect how mututal recursive behave *)
1691-
| Lprim(Prevapply, [x ; f ], outer_loc) ->
1692-
let x = aux x in
1693-
let f = aux f in
1694-
begin match f with
1695-
| Lapply{fn;args;loc=inner_loc} ->
1696-
apply fn (args @[x]) outer_loc App_na
1697-
| _ ->
1698-
apply f [x] outer_loc App_na
1699-
end
1700-
| Lprim(Pdirapply, [f;x], outer_loc) ->
1701-
let f = aux f in
1702-
let x = aux x in
1703-
begin match f with
1704-
| Lapply{fn ; args }
1705-
->
1706-
apply fn (args @ [x]) outer_loc App_na
1707-
| _ -> apply f [x] outer_loc App_na
1691+
| Lprim(Prevapply, [x ; f ], outer_loc)
1692+
| Lprim(Pdirapply, [f ; x], outer_loc) ->
1693+
begin (*match f with
1694+
| Lapply(Lfunction(kind, params,Lprim(external_fn,inner_args,inner_loc)), args, outer_loc )
1695+
1696+
when Ext_list.for_all2_no_exn (fun x y -> match y with Lambda.Lvar y when Ident.same x y -> true | _ -> false ) params inner_args
1697+
&& Ext_list.same_length inner_args (args @ [x])
1698+
->
1699+
1700+
aux (Lprim(external_fn, args @ [x], outer_loc))
1701+
| _ -> *)
1702+
let x = aux x in
1703+
let f = aux f in
1704+
begin match f with
1705+
| Lapply{fn;args} ->
1706+
apply fn (args @[x]) outer_loc App_na
1707+
| _ ->
1708+
apply f [x] outer_loc App_na
1709+
end
17081710
end
17091711
| Lprim (Prevapply, _, _ ) -> assert false
17101712
| Lprim(Pdirapply, _, _) -> assert false
@@ -1835,7 +1837,9 @@ let convert exports lam : _ * _ =
18351837
(* Format.fprintf Format.err_formatter "weird: %d@." (Obj.tag (Obj.repr b)); *)
18361838
Lsend(kind, aux a, b, List.map aux ls, loc )
18371839
end
1838-
| Levent (e, event) -> aux e
1840+
| Levent (e, event) ->
1841+
(* disabled by upstream*)
1842+
assert false
18391843
| Lifused (id, e) ->
18401844
Lifused(id, aux e) (* TODO: remove it ASAP *)
18411845
and aux_switch (s : Lambda.lambda_switch) : switch =

Diff for: jscomp/core/lam_compile_group.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ let lambda_as_module
376376
begin
377377
Js_config.set_current_file filename ;
378378
#if BS_DEBUG then
379-
Js_config.set_debug_file "prepend_data_ffi.ml";
379+
Js_config.set_debug_file "bs_splice_partial.ml";
380380
#end
381381
let lambda_output = compile ~filename output_prefix env sigs lam in
382382
let (//) = Filename.concat in

Diff for: jscomp/test/ext_filename.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,22 @@ function absolute_path(s) {
5454
var match_000 = Curry._1(Filename.basename, s);
5555
var match_001 = Curry._1(Filename.dirname, s);
5656
var dir = match_001;
57-
var base = match_000;
5857
if (dir === s) {
5958
return dir;
6059
}
61-
else if (base === Filename.current_dir_name) {
62-
_s = dir;
63-
continue ;
64-
65-
}
66-
else if (base === Filename.parent_dir_name) {
67-
return Curry._1(Filename.dirname, aux(dir));
68-
}
6960
else {
70-
return Filename.concat(aux(dir), base);
61+
var base = match_000;
62+
if (base === Filename.current_dir_name) {
63+
_s = dir;
64+
continue ;
65+
66+
}
67+
else if (base === Filename.parent_dir_name) {
68+
return Curry._1(Filename.dirname, aux(dir));
69+
}
70+
else {
71+
return Filename.concat(aux(dir), base);
72+
}
7173
}
7274
};
7375
};

0 commit comments

Comments
 (0)