Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# dev (2022-??) - ??
## Features/Changes
* Compiler: initial support for OCaml 5 (#1265)
* Compiler: initial support for OCaml 5 (#1265,#1303)
* Compiler: bump magic number to match the 5.0.0~alpha0 release (#1288)
* Misc: switch to cmdliner.1.1.0
* Misc: remove old binaries jsoo_link, jsoo_fs
* Misc: remove uchar dep
* Misc: use 4.14 in the CI
* Lib: add missing options for Intl.DateTimeFormat
* Lib: add missing options for Intl.NumberFormat
* Lib: wheel event binding
* Lib: add normalize in js_string (ES6)
* Runtime: Implement weak semantic for weak and ephemeron
* Runtime: Implement Gc.finalise_last
* Runtime: Implement buffer for in_channels
* Lib: wheel event binding
* Test: track external used in the stdlib and unix
* Runtime: add support for unix_opendir, unix_readdir, unix_closedir, win_findfirst, win_findnext, win_findclose
* Runtime: Dont use require when target-env is browser
* Lib: add normalize in js_string (ES6)
* Test: track external used in the stdlib and unix

## Bug fixes
* Compiler: fix rewriter bug in share_constant (fix #1247)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ let runtime =
; domain
; prng
; sync
; effect
]

include Files
2 changes: 2 additions & 0 deletions compiler/lib-runtime-files/tests/all.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let%expect_test _ =
+compare.js
+domain.js
+dynlink.js
+effect.js
+fail.js
+format.js
+fs.js
Expand Down Expand Up @@ -62,6 +63,7 @@ let%expect_test _ =
+bigstring.js
+compare.js
+domain.js
+effect.js
+fail.js
+format.js
+fs.js
Expand Down
3 changes: 2 additions & 1 deletion compiler/lib/annot_lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ rule main = parse
| "Weakdef" {TWeakdef}
| "Always" {TAlways}
| "If" {TIf}
| "Alias" {TAlias}
| "pure" {TA_Pure }
| "const" {TA_Const }
| "mutable" {TA_Mutable }
Expand All @@ -43,7 +44,7 @@ rule main = parse
| "(" {LPARENT}
| ")" {RPARENT}
| "," {TComma}
| ":" {TSemi}
| ":" {TColon}
| "<=" {LE}
| "<" {LT}
| ">" {GT}
Expand Down
17 changes: 8 additions & 9 deletions compiler/lib/annot_parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)

%token TProvides TRequires TVersion TWeakdef TIf TAlways
%token TProvides TRequires TVersion TWeakdef TIf TAlways TAlias
%token TA_Pure TA_Const TA_Mutable TA_Mutator TA_Shallow TA_Object_literal
%token<string> TIdent TVNum
%token TComma TSemi EOF EOL LE LT GE GT EQ LPARENT RPARENT
%token TComma TColon EOF EOL LE LT GE GT EQ LPARENT RPARENT
%token<string> TOTHER
%token TBang

Expand All @@ -30,20 +30,19 @@
%%

annot:
| TProvides TSemi id=TIdent opt=option(prim_annot)
| TProvides TColon id=TIdent opt=option(prim_annot)
args=option(delimited(LPARENT, separated_list(TComma,arg_annot),RPARENT))
endline
{ `Provides (id,(match opt with None -> `Mutator | Some k -> k),args) }
| TRequires TSemi l=separated_nonempty_list(TComma,TIdent) endline
| TRequires TColon l=separated_nonempty_list(TComma,TIdent) endline
{ `Requires (l) }
| TVersion TSemi l=separated_nonempty_list(TComma,version) endline
| TVersion TColon l=separated_nonempty_list(TComma,version) endline
{ `Version (l) }
| TWeakdef endline { `Weakdef }
| TAlways endline { `Always }
| TIf TSemi name=TIdent endline
{ `If (name) }
| TIf TSemi TBang name=TIdent endline
{ `Ifnot (name) }
| TAlias TColon name=TIdent endline { `Alias (name) }
| TIf TColon name=TIdent endline { `If (name) }
| TIf TColon TBang name=TIdent endline { `Ifnot (name) }
prim_annot:
| TA_Pure {`Pure}
| TA_Const {`Pure}
Expand Down
1 change: 0 additions & 1 deletion compiler/lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
(libraries
compiler-libs.common
compiler-libs.bytecomp
bytes
menhirLib
(select
source_map_io.ml
Expand Down
12 changes: 12 additions & 0 deletions compiler/lib/linker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ module Fragment = struct
; code : Javascript.program
; js_string : bool option
; fragment_target : Target_env.t option
; aliases : StringSet.t
}

type t =
Expand Down Expand Up @@ -227,6 +228,7 @@ module Fragment = struct
; code
; js_string = None
; fragment_target = None
; aliases = StringSet.empty
}
in
let fragment =
Expand Down Expand Up @@ -255,6 +257,8 @@ module Fragment = struct
}
| `Weakdef -> { fragment with weakdef = true }
| `Always -> { fragment with always = true }
| `Alias name ->
{ fragment with aliases = StringSet.add name fragment.aliases }
| (`Ifnot "js-string" | `If "js-string") as i ->
let b =
match i with
Expand Down Expand Up @@ -391,6 +395,7 @@ let load_fragment ~target_env ~filename (f : Fragment.t) =
; code
; js_string
; fragment_target
; aliases
} -> (
let ignore_because_of_js_string =
match js_string, Config.Flag.use_js_string () with
Expand All @@ -402,6 +407,12 @@ let load_fragment ~target_env ~filename (f : Fragment.t) =
else
match provides with
| None ->
if not (StringSet.is_empty aliases)
then
error
"Found JavaScript code with neither `//Alias` and not `//Provides` in \
file %S@."
filename;
if always
then (
always_included :=
Expand Down Expand Up @@ -468,6 +479,7 @@ let load_fragment ~target_env ~filename (f : Fragment.t) =
Hashtbl.add provided name { id; pi; weakdef; target_env = fragment_target };
Hashtbl.add provided_rev id (name, pi);
Hashtbl.add code_pieces id (code, requires);
StringSet.iter (fun alias -> Primitive.alias alias name) aliases;
`Ok)

let get_provided () =
Expand Down
13 changes: 13 additions & 0 deletions compiler/lib/parse_bytecode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ let predefined_exceptions =
; 10, "Assert_failure"
; 11, "Undefined_recursive_module"
]
@
match Ocaml_version.v with
| `V4_04
| `V4_06
| `V4_07
| `V4_08
| `V4_09
| `V4_10
| `V4_11
| `V4_12
| `V4_13
| `V4_14 -> []
| `V5_00 -> [ 12, "Continuation_already_taken"; 13, "Unhandled" ]

(* Read and manipulate debug section *)
module Debug : sig
Expand Down
1 change: 1 addition & 0 deletions compiler/lib/parse_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ let parse_aux the_parser lexbuf =
| `Always -> Some `Always
| `If name -> Some (`If name)
| `Ifnot name -> Some (`Ifnot name)
| `Alias name -> Some (`Alias name)
with
| Not_found -> None
| _ -> None)
Expand Down
1 change: 1 addition & 0 deletions compiler/lib/primitive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type t =
| `Version of ((int -> int -> bool) * string) list
| `Weakdef
| `Always
| `Alias of string
| condition
]

