Skip to content

Commit 91c199b

Browse files
mshinwellriaqnstedolan
authored
flambda-backend: Continuation of PR2027 (tests passing for runtime 4 and 5) (#2057)
* Dummy C stubs * Run max_arity_locals test only when stack allocation is enabled * Fix and promote typing-local/ tests for stack allocation being disabled * Predicate some tests on having stack allocation * Forward port all SIMD runtime changes from d3c1413 * Fix globrootsprim.c test * Fix asmgen tests * Add runtime4 predicate to ocamltest and use it in runtime-naked-pointers/ tests * Add runtime_dir ocamltest variable + use it to fix output-complete-obj/ tests * git mv debugger debugger4 * Import debugger/ from upstream 5 * Debugger build system * Apply JS-specific modifications from debugger4/ -> debugger/ * Fix pr9971 test * Fix tests/regression/pr9326 * Fix tests/gc-roots * Fix tests/asmcomp/polling.c * Fixing of backtrace tests * Skip instrumented-runtime tests on 5.x (these tests are not present in upstream 5) * Fix Ctype.unify call in debugger/loadprinter.ml * Fixes for systhreads/ build and importing of build attributes from systhreads4/ * Add Condition, Mutex and Semaphore to the stdlib * Fix dynlink (including for move of Mutex to the stdlib) * Fix get_header.ml test * Add runtime5 predicate in ocamltest and use it to fix backtrace_c_exn.ml * Fix wrong position of modules line in ocaml/testsuite/tests/typing-local/regions.ml test header * Fix bug in caml_gc_counters in the 5 runtime * Remove ocaml/otherlibs/systhreads4/st_pthreads.h, merge error * Promote tests * Move caml_stat_free call in ocaml/runtime4/dynlink_nat.c * port #797 (long frames in frametable) (#2048) * Fix upstream bug with dynlink check/registration ordering, and revert lib-dynlink-private testcase * Fix caml_natdynlink_run_toplevel to actually call the registration function * Add GC test for ocamlnat * Address code review comments * Regenerate stdlib/.depend * Fix upstream build * Fix three runtime4/ occurrences * Fix for upstream systhreads4 build * Don't skip statmemprof tests on runtime4/ * Fix upstream build for debugger4/ * Use runtime_dir not RUNTIME_DIR in the testsuite scriptsd * Re-enabling (for runtime4) and fixing statmemprof tests * Fix _runtest debugger installation paths * Port bc9a60d to runtime/ (fix for caml_natdynlink_run_toplevel) * Address comments --------- Co-authored-by: Zesen Qian <[email protected]> Co-authored-by: Stephen Dolan <[email protected]>
1 parent 55bbf4c commit 91c199b

File tree

187 files changed

+9312
-1361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+9312
-1361
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ clean::
11581158
subdirs = \
11591159
stdlib $(addprefix otherlibs/, \
11601160
$(filter-out runtime_events, $(ALL_OTHERLIBS))) \
1161-
debugger ocamldoc ocamltest
1161+
debugger$(RUNTIME_SUFFIX) ocamldoc ocamltest
11621162

11631163
.PHONY: alldepend
11641164
alldepend: depend
@@ -1352,10 +1352,10 @@ clean::
13521352

13531353
.PHONY: ocamldebugger
13541354
ocamldebugger: ocamlc ocamlyacc ocamllex otherlibraries
1355-
$(MAKE) -C debugger all
1355+
$(MAKE) -C debugger$(RUNTIME_SUFFIX) all
13561356

13571357
partialclean::
1358-
$(MAKE) -C debugger clean
1358+
$(MAKE) -C debugger$(RUNTIME_SUFFIX) clean
13591359

13601360
# Check that the native-code compiler is supported
13611361
.PHONY: checknative
@@ -1667,7 +1667,7 @@ depend: beforedepend
16671667

16681668
.PHONY: distclean
16691669
distclean: clean
1670-
$(MAKE) -C debugger distclean
1670+
$(MAKE) -C debugger$(RUNTIME_SUFFIX) distclean
16711671
$(MAKE) -C manual distclean
16721672
$(MAKE) -C ocamldoc distclean
16731673
$(MAKE) -C ocamltest distclean
@@ -1797,7 +1797,7 @@ ifeq "$(WITH_OCAMLDOC)-$(STDLIB_MANPAGES)" "ocamldoc-true"
17971797
$(MAKE) -C api_docgen install
17981798
endif
17991799
if test -n "$(WITH_DEBUGGER)"; then \
1800-
$(MAKE) -C debugger install; \
1800+
$(MAKE) -C debugger$(RUNTIME_SUFFIX) install; \
18011801
fi
18021802
ifeq "$(BOOTSTRAPPING_FLEXDLL)" "true"
18031803
ifeq "$(TOOLCHAIN)" "msvc"

Makefile.common-jst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ $(ocamldir)/otherlibs/dune:
122122

123123
$(ocamldir)/dune.runtime_selection:
124124
if [ "$(RUNTIME_DIR)" = "runtime4" ]; then \
125-
echo "(dirs (:standard \ runtime))" > $@; \
125+
echo "(dirs (:standard \ runtime debugger))" > $@; \
126126
else \
127-
echo "(dirs (:standard \ runtime4))" > $@; \
127+
echo "(dirs (:standard \ runtime4 debugger4))" > $@; \
128128
fi
129129

130130
_build/_bootinstall: Makefile.config $(dune_config_targets)
@@ -276,10 +276,10 @@ install_for_test: _install
276276
mkdir -p _runtest/lib/ocaml/stublibs/
277277
cp $(main_prefix)/lib/ocaml/stublibs/*.so _runtest/lib/ocaml/stublibs
278278
# ocamldebug
279-
mkdir _runtest/debugger
280-
ln -s ../ocamldebug _runtest/debugger
281-
cp $(main_build)/$(ocamldir)/debugger/.ocamldebug.objs/byte/*.cm* \
282-
_runtest/debugger
279+
mkdir _runtest/debugger$(RUNTIME_SUFFIX)
280+
ln -s ../ocamldebug _runtest/debugger$(RUNTIME_SUFFIX)
281+
cp $(main_build)/$(ocamldir)/debugger$(RUNTIME_SUFFIX)/.ocamldebug.objs/byte/*.cm* \
282+
_runtest/debugger$(RUNTIME_SUFFIX)
283283
# The ast_invariants test needs VERSION to be present. In fact ideally
284284
# we should have all the source files in _runtest too for this test,
285285
# but for the moment we accept it being a weaker check. We're not

bytecomp/dll.ml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ type dll_handle
1919
type dll_address
2020
type dll_mode = For_checking | For_execution
2121

22-
(* BACKPORT BEGIN
23-
external dll_open: string -> dll_handle = "caml_dynlink_open_lib"
24-
*)
25-
external dll_open: dll_mode -> string -> dll_handle = "caml_dynlink_open_lib"
26-
(* BACKPORT END *)
22+
external dll_open5: string -> dll_handle = "caml_dynlink_open_lib"
23+
24+
external dll_open4: dll_mode -> string -> dll_handle = "caml_dynlink_open_lib"
25+
26+
let dll_open mode path =
27+
if Config.runtime5 then dll_open5 path else dll_open4 mode path
28+
2729
external dll_close: dll_handle -> unit = "caml_dynlink_close_lib"
2830
external dll_sym: dll_handle -> string -> dll_address
2931
= "caml_dynlink_lookup_symbol"
@@ -85,11 +87,7 @@ let open_dll mode name =
8587
failwith (fullname ^ ": " ^ Binutils.error_to_string err)
8688
end
8789
| (None | Some (Checking _) as current), For_execution ->
88-
(* BACKPORT BEGIN
89-
begin match dll_open fullname with
90-
*)
9190
begin match dll_open For_execution fullname with
92-
(* BACKPORT END *)
9391
| dll ->
9492
let opened = match current with
9593
| None -> List.remove_assoc fullname !opened_dlls

debugger/.depend

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ eval.cmo : \
182182
../typing/env.cmi \
183183
debugcom.cmi \
184184
../typing/ctype.cmi \
185-
../utils/compilation_unit.cmi \
186185
../typing/btype.cmi \
187186
eval.cmi
188187
eval.cmx : \
@@ -203,7 +202,6 @@ eval.cmx : \
203202
../typing/env.cmx \
204203
debugcom.cmx \
205204
../typing/ctype.cmx \
206-
../utils/compilation_unit.cmx \
207205
../typing/btype.cmx \
208206
eval.cmi
209207
eval.cmi : \
@@ -286,12 +284,10 @@ loadprinter.cmo : \
286284
../utils/misc.cmi \
287285
../parsing/longident.cmi \
288286
../utils/load_path.cmi \
289-
../typing/jkind.cmi \
290287
../typing/ident.cmi \
291288
../typing/env.cmi \
292289
../otherlibs/dynlink/dynlink.cmi \
293290
../typing/ctype.cmi \
294-
../utils/compilation_unit.cmi \
295291
loadprinter.cmi
296292
loadprinter.cmx : \
297293
../typing/types.cmx \
@@ -303,12 +299,10 @@ loadprinter.cmx : \
303299
../utils/misc.cmx \
304300
../parsing/longident.cmx \
305301
../utils/load_path.cmx \
306-
../typing/jkind.cmx \
307302
../typing/ident.cmx \
308303
../typing/env.cmx \
309-
../otherlibs/dynlink/dynlink.cmx \
304+
../otherlibs/dynlink/dynlink.cmi \
310305
../typing/ctype.cmx \
311-
../utils/compilation_unit.cmx \
312306
loadprinter.cmi
313307
loadprinter.cmi : \
314308
../parsing/longident.cmi \
@@ -407,7 +401,6 @@ printval.cmo : \
407401
../toplevel/genprintval.cmi \
408402
../typing/env.cmi \
409403
debugcom.cmi \
410-
../utils/compilation_unit.cmi \
411404
printval.cmi
412405
printval.cmx : \
413406
../typing/types.cmx \
@@ -419,7 +412,6 @@ printval.cmx : \
419412
../toplevel/genprintval.cmx \
420413
../typing/env.cmx \
421414
debugcom.cmx \
422-
../utils/compilation_unit.cmx \
423415
printval.cmi
424416
printval.cmi : \
425417
../typing/types.cmi \

debugger/debugcom.ml

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ type pc =
5252
module Sp = struct
5353

5454
(* Position in the debuggee's stack. *)
55-
(* BACKPORT BEGIN
5655
type t = {
5756
block : int;
5857
offset : int;
@@ -66,25 +65,14 @@ module Sp = struct
6665
match Stdlib.compare sp1.block sp2.block with
6766
| 0 -> Stdlib.compare sp1.offset sp2.offset
6867
| x -> x
69-
*)
70-
type t = int
71-
72-
let null = 0
73-
let base _ _ = assert false
74-
let compare = Int.compare
75-
(* BACKPORT END *)
7668

7769
end
7870

7971
(* Identifier of the code fragment for the main program.
8072
Numbering starts at 1 and the runtime registers 2 fragments before
8173
the main program: one for uncaught exceptions and one for callbacks.
8274
*)
83-
(* BACKPOR BEGIN
8475
let main_frag = 3
85-
*)
86-
let main_frag = 0
87-
(* BACKPORT END *)
8876

8977
let set_event {frag; pos} =
9078
output_char !conn.io_out 'e';
@@ -149,21 +137,13 @@ let do_go_smallint n =
149137
| c -> Misc.fatal_error (Printf.sprintf "Debugcom.do_go %c" c)
150138
in
151139
let event_counter = input_binary_int !conn.io_in in
152-
(* BACKPORT BEGIN
153140
let block = input_binary_int !conn.io_in in
154141
let offset = input_binary_int !conn.io_in in
155-
*)
156-
let rep_stack_pointer = input_binary_int !conn.io_in in
157-
(* BACKPORT END *)
158142
let frag = input_binary_int !conn.io_in in
159143
let pos = input_binary_int !conn.io_in in
160144
{ rep_type = summary;
161145
rep_event_count = Int64.of_int event_counter;
162-
(* BACKPORT BEGIN
163146
rep_stack_pointer = Sp.{block; offset};
164-
*)
165-
rep_stack_pointer;
166-
(* BACKPORT END *)
167147
rep_program_pointer = {frag; pos} })
168148

169149
let rec do_go n =
@@ -212,19 +192,11 @@ let wait_child chan =
212192
let initial_frame () =
213193
output_char !conn.io_out '0';
214194
flush !conn.io_out;
215-
(* BACKPORT BEGIN
216195
let block = input_binary_int !conn.io_in in
217196
let offset = input_binary_int !conn.io_in in
218-
*)
219-
let stack_pos = input_binary_int !conn.io_in in
220-
(* BACKPORT END *)
221197
let frag = input_binary_int !conn.io_in in
222198
let pos = input_binary_int !conn.io_in in
223-
(* BACKPORT BEGIN
224199
(Sp.{block; offset}, {frag; pos})
225-
*)
226-
(stack_pos, {frag; pos})
227-
(* BACKPOR END *)
228200

229201
let set_initial_frame () =
230202
ignore(initial_frame ())
@@ -237,14 +209,9 @@ let up_frame stacksize =
237209
output_char !conn.io_out 'U';
238210
output_binary_int !conn.io_out stacksize;
239211
flush !conn.io_out;
240-
(* BACKPORT BEGIN
241212
let block = input_binary_int !conn.io_in in
242213
let offset = input_binary_int !conn.io_in in
243-
*)
244-
let stack_pos = input_binary_int !conn.io_in in
245-
(* BACKPORT END *)
246214
let frag, pos =
247-
(* BACKPORT BEGIN
248215
if block = -1 then
249216
begin
250217
assert (offset = -1);
@@ -254,56 +221,31 @@ let up_frame stacksize =
254221
let pos = input_binary_int !conn.io_in in
255222
frag, pos
256223
end
257-
*)
258-
if stack_pos = -1
259-
then 0, 0
260-
else let frag = input_binary_int !conn.io_in in
261-
let pos = input_binary_int !conn.io_in in
262-
frag, pos
263-
(* BACKPORT END *)
264224
in
265-
(* BACKPORT BEGIN
266225
(Sp.{block; offset}, { frag; pos })
267-
*)
268-
(stack_pos, { frag; pos })
269-
(* BACKPORT END *)
270226

271227
(* Get and set the current frame position *)
272228

273229
let get_frame () =
274230
output_char !conn.io_out 'f';
275231
flush !conn.io_out;
276-
let stack_pos = input_binary_int !conn.io_in in
277-
(*
278232
let block = input_binary_int !conn.io_in in
279233
let offset = input_binary_int !conn.io_in in
280-
*)
281234
let frag = input_binary_int !conn.io_in in
282235
let pos = input_binary_int !conn.io_in in
283-
(*
284236
(Sp.{block; offset}, {frag; pos})
285-
*)
286-
(stack_pos, {frag; pos})
287237

288238
let set_frame stack_pos =
289239
output_char !conn.io_out 'S';
290-
(* BACKPORT BEGIN
291240
output_binary_int !conn.io_out stack_pos.Sp.block;
292241
output_binary_int !conn.io_out stack_pos.Sp.offset
293-
*)
294-
output_binary_int !conn.io_out stack_pos
295-
(* BACKPORT END *)
296242

297243
(* Set the trap barrier to given stack position. *)
298244

299245
let set_trap_barrier pos =
300246
output_char !conn.io_out 'b';
301-
(* BACKPORT BEGIN
302247
output_binary_int !conn.io_out pos.Sp.block;
303248
output_binary_int !conn.io_out pos.Sp.offset
304-
*)
305-
output_binary_int !conn.io_out pos
306-
(* BACKPORT END *)
307249

308250
(* Handling of remote values *)
309251

debugger/debugcom.mli

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
(* Low-level communication with the debuggee *)
1818

1919
module Sp : sig
20-
(* BACKPORT BEGIN
2120
type t
22-
*)
23-
type t = int
24-
(* BACKPORT END *)
2521
val null : t
2622
val base : t -> int -> t
2723
val compare : t -> t -> int

debugger/eval.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ exception Error of error
3939

4040
let abstract_type =
4141
Btype.newgenty (Tconstr (Pident (Ident.create_local "<abstr>"), [], ref Mnil))
42-
4342
let get_global_or_predef id =
4443
try
4544
Debugcom.Remote_value.global (Symtable.get_global_position id)

debugger/frames.ml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ let selected_event_is_before () =
5353
let rec move_up frame_count event =
5454
if frame_count <= 0 then event else begin
5555
let (sp, pc) = up_frame event.ev_ev.ev_stacksize in
56-
(* BACKPORT BEGIN
5756
if sp = Sp.null then raise Not_found;
58-
*)
59-
if sp < Sp.null then raise Not_found;
60-
(* BACKPORT END *)
6157
move_up (frame_count - 1) (any_event_at_pc pc)
6258
end
6359

@@ -117,11 +113,7 @@ let do_backtrace action =
117113
begin try
118114
while action (Some !event) do
119115
let (sp, pc) = up_frame !event.ev_ev.ev_stacksize in
120-
(* BACKPORT BEGIN
121116
if sp = Sp.null then raise Exit;
122-
*)
123-
if sp < Sp.null then raise Exit;
124-
(* BACKPORT END *)
125117
event := any_event_at_pc pc
126118
done
127119
with Exit -> ()

0 commit comments

Comments
 (0)