summaryrefslogtreecommitdiff
path: root/src/comp.h
Commit message (Collapse)AuthorAgeFilesLines
* ; Add 2024 to copyright yearsPo Lu2024-01-021-1/+1
|
* ; Add 2023 to copyright years.Eli Zaretskii2023-01-011-1/+1
|
* Port to gcc -D EMACS_EXTERN_INLINEPaul Eggert2022-03-191-0/+4
| | | | | | * src/comp.h, src/thread.h: Add INLINE_HEADER_BEGIN and INLINE_HEADER_END, since it uses INLINE. * src/emacs.c: Include these two files.
* ; Add 2022 to copyright years.Eli Zaretskii2022-01-011-1/+1
|
* Port to C compilers that lack size-0 arraysPaul Eggert2021-12-021-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The C standard does not allow size-zero arrays, so redo struct Lisp_Subr to not use size-zero arrays when native compilation is not being used. Formerly, the code was using size-zero arrays (a GNU C extension) to avoid using memory unnecessarily when HAVE_NATIVE_COMP is not defined. Replace this hack with the more-traditional hack of putting the relevant members inside ‘#ifdef HAVE_NATIVE_COMP’. * src/alloc.c (cleanup_vector, mark_object): * src/comp.c (make_subr): * src/data.c (Fsubr_native_lambda_list, Fsubr_native_comp_unit): * src/eval.c (init_eval_once, funcall_lambda): * src/lisp.h (SUBR_NATIVE_COMPILEDP, SUBR_NATIVE_COMPILED_DYNP) (SUBR_TYPE): * src/lread.c (Fload): Conditionally compile with ‘#ifdef HAVE_NATIVE_COMP’ instead of with ‘if (NATIVE_COMP_FLAG)’. Redo members like native_comp_u[0] to be plain native_comp_u. Put all uses of these members inside ‘#ifdef HAVE_NATIVE_COMP’. * src/lisp.h (struct Lisp_Subr): Members native_comp_u, native_c_name, lambda_list, type are now all ifdeffed out if HAVE_NATIVE_COMP is not defined, instead of being size-zero arrays. All uses changed. * src/pdumper.c (dump_subr, dump_cold_native_subr) (dump_do_dump_relocation): * src/comp.h (NATIVE_COMP_FLAG): Remove; no longer needed.
* ; Add 2021 to copyright yearsGlenn Morris2021-04-251-1/+2
|
* Fix loading *.eln files when Emacs is installed via symlinksEli Zaretskii2021-04-171-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/emacs.c (real_filename, set_invocation_vars) (init_vars_for_load): Functions deleted; callers adjusted. (init_cmdargs): Put back all the code which was extracted into set_invocation_vars. (load_pdump_find_executable): Make sure the return value has any symlinks in it expanded. (load_pdump): Accept only 2 arguments, not 3. Determine both the file name of the Emacs executable and of the dump file in synchronized manner, so that if we decided to look for the dump file in its hardcoded installation directory, the directory of the Emacs executable will also be where we expect it to be installed. Pass only 2 arguments to pdumper_load. (Bug#47800) (Bug#44128) * src/pdumper.c (dump_do_dump_relocation): Use emacs_execdir instead of Vinvocation_directory to produce absolute file names of *.eln files that are recorded in the pdumper file. Pass the full .eln file name to fixup_eln_load_path. (pdumper_set_emacs_execdir) [HAVE_NATIVE_COMP]: New function. (pdumper_load) [HAVE_NATIVE_COMP]: Call pdumper_set_emacs_execdir. * src/comp.c (fixup_eln_load_path): Use Fsubstring_no_properties instead of Fsubstring. No need to cons a file name, as the caller already did that. Use explicit const string to avoid "magic" values. * lisp/startup.el (normal-top-level): Use expand-file-name instead of concat. Decode comp-eln-load-path and expand-file-name its members.
* * src/comp.h (unload_comp_unit): Define for vanilla build (warning removal).Andrea Corallo2021-04-011-0/+4
|
* Zero stale pointer when unloading comp units (bug#46256)Pip Cet2021-03-091-0/+2
| | | | | * src/alloc.c (cleanup_vector): Call unload_comp_unit. * src/comp.c (unload_comp_unit): New function.
* ; Fix trivial typosStefan Kangas2020-11-201-1/+1
|
* Have `native-elisp-load' return the last registerd functionAndrea Corallo2020-10-141-2/+2
| | | | | | | | | | * lisp/emacs-lisp/comp.el (comp-emit-for-top-level): Synthesize 'top_level_run' so it returns the last value returned by `comp--register-subr'. * src/comp.c (load_comp_unit): Return what 'top_level_run' returns. (Fnative_elisp_load): Return what 'load_comp_unit' returns. * src/comp.h (load_comp_unit): Update signature.
* Rework eln deletion strategy for new eln-cache folder structureAndrea Corallo2020-09-061-33/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When recompiling remove the corresponding stale elns found in the `comp-eln-load-path'. When removing a package remove the corresponding elns too. On Windows both of these are performed only when possible, when it's not the file is renamed as .eln.old and a last attempt to remove this is performed closing the Emacs session. When a file being deleted was loaded by multiple Emacs sessions the last one being closed should delete it. * lisp/emacs-lisp/comp.el (comp-clean-up-stale-eln): New function. (comp-delete-or-replace-file): Rename from `comp--replace-output-file' and update so it can be used for replacing or deleting shared libs safetly. * lisp/emacs-lisp/package.el (package--delete-directory): When native compiled just call `comp-clean-up-stale-eln' for each eln file we want to clean-up. * src/alloc.c (cleanup_vector): Call directly the dynlib_close. * src/comp.c (syms_of_comp): Update for comp_u->cfile removal. Make 'all_loaded_comp_units_h' key-value weak as now the key will be the filename. (load_comp_unit): Register the compilation unit only when the load is fully completed. (register_native_comp_unit): Make the key of all_loaded_comp_units_h the load filename. (eln_load_path_final_clean_up): New function. (dispose_comp_unit) (finish_delayed_disposal_of_comp_units) (dispose_all_remaining_comp_units) (clean_package_user_dir_of_old_comp_units): Remove. (Fcomp__compile_ctxt_to_file): Update for `comp--replace-output-file' -> `comp-delete-or-replace-file' rename. * src/comp.h (dispose_comp_unit) (finish_delayed_disposal_of_comp_units) (dispose_all_remaining_comp_units) (clean_package_user_dir_of_old_comp_units): Remove. (eln_load_path_final_clean_up): Add. (struct Lisp_Native_Comp_Unit): Remove cfile field. * src/emacs.c (Fkill_emacs): Call 'eln_load_path_final_clean_up'. * src/pdumper.c (dump_do_dump_relocation): Do not set comp_u->cfile.
* Make install target functional for new eln-cache directory arrangementAndrea Corallo2020-08-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | * src/comp.h (fixup_eln_load_path): New extern. * src/comp.c (fixup_eln_load_path): New function. * src/pdumper.c (dump_do_dump_relocation): Update to make use of 'fixup_eln_load_path'. * lisp/loadup.el: Update to store in the compilation unit the correct eln-cache installed path. Rename --lisp-dest -> --eln-dest and. * Makefile.in: Pass the eln destination directory to src/Makefile. Rename LISP_DESTDIR -> ELN_DESTDIR. (ELN_DESTDIR): Define. (install-eln): New target. (install): Add install-eln as prerequisite. * src/Makefile.in: Rename --lisp-dest -> --eln-dest and LISP_DESTDIR -> ELN_DESTDIR.
* Fix recursive load for non cons hashed 'data_ephemeral_vec' contentAndrea Corallo2020-06-111-1/+1
| | | | | | | | | | | | | | Removing `Vcomp_sym_subr_c_name_h' all c_name functions are GC markable only through 'data_ephemeral_vec'. A recursive load must not overide its content otherwise a previously activated load will have the original content collected before it's used. * src/comp.h (struct Lisp_Native_Comp_Unit): Add 'load_ongoing' field. * src/comp.c (unset_cu_load_ongoing): New function. (load_comp_unit): Update logic to detect and handle recursive loads.
* * src/comp.h (struct Lisp_Native_Comp_Unit): Fix missing GCALIGNED_STRUCT.Andrea Corallo2020-06-081-1/+1
|
* Rename lambda_gc_guard -> lambda_gc_guard_hAndrea Corallo2020-06-081-3/+3
| | | | | | | | | | * src/comp.h (struct Lisp_Native_Comp_Unit): Rename lambda_gc_guard -> lambda_gc_guard_h * src/pdumper.c (dump_do_dump_relocation): Likewise. * src/comp.c (check_comp_unit_relocs, Fcomp__register_lambda) (Fnative_elisp_load): Likewise.
* ; Ease ifdef navigation in native-comp filesAndrea Corallo2020-05-241-3/+4
| | | | | | | * src/comp.c (syms_of_comp): Add a comment to ease #endif understading. * src/comp.h: Likewise.
* Fix GNU styleAndrea Corallo2020-05-241-3/+4
| | | | | | | | | | * src/comp.h: Fix GNU style. * src/comp.c (Fcomp__compile_ctxt_to_file): Likewise. * lisp/emacs-lisp/comp.el (comp--replace-output-file): Likewise. * src/pdumper.c (dump_do_dump_relocation): Likewise.
* Fix non Windows buildsAndrea Corallo2020-05-241-1/+1
| | | | | | | | | | | * src/emacs.c (Fkill_emacs): Given 'finish_delayed_disposal_of_comp_units', 'dispose_all_remaining_comp_units' and 'clean_package_user_dir_of_old_comp_units' are defined only with windows native-comp builds ifdef them. * src/comp.h (dispose_comp_unit): Fix missing parameter in declaration.
* Improve handling of native compilation units still in use in WindowsNicolás Bértolo2020-05-251-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Load libgccjit dynamically in Windows.Nicolás Bértolo2020-05-231-5/+1
| | | | | | | | | | | | | | | | | | | * configure.ac: don't add linker flags if compiling on Windows. Compile dynlib.c if modules or native compilation are enabled. Always compile comp.c * lisp/term/w32-win.el: Map 'gccjit to "libgccjit.dll" in `dynamic-library-alist`. * src/Makefile.in: Update comments. Update to handle changes in configure.ac. * src/comp.c: Add declarations of used libgccjit functions using DEF_DLL_FN. Add calls to load_gccjit_if_necessary() where necessary. Add `native-comp-available-p` * src/comp.h: Remove Fnative_elisp_load. Add syms_of_comp(). * src/emacs.c (main): Always call syms_of_comp() * src/w32.c (globals_of_w32): Clear Vlibrary_cache when starting because the libraries loaded when dumping will not be loaded when starting. * src/w32fns.c: Add Qgccjit symbol.
* Add anonymous lambdas reload mechanismAndrea Corallo2020-05-151-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | * src/pdumper.c (dump_do_dump_relocation): Initialize 'lambda_gc_guard' while resurrecting. (dump_do_dump_relocation): Revive lambdas and fixup them. * src/comp.h (struct Lisp_Native_Comp_Unit): Define new 'lambda_gc_guard' 'lambda_c_name_idx_h' 'data_imp_relocs' 'loaded_once' fields. * src/comp.c (load_comp_unit): Use compilaiton unit 'loaded_once' field. (make_subr, Fcomp__register_lambda): New functions. (Fcomp__register_subr): Make use of 'make_subr'. (Fnative_elisp_load): Indent. (Fnative_elisp_load): Initialize 'lambda_gc_guard' 'lambda_c_name_idx_h' fields. (syms_of_comp): Add Scomp__register_lambda. * lisp/emacs-lisp/comp.el (comp-ctxt): Change 'byte-func-to-func-h' hash key test. (comp-ctxt): Add 'lambda-fixups-h' slot. (comp-emit-lambda-for-top-level): New function. (comp-finalize-relocs): Never emit lambdas in pure space. (comp-finalize-relocs): Fixup relocation indexes.
* Convert before final function doc hash into a vector.Andrea Corallo2020-04-261-1/+1
| | | | | | | | | | | | | | | | | * lisp/emacs-lisp/comp.el (comp-finalize-relocs): Convert doc hash table into vector befor final. (comp-emit-for-top-level): Rename `comp-ctxt-doc-index-h' -> `comp-ctxt-function-docs'. (comp-ctxt): Likewise. * src/comp.c (native_function_doc): Update logic for documentation being a vector. (emit_ctxt_code): Update for 'comp-ctxt-doc-index-h' slot rename. * src/comp.h (struct Lisp_Native_Comp_Unit): Rename 'data_fdoc_h' into data_fdoc_v. * src/pdumper.c (dump_native_comp_unit): Likewise.
* * src/comp.h (Fnative_elisp_load): Add fake inline for stock build.Andrea Corallo2020-04-251-0/+6
|
* Lazy load function documentation.Andrea Corallo2020-04-251-0/+2
| | | | | | | | | | | | | * src/comp.c (native_function_doc): New function. (load_comp_unit): Do not load function doc during load. * src/comp.h: Extern 'native_function_doc'. * src/doc.c (Fdocumentation): Call 'native_function_doc' to retrive function doc. * src/pdumper.c (dump_native_comp_unit): Zero 'data_fdoc_h' before dumping.
* * src/comp.h (load_comp_unit): Fix declaration style.Andrea Corallo2020-04-251-2/+3
|
* Store function documentations in a hash table.Andrea Corallo2020-04-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/pdumper.c (dump_subr): Update Lisp_Subr hash. (dump_subr): Update for new compilation unit layout. (dump_vectorlike): Update pvec_type hash. * src/lisp.h (struct Lisp_Subr): Remove 'native_doc' index. (DEFUN): Update macro for new compilation unit layout. * src/doc.c (Fdocumentation): Update for new compilation unit layout. * src/comp.h (struct Lisp_Native_Comp_Unit): Add 'data_fdoc_h' field. * src/comp.c (TEXT_FDOC_SYM): New macro. (emit_ctxt_code): Emit function documentations. (load_comp_unit): Load function documentation. (Fcomp__register_subr): Rename parameter. (Fcomp__register_subr): Update for new compilation unit layout. * src/alloc.c (mark_object): Update for new compilation unit layout. (syms_of_alloc): Likewise. * lisp/emacs-lisp/comp.el (comp-ctxt): Add doc-index-h slot. (comp-emit-for-top-level): Emit doc index as 'comp--register-subr' doc parameter.
* Extend low level code for late loadAndrea Corallo2020-03-191-2/+2
|
* Trigger native compilation when loading bytecodeAndrea Corallo2020-03-161-0/+10
| | | | | Introduce a first mechanism to trigger compilation when lex elc files are loaded. This is off by default and has to be better tested.
* Hash eln ABI once and add it to the output compilation pathAndreaCorallo2020-03-031-0/+4
|
* Store optimize qualities into .eln filesAndreaCorallo2020-02-261-0/+1
| | | | For now just comp-speed and comp-debug are stored.
* Update copyright years plus two style nitsAndrea Corallo2020-02-161-1/+1
|
* Split relocated data into two separate arraysAndrea Corallo2020-01-121-0/+3
| | | | Rework the functionality of the previous commit to be more efficient.
* make standard emacs compilable againAndrea Corallo2020-01-011-2/+2
|
* never load a compilation unit without filling the func link tableAndrea Corallo2020-01-011-5/+0
|
* mitigate ifdef proliferationAndrea Corallo2020-01-011-0/+10
|
* add native compilation unit pdumper supportAndrea Corallo2020-01-011-1/+2
|
* some more pdumper integration supportAndrea Corallo2020-01-011-2/+4
|
* better printing for native compilation unitAndrea Corallo2020-01-011-1/+1
|
* rationalize load functionsAndrea Corallo2020-01-011-0/+2
|
* better compilation unit definitionAndrea Corallo2020-01-011-1/+2
|
* some rename on compilation unit structAndrea Corallo2020-01-011-6/+6
|
* initial gc supportAndrea Corallo2020-01-011-0/+1
|
* initial compilation unit as object addAndrea Corallo2020-01-011-0/+52