Commit graph

39 commits

Author SHA1 Message Date
Douglas Katzman a068699d26 Get rid of src/runtime/sbcl.h
Can't see any value in having a 'make' recipe for it.
2023-11-02 20:50:29 -04:00
Douglas Katzman 40276b2537 Complete merge of mark-region-gc
Put "--without-gencgc --with-mark-region-gc" in the make.sh invocation
to enable it (which automatically disables immobile space for now).
There are some known test failures.

Big thanks to Hayley Patton for this.
2023-08-09 22:20:11 -04:00
Douglas Katzman 60841929fe Remove and/or rename a lot of #+gencgc
The C runtime will soon need to support the new mark-region collector which
is generational in nature with the identical heap structure as gencgc.
For clarity's sake, :GENCGC will refer to the specific implementation
contained in the file gencgc.c, whereas :GENERATIONAL shall imply either
gencgc or :MARK-REGION-GC without having to spell the (OR ...) everywhere.
The new feature name is not perfect- there could exist an incompatible
generational GC. Deal with that later, if ever.

That said, a few techniques were used in changing featureization:
- If it was code we would like to work on any GC, then delete the conditional.
  Later, conditional code could be re-added if something can't be made to work
  for whatever different GC is implemented.
- If it was something such as GENERATION-OF we'd like to remember not to allow
  to be called with a non-generational collector, add #+generational.
- If something was #-gencgc but meant "#+cheneygc" then either change to that
  or delete the code. Retained dead code is a hint to where subsequent changes
  might be required if not obvious, for example the compiler's decision about
  L-T-V and value-cells. Absence of a feature marker could leave you wondering.
- No machine-dependent files were touched, as the mark-region collector
  will support only x86-64 at present.

(I don't always write long commit messages, but when I do, they concern
multiple work-in-progress GC implementations.)
2023-08-09 11:17:20 -04:00
Douglas Katzman 6384c14f9d Stuff all gc-related headers into gc.h
Client code should henceforth include gc.h and nothing but that,
and in turn, gc.h will include a GC implementation header.
That was the idea from the beginning, by separating gencgc-internal
from cheneygc-internal, except it never worked. Now that cheneygc
is gone we can do a re-design this for the mark-region GC.

Also this change requires that includers of of gc.h understand their own
_direct_ dependencies. So for example it is not correct to assume that gc.h
provides fun_code_header(). It might but only if pinned_p uses that.
Similarly, grovel-headers.c did not directly include any header providing
os_vm_size_t. (clang-tidy is quite upset by the amount of accidental
reliance on indirectly included things in our sources)
2023-08-07 11:19:30 -04:00
Douglas Katzman 9da8dca80f Remove some junk from gc-internal
* Move a few thread-related prototypes to thread.h
* Removing thread.h exposed the fact that a lot of C files
  did not directly include things they needed such as vector_len
* Delete stray copy of 2 duplicated prototypes
  and nonexistent instance_scan declaration
2023-08-07 01:14:38 -04:00
Douglas Katzman a88b8baf7f Move a bunch of preprocessor macros out of gc headers
The goal is to have good separation between macros that deal with object
representation versus the allocator/collector and other random logic.
Previous attempts have been a total failure, considering that there are
nearly 30 files that include gc-private.h. By starting over with the
manipulators of the object model, it should be possible to arrive at a
healthier state with respect to changing out the GC.
2023-08-01 15:48:08 -04:00
Douglas Katzman 6177fcb8ab Combine 3 autogenerated headers
{layout,instance,funcallable-instance} all become part of "instance.h".
Also autgenerate the #defines for known layout IDs.

