Skip to content
Permalink
Browse files

Merge the natdynlink branch into HEAD.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8477 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information
alainfrisch committed Nov 6, 2007
1 parent 2a99b87 commit 3958a92c729c6588bdd4a39d6d8bc5dadb00b3de
Showing with 3,500 additions and 2,472 deletions.
  1. +47 −1 .depend
  2. +17 −1 Makefile
  3. +19 −6 Makefile.nt
  4. +1 −1 VERSION
  5. +1 −1 _tags
  6. +50 −22 asmcomp/amd64/emit.mlp
  7. +1 −1 asmcomp/amd64/proc.ml
  8. +1 −1 asmcomp/amd64/reload.ml
  9. +2 −2 asmcomp/amd64/selection.ml
  10. +13 −1 asmcomp/asmgen.ml
  11. +1 −0 asmcomp/asmgen.mli
  12. +187 −116 asmcomp/asmlink.ml
  13. +5 −1 asmcomp/asmlink.mli
  14. +8 −4 asmcomp/asmpackager.ml
  15. +66 −4 asmcomp/cmmgen.ml
  16. +4 −1 asmcomp/cmmgen.mli
  17. +22 −3 asmcomp/compilenv.ml
  18. +8 −0 asmcomp/compilenv.mli
  19. +2 −1 asmcomp/i386/proc_nt.ml
  20. +76 −15 asmcomp/power/emit.mlp
  21. +1 −1 asmcomp/power/selection.ml
  22. +2 −2 asmrun/Makefile
  23. +2 −2 asmrun/Makefile.nt
  24. +169 −0 asmrun/natdynlink.c
  25. 0 asmrun/natdynlink.h
  26. +76 −9 asmrun/roots.c
  27. +4 −2 asmrun/signals_asm.c
  28. +2 −1 asmrun/stack.h
  29. +2 −1 asmrun/startup.c
  30. BIN boot/ocamlc
  31. BIN boot/ocamldep
  32. BIN boot/ocamllex
  33. +1 −0 build/mkconfig.sh
  34. +1 −0 build/mkmyocamlbuild_config.sh
  35. +27 −29 bytecomp/bytelink.ml
  36. +30 −4 bytecomp/translmod.ml
  37. +2 −0 bytecomp/translmod.mli
  38. +7 −74 byterun/Makefile
  39. +90 −0 byterun/Makefile.common
  40. +23 −86 byterun/Makefile.nt
  41. +2 −2 byterun/array.c
  42. +4 −4 byterun/compare.c
  43. +1 −1 byterun/hash.c
  44. +3 −13 byterun/misc.h
  45. +5 −3 byterun/mlvalues.h
  46. +2 −0 byterun/osdeps.h
  47. +47 −0 byterun/unix.c
  48. +24 −24 byterun/win32.c
  49. +3 −0 camlp4/Camlp4/Sig.ml
  50. +5 −5 camlp4/Camlp4/Struct/DynLoader.ml
  51. +11 −5 camlp4/Camlp4Bin.ml
  52. +12 −6 config/Makefile.mingw
  53. +16 −18 config/Makefile.msvc
  54. +21 −3 configure
  55. +22 −9 driver/optmain.ml
  56. +4 −1 myocamlbuild.ml
  57. +2 −2 ocamldoc/Makefile
  58. +1 −1 ocamldoc/Makefile.nt
  59. +24 −0 otherlibs/Makefile
  60. +24 −0 otherlibs/Makefile.nt
  61. +90 −0 otherlibs/Makefile.shared
  62. +8 −53 otherlibs/bigarray/Makefile
  63. +8 −64 otherlibs/bigarray/Makefile.nt
  64. +7 −0 otherlibs/bigarray/bigarray.ml
  65. +6 −48 otherlibs/dbm/Makefile
  66. +22 −4 otherlibs/dynlink/Makefile
  67. +1 −60 otherlibs/dynlink/Makefile.nt
  68. +2 −0 otherlibs/dynlink/dynlink.ml
  69. +13 −5 otherlibs/dynlink/dynlink.mli
  70. +286 −0 otherlibs/dynlink/natdynlink.ml
  71. +6 −48 otherlibs/graph/Makefile
  72. +1 −9 otherlibs/labltk/Makefile
  73. +9 −5 otherlibs/labltk/Makefile.nt
  74. +2 −61 otherlibs/labltk/browser/Makefile
  75. +4 −57 otherlibs/labltk/browser/Makefile.nt
  76. +63 −0 otherlibs/labltk/browser/Makefile.shared
  77. +4 −4 otherlibs/labltk/browser/winmain.c
  78. +1 −3 otherlibs/labltk/camltk/Makefile
  79. +10 −7 otherlibs/labltk/camltk/Makefile.gen
  80. +1 −46 otherlibs/labltk/camltk/Makefile.gen.nt
  81. +1 −43 otherlibs/labltk/camltk/Makefile.nt
  82. +1 −63 otherlibs/labltk/compiler/Makefile.nt
  83. +3 −3 otherlibs/labltk/frx/Makefile
  84. +1 −53 otherlibs/labltk/frx/Makefile.nt
  85. +3 −3 otherlibs/labltk/jpf/Makefile
  86. +1 −75 otherlibs/labltk/jpf/Makefile.nt
  87. +1 −1 otherlibs/labltk/labltk/Makefile
  88. +10 −7 otherlibs/labltk/labltk/Makefile.gen
  89. +1 −40 otherlibs/labltk/labltk/Makefile.gen.nt
  90. +1 −43 otherlibs/labltk/labltk/Makefile.nt
  91. +10 −10 otherlibs/labltk/lib/Makefile
  92. +1 −60 otherlibs/labltk/lib/Makefile.nt
  93. +20 −19 otherlibs/labltk/support/Makefile
  94. +3 −3 otherlibs/labltk/support/Makefile.common
  95. +0 −30 otherlibs/labltk/support/Makefile.common.nt
  96. +1 −80 otherlibs/labltk/support/Makefile.nt
  97. +23 −22 otherlibs/labltk/tkanim/Makefile
  98. +1 −78 otherlibs/labltk/tkanim/Makefile.nt
  99. +7 −55 otherlibs/num/Makefile
  100. +7 −68 otherlibs/num/Makefile.nt
  101. +7 −48 otherlibs/str/Makefile
  102. +4 −61 otherlibs/str/Makefile.nt
  103. +14 −3 otherlibs/systhreads/Makefile
  104. +31 −26 otherlibs/systhreads/Makefile.nt
  105. +6 −51 otherlibs/unix/Makefile
  106. +6 −65 otherlibs/win32graph/Makefile.nt
  107. +1 −1 otherlibs/win32graph/open.c
  108. +14 −75 otherlibs/win32unix/Makefile.nt
  109. +1 −0 otherlibs/win32unix/winwait.c
  110. +5 −1 stdlib/Makefile.nt
  111. +54 −0 test/dynlink/Makefile
  112. +17 −0 test/dynlink/main.ml
  113. +4 −0 test/dynlink/plug1.ml
  114. +4 −0 test/dynlink/plug2.ml
  115. +11 −0 test/dynlink/stub1.c
  116. +13 −0 test/dynlink/stub2.c
  117. +83 −0 test/natdynlink/Makefile
  118. +18 −0 test/natdynlink/api.ml
  119. +2 −0 test/natdynlink/bug.ml
  120. +18 −0 test/natdynlink/factorial.c
  121. +20 −0 test/natdynlink/main.ml
  122. +2 −0 test/natdynlink/pack_client.ml
  123. +6 −0 test/natdynlink/packed1.ml
  124. +3 −0 test/natdynlink/packed1_client.ml
  125. +10 −0 test/natdynlink/plugin.ml
  126. +1 −0 test/natdynlink/plugin.mli
  127. +8 −0 test/natdynlink/plugin2.ml
  128. +5 −0 test/natdynlink/plugin4.ml
  129. +5 −0 test/natdynlink/plugin_ext.ml
  130. +6 −0 test/natdynlink/plugin_high_arity.ml
  131. +11 −0 test/natdynlink/plugin_ref.ml
  132. +3 −0 test/natdynlink/plugin_simple.ml
  133. +21 −0 test/natdynlink/plugin_thread.ml
  134. +3 −0 test/natdynlink/sub/api.ml
  135. +1 −0 test/natdynlink/sub/api.mli
  136. +7 −0 test/natdynlink/sub/plugin.ml
  137. +3 −0 test/natdynlink/sub/plugin3.ml
  138. +1 −244 tools/Makefile
  139. +2 −151 tools/Makefile.nt
  140. +274 −0 tools/Makefile.shared
  141. +17 −9 tools/ocamlmklib.mlp
  142. +189 −0 toplevel/opttopdirs.ml
  143. +31 −0 toplevel/opttopdirs.mli
  144. +444 −0 toplevel/opttoploop.ml
  145. +102 −0 toplevel/opttoploop.mli
  146. +121 −0 toplevel/opttopmain.ml
  147. +17 −0 toplevel/opttopmain.mli
  148. +15 −0 toplevel/opttopstart.ml
  149. +9 −15 utils/ccomp.ml
  150. +0 −1 utils/ccomp.mli
  151. +4 −0 utils/clflags.ml
  152. +2 −0 utils/clflags.mli
  153. +1 −1 yacc/Makefile.nt
