Skip to content

Commit b8b3a93

Browse files
committed
Shrink TyKind::FnPtr.
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI.
1 parent 37da264 commit b8b3a93

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<types::Typ
6969
FloatTy::F64 => types::F64,
7070
FloatTy::F128 => unimplemented!("f16_f128"),
7171
},
72-
ty::FnPtr(_) => pointer_ty(tcx),
72+
ty::FnPtr(..) => pointer_ty(tcx),
7373
ty::RawPtr(pointee_ty, _) | ty::Ref(_, pointee_ty, _) => {
7474
if has_ptr_meta(tcx, *pointee_ty) {
7575
return None;

src/value_and_place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ pub(crate) fn assert_assignable<'tcx>(
872872
(ty::Ref(_, a, _), ty::RawPtr(b, _)) | (ty::RawPtr(a, _), ty::Ref(_, b, _)) => {
873873
assert_assignable(fx, *a, *b, limit - 1);
874874
}
875-
(ty::FnPtr(_), ty::FnPtr(_)) => {
875+
(ty::FnPtr(..), ty::FnPtr(..)) => {
876876
let from_sig = fx.tcx.normalize_erasing_late_bound_regions(
877877
ParamEnv::reveal_all(),
878878
from_ty.fn_sig(fx.tcx),

0 commit comments

Comments
 (0)