summaryrefslogtreecommitdiff
path: root/src/alloc.c
AgeCommit message (Collapse)Author
2014-07-11Implement memory-info for MS-DOS.Eli Zaretskii
src/dosfns.c (dos_memory_info): New function. src/dosfns.h (dos_memory_info): Add prototype. src/alloc.c (Fmemory_info) [MSDOS]: Call dos_memory_info. src/vm-limit.c (get_lim_data) [MSDOS]: Call dos_memory_info, instead of doing some of its job.
2014-07-10Implement memory-info for MS-Windows.Eli Zaretskii
src/w32.c (w32_memory_info): New function. src/w32.h (w32_memory_info): Prototype it. src/alloc.c (Fmemory_info) [WINDOWSNT]: Call it.
2014-07-10* configure.ac: Check whether sys/sysinfo.h providesDmitry Antipov
Linux 'sysinfo' function and 'struct sysinfo' type. * src/alloc.c (Fmemory_info): New function. * lisp/files.el (warn-maybe-out-of-memory): New function. (find-file-noselect): Use it.
2014-07-02Shrink Lisp_Sub_Char_Table by preferring C integers to Lisp_Objects.Dmitry Antipov
* lisp.h (struct Lisp_Sub_Char_Table): Use C integers for depth and min_char slots. Adjust comment. (enum char_table_specials): Rename from CHAR_TABLE_STANDARD_SLOTS. Add SUB_CHAR_TABLE_OFFSET member. (make_uninit_sub_char_table): New function. * alloc.c (mark_char_table): Add extra argument to denote char table subtype. Adjust to match new layout of sub char-table. (mark_object): Always mark sub char-tables with mark_char_table. * chartab.c (make_sub_char_table, copy_sub_char_table) (sub_char_table_ref, sub_char_table_ref_and_range, sub_char_table_set) (sub_char_table_set_range, optimize_sub_char_table, map_sub_char_table) (map_sub_char_table_for_charset, uniprop_table_uncompress): All related users changed. * lread.c (read1): Adjust to match new layout of sub char-table.
2014-06-14Merge from emacs-24; up to 2014-06-03T06:51:18Z!eliz@gnu.orgGlenn Morris
2014-06-13Attempt to fix bug #17771 with segfault if "C-h h" is interrupted.Eli Zaretskii
src/alloc.c (cleanup_vector): Don't dereference a font driver pointer if it is NULL.
2014-06-11Spelling fix.Paul Eggert
2014-06-09Further adjustments to mark_object and friends.Dmitry Antipov
Now the mark_object's stack is just 32 bytes on a 64-bit system, which means extra 20% off the stack usage. * alloc.c (mark_save_value): As before, refactored out from ... (mark_object): ... adjusted user. Also add comment.
2014-06-08Change object marking routines to minimize stack usage.Dmitry Antipov
This change moves a few cold paths from mark_object to NO_INLINE functions and adjusts symbol marking loop. According to GCC 4.8.2 -Wstack-usage, this reduces mark_object's stack usage from 80 to 48 bytes on a 64-bit system. For a long byte-force-recompile runs, stack usage at the mark phase is reduced up to 28%. Surprisingly, it also gains up to 3% in speed (with default '-O2 -g3' flags). * alloc.c (mark_compiled, mark_localized_symbol): New functions, refactored out from ... (mark_object): ... adjusted user. Also mark symbols in a tight inner loop. (mark_face_cache): Add NO_INLINE.
2014-06-01Merge from emacs-24; up to 2014-05-29T17:16:00Z!dmantipov@yandex.ruGlenn Morris
2014-05-30Fix port to 32-bit AIX with xlc.Paul Eggert
This doesn't fix Bug#17598, but it does fix a regression since Emacs built with xlc until recently, and perhaps it'll help us fix Bug#17598. * configure.ac (GC_SETJMP_WORKS): Define for AIX, too. Merge from gnulib, incorporating: 2014-05-30 ftoastr: work around compiler bug in IBM xlc 12.1 * lib/ftoastr.c: Update from gnulib. * src/alloc.c (gdb_make_enums_visible): Remove FLOAT_TO_STRING_BUFSIZE. * src/conf_post.h (FLEXIBLE_ARRAY_MEMBER) [__IBMC__]: Don't define to empty. * src/lisp.h (FLOAT_TO_STRING_BUFSIZE): Make it a macro, instead of an enum, to work around a compiler bug in IBM xlc 12.1.
2014-05-30Debugging facility to check whether 'const char *' points toDmitry Antipov
relocatable data of non-pure Lisp string. * alloc.c (maybe_lisp_pointer): New function, refactored out of ... (mark_maybe_pointer): ... adjusted user. (relocatable_string_data_p): New function. * lisp.h (relocatable_string_data_p): Add prototype. * xdisp.c (message_with_string): If ENABLE_CHECKING, make sure the pointer to relocatable Lisp data is not used.
2014-05-29* alloc.c (Fgarbage_collect): Fix compilation withDmitry Antipov
GC_MARK_STACK == GC_USE_GCPROS_AS_BEFORE.
2014-05-24Avoid marking too deep portions of stack in mark_stack.Eli Zaretskii
src/alloc.c (garbage_collect_1): New function, with all of the guts of Fgarbage_collect. (mark_stack): Accept an argument END and don't mark Lisp objects on the stack beyond the address given by END. Calculation of END was moved to Fgarbage_collect. (Fgarbage_collect): Calculate the end address of the stack portion that needs to be examined by mark_stack, and pass that address to garbage_collect_1, which will pass it to mark_stack. See http://lists.gnu.org/archive/html/emacs-devel/2014-05/msg00270.html for more details about the underlying problems. In particular, this avoids dumping Emacs with the large hash-table whose value is held in purify-flag for most of the time loadup.el runs.
2014-05-19Allow any non-nil value to count as true in bool-vector.Paul Eggert
Likewise for xd_signature in dbusbind.c. This is more consistent with the usual practice in Emacs, which is that any non-nil value counts as true. * doc/lispref/sequences.texi (Bool-Vectors): Coalesce discussion of how to print them. bool-vector's args need not be t or nil. * src/alloc.c (Fbool_vector): Don't require args to be t or nil. * src/dbusbind.c (xd_signature): Likewise, for booleans. * src/data.c, lisp.h (Qbooleanp): * src/lisp.h (CHECK_BOOLEAN): Remove. All uses removed.
2014-05-19* src/lisp.h (CHECK_BOOLEAN): New function.Dmitry Antipov
* src/alloc.c (Fbool_vector): New function. (syms_of_alloc): Defsubr it. * src/data.c (Qbooleanp): New symbol. (syms_of_data): DEFSYM it. * src/dbusbind.c (xd_signature): Use CHECK_BOOLEAN. * doc/lispref/sequences.texi (Bool-vectors): Mention bool-vector.
2014-04-28Use bits_word for gcmarkbits.Paul Eggert
* alloc.c (struct cons_block, struct float_block): On 64-bit hosts, bits_word is typically a tad more efficient for mark bits than unsigned is, so use bits_word. All uses changed. * lisp.h (BITS_PER_INT): Remove; no longer used.
2014-04-27Avoid undefined behavior in signed left shift.Paul Eggert
This ports to GCC 4.9.0 with -fsanitize=undefined. * alloc.c (bool_vector_fill, SETMARKBIT, UNSETMARKBIT): * data.c (Fash): * regex.c (extract_number): * lisp.h (make_number, XINT): Do not shift a 1 bit left into a sign bit. * alloc.c (struct cons_block, struct float_block): Use unsigned, not int, for gcmarkbits. All uses changed.
2014-04-16Merge from emacs-24; up to 2014-04-16T15:28:26Z!monnier@iro.umontreal.caPaul Eggert
2014-04-16Remove DATA_SEG_BITS.Paul Eggert
The DATA_SEG_BITS hack was needed for older 32 bit platforms. As a result of this change, Emacs won't work on IRIX 6.5 with IRIX cc, but that platform is so old that SGI itself stopped supporting it in December 2013. If you still need Emacs on IRIX, please either compile with GCC and port the undumping code, or run './configure --with-wide-int'. * configure.ac (DATA_SEG_BITS): Remove. All uses removed. * src/alloc.c (gdb_make_enums_visible): Update to match lisp.h. * src/lisp.h (GCTYPEBITS): Move definition up, and switch to the DEFINE_GDB_SYMBOL_START way to define it. (NONPOINTER_BITS): New macro. (EMACS_INT): Use it. [!USE_LSB_TAG && !WIDE_EMACS_INT]: Fail, and suggest reporting the problem and/or configuring --with-wide-int. (USE_LSB_TAG): Simplify, based on above changes. (gdb_DATA_SEG_BITS): Remove. All uses removed. * src/vm-limit.c (exceeds_lisp_ptr): Remove. All uses removed.
2014-04-13Port to IRIX 6.5.Paul Eggert
This port requires IRIX cc, as I did not have time to get undump working with the old GCC on the system I had access to, but that's better than nothing. * configure.ac (gl_GCC_VERSION_IFELSE): Remove unused macro that wouldn't have worked anyway, with IRIX cc. (emacs_cv_clang, emacs_cv_sanitize_address) (ns_osx_have_104, ns_osx_have_105): Don't assume '#error' makes the compiler fail, as this doesn't work with IRIX cc. (CFLAGS, LIBS): Don't let the GnuTLS results infect later 'configure' checks. This runs afoul of an IRIX configuration where GnuTLS is in an optional library that also contains getdelim, and causes a later 'configure' to incorrectly think getdelim is supported. * src/alloc.c (TAGGABLE_NULL): New constant, for porting to hosts with nontrivial DATA_SEG_BITS settings. (next_vector, set_next_vector): Use it. * src/conf_post.h (INET6) [IRIX6_5]: Define. (HAVE_GETADDRINFO) [IRIX6_5]: Undef. * src/data.c (BITS_PER_ULL): Don't assume ULLONG_MAX is defined. * src/lisp.h (lisp_h_XPNTR): Don't OR in bits that aren't masked out, for consistency with how TAGGABLE_NULL is computed. Fixes: debbugs:9684
2014-04-08Correct mergeDaniel Colascione
2014-04-08More GC assertionsDaniel Colascione
2014-04-08Rearrange pointer loggingDaniel Colascione
2014-04-07Merge from emacs-24; up to 2014-04-01T20:18:12Z!eggert@cs.ucla.eduDaniel Colascione
2014-04-07* alloc.c: Simplify by removing use of HAVE_EXECINFO_H.Paul Eggert
We have a substitute execinfo.h on hosts that lack it. (suspicious_free_history): Make it EXTERNALLY_VISIBLE so it isn't optimized away.
2014-04-07* src/alloc.c: Keep track of symbols referenced from pure space (bug#17168).Stefan Monnier
(symbol_block_pinned): New var. (Fmake_symbol): Initialize `pinned'. (purecopy): New function, extracted from Fpurecopy. Mark symbols as pinned and signal an error for un-purifiable objects. (pure_cons): Use it. (Fpurecopy): Use it, except for objects that can't be purified. (mark_pinned_symbols): New function. (Fgarbage_collect): Use it. (gc_sweep): Remove hack made unnecessary. * src/lisp.h (struct Lisp_Symbol): New bitfield `pinned'.
2014-04-05Prefer 'ARRAYELTS (x)' to 'sizeof x / sizeof *x'.Paul Eggert
* alloc.c (memory_full): * charset.c (syms_of_charset): * doc.c (Fsnarf_documentation): * emacs.c (main): * font.c (BUILD_STYLE_TABLE): * keyboard.c (make_lispy_event): * profiler.c (setup_cpu_timer): * xgselect.c (xg_select): * xterm.c (record_event, STORE_KEYSYM_FOR_DEBUG): Use ARRAYELTS. * font.c (FONT_PROPERTY_TABLE_SIZE): Remove. Replace the only use with ARRAYELTS (font_property_table). * xfaces.c (DIM): Remove. All uses replaced by ARRAYELTS.
2014-04-03Rename EARRAYSIZE to ARRAYELTSDaniel Colascione
2014-04-03Assert that function cells contain valid lisp objectsDaniel Colascione
2014-04-03Rearrange suspicious pointer loggingDaniel Colascione
2014-04-02Fix typoDaniel Colascione
* alloc.c: Include execinfo.h if available. (SUSPICIOUS_OBJECT_CHECKING): New macro; define unconditionally. (suspicious_free_record): New structure. (suspicious_objects,suspicious_object_index) (suspicious_free_history, suspicious_free_history_index): New variables. (find_suspicious_object_in_range,detect_suspicious_free,Fsuspicious_object): New functions. (cleanup_vector): Call find_suspicious_object_in_range.
2014-04-02Add GC bug investigation codeDaniel Colascione
2014-03-23Clean up gc_sweepDaniel Colascione
2014-03-21Allow lisp allocation via mmap in dumped emacsDaniel Colascione
2014-03-20* src/frame.h (SET_FRAME_VISIBLE): Keep frame_garbaged up to date.Stefan Monnier
* src/xterm.c (handle_one_xevent) <MapNotify>: Don't garbage the frame. * src/frame.c (frame_garbaged): Make "docstring" more precise.
2014-02-28Fix a few crashes and leaks when cloning C strings.Paul Eggert
* alloc.c, lisp.h (dupstring): New function. * gtkutil.c (xg_get_font): * term.c (tty_default_color_capabilities): * xsettings.c (store_monospaced_changed) (store_font_name_changed, parse_settings) (read_and_apply_settings, init_gsettings, init_gconf): Use it. This avoids some unlikely crashes due to accessing freed storage, and avoids some minor memory leaks in the more-typical case.
2014-01-20Apply previous change even if valgrind is not in use, since it avoids ↵Paul Eggert
undefined behavior. This is simpler.
2014-01-20Pacify valgrind by initializing buffer redisplay bit.Paul Eggert
Problem reported by Dmitry Antipov in <http://lists.gnu.org/archive/html/emacs-devel/2014-01/msg01756.html>. * alloc.c (USE_VALGRIND): Move this to ... * conf_post.h (USE_VALGRIND): ... here. Use booleans. * buffer.c (Fget_buffer_create): Initialize redisplay bit to pacify valgrind.
2014-01-02Whitespace fixes for recently-added code.Paul Eggert
2014-01-01Update copyright year to 2014 by running admin/update-copyright.Paul Eggert
2013-12-26Fix core dumps with gcc -fsanitize=address and GNU/Linux.Paul Eggert
On my Fedora 19 platform the core dumps were so big that my desktop became nearly catatonic. * configure.ac: Check whether addresses are sanitized. (CANNOT_DUMP): Warn if addresses are sanitized and not CANNOT_DUMP. (DOUG_LEA_MALLOC): Do not define if addresses are sanitized. (SYSTEM_MALLOC): Define if addresses are sanitized. * src/alloc.c (no_sanitize_memcpy) [MAX_SAVE_STACK > 0]: New function. (Fgarbage_collect) [MAX_SAVE_STACK > 0]: Use it. (USE_ALIGNED_MALLOC): Do not define if addresses are sanitized. (mark_memory): Use ATTRIBUTE_NO_SANITIZE_ADDRESS rather than a clang-only syntax. * src/conf_post.h (__has_feature): New macro, if not already defined. (ADDRESS_SANITIZER, ADDRESS_SANITIZER_WORKAROUND) (ATTRIBUTE_NO_SANITIZE_ADDRESS): New macros.
2013-12-16* font.c (valid_font_driver) [ENABLE_CHECKING]: New functionDmitry Antipov
intended to find bogus pointers in font objects (Bug#16140). * font.h (valid_font_driver) [ENABLE_CHECKING]: Add prototype. * alloc.c (cleanup_vector): Use valid_font_driver in eassert. (compact_font_cache_entry, compact_font_caches) [!HAVE_NTGUI]: Disable for MS-Windows due to Bug#15876; apparently this requires more or less substantial changes in fontset code. * xfont.c (xfont_close): * xftfont.c (xftfont_close): Call x_display_info_for_display to check whether 'Display *' is valid (Bug#16093 and probably Bug#16069).
2013-12-14Revert 2 last commits in src/alloc.c.Eli Zaretskii
2013-12-14Minor tweak of the last commit.Eli Zaretskii
2013-12-14Avoid crashing due to closing of font whose driver pointer is NULL.Eli Zaretskii
src/alloc.c (cleanup_vector): Don't call the font driver's 'close' method if the 'driver' pointer is NULL.
2013-12-13* alloc.c, font.c, font.h, ftfont.c, ftxfont.c, macfont.m,Dmitry Antipov
* nsfont.m, w32font.c, xfont.c, xftfont.c: Revert last and 2013-12-12 font-related change to avoid Bug#16128, which is quite hard to fix without even more substantial changes.
2013-12-12* font.h (struct font_entity) [HAVE_NS]: New field to recordDmitry Antipov
font driver which was used to create this entity. (struct font) [HAVE_WINDOW_SYSTEM]: New field to record frame where the font was opened. (font_close_object): Add prototype. * font.c (font_make_entity) [HAVE_NS]: Zero out driver field. (font_close_object): Not static any more. Lost frame arg. Adjust comment and users. * alloc.c (cleanup_vector): Call font_close_object to adjust per-frame font counters correctly. If HAVE_NS, also call driver-specific cleanup for font-entity objects. * ftfont.c (ftfont_open): * nsfont.m (nsfont_open): * w32font.c (w32font_open_internal): * xfont.c (xfont_open): * xftfont.c (xftfont_open): Save frame pointer in font object. * macfont.m (macfont_open): Likewise. (macfont_descriptor_entity): Save driver pointer to be able to call its free_entity routine when font-entity is swept. * ftxfont.c (ftxfont_open): Add eassert because frame pointer should be saved by ftfont_driver.open.
2013-12-09* alloc.c (Fmemory_limit): Avoid compiler warning. Return 0 always.Jan Djärv
2013-12-01Spelling and punctuation fixes.Paul Eggert