48 .depend
@@ -447,7 +447,7 @@ asmcomp/clambda.cmi: bytecomp/lambda.cmi typing/ident.cmi \
asmcomp/debuginfo.cmi parsing/asttypes.cmi
asmcomp/closure.cmi: bytecomp/lambda.cmi asmcomp/clambda.cmi
asmcomp/cmm.cmi: typing/ident.cmi asmcomp/debuginfo.cmi
asmcomp/cmmgen.cmi: asmcomp/cmm.cmi asmcomp/clambda.cmi
asmcomp/cmmgen.cmi: asmcomp/compilenv.cmi asmcomp/cmm.cmi asmcomp/clambda.cmi
asmcomp/codegen.cmi: asmcomp/cmm.cmi
asmcomp/comballoc.cmi: asmcomp/mach.cmi
asmcomp/compilenv.cmi: typing/ident.cmi asmcomp/clambda.cmi
@@ -745,6 +745,10 @@ driver/pparse.cmx: utils/misc.cmx parsing/location.cmx utils/clflags.cmx \
utils/ccomp.cmx driver/pparse.cmi
toplevel/genprintval.cmi: typing/types.cmi typing/path.cmi \
typing/outcometree.cmi typing/env.cmi
toplevel/opttopdirs.cmi: parsing/longident.cmi
toplevel/opttoploop.cmi: utils/warnings.cmi typing/types.cmi typing/path.cmi \
parsing/parsetree.cmi typing/outcometree.cmi parsing/longident.cmi \
parsing/location.cmi typing/env.cmi
toplevel/topdirs.cmi: parsing/longident.cmi
toplevel/toploop.cmi: utils/warnings.cmi typing/types.cmi typing/path.cmi \
parsing/parsetree.cmi typing/outcometree.cmi parsing/longident.cmi \
@@ -763,6 +767,48 @@ toplevel/genprintval.cmx: typing/types.cmx typing/printtyp.cmx \
typing/predef.cmx typing/path.cmx typing/outcometree.cmi utils/misc.cmx \
parsing/longident.cmx typing/ident.cmx typing/env.cmx typing/datarepr.cmx \
typing/ctype.cmx typing/btype.cmx toplevel/genprintval.cmi
toplevel/opttopdirs.cmo: utils/warnings.cmi typing/types.cmi \
typing/printtyp.cmi typing/path.cmi toplevel/opttoploop.cmi \
utils/misc.cmi parsing/longident.cmi typing/ident.cmi typing/env.cmi \
typing/ctype.cmi utils/config.cmi utils/clflags.cmi \
toplevel/opttopdirs.cmi
toplevel/opttopdirs.cmx: utils/warnings.cmx typing/types.cmx \
typing/printtyp.cmx typing/path.cmx toplevel/opttoploop.cmx \
utils/misc.cmx parsing/longident.cmx typing/ident.cmx typing/env.cmx \
typing/ctype.cmx utils/config.cmx utils/clflags.cmx \
toplevel/opttopdirs.cmi
toplevel/opttoploop.cmo: utils/warnings.cmi typing/unused_var.cmi \
typing/types.cmi typing/typemod.cmi typing/typedtree.cmi \
typing/typecore.cmi bytecomp/translmod.cmi bytecomp/simplif.cmi \
typing/printtyp.cmi bytecomp/printlambda.cmi parsing/printast.cmi \
typing/predef.cmi typing/path.cmi parsing/parsetree.cmi parsing/parse.cmi \
typing/outcometree.cmi driver/opterrors.cmi driver/optcompile.cmi \
typing/oprint.cmi utils/misc.cmi parsing/longident.cmi \
parsing/location.cmi parsing/lexer.cmi bytecomp/lambda.cmi \
typing/ident.cmi toplevel/genprintval.cmi typing/env.cmi utils/config.cmi \
asmcomp/compilenv.cmi utils/clflags.cmi typing/btype.cmi \
asmcomp/asmlink.cmi asmcomp/asmgen.cmi toplevel/opttoploop.cmi
toplevel/opttoploop.cmx: utils/warnings.cmx typing/unused_var.cmx \
typing/types.cmx typing/typemod.cmx typing/typedtree.cmx \
typing/typecore.cmx bytecomp/translmod.cmx bytecomp/simplif.cmx \
typing/printtyp.cmx bytecomp/printlambda.cmx parsing/printast.cmx \
typing/predef.cmx typing/path.cmx parsing/parsetree.cmi parsing/parse.cmx \
typing/outcometree.cmi driver/opterrors.cmx driver/optcompile.cmx \
typing/oprint.cmx utils/misc.cmx parsing/longident.cmx \
parsing/location.cmx parsing/lexer.cmx bytecomp/lambda.cmx \
typing/ident.cmx toplevel/genprintval.cmx typing/env.cmx utils/config.cmx \
asmcomp/compilenv.cmx utils/clflags.cmx typing/btype.cmx \
asmcomp/asmlink.cmx asmcomp/asmgen.cmx toplevel/opttoploop.cmi
toplevel/opttopmain.cmo: utils/warnings.cmi asmcomp/printmach.cmi \
toplevel/opttoploop.cmi toplevel/opttopdirs.cmi driver/opterrors.cmi \
utils/misc.cmi utils/config.cmi utils/clflags.cmi asmcomp/arch.cmo \
toplevel/opttopmain.cmi
toplevel/opttopmain.cmx: utils/warnings.cmx asmcomp/printmach.cmx \
toplevel/opttoploop.cmx toplevel/opttopdirs.cmx driver/opterrors.cmx \
utils/misc.cmx utils/config.cmx utils/clflags.cmx asmcomp/arch.cmx \
toplevel/opttopmain.cmi
toplevel/opttopstart.cmo: toplevel/opttopmain.cmi
toplevel/opttopstart.cmx: toplevel/opttopmain.cmx
toplevel/topdirs.cmo: utils/warnings.cmi typing/types.cmi toplevel/trace.cmi \
toplevel/toploop.cmi bytecomp/symtable.cmi typing/printtyp.cmi \
typing/path.cmi bytecomp/opcodes.cmo utils/misc.cmi bytecomp/meta.cmi \
@@ -18,7 +18,7 @@ include config/Makefile
include stdlib/StdlibModules

