Take pointer, not word count, as upper limit in verify_space()
[sbcl.git] / src / runtime / forwarding-ptr.h
blob72ea194501a1707081d4606233fcff8fb350089a
1 #ifndef _FORWARDING_PTR_H_
2 #define _FORWARDING_PTR_H_
4 #ifndef LISP_FEATURE_GENCGC
5 inline static boolean
6 in_gc_p(void) {
7 return current_dynamic_space == from_space;
9 #endif
11 inline static boolean
12 forwarding_pointer_p(lispobj *pointer) {
13 lispobj first_word=*pointer;
14 #ifdef LISP_FEATURE_GENCGC
15 return (first_word == 0x01);
16 #else
17 // FIXME: change 5c0d71f92c371769f911e6a2ac60b2dd9fbde349 added
18 // an extra test here, which theoretically slowed things down.
19 // This was in response to 044e22192c25578efceedba042554dc9a96124c6
20 // which caused cheneygc to break. But now the latter revision has been
21 // reverted due to performance degradation in gencgc.
22 // The right fix is probably that search_spaces() should use its own
23 // special version of gc_search_space for ldb. That is unfortunately
24 // made difficult by the call chain:
25 // search_spaces() -> search_{foo}_space() -> gc_search_space().
26 // which requires informing gc_search_space() to be more careful,
27 // and similarly forwarding_pointer_p().
28 return (is_lisp_pointer(first_word)
29 && in_gc_p() /* cheneygc new_space_p() is broken when not in gc */
30 && new_space_p(first_word));
31 #endif
34 static inline lispobj
35 forwarding_pointer_value(lispobj *pointer) {
36 #ifdef LISP_FEATURE_GENCGC
37 return pointer[1];
38 #else
39 return pointer[0];
40 #endif
42 static inline lispobj
43 set_forwarding_pointer(lispobj *pointer, lispobj newspace_copy) {
44 // The object at 'pointer' might already have been forwarded,
45 // but that's ok. Such occurs primarily when dealing with
46 // code components, because code can be forwarded by scavenging any
47 // pointer to a function that resides within the code.
48 // Testing whether the object had been forwarded would just slow
49 // things down, so we blindly stomp on whatever was there.
50 // Unfortunately this also implies we can't assert
51 // that we're operating on a not-yet-forwarded object here.
52 #ifdef LISP_FEATURE_GENCGC
53 pointer[0]=0x01;
54 pointer[1]=newspace_copy;
55 #else
56 pointer[0]=newspace_copy;
57 #endif
58 return newspace_copy;
61 #endif