Expand Down
1 change: 1 addition & 0 deletions compiler/lib/primitive.mli
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type t =
| `Version of ((int -> int -> bool) * string) list
| `Weakdef
| `Always
| `Alias of string
| condition
]

Expand Down
72 changes: 41 additions & 31 deletions compiler/tests-check-prim/main.output
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,20 @@ caml_atomic_load
caml_domain_dls
caml_domain_dls_get
caml_domain_dls_set
caml_domain_id
caml_domain_spawn
caml_ml_domain_cpu_relax
caml_ml_domain_id
caml_ml_domain_set_name
caml_ml_domain_unique_token
caml_recommended_domain_count

From +effect.js:
caml_alloc_stack
caml_ml_condition_broadcast
caml_ml_condition_new
caml_ml_condition_signal
caml_ml_condition_wait

From +fail.js:
caml_return_exn_constant
Expand Down Expand Up @@ -137,7 +149,6 @@ caml_mod

From +io.js:
caml_input_value_to_outside_heap
win_filedescr_of_channel

From +jslib.js:
caml_is_js
Expand Down Expand Up @@ -167,7 +178,6 @@ caml_lazy_read_result
caml_lazy_reset_to_lazy
caml_lazy_update_to_forcing
caml_lazy_update_to_forward
caml_ml_domain_id
caml_obj_compare_and_swap
caml_obj_is_block
caml_obj_is_shared
Expand Down Expand Up @@ -205,35 +215,35 @@ caml_register_channel_for_spacetime
caml_set_static_env
caml_spacetime_enabled
caml_spacetime_only_works_for_native_code
unix_inet_addr_of_string