CAMLC=boot/ocamlrun boot/ocamlc -nostdlib -I boot
CAMLOPT=boot/ocamlrun ./ocamlopt -nostdlib -I stdlib
CAMLOPT=boot/ocamlrun ./ocamlopt -nostdlib -I stdlib -I otherlibs/dynlink
COMPFLAGS=-warn-error A $(INCLUDES)
LINKFLAGS=

@@ -102,6 +102,11 @@ TOPLIB=$(UTILS) $(PARSING) $(TYPING) $(COMP) $(BYTECOMP) $(TOPLEVEL)

TOPOBJS=$(TOPLEVELLIB) $(TOPLEVELSTART)

NATTOPOBJS=$(OPTUTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) \
driver/pparse.cmo driver/opterrors.cmo driver/optcompile.cmo \
toplevel/genprintval.cmo toplevel/opttoploop.cmo toplevel/opttopdirs.cmo \
toplevel/opttopmain.cmo toplevel/opttopstart.cmo

OPTOBJS=$(OPTUTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) $(OPTDRIVER)

EXPUNGEOBJS=utils/misc.cmo utils/tbl.cmo \
@@ -315,6 +320,17 @@ toplevel/toplevellib.cma: $(TOPLIB)
partialclean::
rm -f ocaml toplevel/toplevellib.cma

