Skip to content

Commit 5dfd454

Browse files
committed
Auto merge of #116707 - cjgillot:slice-id, r=oli-obk,RalfJung
Create an `AllocId` for `ConstValue::Slice`. This PR modifies `ConstValue::Slice` to use an `AllocId` instead of directly manipulating the allocation. This was originally proposed by rust-lang/rust#115764 but was a perf regression. Almost 2 years later, enough code has changed to make this a perf improvement: rust-lang/rust#116707 (comment)
2 parents 6fc11e6 + 1071390 commit 5dfd454

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/alloc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn new_empty_allocation(align: Align) -> Allocation {
3333
#[allow(rustc::usage_of_qualified_ty)]
3434
pub(crate) fn new_allocation<'tcx>(
3535
ty: rustc_middle::ty::Ty<'tcx>,
36-
const_value: ConstValue<'tcx>,
36+
const_value: ConstValue,
3737
tables: &mut Tables<'tcx, BridgeTys>,
3838
cx: &CompilerCtxt<'tcx, BridgeTys>,
3939
) -> Allocation {
@@ -44,7 +44,7 @@ pub(crate) fn new_allocation<'tcx>(
4444
#[allow(rustc::usage_of_qualified_ty)]
4545
pub(crate) fn try_new_allocation<'tcx>(
4646
ty: rustc_middle::ty::Ty<'tcx>,
47-
const_value: ConstValue<'tcx>,
47+
const_value: ConstValue,
4848
tables: &mut Tables<'tcx, BridgeTys>,
4949
cx: &CompilerCtxt<'tcx, BridgeTys>,
5050
) -> Result<Allocation, Error> {
@@ -54,8 +54,8 @@ pub(crate) fn try_new_allocation<'tcx>(
5454
alloc::try_new_scalar(layout, scalar, cx).map(|alloc| alloc.stable(tables, cx))
5555
}
5656
ConstValue::ZeroSized => Ok(new_empty_allocation(layout.align.abi)),
57-
ConstValue::Slice { data, meta } => {
58-
alloc::try_new_slice(layout, data, meta, cx).map(|alloc| alloc.stable(tables, cx))
57+
ConstValue::Slice { alloc_id, meta } => {
58+
alloc::try_new_slice(layout, alloc_id, meta, cx).map(|alloc| alloc.stable(tables, cx))
5959
}
6060
ConstValue::Indirect { alloc_id, offset } => {
6161
let alloc = alloc::try_new_indirect(alloc_id, cx);

0 commit comments

Comments
 (0)