aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorNicolás Bértolo2020-05-19 15:57:31 -0300
committerAndrea Corallo2020-05-25 09:42:10 +0100
commit1b809f378f6263bc099da45c5e4a42c89fef8d71 (patch)
tree1adfe55b6b0761de4f12bc0830aaab7a3296bc07 /src/eval.c
parent9daffe9cfe82d3b1e1e9fa8929dbb40cfed60f0f (diff)
downloademacs-1b809f378f6263bc099da45c5e4a42c89fef8d71.tar.gz
emacs-1b809f378f6263bc099da45c5e4a42c89fef8d71.zip
Improve handling of native compilation units still in use in Windows
When closing emacs will inspect all directories from which it loaded native compilation units. If it finds a ".eln.old" file it will try to delete it, if it fails that means that another Emacs instance is using it. When compiling a file we rename the file that was in the output path in case it has been loaded into another Emacs instance. When deleting a package we move any ".eln" or ".eln.old" files in the package folder that we can't delete to `package-user-dir`. Emacs will check that directory when closing and delete them. * lisp/emacs-lisp/comp.el (comp--replace-output-file): Function called from C code to finish the compilation process. It performs renaming of the old file if necessary. * lisp/emacs-lisp/package.el (package--delete-directory): Function to delete a package directory. It moves native compilation units that it can't delete to `package-user-dir'. * src/alloc.c (cleanup_vector): Call dispose_comp_unit(). (garbage_collect): Call finish_delayed_disposal_of_comp_units(). * src/comp.c: Restore the signal mask using unwind-protect. Store loaded native compilation units in a hash table for disposal on close. Store filenames of native compilation units GC'd in a linked list to finish their disposal when the GC is over. (clean_comp_unit_directory): Delete all *.eln.old files in a directory. (clean_package_user_dir_of_old_comp_units): Delete all *.eln.old files in `package-user-dir'. (dispose_all_remaining_comp_units): Dispose of native compilation units that are still loaded. (dispose_comp_unit): Close handle and cleanup directory or arrange for later cleanup if DELAY is true. (finish_delayed_disposal_of_comp_units): Dispose of native compilation units that were GC'd. (register_native_comp_unit): Register native compilation unit for disposal when Emacs closes. * src/comp.h: Introduce cfile member in Lisp_Native_Comp_Unit. Add declarations of functions that: clean directories of unused native compilation units, handle disposal of native compilation units. * src/emacs.c (kill-emacs): Dispose all remaining compilation units right right before calling exit(). * src/eval.c (internal_condition_case_3, internal_condition_case_4): Add functions. * src/lisp.h (internal_condition_case_3, internal_condition_case_4): Add functions. * src/pdumper.c (dump_do_dump_relocation): Set cfile to a copy of the Lisp string specifying the file path.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c
index 37d466f69ed..9e86a185908 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1419,6 +1419,61 @@ internal_condition_case_2 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object),
1419 } 1419 }
1420} 1420}
1421 1421
1422/* Like internal_condition_case_1 but call BFUN with ARG1, ARG2, ARG3 as
1423 its arguments. */
1424
1425Lisp_Object
1426internal_condition_case_3 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object,
1427 Lisp_Object),
1428 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
1429 Lisp_Object handlers,
1430 Lisp_Object (*hfun) (Lisp_Object))
1431{
1432 struct handler *c = push_handler (handlers, CONDITION_CASE);
1433 if (sys_setjmp (c->jmp))
1434 {
1435 Lisp_Object val = handlerlist->val;
1436 clobbered_eassert (handlerlist == c);
1437 handlerlist = handlerlist->next;
1438 return hfun (val);
1439 }
1440 else
1441 {
1442 Lisp_Object val = bfun (arg1, arg2, arg3);
1443 eassert (handlerlist == c);
1444 handlerlist = c->next;
1445 return val;
1446 }
1447}
1448
1449/* Like internal_condition_case_1 but call BFUN with ARG1, ARG2, ARG3, ARG4 as
1450 its arguments. */
1451
1452Lisp_Object
1453internal_condition_case_4 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object,
1454 Lisp_Object, Lisp_Object),
1455 Lisp_Object arg1, Lisp_Object arg2,
1456 Lisp_Object arg3, Lisp_Object arg4,
1457 Lisp_Object handlers,
1458 Lisp_Object (*hfun) (Lisp_Object))
1459{
1460 struct handler *c = push_handler (handlers, CONDITION_CASE);
1461 if (sys_setjmp (c->jmp))
1462 {
1463 Lisp_Object val = handlerlist->val;
1464 clobbered_eassert (handlerlist == c);
1465 handlerlist = handlerlist->next;
1466 return hfun (val);
1467 }
1468 else
1469 {
1470 Lisp_Object val = bfun (arg1, arg2, arg3, arg4);
1471 eassert (handlerlist == c);
1472 handlerlist = c->next;
1473 return val;
1474 }
1475}
1476
1422/* Like internal_condition_case but call BFUN with NARGS as first, 1477/* Like internal_condition_case but call BFUN with NARGS as first,
1423 and ARGS as second argument. */ 1478 and ARGS as second argument. */
1424 1479