# The native toplevel

ocamlnat: ocamlopt otherlibs/dynlink/dynlink.cmxa $(NATTOPOBJS:.cmo=.cmx)
$(CAMLOPT) $(LINKFLAGS) otherlibs/dynlink/dynlink.cmxa -o ocamlnat $(NATTOPOBJS:.cmo=.cmx) -linkall

toplevel/opttoploop.cmx: otherlibs/dynlink/dynlink.cmxa

otherlibs/dynlink/dynlink.cmxa: otherlibs/dynlink/natdynlink.ml
cd otherlibs/dynlink && make allopt


# The configuration file

utils/config.ml: utils/config.mlp config/Makefile
@@ -18,7 +18,7 @@ include config/Makefile
include stdlib/StdlibModules

CAMLC=boot/ocamlrun boot/ocamlc -I boot
CAMLOPT=boot/ocamlrun ./ocamlopt -I stdlib
CAMLOPT=boot/ocamlrun ./ocamlopt -I stdlib -I otherlibs/dynlink
COMPFLAGS=$(INCLUDES)
LINKFLAGS=
CAMLYACC=boot/ocamlyacc
@@ -98,6 +98,11 @@ TOPLIB=$(UTILS) $(PARSING) $(TYPING) $(COMP) $(BYTECOMP) $(TOPLEVEL)

