这是indexloc提供的服务,不要输入任何密码
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/runtime/js/jslib.js b/runtime/js/jslib.js
index 6a711bbb1d..081361a841 100644
--- a/runtime/js/jslib.js
+++ b/runtime/js/jslib.js
@@ -134,8 +134,9 @@ function caml_jsoo_flags_use_js_string(unit) {
}

//Provides: caml_jsoo_flags_effects
+//Requires: caml_string_of_jsstring
function caml_jsoo_flags_effects(unit) {
- return CONFIG("effects");
+ return caml_string_of_jsstring(CONFIG("effects"));
}

//Provides: caml_wrap_exception const (mutable)

Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
diff --git a/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml b/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml
index 140a53b..d857289 100644
--- a/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml
+++ b/compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml
@@ -4,7 +4,7 @@ module J = Jsoo_runtime.Js

type bytecode_sections =
{ symb : Ocaml_compiler.Symtable.GlobalMap.t
- ; crcs : (string * Digest.t option) list
+ ; crcs : Import_info.t array
; prim : string list
; dlpt : string list
}
diff --git a/compiler/lib/link_js.ml b/compiler/lib/link_js.ml
index 68f0c32..3ec9ddc 100644
--- a/compiler/lib/link_js.ml
+++ b/compiler/lib/link_js.ml
@@ -426,7 +426,7 @@ let link ~output ~linkall ~mklib ~toplevel ~files ~resolve_sourcemap_url ~(sourc
List.fold_left units ~init:StringSet.empty ~f:(fun acc (u : Unit_info.t) ->
StringSet.union acc (StringSet.of_list u.primitives))
in
- let code = Parse_bytecode.link_info ~symbols:!sym ~primitives ~crcs:[] in
+ let code = Parse_bytecode.link_info ~symbols:!sym ~primitives ~crcs:[||] in
let b = Buffer.create 100 in
let fmt = Pretty_print.to_buffer b in
Driver.configure fmt;
diff --git a/compiler/lib/parse_bytecode.ml b/compiler/lib/parse_bytecode.ml
index 79e0c8f..bf8751a 100644
--- a/compiler/lib/parse_bytecode.ml
+++ b/compiler/lib/parse_bytecode.ml
@@ -35,6 +35,9 @@ let predefined_exceptions =

let new_closure_repr = Ocaml_version.compare Ocaml_version.current [ 4; 12 ] >= 0

+let crc_name v = Import_info.name v |> Compilation_unit.Name.to_string
+let crc_crc v = Import_info.crc v
+
(* Read and manipulate debug section *)
module Debug : sig
type t
@@ -76,11 +79,11 @@ module Debug : sig
-> unit

val read :
- t -> crcs:(string * string option) list -> includes:string list -> in_channel -> unit
+ t -> crcs:Import_info.t list -> includes:string list -> in_channel -> unit

val read_event_list :
t
- -> crcs:(string * string option) list
+ -> crcs:Import_info.t list
-> includes:string list
-> orig:int
-> in_channel
@@ -146,6 +149,7 @@ end = struct
| Some _ as x -> x
| None -> Fs.find_in_path paths (name ^ ".ml")

+
let read_event
~paths
~crcs
@@ -216,7 +220,7 @@ end = struct
fun debug ~crcs ~includes ~orig ic ->
let crcs =
let t = Hashtbl.create 17 in
- List.iter crcs ~f:(fun (m, crc) -> Hashtbl.add t m crc);
+ List.iter crcs ~f:(fun i -> Hashtbl.add t (crc_name i) (crc_crc i));
t
in
let evl : debug_event list = input_value ic in
@@ -2520,7 +2524,7 @@ module Toc : sig

val read_data : t -> in_channel -> Obj.t array

- val read_crcs : t -> in_channel -> (string * Digest.t option) list
+ val read_crcs : t -> in_channel -> Import_info.t array

val read_prim : t -> in_channel -> string

@@ -2570,9 +2574,10 @@ end = struct
let read_crcs toc ic =
ignore (seek_section toc ic "CRCS");
let orig_crcs : Import_info.t array = input_value ic in
- List.map (Array.to_list orig_crcs) ~f:(fun import ->
- Import_info.name import |> Compilation_unit.Name.to_string,
- Import_info.crc import)
+ orig_crcs
+ (* List.map (Array.to_list orig_crcs) ~f:(fun import -> *)
+ (* Import_info.name import |> Compilation_unit.Name.to_string, *)
+ (* Import_info.crc import) *)

let read_prim toc ic =
let prim_size = seek_section toc ic "PRIM" in
@@ -2587,12 +2592,13 @@ let read_primitives toc ic =

type bytesections =
{ symb : Ocaml_compiler.Symtable.GlobalMap.t
- ; crcs : (string * Digest.t option) list
+ ; crcs : Import_info.t array
; prim : string list
; dlpt : string list
}
[@@ocaml.warning "-unused-field"]

+
let from_exe
?(includes = [])
~linkall
@@ -2625,7 +2631,7 @@ let from_exe
| Some l -> List.mem s ~set:l
| None -> true)
in
- let crcs = List.filter ~f:(fun (unit, _crc) -> keep unit) orig_crcs in
+ let crcs = List.filter ~f:(fun info -> keep (crc_name info)) (Array.to_list orig_crcs) in
let symbols =
Ocaml_compiler.Symtable.GlobalMap.filter
(function
@@ -2690,7 +2696,7 @@ let from_exe
|> Array.of_list
in
(* Include linking information *)
- let sections = { symb = symbols; crcs; prim = primitives; dlpt = [] } in
+ let sections = { symb = symbols; crcs = Array.of_list crcs; prim = primitives; dlpt = [] } in
let gdata = Var.fresh () in
let need_gdata = ref false in
let infos =
diff --git a/compiler/lib/parse_bytecode.mli b/compiler/lib/parse_bytecode.mli
index 7bcc822..b34113b 100644
--- a/compiler/lib/parse_bytecode.mli
+++ b/compiler/lib/parse_bytecode.mli
@@ -91,5 +91,5 @@ val predefined_exceptions : unit -> Code.program * Unit_info.t
val link_info :
symbols:Ocaml_compiler.Symtable.GlobalMap.t
-> primitives:StringSet.t
- -> crcs:(string * Digest.t option) list
+ -> crcs:Import_info.t array
-> Code.program
diff --git a/runtime/js/capsule.js b/runtime/js/capsule.js
new file mode 100644
index 0000000..0c02acc
--- /dev/null
+++ b/runtime/js/capsule.js
@@ -0,0 +1,14 @@
+//Provides: caml_capsule_mutex_new
+function caml_capsule_mutex_new () {
+ return 0;
+}
+
+//Provides: caml_capsule_mutex_lock
+function caml_capsule_mutex_lock () {
+ return 0;
+}
+
+//Provides: caml_capsule_mutex_unlock
+function caml_capsule_mutex_unlock () {
+ return 0;
+}
diff --git a/runtime/js/dune b/runtime/js/dune
index f31ffd1..7e76a14 100644
--- a/runtime/js/dune
+++ b/runtime/js/dune
@@ -4,6 +4,7 @@
(files
bigarray.js
bigstring.js
+ capsule.js
dynlink.js
fs.js
fs_fake.js
diff --git a/runtime/js/float32.js b/runtime/js/float32.js
index 0c60d3d..74bb433 100644
--- a/runtime/js/float32.js
+++ b/runtime/js/float32.js
@@ -12,6 +12,11 @@
by native programs and vice versa.
*/

+//Provides: caml_is_boot_compiler
+function caml_is_boot_compiler(x) {
+ return 0;
+}
+
//Provides: caml_float_of_float32 const
function caml_float_of_float32(x) {
return x;
diff --git a/runtime/js/toplevel.js b/runtime/js/toplevel.js
index 2e4547e..adaffd3 100644
--- a/runtime/js/toplevel.js
+++ b/runtime/js/toplevel.js
@@ -94,7 +94,7 @@ function jsoo_toplevel_init_reloc(f) {
//Requires: caml_callback
//Requires: caml_string_of_uint8_array, caml_ba_to_typed_array
//Requires: jsoo_toplevel_compile, caml_failwith
-//Version: >= 5.2
+//Version: >= 5.3
function caml_reify_bytecode(code, debug, _digest) {
if (!jsoo_toplevel_compile) {
caml_failwith("Toplevel not initialized (jsoo_toplevel_compile)");
@@ -107,7 +107,7 @@ function caml_reify_bytecode(code, debug, _digest) {
//Requires: caml_callback
//Requires: caml_string_of_uint8_array, caml_uint8_array_of_bytes
//Requires: jsoo_toplevel_compile, caml_failwith
-//Version: < 5.2
+//Version: < 5.3
function caml_reify_bytecode(code, debug, _digest) {
if (!jsoo_toplevel_compile) {
caml_failwith("Toplevel not initialized (jsoo_toplevel_compile)");
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- a/compiler/bin-wasm_of_ocaml/compile.ml
+++ b/compiler/bin-wasm_of_ocaml/compile.ml
@@ -226,8 +226,14 @@
Option.iter sm ~f:(fun sm ->
if not sourcemap_don't_inline_content
then
+ let rewrite =
+ match Build_path_prefix_map.get_build_path_prefix_map () with
+ | Some map -> let map = Build_path_prefix_map.flip map in (fun path -> Build_path_prefix_map.rewrite map path)
+ | None -> Fun.id
+ in
Wasm_source_map.iter_sources sm (fun i j file ->
+ let file = rewrite file in
if Sys.file_exists file && not (Sys.is_directory file)
then
let sm = Fs.read_file file in
Zip.add_entry
20 changes: 15 additions & 5 deletions packages/js_of_ocaml-compiler/js_of_ocaml-compiler.6.0.1+ox/opam
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ patches: [
"js_of_ocaml-add-unboxed-and-float-block.patch"
"js_of_ocaml-ident-is_global.patch"
"js_of_ocaml-remove-float-externals.patch"
"js_of_ocaml-ocaml_version-ppx.patch"
"js_of_ocaml-test-diffs-caused-by-build-differences.patch"
"js_of_ocaml-fix-build_fs.patch"
"js_of_ocaml-iarray-primitives.patch"
Expand All @@ -73,6 +72,7 @@ patches: [
"js_of_ocaml-jane-street-5.2-compatibility.patch"
"js_of_ocaml-migrate-labeled-tuples-shims.patch"
"js_of_ocaml-floatarray_create_local.patch"
"wasm_of_ocaml-sourcemap-contents.patch"
"js_of_ocaml-jane-street-const_null-support.patch"
"js_of_ocaml-float32.patch"
"js_of_ocaml-caml_array_append.patch"
Expand All @@ -84,6 +84,8 @@ patches: [
"js_of_ocaml-obj_stubs.patch"
"js_of_ocaml-float32-2.patch"
"dune.patch"
"js_of_ocaml-top-effects.patch"
"js_of_ocaml-toplevel.patch"
]
extra-files: [
[
Expand Down Expand Up @@ -114,10 +116,6 @@ extra-files: [
"js_of_ocaml-remove-float-externals.patch"
"sha256=a3aa95ee08210377c1470e5bf0f832bc27ad98299bca22c7a88eb9fd6c32e655"
]
[
"js_of_ocaml-ocaml_version-ppx.patch"
"sha256=df6bcb6da8aa3dfd6bd0a178679987d41c400ec1803f4a66659cfc822d1b280f"
]
[
"js_of_ocaml-test-diffs-caused-by-build-differences.patch"
"sha256=00d38ead67c67220351605d72c2b3a4e3faa8053087ef8ab47b7067b42900ba9"
Expand Down Expand Up @@ -194,6 +192,10 @@ extra-files: [
"js_of_ocaml-floatarray_create_local.patch"
"sha256=f17e392acc941dde475cb7be0654037df9b8d550aeae0d96b65394e4c4a1d4ca"
]
[
"wasm_of_ocaml-sourcemap-contents.patch"
"sha256=93b7dddf6313836ce02fbe762c40380e20daefdd8b87ec885ee0f4ef779ad76b"
]
[
"js_of_ocaml-jane-street-const_null-support.patch"
"sha256=e708cdc01c0cef3fce1cb9f31b33324977dcca1c166601905fcac1ef10262c3a"
Expand Down Expand Up @@ -238,4 +240,12 @@ extra-files: [
"dune.patch"
"sha256=f76da998ab76de56309bd0da3e4db1fb496d6d235d7a0ac2f78e3bafe098714e"
]
[
"js_of_ocaml-top-effects.patch"
"sha256=638247bd3f7bacb99612353b29c0afdcc48598c5771a52602a96baabbc141370"
]
[
"js_of_ocaml-toplevel.patch"
"sha256=56c305aa9ed8cb35e9a3bee9fb17aaae244522bacb54a78115b03182a746b7b2"
]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
--- a/runtime/js/obj.js
+++ b/runtime/js/obj.js
@@ -44,6 +44,22 @@
return +Array.isArray(x);
}

+//Provides: caml_obj_is_stack
+function caml_obj_is_stack(x) {
+ return 0;
+}
+
+//Provides: caml_succ_scannable_prefix_len
+function caml_succ_scannable_prefix_len(x) {
+ return 0;
+}
+
+//Provides: caml_obj_uniquely_reachable_words
+//Requires: caml_failwith
+function caml_obj_uniquely_reachable_words(x) {
+ caml_failwith("Obj.uniquely_reachable_words is not available in javascript.");
+}
+
//Provides: caml_obj_tag
//Requires: caml_is_ml_bytes, caml_is_ml_string
function caml_obj_tag(x) {
--- a/runtime/wasm/obj.wat
+++ b/runtime/wasm/obj.wat
@@ -101,6 +101,21 @@
(global $double_array_tag (export "double_array_tag") i32 (i32.const 254))
(global $custom_tag i32 (i32.const 255))

+ (func (export "caml_obj_is_stack")
+ (param (ref eq)) (result (ref eq))
+ (ref.i31 (i32.const 0)))
+
+ (func (export "caml_succ_scannable_prefix_len")
+ (param (ref eq)) (result (ref eq))
+ (ref.i31 (i32.const 0)))
+
+ (@string $unique_words_unsupported "Obj.uniquely_reachable_words is not available in wasm.")
+
+ (func (export "caml_obj_uniquely_reachable_words")
+ (param (ref eq)) (result (ref eq))
+ (call $caml_failwith (global.get $unique_words_unsupported))
+ (ref.i31 (i32.const 0)))
+
(func $caml_is_closure (export "caml_is_closure")
(param $v (ref eq)) (result i32)
(i32.or (ref.test (ref $closure) (local.get $v))
Loading