1 #include "shotgun/lib/auto.h"
3 #if CONFIG_ENABLE_DTRACE
4 #include "shotgun/lib/dtrace_probes.h"
7 static inline void _om_apply_class_flags(OBJECT obj
, OBJECT cls
) {
8 obj
->CanStoreIvars
= (class_get_has_ivars(cls
) == Qtrue
);
9 obj
->RequiresCleanup
= (class_get_needs_cleanup(cls
) == Qtrue
);
10 obj
->obj_type
= N2I(class_get_object_type(cls
));
13 static inline OBJECT
_om_inline_new_object(object_memory om
, OBJECT cls
, unsigned int fields
) {
18 if(fields
> LargeObjectThreshold
) {
19 mark_sweep_gc ms
= om
->ms
;
20 obj
= mark_sweep_allocate(ms
, fields
);
22 om
->collect_now
|= OMCollectMature
;
25 loc
= MatureObjectZone
;
27 size
= SIZE_IN_BYTES_FIELDS(fields
);
28 if(!heap_enough_space_p(om
->gc
->current
, size
)) {
29 if(!heap_enough_space_p(om
->gc
->next
, size
)) {
30 mark_sweep_gc ms
= om
->ms
;
31 obj
= mark_sweep_allocate(ms
, fields
);
33 om
->collect_now
|= OMCollectMature
;
36 loc
= MatureObjectZone
;
38 loc
= YoungObjectZone
;
39 obj
= (OBJECT
)baker_gc_allocate_spilled(om
->gc
, size
);
40 // DEBUG("Ran out of space! spilled into %p\n", obj);
41 om
->collect_now
|= OMCollectYoung
;
42 // baker_gc_enlarge_next(om->gc, om->gc->current->size * GC_SCALING_FACTOR);
45 obj
= (OBJECT
)baker_gc_allocate(om
->gc
, size
);
46 loc
= YoungObjectZone
;
54 rbs_set_class(om
, obj
, cls
);
55 SET_NUM_FIELDS(obj
, fields
);
56 if(cls
&& REFERENCE_P(cls
)) {
57 _om_apply_class_flags(obj
, cls
);
63 static inline OBJECT
_om_inline_new_object_init(object_memory om
, OBJECT cls
, unsigned int fields
) {
67 if (RUBINIUS_OBJECT_CREATE_START_ENABLED() && om
->bootstrap_loaded
== 1) {
68 object_create_start(cls
);
72 obj
= _om_inline_new_object(om
, cls
, fields
);
73 fast_memfill((void*)BYTES_OF(obj
), (uintptr_t)Qnil
, fields
);
76 if (RUBINIUS_OBJECT_CREATE_DONE_ENABLED() && om
->bootstrap_loaded
== 1) {
77 object_create_done(cls
);
84 static inline OBJECT
_om_new_ultra(object_memory om
, OBJECT cls
, unsigned int size
) {
86 /* I'd love to remove this check, but context allocation could flow over. */
87 if(!heap_enough_space_p(om
->gc
->current
, size
)) {
88 obj
= (OBJECT
)baker_gc_allocate_spilled_ultra(om
->gc
, size
);
89 om
->collect_now
|= OMCollectYoung
;
91 obj
= (OBJECT
)baker_gc_allocate_ultra(om
->gc
, size
);
95 obj
->gc_zone
= YoungObjectZone
;
96 rbs_set_class(om
, obj
, cls
);