TOPOBJS=$(TOPLEVELLIB) $(TOPLEVELSTART)

NATTOPOBJS=$(OPTUTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) \
driver/pparse.cmo driver/opterrors.cmo driver/optcompile.cmo \
toplevel/genprintval.cmo toplevel/opttoploop.cmo toplevel/opttopdirs.cmo \
toplevel/opttopmain.cmo toplevel/opttopstart.cmo

OPTOBJS=$(OPTUTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) $(OPTDRIVER)

EXPUNGEOBJS=utils/misc.cmo utils/tbl.cmo \
@@ -148,7 +153,6 @@ LIBFILES=stdlib.cma std_exit.cmo *.cmi camlheader
coldstart:
cd byterun ; $(MAKEREC) all
cp byterun/ocamlrun.exe boot/ocamlrun.exe
cp byterun/ocamlrun.dll boot/ocamlrun.dll
cd yacc ; $(MAKEREC) all
cp yacc/ocamlyacc.exe boot/ocamlyacc.exe
cd stdlib ; $(MAKEREC) COMPILER=../boot/ocamlc all
@@ -213,8 +217,6 @@ installbyt:
mkdir -p $(BINDIR)
mkdir -p $(LIBDIR)
cd byterun ; $(MAKEREC) install
echo "$(STUBLIBDIR)" > $(LIBDIR)/ld.conf
echo "$(LIBDIR)" >> $(LIBDIR)/ld.conf
cp ocamlc $(BINDIR)/ocamlc.exe
cp ocaml $(BINDIR)/ocaml.exe
cd stdlib ; $(MAKEREC) install
@@ -288,6 +290,17 @@ toplevel/toplevellib.cma: $(TOPLIB)
partialclean::
rm -f ocaml

