0.9.9.36:
[sbcl.git] / doc / internals-notes / GENCGC-PORTING-NOTES
1
2 ====================================================
3 OPEN GENGC BUGS
4 ====================================================
5
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
10
11 ====================================================
12 CLOSED GENGC BUGS
13 ====================================================
14
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.
21
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.
26
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.
30
31 4. FIXED. PPC/Linux gencgc fails with a BUS ERROR (SIGSEGV maybe?)
32    after the first GC.
33
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.
38
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.
42
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.
49
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.
54
55
56
57 ====================================================
58 CVS tag: ALLOCATION_CLEANUP_1
59 ====================================================
60
61 File: src/assembly/ppc/arith.lisp
62 ================
63
64 * Fixed allocation for CONS-BIGNUM. Note that we now always cons 2 words
65   instead of trying to fit into 1 word first
66
67 File: src/compiler/ppc/alloc.lisp
68 ================
69
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.
74
75 * Fixed vop for make-closure. See note above. Dynamic extent should
76   still work.
77
78 * TODO: [FUTURE] add stack allocation to the allocate macro.
79
80 File: src/compiler/ppc/macros.lisp
81
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.
84
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.
89
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.
95
96
97 File: move.lisp
98 ===============
99
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.
103
104
105 ====================================================
106 CVS tag: ALLOCATION_CLEANUP_2
107 ====================================================
108
109 File: src/assembly/ppc/array.lisp
110 =============================
111
112 * Fixed allocate-vector assembly-routine to use allocate macro instead
113   of adjusting alloc-tn directly.
114
115 File: src/compiler/ppc/array.lisp
116 =============================
117
118 * make-array-header vop now uses allocation macro instead of setting
119   alloc-tn directly
120
121 File: src/compiler/ppc/call.lisp
122 ============================
123
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.
128
129
130 ====================================================
131 CVS tag: BUILD_CLEANUP_1
132 ====================================================
133
134 File: src/code/ppc-vm.lisp
135
136 * Add flag disabling scavenging of read-only space (to be used later)
137
138 File: src/compiler/ppc/parms.lisp
139
140 * Add gencgc-page-size variable. Currently 4096. Bump to 32k later.
141
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.
145
146 * Added *restart-lisp-function*, *current-region-end-addr* and
147   *scavenge-read-only-space* static-symbols.
148
149 File: src/runtime/Config.ppc-darwin
150
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
154
155 File: src/runtime/Config.ppc-linux
156
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
160
161 ====================================================
162 CVS tag: GENCGC_PREP_1
163 ====================================================
164
165 File: src/runtime/arch.h
166
167 * Moved extern fpu_save and fpu_restore defintions here
168
169 File: src/runtime/cheneygc.c
170
171 * removed static scavenge_interrupt_contexts prototype
172
173 File: gc-common.c
174
175 * Instead of #ifndef LISP_FEATURE_SPARC for scav_fdefn, use
176   defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
177
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)
181
182 * set scav_tab[FDEFN_WIDETAG] to scav_fdefn on X86 and X86_64 and
183   scav_boxed for everything else.
184
185 File: gc-internal.h
186
187 * added prototype for scavenge_interrupt_contexts
188
189 ====================================================
190 CVS tag: GENCGC_PREP_2
191 ====================================================
192
193 File: gc-common.c
194
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.
200
201 File: ppc-arch.c
202
203 * Moved PSEUDO_ATOMIC_INTERRUPTED_BIAS to ppc-arch.h
204
205 File: ppc-arch.h
206
207 * Moved PSEUDO_ATOMIC_INTERRUPTED_BIAS to ppc-arch.h
208
209 File: ppc-assem.S
210
211 * Added do_pending_interrupt, fpu_save and fpu_restore.
212
213 File: ppc-darwin-spacelist.h
214
215 * Adjust spaces for #+gencgc and #-gencgc
216
217 File: purify.c
218
219 * #ifdef LISP_FEATURE_GENCGC -> X86{_64}
220
221 File: gencgc.c
222
223 * Remove fpu_save and fpu_restore prototypes
224
225 ====================================================
226 CVS tag: GENCGC_PREP_3
227 ====================================================
228
229 File: src/runtime/gc.h
230
231 * Added xxx_pseudo_atomic_xxx and xxx_alloc_pointer #defines
232
233 File: src/runtime/alloc.c
234
235 * Start using xxx_pseudo_atomic_xxx
236
237 ====================================================
238 CVS tag: GENCGC_PREP_4
239 ====================================================
240
241 File: src/runtime/globals.c
242
243 * Cleaning up GENCGC/X86[_64] ifdefs
244
245 File: src/runtime/globals.h
246
247 * Cleaning up GENCGC/X86[_64] ifdefs
248
249 File: src/runtime/parse.c
250
251 * Use get_alloc_pointer instead of arch specific ways of doing so
252
253 ====================================================
254 CVS tag: PSEUDO_ATOMIC_REG_ALLOC
255 ====================================================
256
257 File: compiler/ppc/macros.lisp
258
259 * Pseudo-atomic now uses bits 3 and 1 of reg_ALLOC insetead of using
260   reg_NL3 for the interrutped part.
261
262 File: src/runtime/gc.h
263
264 * Pseudo-atomic now uses bits 3 and 1 of reg_ALLOC insetead of using
265   reg_NL3 for the interrutped part.
266
267 File: src/runtime/ppc-arch.c
268
269 * Pseudo-atomic now uses bits 3 and 1 of reg_ALLOC insetead of using
270   reg_NL3 for the interrutped part.
271
272 * Brought the allocation trap stuff along, but this is untested.
273
274 File: src/runtime/ppc-assem.S
275
276 * Pseudo-atomic now uses bits 3 and 1 of reg_ALLOC insetead of using
277   reg_NL3 for the interrutped part.
278
279 ====================================================
280 CVS tag: GENCGC_BUILDS_1
281 ====================================================
282
283 File: src/runtime/gencgc.c
284
285 * The big kahuna...
286
287 * Ok, lots of little changes to get things working. Had to fix up the
288   allocation macro, the uses of it, etc... 
289
290
291 ====================================================
292 CVS tag: GENCGC_RUNS_1
293 ====================================================
294
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.
297
298 ====================================================
299 CVS tag: GENCGC_RUNS_INLINE_ALLOCATION_1
300 ====================================================
301
302 File: src/compiler/generic/genesis.lisp
303
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.
306
307 File: src/compiler/ppc/insts.lisp
308
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.
312
313 File: src/compiler/ppc/macros.lisp
314
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.
320
321 File: src/runtime/gc.h
322
323 * removed set_current_region_free, get_current_free, and
324   set_current_region_end.
325
326 File: src/runtime/gencgc.c
327
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.
330
331 * removed set_current_region_end calls.
332
333 File: src/runtime/ppc-arch.c
334
335 * include gencgc-alloc-region.h
336
337 * look back 3 instructions instead of 2 to match the new allocation
338   macro
339
340 * added end_addr variable for debugging.
341
342 * no longer adjust dynamic_space_free_pointer
343
344 ====================================================
345 CVS TAG: GENCGC_MOSTLY_WORKING_1
346 ====================================================
347
348 * Making purify and loading callbacks from cores work for ppc/gengc.
349
350 * Remove *scavenge-read-only-space*
351
352 File: src/compiler/ppc/c-call.lisp
353
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.
359
360 File: src/runtime/gencgc.c
361
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.
365
366 ====================================================
367 CVS TAG: GENCGC_MOSTLY_WORKING_2
368 ====================================================
369
370 * New allocation macro. Seems to make things better.
371
372 ====================================================
373 CVS TAG: GENCGC_MOSTLY_WORKING_3
374 ====================================================
375
376 * Trying to undo damage done along the way. Lots of little
377   changes. Please document these in the morning.
378
379 ====================================================
380 CVS TAG: This stuff never got tagged. I backed it out before I tagged
381          it.
382 ====================================================
383
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.
387
388 ====================================================
389 CVS TAG: GENCGC_ALL_TESTS_PASSED
390 ====================================================
391
392 File: src/runtime/gc.h
393
394 * set_alloc_pointer now just sets the high bits and leaves the p-a
395   flags alone.
396
397 File: src/runtime/interrupt.c
398
399 * interrupt_handle_pending clears the p-a-interrupted flag
400
401 * undo_fake_foreign_function_call doesn't zap the p-a bits in
402   reg_ALLOC
403
404 File: src/runtime/ppc-arch.c
405
406 * handle_allocation_trap doesn't zap the p-a bits in reg_ALLOC
407
408 ====================================================
409 CVS TAG: GENCGC_ALL_0_9_9_27_MERGE
410 ====================================================
411
412 * Forward ported to 0.9.9.27
413
414 ====================================================
415 CVS TAG: GENCGC_CANDIDATE_1
416 ====================================================
417
418 File: src/runtime/ppc-assem.S
419
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.
425
426 File: src/runtime/ppc-arch.c
427
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?).
431
432 File: src/code/toplevel.lisp
433
434 * Fix the way we compute the end-of-stack in scrub-control-stack.
435
436 File: src/runtime/bsd-os.c
437
438 * Use arch_get_bad_addr to get fault address
439
440 ====================================================
441 CVS TAG: GENCGC_SBCL_0_9_9_34_MERGE
442 ====================================================
443
444 * Forward ported to 0.9.9.34
445
446 ====================================================
447 CVS TAG: GENCGC_CANDIDATE_2
448 ====================================================
449
450 File: src/compiler/ppc/macros.lisp
451
452 * cleaned up comments for allocation macro
453
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
457
458 File: src/compiler/ppc/parms.lisp
459
460 * gencgc-page-size -> 4096
461
462 * added pseudo-atomic-interrupted-flag and pseudo-atomic-flag
463
464 File: src/runtime/alloc.c
465
466 * clr_pseudo_atomic -> clear_pseudo_atomic
467
468 File: src/runtime/gc.h
469
470 * clr_pseudo_atomic -> clear_pseudo_atomic
471
472 * PSEUDO_ATOMIC_[INTERRUPTED_]VALUE -> flag_PseudoAtomic[Interrupted]
473
474 File: src/runtime/interrupt.c
475
476 * clr_pseudo_atomic -> clear_pseudo_atomic
477
478 File: src/runtime/ppc-arch.c
479
480 * whitespace fix
481
482 File: package-data-list.lisp-expr
483
484 * added PSEUDO-ATOMIC-INTERRUPTED-FLAG and PSEUDO-ATOMIC-FLAG to sb-vm
485   exports
486
487 ====================================================
488 CVS TAG: GENCGC_SBCL_0_9_9_35_MERGE
489 ====================================================
490
491 * Forward parted to 0.9.9.35
492
493 ====================================================
494 CVS TAG: GENCGC_CANDIDATE_3
495 ====================================================
496
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.
500
501 File: src/runtime/purify.c
502
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
506
507 File: src/runtime/parse.c
508
509 * dunamic_space_free_ptr -> dynamic_space_free_pointer
510
511 File: src/runtime/ppc-arch.c
512
513 * Fixing comment text in allocation_trap_p
514 * arch_clr_pseudo_atomic_interrupted ->
515     arch_clear_pseudo_atomic_interrupted
516
517 File: src/runtime/gc-common.c
518
519 * restore workaround behvaior for !GENCGC, not !X86[_64]
520
521 * whitespace fix
522
523 File :src/runtime/gencgc.c
524
525 * undoing gratuitous spacing changes and fixing whitespace
526 * remove bogus comment
527
528 ====================================================
529 CVS TAG: GENCGC_CANDIDATE_4
530 ====================================================
531
532 File: src/runtime/purify.c
533
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
538
539 File: src/runtime/interrupt.c
540
541 clear_psuedo_atomic_interrupted -> arch_clear_pseudo_atomic_interrupted
542
543 ====================================================
544 CVS TAG: GENCGC_CANDIDATE_5
545 ** Note: not tagged, but patch made
546 ====================================================
547
548 File: src/runtime/assembly/ppc/array.lisp
549
550 * cleaning up comment
551
552 File: src/code/ppc-vm.lisp
553
554 * removed unused commented-out chunk
555
556 File: src/compiler/generic/genesis.lisp
557
558 * Added FIXME about ppc offset fixups only being half-done
559
560 File: src/compiler/ppc/c-call.lisp
561
562 * Comment cleanup
563
564 File: src/compiler/ppc/macros.lisp
565
566 * Allocation macro comment cleanup
567
568 File: src/runtime/gc.h
569
570 * Whitespace
571
572 * #ifdef GENCGC for the p_a macros
573
574 File: src/runtime/gencgc.c
575
576 * whitespace
577
578 * removed bogus comment
579
580 * restore gc_assert for alignment check on PPC
581
582 File: src/runtime/globals.h
583
584 * updated comment about dyanmic_space_free_pointer
585
586 File: src/runtime/interrupt.c
587
588 * whitespace
589
590 File: src/runtime/ppc-arch.c
591
592 * Remove pc checking stuff
593
594 * remove SIGILL handling and adjust comment
595
596 * whitespace
597
598 * updated comment aboud dynamic_space_free_pointer
599
600 File: src/runtime/ppc-arch.h
601
602 * removed bogus comment
603
604 File: src/runtime/ppc-darwin-spacelist.h
605
606 * removed extraneous space
607
608 ====================================================
609 CVS TAG: GENCGC_CANDIDATE_6
610 ====================================================
611
612 File: src/runtime/ppc-arch.c
613
614 * Removed enable_some_signals and call to it. We don't need these
615   signals on when we call alloc, but CMUCL does.
616
617 File: src/runtime/alloc.c
618
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
624  
625 ====================================================
626 CVS TAG: GENCGC_CANDIDATE_7
627 ====================================================
628
629 * Fix mismatched } and #endif in bsd-os.c/memory_fault_handler
630
631 ====================================================
632 Untagged Changes
633 ====================================================
634
635
636 ====================================================
637 Uncommited Changes
638 ====================================================
639