From 809cf25a405d924031cafd533fb3d115d0347e05 Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Tue, 16 Jun 2026 03:30:10 +0000 Subject: [PATCH] Check typeeq for object size. Minor refactoring --- mmtk/src/julia_scanning.rs | 17 +---------------- mmtk/src/object_model.rs | 35 ++++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/mmtk/src/julia_scanning.rs b/mmtk/src/julia_scanning.rs index 44efb7c6..819ffb11 100644 --- a/mmtk/src/julia_scanning.rs +++ b/mmtk/src/julia_scanning.rs @@ -84,22 +84,7 @@ pub unsafe fn scan_julia_object>(obj: Address, clos return; } - if vtag_usize == ((jl_small_typeof_tags_jl_datatype_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_unionall_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_uniontype_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_typeeq_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_tvar_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_vararg_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_globalref_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_gotoifnot_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_returnnode_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_enternode_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_pinode_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_phinode_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_phicnode_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_upsilonnode_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_quotenode_tag as usize) << 4) - { + if crate::object_model::is_small_typeof_tag_with_no_pointer(vtag_usize) { // these objects have pointers in them, but no other special handling // so we want these to fall through to the end vtag_usize = jl_small_typeof[vtag.as_usize() / std::mem::size_of::
()] as usize; diff --git a/mmtk/src/object_model.rs b/mmtk/src/object_model.rs index d57da5e8..ea03a8b4 100644 --- a/mmtk/src/object_model.rs +++ b/mmtk/src/object_model.rs @@ -186,21 +186,7 @@ pub unsafe fn get_so_object_size(object: ObjectReference) -> usize { return mmtk_get_obj_size(object); } - if vtag_usize == ((jl_small_typeof_tags_jl_datatype_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_unionall_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_uniontype_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_tvar_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_vararg_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_globalref_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_gotoifnot_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_returnnode_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_enternode_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_pinode_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_phinode_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_phicnode_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_upsilonnode_tag as usize) << 4) - || vtag_usize == ((jl_small_typeof_tags_jl_quotenode_tag as usize) << 4) - { + if is_small_typeof_tag_with_no_pointer(vtag_usize) { // these objects have pointers in them, but no other special handling // so we want these to fall through to the end vtag_usize = jl_small_typeof[vtag.as_usize() / std::mem::size_of::
()] as usize; @@ -334,3 +320,22 @@ pub unsafe fn mmtk_jl_is_uniontype(t: *const jl_datatype_t) -> bool { mmtk_jl_typetagof(Address::from_ptr(t)).as_usize() == (jl_small_typeof_tags_jl_uniontype_tag << 4) as usize } + +#[inline(always)] +pub fn is_small_typeof_tag_with_no_pointer(vtag: usize) -> bool { + vtag == ((jl_small_typeof_tags_jl_datatype_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_unionall_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_uniontype_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_typeeq_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_tvar_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_vararg_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_globalref_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_gotoifnot_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_returnnode_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_enternode_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_pinode_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_phinode_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_phicnode_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_upsilonnode_tag as usize) << 4) + || vtag == ((jl_small_typeof_tags_jl_quotenode_tag as usize) << 4) +}