# The native toplevel

ocamlnat: ocamlopt otherlibs/dynlink/dynlink.cmxa $(NATTOPOBJS:.cmo=.cmx)
$(CAMLOPT) $(LINKFLAGS) otherlibs/dynlink/dynlink.cmxa -o ocamlnat $(NATTOPOBJS:.cmo=.cmx) -linkall

toplevel/opttoploop.cmx: otherlibs/dynlink/dynlink.cmxa

otherlibs/dynlink/dynlink.cmxa: otherlibs/dynlink/natdynlink.ml
cd otherlibs/dynlink && make allopt


# The configuration file

utils/config.ml: utils/config.mlp config/Makefile
@@ -296,9 +309,9 @@ utils/config.ml: utils/config.mlp config/Makefile
-e "s|%%BYTERUN%%|ocamlrun|" \
-e 's|%%CCOMPTYPE%%|$(CCOMPTYPE)|' \
-e "s|%%BYTECC%%|$(BYTECC) $(BYTECCCOMPOPTS)|" \
-e "s|%%BYTELINK%%|$(BYTECC) $(BYTECCLINKOPTS)|" \
-e "s|%%BYTELINK%%|flexlink|" \
-e "s|%%NATIVECC%%|$(NATIVECC) $(NATIVECCCOMPOPTS)|" \
-e "s|%%NATIVELINK%%|$(NATIVECC) $(NATIVECCLINKOPTS)|" \
-e "s|%%NATIVELINK%%|flexlink|" \
-e "s|%%PARTIALLD%%|$(PARTIALLD)|" \
-e "s|%%PACKLD%%|$(PACKLD)|" \
-e "s|%%BYTECCLIBS%%|$(BYTECCLIBS)|" \
@@ -1,4 +1,4 @@
3.11+dev5 Private_abbrevs (2007-11-1)
3.11+dev5 Private_abbrevs+natdynlink (2007-11-1)

