Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 15 pull requests #129809

Merged
merged 34 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6ed283b
rustdoc-json: Add test for `Self` type
aDotInTheVoid Aug 15, 2024
42a901a
Don't use TyKind in lint
compiler-errors Aug 24, 2024
af05882
Deny wasm_c_abi lint to nudge the last 25%
workingjubilee Aug 24, 2024
c61f85b
Don't make pattern nonterminals match statement nonterminals
compiler-errors Jan 22, 2024
0763a3a
Bump backtrace to rust-lang/backtrace@fc37b22
workingjubilee Aug 27, 2024
a1c36c6
linker: Synchronize native library search in rustc and linker
petrochenkov Aug 14, 2024
05bd36d
linker: Better support alternative static library naming on MSVC
petrochenkov Aug 21, 2024
ac8f132
docs: Update docs for the rustc's `-L` option
petrochenkov Aug 27, 2024
ee05de8
Re-enable android tests/benches in alloc
saethlin Aug 27, 2024
83de14c
Enable some ilog2 tests as well
saethlin Aug 27, 2024
1eb4cb4
Separate core search logic with search ui
Folyd Jun 9, 2024
ae6f8a7
allow BufReader::peek to be called on unsized types
lolbinarycat Aug 28, 2024
9200452
Stop using ty::GenericPredicates for non-predicates_of queries
compiler-errors Aug 29, 2024
e20a888
Allow running `./x.py test compiler`
Veykril Aug 29, 2024
de34a91
interpret/visitor: make memory order iteration slightly more efficient
RalfJung Aug 29, 2024
8c798c8
Simplify some extern providers
compiler-errors Aug 29, 2024
c824c1a
wasi: Fix sleeping for `Duration::MAX`
alexcrichton Aug 29, 2024
518b41c
Try latest backtrace
workingjubilee Aug 29, 2024
fa4f892
Remove `Option<!>` return types.
nnethercote Aug 29, 2024
1fd0c71
Rollup merge of #120221 - compiler-errors:statements-are-not-patterns…
matthiaskrgr Aug 31, 2024
1f0292b
Rollup merge of #126183 - Folyd:search-core, r=GuillaumeGomez,notriddle
matthiaskrgr Aug 31, 2024
defc245
Rollup merge of #129123 - aDotInTheVoid:rustdoc-json-self, r=fmease
matthiaskrgr Aug 31, 2024
9f3ce40
Rollup merge of #129366 - petrochenkov:libsearch, r=jieyouxu
matthiaskrgr Aug 31, 2024
2a321e1
Rollup merge of #129527 - compiler-errors:lint-nit, r=Nadrieril
matthiaskrgr Aug 31, 2024
8f35a4f
Rollup merge of #129534 - workingjubilee:ratchet-wasm-c-abi-fcw-to-de…
matthiaskrgr Aug 31, 2024
385ffae
Rollup merge of #129640 - saethlin:unignore-android-in-alloc, r=tgross35
matthiaskrgr Aug 31, 2024
fbf74df
Rollup merge of #129642 - workingjubilee:bump-backtrace-fc37b22, r=wo…
matthiaskrgr Aug 31, 2024
10fb626
Rollup merge of #129675 - lolbinarycat:bufreader_peek_unsized, r=work…
matthiaskrgr Aug 31, 2024
9510beb
Rollup merge of #129723 - compiler-errors:extern-providers, r=lcnr
matthiaskrgr Aug 31, 2024
4418552
Rollup merge of #129724 - nnethercote:rm-Option-bang, r=fee1-dead
matthiaskrgr Aug 31, 2024
5f10a99
Rollup merge of #129725 - compiler-errors:predicates-of, r=fmease
matthiaskrgr Aug 31, 2024
6c8b07f
Rollup merge of #129731 - ferrocene:x-test-compiler, r=onur-ozkan
matthiaskrgr Aug 31, 2024
a59c1a4
Rollup merge of #129751 - RalfJung:interpret-visit-field-order, r=com…
matthiaskrgr Aug 31, 2024
25e3b66
Rollup merge of #129754 - alexcrichton:fix-wasi-long-sleep, r=working…
matthiaskrgr Aug 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
interpret/visitor: make memory order iteration slightly more efficient
  • Loading branch information
RalfJung committed Aug 29, 2024
commit de34a9135069a559e3a2249b481fe551a5c1a8dd
19 changes: 10 additions & 9 deletions compiler/rustc_const_eval/src/interpret/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
}

/// This function provides the chance to reorder the order in which fields are visited for
/// `FieldsShape::Aggregate`: The order of fields will be
/// `(0..num_fields).map(aggregate_field_order)`.
/// `FieldsShape::Aggregate`.
///
/// The default means we iterate in source declaration order; alternative this can do an inverse
/// lookup in `memory_index` to use memory field order instead.
/// The default means we iterate in source declaration order; alternatively this can do some
/// work with `memory_index` to iterate in memory order.
#[inline(always)]
fn aggregate_field_order(_memory_index: &IndexVec<FieldIdx, u32>, idx: usize) -> usize {
idx
fn aggregate_field_iter(
memory_index: &IndexVec<FieldIdx, u32>,
) -> impl Iterator<Item = FieldIdx> + 'static {
memory_index.indices()
}

// Recursive actions, ready to be overloaded.
Expand Down Expand Up @@ -172,9 +173,9 @@ pub trait ValueVisitor<'tcx, M: Machine<'tcx>>: Sized {
&FieldsShape::Union(fields) => {
self.visit_union(v, fields)?;
}
FieldsShape::Arbitrary { offsets, memory_index } => {
for idx in 0..offsets.len() {
let idx = Self::aggregate_field_order(memory_index, idx);
FieldsShape::Arbitrary { memory_index, .. } => {
for idx in Self::aggregate_field_iter(memory_index) {
let idx = idx.as_usize();
let field = self.ecx().project_field(v, idx)?;
self.visit_field(v, idx, &field)?;
}
Expand Down
13 changes: 5 additions & 8 deletions src/tools/miri/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
self.ecx
}

fn aggregate_field_order(memory_index: &IndexVec<FieldIdx, u32>, idx: usize) -> usize {
// We need to do an *inverse* lookup: find the field that has position `idx` in memory order.
for (src_field, &mem_pos) in memory_index.iter_enumerated() {
if mem_pos as usize == idx {
return src_field.as_usize();
}
}
panic!("invalid `memory_index`, could not find {}-th field in memory order", idx);
fn aggregate_field_iter(
memory_index: &IndexVec<FieldIdx, u32>,
) -> impl Iterator<Item = FieldIdx> + 'static {
let inverse_memory_index = memory_index.invert_bijective_mapping();
inverse_memory_index.into_iter()
}

// Hook to detect `UnsafeCell`.
Expand Down
Loading