From +unix.js:
unix_closedir
unix_getpwuid
unix_gettimeofday
unix_getuid
unix_gmtime
unix_has_symlink
unix_isatty
unix_localtime
unix_lstat
unix_lstat_64
unix_mkdir
unix_mktime
unix_opendir
unix_readdir
unix_readlink
unix_rewinddir
unix_rmdir
unix_stat
unix_stat_64
unix_symlink
unix_time
unix_unlink
win_cleanup
win_findclose
win_findfirst
win_findnext
win_handle_fd
win_startup
caml_unix_cleanup
caml_unix_closedir
caml_unix_filedescr_of_fd
caml_unix_findclose
caml_unix_findfirst
caml_unix_findnext
caml_unix_getpwuid
caml_unix_gettimeofday
caml_unix_getuid
caml_unix_gmtime
caml_unix_has_symlink
caml_unix_inet_addr_of_string
caml_unix_isatty
caml_unix_localtime
caml_unix_lstat
caml_unix_lstat_64
caml_unix_mkdir
caml_unix_mktime
caml_unix_opendir
caml_unix_readdir
caml_unix_readlink
caml_unix_rewinddir
caml_unix_rmdir
caml_unix_startup
caml_unix_stat
caml_unix_stat_64
caml_unix_symlink
caml_unix_time
caml_unix_unlink

49 changes: 41 additions & 8 deletions compiler/tests-check-prim/unix-unix.output
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,20 @@ caml_atomic_load
caml_domain_dls
caml_domain_dls_get
caml_domain_dls_set
caml_domain_id
caml_domain_spawn
caml_ml_domain_cpu_relax
caml_ml_domain_id
caml_ml_domain_set_name
caml_ml_domain_unique_token
caml_recommended_domain_count

From +effect.js:
caml_alloc_stack
caml_ml_condition_broadcast
caml_ml_condition_new
caml_ml_condition_signal
caml_ml_condition_wait

From +fail.js:
caml_return_exn_constant
Expand Down Expand Up @@ -246,7 +258,6 @@ caml_mod

From +io.js:
caml_input_value_to_outside_heap
win_filedescr_of_channel

From +jslib.js:
caml_is_js
Expand Down Expand Up @@ -276,7 +287,6 @@ caml_lazy_read_result
caml_lazy_reset_to_lazy
caml_lazy_update_to_forcing
caml_lazy_update_to_forward
caml_ml_domain_id
caml_obj_compare_and_swap
caml_obj_is_block
caml_obj_is_shared
Expand Down Expand Up @@ -316,10 +326,33 @@ caml_spacetime_enabled
caml_spacetime_only_works_for_native_code

From +unix.js:
win_cleanup
win_findclose
win_findfirst
win_findnext
win_handle_fd
win_startup
caml_unix_cleanup
caml_unix_closedir
caml_unix_filedescr_of_fd
caml_unix_findclose
caml_unix_findfirst
caml_unix_findnext
caml_unix_getpwuid
caml_unix_gettimeofday
caml_unix_getuid
caml_unix_gmtime
caml_unix_has_symlink
caml_unix_inet_addr_of_string
caml_unix_isatty
caml_unix_localtime
caml_unix_lstat
caml_unix_lstat_64
caml_unix_mkdir
caml_unix_mktime
caml_unix_opendir
caml_unix_readdir
caml_unix_readlink
caml_unix_rewinddir
caml_unix_rmdir
caml_unix_startup
caml_unix_stat
caml_unix_stat_64
caml_unix_symlink
caml_unix_time
caml_unix_unlink

Loading