# The version string is the first line of this file.
# It must be in the format described in stdlib/sys.mli
2 _tags
@@ -32,7 +32,7 @@ true: use_stdlib
<camlp4/**/*.ml*>: camlp4boot, -warn_Alez, warn_Ale
<camlp4/Camlp4_config.ml*>: -camlp4boot
<camlp4/build/*> or <camlp4/boot/*> or "camlp4/Camlp4/Struct/Lexer.ml": -camlp4boot, -warn_Ale, warn_a
"camlp4/Camlp4Bin.byte" or "camlp4/mkcamlp4.byte" or "camlp4/camlp4lib.cma": use_dynlink
<camlp4/Camlp4Bin.{byte,native}> or "camlp4/mkcamlp4.byte" or "camlp4/camlp4lib.cma": use_dynlink
"camlp4/Camlp4/Printers/OCaml.ml" or "camlp4/Camlp4/Printers/OCamlr.ml": warn_Alezv
<camlp4/Camlp4Printers/**.ml>: include_unix
"camlp4/Camlp4/Struct/DynLoader.ml": include_dynlink
@@ -56,6 +56,24 @@ let slot_offset loc cl =
let emit_symbol s =
Emitaux.emit_symbol '$' s

let emit_call s =
if !Clflags.dlcode
then `call {emit_symbol s}@PLT`
else `call {emit_symbol s}`

let emit_jump s =
if !Clflags.dlcode
then `jmp {emit_symbol s}@PLT`
else `jmp {emit_symbol s}`

let load_symbol_addr s =
if !Clflags.dlcode
then `movq {emit_symbol s}@GOTPCREL(%rip)`
else if !pic_code
then `leaq {emit_symbol s}(%rip)`
else `movq ${emit_symbol s}`


(* Output a label *)

let emit_label lbl =
@@ -111,7 +129,8 @@ let emit_reg32 r = emit_subreg reg_low_32_name r

let emit_addressing addr r n =
match addr with
Ibased(s, d) ->
| Ibased _ when !Clflags.dlcode -> assert false
| Ibased(s, d) ->
`{emit_symbol s}`;
if d <> 0 then ` + {emit_int d}`;
`(%rip)`
@@ -164,7 +183,7 @@ type gc_call =
let call_gc_sites = ref ([] : gc_call list)

let emit_call_gc gc =
`{emit_label gc.gc_lbl}: call {emit_symbol "caml_call_gc"}\n`;
`{emit_label gc.gc_lbl}: {emit_call "caml_call_gc"}\n`;
`{emit_label gc.gc_frame}: jmp {emit_label gc.gc_return_lbl}\n`

(* Record calls to caml_ml_array_bound_error.
@@ -191,13 +210,13 @@ let bound_error_label dbg =
end

let emit_call_bound_error bd =
`{emit_label bd.bd_lbl}: call {emit_symbol "caml_ml_array_bound_error"}\n`;
`{emit_label bd.bd_lbl}: {emit_call "caml_ml_array_bound_error"}\n`;
`{emit_label bd.bd_frame}:\n`

let emit_call_bound_errors () =
List.iter emit_call_bound_error !bound_error_sites;
if !bound_error_call > 0 then
`{emit_label !bound_error_call}: jmp {emit_symbol "caml_ml_array_bound_error"}\n`
`{emit_label !bound_error_call}: {emit_jump "caml_ml_array_bound_error"}\n`

(* Names for instructions *)

@@ -326,15 +345,12 @@ let emit_instr fallthrough i =
` movlpd {emit_label lbl}(%rip), {emit_reg i.res.(0)}\n`
end
| Lop(Iconst_symbol s) ->
if !pic_code then
` leaq {emit_symbol s}(%rip), {emit_reg i.res.(0)}\n`
else
` movq ${emit_symbol s}, {emit_reg i.res.(0)}\n`
` {load_symbol_addr s}, {emit_reg i.res.(0)}\n`
| Lop(Icall_ind) ->
` call *{emit_reg i.arg.(0)}\n`;
record_frame i.live i.dbg
| Lop(Icall_imm(s)) ->
` call {emit_symbol s}\n`;
` {emit_call s}\n`;
record_frame i.live i.dbg
| Lop(Itailcall_ind) ->
output_epilogue();
@@ -344,15 +360,15 @@ let emit_instr fallthrough i =
` jmp {emit_label !tailrec_entry_point}\n`
else begin
output_epilogue();
` jmp {emit_symbol s}\n`
` {emit_jump s}\n`
end
| Lop(Iextcall(s, alloc)) ->
if alloc then begin
` leaq {emit_symbol s}(%rip), %rax\n`;
` call {emit_symbol "caml_c_call"}\n`;
` {load_symbol_addr s}, %rax\n`;
` {emit_call "caml_c_call"}\n`;
record_frame i.live i.dbg
end else begin
` call {emit_symbol s}\n`
` {emit_call s}\n`
end
| Lop(Istackoffset n) ->
if n < 0
@@ -401,7 +417,11 @@ let emit_instr fallthrough i =
if !fastcode_flag then begin
let lbl_redo = new_label() in
`{emit_label lbl_redo}: subq ${emit_int n}, %r15\n`;
` cmpq {emit_symbol "caml_young_limit"}(%rip), %r15\n`;
if !Clflags.dlcode then begin
` {load_symbol_addr "caml_young_limit"}, %rax\n`;
` cmpq (%rax), %r15\n`;
end else
` cmpq {emit_symbol "caml_young_limit"}(%rip), %r15\n`;
let lbl_call_gc = new_label() in
let lbl_frame = record_frame_label i.live Debuginfo.none in
` jb {emit_label lbl_call_gc}\n`;
@@ -412,11 +432,11 @@ let emit_instr fallthrough i =
gc_frame = lbl_frame } :: !call_gc_sites
end else begin
begin match n with
16 -> ` call {emit_symbol "caml_alloc1"}\n`
| 24 -> ` call {emit_symbol "caml_alloc2"}\n`
| 32 -> ` call {emit_symbol "caml_alloc3"}\n`
16 -> ` {emit_call "caml_alloc1"}\n`
| 24 -> ` {emit_call "caml_alloc2"}\n`
| 32 -> ` {emit_call "caml_alloc3"}\n`
| _ -> ` movq ${emit_int n}, %rax\n`;
` call {emit_symbol "caml_allocN"}\n`
` {emit_call "caml_allocN"}\n`
end;
`{record_frame i.live Debuginfo.none} leaq 8(%r15), {emit_reg i.res.(0)}\n`
end
@@ -487,7 +507,7 @@ let emit_instr fallthrough i =
| Lop(Ispecific(Istore_int(n, addr))) ->
` movq ${emit_nativeint n}, {emit_addressing addr i.arg 0}\n`
| Lop(Ispecific(Istore_symbol(s, addr))) ->
assert (not !pic_code);
assert (not !pic_code && not !Clflags.dlcode);
` movq ${emit_symbol s}, {emit_addressing addr i.arg 0}\n`
| Lop(Ispecific(Ioffset_loc(n, addr))) ->
` addq ${emit_int n}, {emit_addressing addr i.arg 0}\n`
@@ -548,7 +568,7 @@ let emit_instr fallthrough i =
end
| Lswitch jumptbl ->
let lbl = new_label() in
if !pic_code then begin
if !pic_code || !Clflags.dlcode then begin
` leaq {emit_label lbl}(%rip), %r11\n`;
` jmp *(%r11, {emit_reg i.arg.(0)}, 8)\n`
end else begin
@@ -573,7 +593,7 @@ let emit_instr fallthrough i =
stack_offset := !stack_offset - 16
| Lraise ->
if !Clflags.debug then begin
` call {emit_symbol "caml_raise_exn"}\n`;
` {emit_call "caml_raise_exn"}\n`;
record_frame Reg.Set.empty i.dbg
end else begin
` movq %r14, %rsp\n`;
@@ -605,7 +625,7 @@ let emit_profile () =
` pushq %r10\n`;
` movq %rsp, %rbp\n`;
` pushq %r11\n`;
` call {emit_symbol "mcount"}\n`;
` {emit_call "mcount"}\n`;
` popq %r11\n`;
` popq %r10\n`
| _ ->
@@ -679,6 +699,14 @@ let data l =
(* Beginning / end of an assembly file *)

let begin_assembly() =
if !Clflags.dlcode then begin
(* from amd64.S; could emit these constants on demand *)
` .section .rodata.cst8,\"a\",@progbits\n`;
` .align 16\n`;
`caml_negf_mask: .quad 0x8000000000000000, 0\n`;
` .align 16\n`;
`caml_absf_mask: .quad 0x7FFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF\n`;
end;
let lbl_begin = Compilenv.make_symbol (Some "data_begin") in
` .data\n`;
` .globl {emit_symbol lbl_begin}\n`;
@@ -170,7 +170,7 @@ let destroyed_at_oper = function
| Iop(Istore(Single, _)) -> [| rxmm15 |]
| Iop(Ialloc _ | Iintop(Icomp _) | Iintop_imm((Idiv|Imod|Icomp _), _))
-> [| rax |]
| Iswitch(_, _) when !pic_code -> [| r11 |]
| Iswitch(_, _) when !pic_code || !Clflags.dlcode -> [| r11 |]
| _ -> [||]

let destroyed_at_raise = all_phys_regs
@@ -93,7 +93,7 @@ method reload_operation op arg res =
then (arg, res)
else super#reload_operation op arg res
| Iconst_symbol _ ->
if !pic_code
if !pic_code || !Clflags.dlcode
then super#reload_operation op arg res
else (arg, res)
| _ -> (* Other operations: all args and results in registers *)

0 comments on commit 3958a92

Please sign in to comment.
You can’t perform that action at this time.