
Change the GC so that it can mark and sweep objects in-place, instead of always copying. This change is helpful for reducing peak memory use while performing a collection on a large, old heap. Some non-copying support was already in place for locked objects, but the new implementation is faster and more general. As an alternative to locking, the storage manager now provides "immobile" allocation (currently only for bytevectors, vectors, and boxes), which allocates an object that won't move but that can be GCed if it's not referenced. A locked object is an object that has been immobiled and that is on a global list --- mostly the old, non-scalable implementation of locked objects brought back, since immobile objects cover the cases that need to scale. original commit: aecb7b736cb1d52764c292fa6364a674958dfde3
85 lines
2.4 KiB
C
85 lines
2.4 KiB
C
/* segment.h
|
|
* Copyright 1984-2017 Cisco Systems, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifdef WIN32
|
|
# ifndef __MINGW32__
|
|
# undef FORCEINLINE
|
|
# define FORCEINLINE static __forceinline
|
|
# endif
|
|
#else
|
|
#define FORCEINLINE static inline
|
|
#endif
|
|
|
|
/* segment_info */
|
|
|
|
#define SEGMENT_T1_SIZE (1<<segment_t1_bits)
|
|
#define SEGMENT_T1_IDX(i) ((i)&(SEGMENT_T1_SIZE-1))
|
|
|
|
#ifdef segment_t3_bits
|
|
|
|
#define SEGMENT_T2_SIZE (1<<segment_t2_bits)
|
|
#define SEGMENT_T2_IDX(i) (((i)>>segment_t1_bits)&(SEGMENT_T2_SIZE-1))
|
|
#define SEGMENT_T3_SIZE (1<<segment_t3_bits)
|
|
#define SEGMENT_T3_IDX(i) ((i)>>(segment_t2_bits+segment_t1_bits))
|
|
|
|
FORCEINLINE seginfo *SegInfo(uptr i) {
|
|
return S_segment_info[SEGMENT_T3_IDX(i)]->t2[SEGMENT_T2_IDX(i)]->t1[SEGMENT_T1_IDX(i)];
|
|
}
|
|
|
|
FORCEINLINE seginfo *MaybeSegInfo(uptr i) {
|
|
t2table *t2i; t1table *t1i;
|
|
if ((t2i = S_segment_info[SEGMENT_T3_IDX(i)]) == NULL) return NULL;
|
|
if ((t1i = t2i->t2[SEGMENT_T2_IDX(i)]) == NULL) return NULL;
|
|
return t1i->t1[SEGMENT_T1_IDX(i)];
|
|
}
|
|
|
|
#else /* segment_t3_bits */
|
|
#ifdef segment_t2_bits
|
|
|
|
#define SEGMENT_T2_SIZE (1<<segment_t2_bits)
|
|
#define SEGMENT_T2_IDX(i) ((i)>>segment_t1_bits)
|
|
#define SEGMENT_T3_SIZE 0
|
|
|
|
FORCEINLINE seginfo *SegInfo(uptr i) {
|
|
return S_segment_info[SEGMENT_T2_IDX(i)]->t1[SEGMENT_T1_IDX(i)];
|
|
}
|
|
|
|
FORCEINLINE seginfo *MaybeSegInfo(uptr i) {
|
|
t1table *t1i;
|
|
if ((t1i = S_segment_info[SEGMENT_T2_IDX(i)]) == NULL) return NULL;
|
|
return t1i->t1[SEGMENT_T1_IDX(i)];
|
|
}
|
|
|
|
#else /* segment_t2_bits */
|
|
|
|
#define SEGMENT_T2_SIZE 0
|
|
#define SEGMENT_T3_SIZE 0
|
|
|
|
FORCEINLINE seginfo *SegInfo(uptr i) {
|
|
return S_segment_info[SEGMENT_T1_IDX(i)];
|
|
}
|
|
|
|
FORCEINLINE seginfo *MaybeSegInfo(uptr i) {
|
|
return S_segment_info[SEGMENT_T1_IDX(i)];
|
|
}
|
|
|
|
#endif /* segment_t2_bits */
|
|
#endif /* segment_t3_bits */
|
|
|
|
#define SegmentSpace(i) (SegInfo(i)->space)
|
|
#define SegmentGeneration(i) (SegInfo(i)->generation)
|
|
#define SegmentOldSpace(i) (SegInfo(i)->old_space)
|