More compact (format nil "~a" ...)
[sbcl.git] / doc / internals-notes / GENCGC-PORTING-NOTES
blob07a5d1dadb235ae915ddfce6dbc3b9fe448bc002
2 ====================================================
3 OPEN GENGC BUGS
4 ====================================================
6 7. OPEN. This isn't really a GENGC bug, but, for completeness, we
7    should fix ppc-vm.lisp so that the fixup can take an offset a la
8    x86-64. This was done in generic.lisp, but needs corresponding
9    changes in pcc-vm.lisp
11 ====================================================
12 CLOSED GENGC BUGS
13 ====================================================
15 1. FIXED. Occasional inline allocation failures? I'm guessing that's
16    what we're seeing here. Certain operations take a long time and
17    involve a lot kernel_task CPU activity. It's possible that this is
18    just I/O, but I don't think so. This seems to have gotten worse
19    recently. Changing the allocation macro to not use a fixup with an
20    offset fixes this.
22 2. FIXED. Purify fails. Running the core-test.sh test causes a BUS
23    ERROR. The problem was that calling alien-callbacks loaded from a
24    saved core was failing. See note in
25    c-call.lisp/alien-assembler-callback-wrapper for details.
27 3. FIXED! cons-madly test (gc.impure.lisp) fails and
28    drops into LDB. My hunch is that this is related to the
29    allocation/moving of large objects in gencgc.c.
31 4. FIXED. PPC/Linux gencgc fails with a BUS ERROR (SIGSEGV maybe?)
32    after the first GC.
34 5. FIXED. sb-md5 and cltl2 often (but not always) fail to build out of
35    contrib. Latest gencgc fixes seem to have fixed this. Keep an eye
36    out for it though. I think the allocation macro fixup changes fixed
37    this one.
39 6. FIXED. finalize-test.sh fails. finalizers weren't being run
40    properly. removed #ifdef LISP_FEATURE_X86[_64] in
41    gencgc.c/scav_weak_pointer and now things seem to work.
43 8. NOT A BUG. In insts.lisp, we do a lis/addi to load the address of a
44    fixup. This should really be lis/ori, but the ori instruction
45    doesn't deal with fixups. This should be fixed, but doesn't seem to
46    be rearing its ugly head at the moment. This is wrong. The fixup
47    deals with adjusting the high word such that the the lis/addi
48    sequence functions correctly here.
50 9. FIXED. x86-64 builds busted. they build ok, but then can't do a
51    full rebuild of themselves. They die after the first purify.
52    GENCGC_RUNS_1 works, GENCGC_CANDIDATE_1 breaks. Wrongly #ifdef'ed
53    out an os_zero call in purify.c. Restoring this fixes things.
57 ====================================================
58 CVS tag: ALLOCATION_CLEANUP_1
59 ====================================================
61 File: src/assembly/ppc/arith.lisp
62 ================
64 * Fixed allocation for CONS-BIGNUM. Note that we now always cons 2 words
65   instead of trying to fit into 1 word first
67 File: src/compiler/ppc/alloc.lisp
68 ================
70 * Fixed vop for list-or-list*. Uses the allocation macro instead of
71   setting alloc-tn directly. Note that the (relatively) recent dynamic
72   extent support should still work here. In this case, we directly
73   allocate this by adjusting csp-tn.
75 * Fixed vop for make-closure. See note above. Dynamic extent should
76   still work.
78 * TODO: [FUTURE] add stack allocation to the allocate macro.
80 File: src/compiler/ppc/macros.lisp
82 * Added allocation macro. Note that this is using king nato's version
83   and may not do everything we need to do for GENCGC.
85 * with-fixed-allocation changes. Now takes a keyword argument (:lowtag
86   other-pointer-lowtag). Removed restriction on having a non-empty
87   body as we can use this macro just for allocating data. Now uses the
88   allocation macro instead of adjusting alloc-tn directly.
90 * Removed the :extra keyword argument from pseudo-atomic. Don't use
91   this for allocating memory anymore! Removed the corresponding gensym
92   and let. This is still King Nato's pseudo-atomic. At some point we
93   should better understand the differences between rtoy's version and
94   king nato's version.
97 File: move.lisp
98 ===============
100 * move-from-unsigned vop now uses with-fixed allocation instead of
101   setting alloc-tn directly. We always allocate two words now instead
102   of trying to get away with one first.
105 ====================================================
106 CVS tag: ALLOCATION_CLEANUP_2
107 ====================================================
109 File: src/assembly/ppc/array.lisp
110 =============================
112 * Fixed allocate-vector assembly-routine to use allocate macro instead
113   of adjusting alloc-tn directly.
115 File: src/compiler/ppc/array.lisp
116 =============================
118 * make-array-header vop now uses allocation macro instead of setting
119   alloc-tn directly
121 File: src/compiler/ppc/call.lisp
122 ============================
124 * listify-rest-args now uses the allocation macro instead of adjusting
125   alloc-tn directly.  For dynamic extent args, we still allocate
126   directly by adjusting csp-tn. We should implement stack allocation
127   in the allocation macro.
130 ====================================================
131 CVS tag: BUILD_CLEANUP_1
132 ====================================================
134 File: src/code/ppc-vm.lisp
136 * Add flag disabling scavenging of read-only space (to be used later)
138 File: src/compiler/ppc/parms.lisp
140 * Add gencgc-page-bytes variable. Currently 4096. Bump to 32k later.
142 * Added dynamic-space-start and dynamic-space-end constants for linux
143   and darwin #!+gencgc. Conditionalized dynamic-0 and dynamic-1
144   constants for#!-gencgc.
146 * Added *restart-lisp-function*, *current-region-end-addr* and
147   *scavenge-read-only-space* static-symbols.
149 File: src/runtime/Config.ppc-darwin
151 * Make GC_SRC shell commands that search for LISP_FEATURE_GENCGC in
152   genesis/config.h and set GC_SRC to gencgc.c or cheneygc.c as
153   appropriate
155 File: src/runtime/Config.ppc-linux
157 * Make GC_SRC shell commands that search for LISP_FEATURE_GENCGC in
158   genesis/config.h and set GC_SRC to gencgc.c or cheneygc.c as
159   appropriate
161 ====================================================
162 CVS tag: GENCGC_PREP_1
163 ====================================================
165 File: src/runtime/arch.h
167 * Moved extern fpu_save and fpu_restore defintions here
169 File: src/runtime/cheneygc.c
171 * removed static scavenge_interrupt_contexts prototype
173 File: gc-common.c
175 * Instead of #ifndef LISP_FEATURE_SPARC for scav_fdefn, use
176   defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
178 * Instead of #ifndef LISP_FEATURE_GENCGC for scav_fun_header and
179   scav_return_pc_header scavtab entries, use #if
180   !defined(LISP_FEATURE_X86) && !defined(LISP_FEATURE_X86_64)
182 * set scav_tab[FDEFN_WIDETAG] to scav_fdefn on X86 and X86_64 and
183   scav_boxed for everything else.
185 File: gc-internal.h
187 * added prototype for scavenge_interrupt_contexts
189 ====================================================
190 CVS tag: GENCGC_PREP_2
191 ====================================================
193 File: gc-common.c
195 * Reverted gc-common.c changes from GENCGC_PREP_1. The problem was
196   that I was mimicing rtoy's FDEFN changes for PPC, superficially,
197   without changing the underlying code. He changed the way fdefn's
198   work on ppc to look more like they do on SPARC. I think we can get
199   away with leaving this alone, at least for now.
201 File: ppc-arch.c
203 * Moved PSEUDO_ATOMIC_INTERRUPTED_BIAS to ppc-arch.h
205 File: ppc-arch.h
207 * Moved PSEUDO_ATOMIC_INTERRUPTED_BIAS to ppc-arch.h
209 File: ppc-assem.S
211 * Added do_pending_interrupt, fpu_save and fpu_restore.
213 File: ppc-darwin-spacelist.h
215 * Adjust spaces for #+gencgc and #-gencgc
217 File: purify.c
219 * #ifdef LISP_FEATURE_GENCGC -> X86{_64}
221 File: gencgc.c
223 * Remove fpu_save and fpu_restore prototypes
225 ====================================================
226 CVS tag: GENCGC_PREP_3
227 ====================================================
229 File: src/runtime/gc.h
231 * Added xxx_pseudo_atomic_xxx and xxx_alloc_pointer #defines
233 File: src/runtime/alloc.c
235 * Start using xxx_pseudo_atomic_xxx
237 ====================================================
238 CVS tag: GENCGC_PREP_4
239 ====================================================
241 File: src/runtime/globals.c
243 * Cleaning up GENCGC/X86[_64] ifdefs
245 File: src/runtime/globals.h
247 * Cleaning up GENCGC/X86[_64] ifdefs
249 File: src/runtime/parse.c
251 * Use get_alloc_pointer instead of arch specific ways of doing so
253 ====================================================
254 CVS tag: PSEUDO_ATOMIC_REG_ALLOC
255 ====================================================
257 File: compiler/ppc/macros.lisp
259 * Pseudo-atomic now uses bits 3 and 1 of reg_ALLOC insetead of using
260   reg_NL3 for the interrutped part.
262 File: src/runtime/gc.h
264 * Pseudo-atomic now uses bits 3 and 1 of reg_ALLOC insetead of using
265   reg_NL3 for the interrutped part.
267 File: src/runtime/ppc-arch.c
269 * Pseudo-atomic now uses bits 3 and 1 of reg_ALLOC insetead of using
270   reg_NL3 for the interrutped part.
272 * Brought the allocation trap stuff along, but this is untested.
274 File: src/runtime/ppc-assem.S
276 * Pseudo-atomic now uses bits 3 and 1 of reg_ALLOC insetead of using
277   reg_NL3 for the interrutped part.
279 ====================================================
280 CVS tag: GENCGC_BUILDS_1
281 ====================================================
283 File: src/runtime/gencgc.c
285 * The big kahuna...
287 * Ok, lots of little changes to get things working. Had to fix up the
288   allocation macro, the uses of it, etc... 
291 ====================================================
292 CVS tag: GENCGC_RUNS_1
293 ====================================================
295 * Ok, it runs now, but we seem to trap on every allocation. Trying to
296   figure out why. Works -gencgc/ppc and works on x86-64.
298 ====================================================
299 CVS tag: GENCGC_RUNS_INLINE_ALLOCATION_1
300 ====================================================
302 File: src/compiler/generic/genesis.lisp
304 * do-cold-fixup now looks at the SI portion of PPC instructions in :ha
305   and :l fixups and uses these as offsets in calculating the address.
307 File: src/compiler/ppc/insts.lisp
309 * in define-d-si-instruction we now stick the fikup-offset into the si
310   portion of the opcode instead of always using 0. This allows us to
311   pass this information on to do-cold-fixup in genesis.lisp.
313 File: src/compiler/ppc/macros.lisp
315 * gencgc allocation macro now uses fixups to boxed_region.free_pointer
316   and boxed_region.end_addr to get these values instead of pulling
317   them out of registers. This removes the need to keep these registers
318   in sync with the C struct values. And it is more like what we will
319   eventually need to do if we ever do PPC threads.
321 File: src/runtime/gc.h
323 * removed set_current_region_free, get_current_free, and
324   set_current_region_end.
326 File: src/runtime/gencgc.c
328 * In gc_alloc_new_region, use page_address(last_page) + PAGE_BYTES to
329   get the end_addr instead of start_addr + bytes_found.
331 * removed set_current_region_end calls.
333 File: src/runtime/ppc-arch.c
335 * include gencgc-alloc-region.h
337 * look back 3 instructions instead of 2 to match the new allocation
338   macro
340 * added end_addr variable for debugging.
342 * no longer adjust dynamic_space_free_pointer
344 ====================================================
345 CVS TAG: GENCGC_MOSTLY_WORKING_1
346 ====================================================
348 * Making purify and loading callbacks from cores work for ppc/gengc.
350 * Remove *scavenge-read-only-space*
352 File: src/compiler/ppc/c-call.lisp
354 * Fixed alien-callback-assembler-wrapper to get the address for
355   enter-alien-callback from the symbol-value slot of
356   SB-ALIEN::*ENTER-ALIEN-CALLBACK* to ensure that this works even if
357   the GC moves ENTER-ALIEN-CALLBACK. Thanks to JES for the suggestion
358   on the fix. callback.impure.lisp now passes.
360 File: src/runtime/gencgc.c
362 * Removed #ifdef LISP_FEATURE_X86[_64] in
363   gengcc.c/scav_weak_pointer. Definitely some OOAO violations here,
364   but now finalize.test.sh passes.
366 ====================================================
367 CVS TAG: GENCGC_MOSTLY_WORKING_2
368 ====================================================
370 * New allocation macro. Seems to make things better.
372 ====================================================
373 CVS TAG: GENCGC_MOSTLY_WORKING_3
374 ====================================================
376 * Trying to undo damage done along the way. Lots of little
377   changes. Please document these in the morning.
379 ====================================================
380 CVS TAG: This stuff never got tagged. I backed it out before I tagged
381          it.
382 ====================================================
384 * Added ARCH_HAS_CTR_REGISTER and friends. Now we fixup the CTR in
385   scavenge_interrupt_context. Whoops. Backed this out as it seemed to
386   be messing things up.
388 ====================================================
389 CVS TAG: GENCGC_ALL_TESTS_PASSED
390 ====================================================
392 File: src/runtime/gc.h
394 * set_alloc_pointer now just sets the high bits and leaves the p-a
395   flags alone.
397 File: src/runtime/interrupt.c
399 * interrupt_handle_pending clears the p-a-interrupted flag
401 * undo_fake_foreign_function_call doesn't zap the p-a bits in
402   reg_ALLOC
404 File: src/runtime/ppc-arch.c
406 * handle_allocation_trap doesn't zap the p-a bits in reg_ALLOC
408 ====================================================
409 CVS TAG: GENCGC_ALL_0_9_9_27_MERGE
410 ====================================================
412 * Forward ported to 0.9.9.27
414 ====================================================
415 CVS TAG: GENCGC_CANDIDATE_1
416 ====================================================
418 File: src/runtime/ppc-assem.S
420 * Massive props to Xophe for finding this. For a long time now, we had
421   been using lis, addi to load the address of NIL. Turns out this
422   fails when the high bit of the low word is set. I have no idea how
423   we missed this for so long, but changing the instruction sequence to
424   lis, ori fixes the problem of linux/ppc gencgc not working.
426 File: src/runtime/ppc-arch.c
428 * Turn off the address checking in arch_get_bad_addr. The pointer
429   arithmetic was wrong and was causing problems. We don't really need
430   this check (right?).
432 File: src/code/toplevel.lisp
434 * Fix the way we compute the end-of-stack in scrub-control-stack.
436 File: src/runtime/bsd-os.c
438 * Use arch_get_bad_addr to get fault address
440 ====================================================
441 CVS TAG: GENCGC_SBCL_0_9_9_34_MERGE
442 ====================================================
444 * Forward ported to 0.9.9.34
446 ====================================================
447 CVS TAG: GENCGC_CANDIDATE_2
448 ====================================================
450 File: src/compiler/ppc/macros.lisp
452 * cleaned up comments for allocation macro
454 * removed commented code that used to throw an error for empty
455   allocation macro body. Now we call this for its side effect of
456   allocating memory
458 File: src/compiler/ppc/parms.lisp
460 * gencgc-page-bytes -> 4096
462 * added pseudo-atomic-interrupted-flag and pseudo-atomic-flag
464 File: src/runtime/alloc.c
466 * clr_pseudo_atomic -> clear_pseudo_atomic
468 File: src/runtime/gc.h
470 * clr_pseudo_atomic -> clear_pseudo_atomic
472 * PSEUDO_ATOMIC_[INTERRUPTED_]VALUE -> flag_PseudoAtomic[Interrupted]
474 File: src/runtime/interrupt.c
476 * clr_pseudo_atomic -> clear_pseudo_atomic
478 File: src/runtime/ppc-arch.c
480 * whitespace fix
482 File: package-data-list.lisp-expr
484 * added PSEUDO-ATOMIC-INTERRUPTED-FLAG and PSEUDO-ATOMIC-FLAG to sb-vm
485   exports
487 ====================================================
488 CVS TAG: GENCGC_SBCL_0_9_9_35_MERGE
489 ====================================================
491 * Forward parted to 0.9.9.35
493 ====================================================
494 CVS TAG: GENCGC_CANDIDATE_3
495 ====================================================
497 NOTE: This includes the fix for the problem where x86-64 couldn't
498 build itself. I erroneously removed an os_zero in purify.c. This has
499 been restored.
501 File: src/runtime/purify.c
503 * remove ifndef GENCGC check around os_zero call
504 * undo recent change to add back in a bit setting the
505   dynamic_space_free_pointer on x86[_64]. I don't think we need this
507 File: src/runtime/parse.c
509 * dunamic_space_free_ptr -> dynamic_space_free_pointer
511 File: src/runtime/ppc-arch.c
513 * Fixing comment text in allocation_trap_p
514 * arch_clr_pseudo_atomic_interrupted ->
515     arch_clear_pseudo_atomic_interrupted
517 File: src/runtime/gc-common.c
519 * restore workaround behvaior for !GENCGC, not !X86[_64]
521 * whitespace fix
523 File :src/runtime/gencgc.c
525 * undoing gratuitous spacing changes and fixing whitespace
526 * remove bogus comment
528 ====================================================
529 CVS TAG: GENCGC_CANDIDATE_4
530 ====================================================
532 File: src/runtime/purify.c
534 * Use dynamic_space_purify_pointer instead of
535   dynamic_space_free_pointer to mark the end of the dynamic_space
536   that we purify
537 * call gc_free_heap in purify when using GENCGC
539 File: src/runtime/interrupt.c
541 clear_psuedo_atomic_interrupted -> arch_clear_pseudo_atomic_interrupted
543 ====================================================
544 CVS TAG: GENCGC_CANDIDATE_5
545 ** Note: not tagged, but patch made
546 ====================================================
548 File: src/runtime/assembly/ppc/array.lisp
550 * cleaning up comment
552 File: src/code/ppc-vm.lisp
554 * removed unused commented-out chunk
556 File: src/compiler/generic/genesis.lisp
558 * Added FIXME about ppc offset fixups only being half-done
560 File: src/compiler/ppc/c-call.lisp
562 * Comment cleanup
564 File: src/compiler/ppc/macros.lisp
566 * Allocation macro comment cleanup
568 File: src/runtime/gc.h
570 * Whitespace
572 * #ifdef GENCGC for the p_a macros
574 File: src/runtime/gencgc.c
576 * whitespace
578 * removed bogus comment
580 * restore gc_assert for alignment check on PPC
582 File: src/runtime/globals.h
584 * updated comment about dyanmic_space_free_pointer
586 File: src/runtime/interrupt.c
588 * whitespace
590 File: src/runtime/ppc-arch.c
592 * Remove pc checking stuff
594 * remove SIGILL handling and adjust comment
596 * whitespace
598 * updated comment aboud dynamic_space_free_pointer
600 File: src/runtime/ppc-arch.h
602 * removed bogus comment
604 File: src/runtime/ppc-darwin-spacelist.h
606 * removed extraneous space
608 ====================================================
609 CVS TAG: GENCGC_CANDIDATE_6
610 ====================================================
612 File: src/runtime/ppc-arch.c
614 * Removed enable_some_signals and call to it. We don't need these
615   signals on when we call alloc, but CMUCL does.
617 File: src/runtime/alloc.c
619 * Put in Xophe's fix against GC moving a newly pointer from moving out
620   from under us when we handle a pending interrupt. If the C stack is
621   not scavenged during GC, result needs to be protected against not
622   being referred to by any roots, so we push it onto the lisp control
623   stack, and read it back off after any potential GC has finished
625 ====================================================
626 CVS TAG: GENCGC_CANDIDATE_7
627 ====================================================
629 * Fix mismatched } and #endif in bsd-os.c/memory_fault_handler
631 ====================================================
632 Untagged Changes
633 ====================================================
636 ====================================================
637 Uncommited Changes
638 ====================================================