diff options
Diffstat (limited to 'bytecomp')
-rw-r--r-- | bytecomp/bytegen.ml | 2 | ||||
-rw-r--r-- | bytecomp/bytepackager.ml | 26 | ||||
-rw-r--r-- | bytecomp/dll.ml | 9 | ||||
-rw-r--r-- | bytecomp/instruct.ml | 1 | ||||
-rw-r--r-- | bytecomp/instruct.mli | 1 |
5 files changed, 25 insertions, 14 deletions
diff --git a/bytecomp/bytegen.ml b/bytecomp/bytegen.ml index f7911aa3e..09c254d4f 100644 --- a/bytecomp/bytegen.ml +++ b/bytecomp/bytegen.ml @@ -171,6 +171,7 @@ let copy_event ev kind info repr = ev_kind = kind; ev_info = info; ev_typenv = ev.ev_typenv; + ev_typsubst = ev.ev_typsubst; ev_compenv = ev.ev_compenv; ev_stacksize = ev.ev_stacksize; ev_repr = repr } @@ -714,6 +715,7 @@ let rec comp_expr env exp sz cont = ev_kind = kind; ev_info = info; ev_typenv = lev.lev_env; + ev_typsubst = Subst.identity; ev_compenv = env; ev_stacksize = sz; ev_repr = diff --git a/bytecomp/bytepackager.ml b/bytecomp/bytepackager.ml index bb3a80aa6..31eff07fa 100644 --- a/bytecomp/bytepackager.ml +++ b/bytecomp/bytepackager.ml @@ -66,9 +66,11 @@ let rename_relocation objfile mapping defined base (rel, ofs) = (* Record and relocate a debugging event *) -let relocate_debug base ev = - ev.ev_pos <- base + ev.ev_pos; - events := ev :: !events +let relocate_debug base prefix subst ev = + let ev' = { ev with ev_pos = base + ev.ev_pos; + ev_module = prefix ^ "." ^ ev.ev_module; + ev_typsubst = Subst.compose ev.ev_typsubst subst } in + events := ev' :: !events (* Read the unit information from a .cmo file. *) @@ -110,7 +112,7 @@ let read_member_info file = Accumulate relocs, debug info, etc. Return size of bytecode. *) -let rename_append_bytecode oc mapping defined ofs objfile compunit = +let rename_append_bytecode oc mapping defined ofs prefix subst objfile compunit = let ic = open_in_bin objfile in try Bytelink.check_consistency objfile compunit; @@ -123,7 +125,7 @@ let rename_append_bytecode oc mapping defined ofs objfile compunit = Misc.copy_file_chunk ic oc compunit.cu_codesize; if !Clflags.debug && compunit.cu_debug > 0 then begin seek_in ic compunit.cu_debug; - List.iter (relocate_debug ofs) (input_value ic); + List.iter (relocate_debug ofs prefix subst) (input_value ic); end; close_in ic; compunit.cu_codesize @@ -134,20 +136,22 @@ let rename_append_bytecode oc mapping defined ofs objfile compunit = (* Same, for a list of .cmo and .cmi files. Return total size of bytecode. *) -let rec rename_append_bytecode_list oc mapping defined ofs = function +let rec rename_append_bytecode_list oc mapping defined ofs prefix subst = function [] -> ofs | m :: rem -> match m.pm_kind with | PM_intf -> - rename_append_bytecode_list oc mapping defined ofs rem + rename_append_bytecode_list oc mapping defined ofs prefix subst rem | PM_impl compunit -> let size = - rename_append_bytecode oc mapping defined ofs + rename_append_bytecode oc mapping defined ofs prefix subst m.pm_file compunit in + let id = Ident.create_persistent m.pm_name in + let root = Path.Pident (Ident.create_persistent prefix) in rename_append_bytecode_list - oc mapping (Ident.create_persistent m.pm_name :: defined) - (ofs + size) rem + oc mapping (id :: defined) + (ofs + size) prefix (Subst.add_module id (Path.Pdot (root, Ident.name id, Path.nopos)) subst) rem (* Generate the code that builds the tuple representing the package module *) @@ -187,7 +191,7 @@ let package_object_files files targetfile targetname coercion = let pos_depl = pos_out oc in output_binary_int oc 0; let pos_code = pos_out oc in - let ofs = rename_append_bytecode_list oc mapping [] 0 members in + let ofs = rename_append_bytecode_list oc mapping [] 0 targetname Subst.identity members in build_global_target oc targetname members mapping ofs coercion; let pos_debug = pos_out oc in if !Clflags.debug && !events <> [] then diff --git a/bytecomp/dll.ml b/bytecomp/dll.ml index 4463d5b98..f5ba48d4f 100644 --- a/bytecomp/dll.ml +++ b/bytecomp/dll.ml @@ -85,13 +85,16 @@ let close_all_dlls () = Raise [Not_found] if not found. *) let find_primitive prim_name = - let rec find = function + let rec find seen = function [] -> raise Not_found | dll :: rem -> let addr = dll_sym dll prim_name in - if addr == Obj.magic () then find rem else addr in - find !opened_dlls + if addr == Obj.magic () then find (dll :: seen) rem else begin + if seen <> [] then opened_dlls := dll :: List.rev_append seen rem; + addr + end in + find [] !opened_dlls (* If linking in core (dynlink or toplevel), synchronize the VM table of primitive with the linker's table of primitive diff --git a/bytecomp/instruct.ml b/bytecomp/instruct.ml index 9fd2cb940..4f4fa14fa 100644 --- a/bytecomp/instruct.ml +++ b/bytecomp/instruct.ml @@ -26,6 +26,7 @@ type debug_event = ev_kind: debug_event_kind; (* Before/after event *) ev_info: debug_event_info; (* Extra information *) ev_typenv: Env.summary; (* Typing environment *) + ev_typsubst: Subst.t; (* Substitution over types *) ev_compenv: compilation_env; (* Compilation environment *) ev_stacksize: int; (* Size of stack frame *) ev_repr: debug_event_repr } (* Position of the representative *) diff --git a/bytecomp/instruct.mli b/bytecomp/instruct.mli index 31f526d22..6b9367f9a 100644 --- a/bytecomp/instruct.mli +++ b/bytecomp/instruct.mli @@ -44,6 +44,7 @@ type debug_event = ev_kind: debug_event_kind; (* Before/after event *) ev_info: debug_event_info; (* Extra information *) ev_typenv: Env.summary; (* Typing environment *) + ev_typsubst: Subst.t; (* Substitution over types *) ev_compenv: compilation_env; (* Compilation environment *) ev_stacksize: int; (* Size of stack frame *) ev_repr: debug_event_repr } (* Position of the representative *) |