This will, after subsequent changes, allow putting the layout_of() macro
and other things in that file to improve type-safety and/or clean up the
random mess of logic in gc-*.h headers.
2023-08-01 12:26:23 -04:00
Douglas Katzman e8c69d80c0 Do what the comment in runtime.h says
namely: "... get rid of our own boolean type"
2023-07-11 10:36:56 -04:00
Douglas Katzman f8b0bd0a3d Reduce conditionalization on COMPACT_SYMBOL 2022-09-18 20:06:56 -04:00
Douglas Katzman ede9b6ffb0 Weed out more chaff from win32 headers
macros that conflict with the real pthread headers? Just why.
Tested on 64-bit only.
2022-09-15 20:45:40 -04:00
Douglas Katzman 46b0178450 Do an old FIXME from initial commit
I have to say, it makes grepping for T feasible.
2022-09-15 20:24:58 -04:00
Douglas Katzman 76a3c72f7d Use leaf_obj_widetag_p more 2022-08-02 15:52:26 -04:00
Douglas Katzman 894b122af7 Rename varyobj space to text space
because it becomes the ".text" section of an ELF core.
And rename free_pointer to highwatermark (like dynamic_space).
2022-07-30 16:12:23 -04:00
Douglas Katzman 7e7977abc6 Fix newly introduced bug from 3fc0fa3df0
* Don't assume that index 2 in 'adj' is for varyobj space
* Or that PIE ELF cores are ever going to work
* Or that readonly space can be accessed past its free pointer
2022-07-16 16:08:33 -04:00
Douglas Katzman 8b75a8b959 Remove get_alloc_pointer()
alloc_pointer as a concept might have made sense for cheneygc, where it is the
address at which to next allocate. But gencgc has only a high water mark which
the "allocation pointer" would certainly be strictly less than.
And dynamic_space_free_pointer itself is redundant, so remove that too.
2022-03-04 15:48:51 -05:00
Douglas Katzman 176f8f4c15 Renumber some widetags
So that "(widetag | 4) == FUNCALLABLE_INSTANCE_WIDETAG" is true
for both INSTANCE and FUNCALLABLE-INSTANCE.
2022-01-12 17:34:39 -05:00
Stas Boukarev a7ba4199c4 Coalesce static symbol names on win32 as well. 2021-12-16 20:50:04 +03:00
Stas Boukarev c2dbd855c5 Fix build for some C compilers.
They don't like variable declaration right after case x:
2021-12-16 13:03:13 +03:00
Douglas Katzman 48260c38a5 Fix regression in coalescing SYMBOL-NAME 2021-12-15 22:25:37 -05:00
Douglas Katzman 502561de81 Fix long-standing bug in re-applying write-protect status
This logic has always been both suboptimal and wrong, potentially erring
in either direction: not WPing when it could, and WPing when it mustn't.
Only the latter is an actual bug, and nearly impossible to observe.

One bug was already documented as pertains to FDEFNs. This seems never
to happen, so I'm leaving it alone for now. The observable bug was with
lockfree lists where an element is pending pending physical deletion
after being logically deleted, with GC occurring in between those steps.

