Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factorise bytecode and native toplevels #10124

Merged
20 commits merged into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
297 changes: 164 additions & 133 deletions .depend

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,11 @@ _build
/tools/caml-tex
/tools/eventlog_metadata

/toplevel/byte/toploop.mli
/toplevel/byte/topeval.mli
/toplevel/byte/trace.mli
/toplevel/byte/topdirs.mli
/toplevel/byte/topmain.mli
/toplevel/native/toploop.mli
/toplevel/native/topeval.mli
/toplevel/native/trace.mli
/toplevel/native/topdirs.mli
/toplevel/native/topmain.mli

/utils/config.ml
Expand Down
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ Working version
`Opttoploop`, `Opttopstart`, which are replaced by `Toploop` and `Topstart` in
library `ocamltoplevel`, made available in native code.

- #10124: remove duplicated code from the native toplevel, split toplevel
implementation into the shared part (`Topcommon`, etc.) and specific ones
(`Topeval`, `Trace`, `Topmain`).

* #10086: add the commands `make list-parse-errors` and `make
generate-parse-errors` to generate a set of syntactically incorrect
sentences that covers all error states of the LR automaton. Add these
Expand Down
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ OPTSTART=driver/optmain.cmo

TOPLEVELSTART=toplevel/topstart.cmo

TOPLEVELINIT=toplevel/toploop.cmo

PERVASIVES=$(STDLIB_MODULES) outcometree topdirs toploop

LIBFILES=stdlib.cma std_exit.cmo *.cmi camlheader
Expand Down Expand Up @@ -400,8 +402,8 @@ endif
"$(INSTALL_LIBDIR)"
ifeq "$(INSTALL_SOURCE_ARTIFACTS)" "true"
$(INSTALL_DATA) \
toplevel/byte/topdirs.cmt \
toplevel/topdirs.cmti toplevel/byte/topdirs.mli \
toplevel/topdirs.cmt \
toplevel/topdirs.cmti toplevel/topdirs.mli \
"$(INSTALL_LIBDIR)"
endif
$(MAKE) -C tools install
Expand Down Expand Up @@ -1015,14 +1017,22 @@ ocamlnat$(EXE): compilerlibs/ocamlcommon.cmxa compilerlibs/ocamloptcomp.cmxa \
$(TOPLEVELSTART:.cmo=.cmx)
$(CAMLOPT_CMD) $(LINKFLAGS) -linkall -I toplevel/native -o $@ $^


toplevel/topdirs.cmx: toplevel/topdirs.ml
$(CAMLOPT_CMD) $(COMPFLAGS) $(OPTCOMPFLAGS) -I toplevel/native -c $<

$(TOPLEVELINIT:.cmo=.cmx): $(TOPLEVELINIT:.cmo=.ml) \
toplevel/native/topeval.cmx
$(CAMLOPT_CMD) $(COMPFLAGS) $(OPTCOMPFLAGS) -I toplevel/native -c $<

$(TOPLEVELSTART:.cmo=.cmx): $(TOPLEVELSTART:.cmo=.ml) \
toplevel/native/topmain.cmx
$(CAMLOPT_CMD) $(COMPFLAGS) $(OPTCOMPFLAGS) -I toplevel/native -c $<

partialclean::
rm -f ocamlnat ocamlnat.exe

toplevel/native/toploop.cmx: otherlibs/dynlink/dynlink.cmxa
toplevel/native/topeval.cmx: otherlibs/dynlink/dynlink.cmxa

# The numeric opcodes

Expand Down
22 changes: 13 additions & 9 deletions compilerlibs/Makefile.compilerlibs
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,21 @@ MIDDLE_END_CMI=\
OPTCOMP=$(MIDDLE_END) $(ASMCOMP)
OPTCOMP_CMI=$(MIDDLE_END_CMI) $(ASMCOMP_CMI)

TOPLEVEL=toplevel/genprintval.cmo toplevel/byte/toploop.cmo \
toplevel/byte/trace.cmo toplevel/byte/topdirs.cmo toplevel/byte/topmain.cmo
TOPLEVEL_CMI=toplevel/byte/toploop.cmi toplevel/byte/trace.cmi \
toplevel/byte/topdirs.cmi toplevel/byte/topmain.cmi

OPTTOPLEVEL=toplevel/genprintval.cmo toplevel/native/toploop.cmo \
toplevel/native/topdirs.cmo toplevel/native/topmain.cmo
OPTTOPLEVEL_CMI=toplevel/native/toploop.cmi toplevel/native/topdirs.cmi \
TOPLEVEL=toplevel/genprintval.cmo toplevel/topcommon.cmo \
toplevel/byte/topeval.cmo toplevel/byte/trace.cmo toplevel/toploop.cmo \
toplevel/topdirs.cmo toplevel/byte/topmain.cmo
TOPLEVEL_CMI=toplevel/topcommon.cmi toplevel/byte/topeval.cmi \
toplevel/byte/trace.cmi toplevel/toploop.cmi toplevel/topdirs.cmi \
toplevel/byte/topmain.cmi

OPTTOPLEVEL=toplevel/genprintval.cmo toplevel/topcommon.cmo \
toplevel/native/topeval.cmo toplevel/native/trace.cmo toplevel/toploop.cmo \
toplevel/topdirs.cmo toplevel/native/topmain.cmo
OPTTOPLEVEL_CMI=toplevel/topcommon.cmi toplevel/native/topeval.cmi \
toplevel/native/trace.cmi toplevel/toploop.cmi toplevel/topdirs.cmi \
toplevel/native/topmain.cmi

TOPLEVEL_SHARED_MLIS = toploop.mli trace.mli topdirs.mli topmain.mli
TOPLEVEL_SHARED_MLIS = topeval.mli trace.mli topmain.mli

toplevel/byte/%.mli toplevel/byte/%.cmi: toplevel/%.mli toplevel/%.cmi
cp toplevel/$*.mli toplevel/$*.cmi $(@D)
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/tool-toplevel/pr6468.compilers.reference
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Raised at f in file "//toplevel//", line 2, characters 11-26
Called from g in file "//toplevel//", line 1, characters 11-15
Called from Stdlib__fun.protect in file "fun.ml", line 33, characters 8-15
Re-raised at Stdlib__fun.protect in file "fun.ml", line 38, characters 6-52
Called from Toploop.load_lambda in file "toplevel/byte/toploop.ml", line 212, characters 4-150
Called from Topeval.load_lambda in file "toplevel/byte/topeval.ml", line 112, characters 4-150

2 changes: 1 addition & 1 deletion tools/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ caml_tex.cmo : \
../parsing/ast_iterator.cmi \
../parsing/ast_helper.cmi
caml_tex.cmx : \
../toplevel/toploop.cmi \
../toplevel/toploop.cmx \
../parsing/syntaxerr.cmx \
../parsing/parsetree.cmi \
../parsing/parse.cmx \
Expand Down