The suboptimalities are several (but I'm not fixing them all):
- deposit_filler() does not zeroize words that were formerly occupied
  by an object that was evacuated from the partially pinned pages.
  There were frequently random pointers to lower-generation pages.
- unboxed objects may reside on boxed pages if we were unable to move
  them because of pinning, so we'd treat raw bits as pointers. Whether
  they look like pointers is about as rare as the situation that a stack
  word falsely looks like a pointer, but it's easy enough to skip over
  unboxed objects, same as with filler objects.
- mixed raw/boxed instances should use the bitmap.  It's unclear whether
  doing so would be faster. Treating every word as a pointer is fine
  but continues to be slightly suboptimal.
2021-11-15 16:27:20 -05:00
Stas Boukarev 020eda7f05 Make array-rank and array-flags swappable.
If array-rank is contiguous with the widetag bits then it can be
tested in one instruction.
2021-11-03 19:47:47 +03:00
Douglas Katzman f3752937ec Don't crash if coalesce sees an off-heap pointer 2021-05-10 19:46:34 -04:00
Douglas Katzman 406dbd9aea Fix poor abstractions in C
* Far too many calls to fixnum_value() were to extract VECTOR-LENGTH,
  and in simple_base_stringize() it wasn't called, which was a minor bug
  that resulted in calling malloc() with too large a number.

* Don't constrain C to using unclear terminology: 'scav_vector' is a
  a bad name for 'scav_vector_t'. And I dislike simple_vector, which
  seems as if it means (AND VECTOR SIMPLE-ARRAY). ANSI could have
  picked SIMPLE-T-VECTOR or SIMPLE-VECTOR-T for SIMPLE-VECTOR.
2021-05-07 17:38:19 -04:00
Douglas Katzman 5496e92a00 Move layout bitmap to trailing raw slots of layout
Most places that read the bitmap have an easier time with it now, including
heap relocation and elfination. The 'embiggen' test (which was broken) is
no longer pertinent since there are no external bignums to consider.
2020-10-19 02:01:35 -04:00
Douglas Katzman ae857422e7 Refactor layout bitmap bit extractor
There are two ways of iterating over descriptor slots in C, either a test
of "logbitp" at each word index, or the special code in scav_instance() which
avoids a div and mod operations at each step. But the logbitp approach had to
decide at each iteration whether the bitmask was a fixnum or a bignum.
This change removes that decision by canonicalizing the bitmask once up front,
and further anticipates a change in which the bitmask is moved to the end
of the layout so that we never have to chase a pointer outside of the layout
to utilize the layout, which results in generally more understandable C code.

In fact, I don't see how the assertion about a bignum for the bitmask in
coreparse heap relocation was correct, because it used layout->bitmap
without adjustment. But then it used the adjusted value when iterating.
So the code was right, but the assertion probably would fail.
That's one example of why an external bignum is problematic.
2020-10-17 17:36:18 -04:00
Douglas Katzman 532b885acb Optimize instance layout bitmaps
* Flag the layout as a raw slot in the bitmap. Tracing an instance will
  always examine the layout as a one-off before proceeding to the data slots.
  This ensures that we don't accidentally visit a tagged slot twice in
  situations where it matters (heap relocation, for one).

* If all words are raw or all fixnums (or characters), nothing needs
  examining. The bitmap reduces to 0 which is an early exit.

* It becomes more feasible to unify much of the handling of ordinary
  instances and funcallable-instances.
2020-10-10 15:12:10 -04:00
Douglas Katzman 154f8fbcc1 Add constant for the base of user-visible static-space objects
Skip over the unboxed array in which 'struct alloc_region' is embedded.
I suspect that the array header is not needed now after this.
2020-06-19 13:34:39 -04:00
Douglas Katzman 141d30298b Change most uses of is_cons_half() to the opposite: is_header()
is_header() is a table lookup with no conditional branching
and works in all situations except conservative stack scan.
2020-06-01 16:56:56 -04:00
Douglas Katzman 5d937d6633 Rename and rearrange pseudo-atomic.h
The pseudo-atomic header was more often #included for get_alloc_pointer() than
the p-a accessors,so rename it to 'getallocptr.h', but keep the accessor for
thread->pseudo_atomic_bits in a header that is still named 'pseudo-atomic.h'.

Factor the three major variations into different files. Prior to this change,
too much thinking was needed to figure out which bundle of #defines and #ifs
were applicable to a particular arch x {cheneygc,gencgc} x {+thread,-thread}.
2020-03-10 07:47:21 -04:00
Douglas Katzman 7affbfd41b Restore cheneygc for arm and arm64
{arm,arm64} + cheney stopped working ever since gencgc was
implemented for the respective architecture.
The repairs were basically the same for either, but 32-bit crashes now
with cheneygc selected. That's better than not compiling at all,
but I'll probably disable that combination of build flags if a fix
isn't readily forthcoming.
2020-03-09 00:23:46 -04:00
Douglas Katzman 9f372c852f Add an optional heap inspection on image startup 2019-05-31 12:46:11 -04:00
Douglas Katzman bf8dc6dc4d Remove descriptor constants from simple-fun objects
Store NAME, ARGLIST, FORM/DOC/XREFS, and TYPE in the boxed portion of
the code header. This is easier on C code that scans lisp code for pointers.

I plan to implement a slightly quicker way of determining where each
simple-fun has its boxed words stored by robbing some bits from the fun->code
backpointer, but that's just an optimization and not critical to this change.
2019-05-28 17:36:06 -04:00
Douglas Katzman 8243cffe3b Rename unboxed_obj_widetag_p() to leaf_obj_widetag_p() 2019-05-21 18:24:34 -04:00
Douglas Katzman 538269a072 Add C accessors for computing code object size and text start
This will be necessary for a couple reasons-
* It might be possible for an ELF text section to contain _strictly_ machine
  code, with the code header and simple-funs located in dynamic space.
  If done that way, with text (instructions) disembodied from the header,
  we can't assume that instructions commence at code + header_size.

* To make heap scanning with concurrent creation of code more robust,
  it can't require two memory loads to compute the size of an object.
  The first word should convey the full object size, and the dividing line
  between boxed/unboxed can be indicated by a different word for GC's use.
  It's almost the same issue as atomically inserting into a linked list.
2018-12-06 16:26:52 -05:00
Douglas Katzman 7a2da2652d Fix some gencgc issues and improve comments
* Move more work from preserve_pointer() into pin_object().
  The rationale for doing more in pin_object is that it becomes feasible to
  implement a specific use-case of precise pinning with otherwise conservative
  GC. preserve_pointer() is the interface given a word that may or may not be
  a pointer, and pin_object() is the interface for known good pointers.
  This also corrects a newly introduced bug in precise GC where 'descriptor'
  wasn't getting recomputed if the object's widetag was RETURN_PC or SIMPLE_FUN.
  Conservative GC was fine because scanning the heap for a containing object
  will never find a simple-fun.

* update_code_writeprotection() caused invariant violations if compiled
  without page protection, because no pages should ever be protected.

* There's no reason to bifurcate the instance_length() function.

* Explain the role of the "transother" functions.

* Mention that object coalescing should probably not accidentally
  create hash-table keys that become EQ if the value are different.
2018-11-18 16:16:03 -05:00
Douglas Katzman ebdb9ef98a Make widetag_of() in C act more like SB-KERNEL:WIDETAG-OF
Take an untagged pointer to an object instead of the object header word.
Use header_widetag(word) to extract a widetag from a header word.
2018-08-30 21:46:00 -04:00
Douglas Katzman 0257865975 Improve sb-introspect::map-roots
Bugs fixed:
 - It took care to not do anything on some pointerless objects,
   but erred on a character for no good reason.
 - Due to a typo, it failed to extract both parts of a complex number.
 - It failed to see funcallable-instance-layout if #+compact-instance-header,
   and %code-fixups (which could be the bignum or droid you're looking for).

Express the whole thing in terms of a skeletal object traversal macro
into which you can plug small customizations. Share that with
SB-VM::MAP-REFERENCING-OBJECTS, and use only GC-safe accessors, not SAPs.
2018-05-09 20:40:56 -04:00
Douglas Katzman 649d404d0c Support relocatable heap for cheneygc
* It is neither required nor permitted to specify two sets
  of dynamic space addresses in the 'parms' files

* Whatever address the core file specifies as the dynamic space
  becomes dynamic-0-space. The other semispace is placed anywhere.

* Conditionalization could almost be removed except for win32
2018-02-02 00:54:07 -05:00
Douglas Katzman ba1ef2d44a Enable coalesce_similar_objects() for cheneygc
And a bit of necessary refactoring.

Saves ~2MB in the pristine core on ppc+cheneygc
2018-02-01 15:49:13 -05:00