Skip to content

Commit d4b372d

Browse files
MaikKleinarielb1
authored andcommitted
Rename trans to monomorphize in comments
1 parent 45f8a3b commit d4b372d

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

src/librustc_mir/monomorphize/collector.rs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Translation Item Collection
11+
//! Mono Item Collection
1212
//! ===========================
1313
//!
1414
//! This module is responsible for discovering all items that will contribute to
@@ -22,7 +22,7 @@
2222
//! in crate X might produce monomorphizations that are compiled into crate Y.
2323
//! We also have to collect these here.
2424
//!
25-
//! The following kinds of "translation items" are handled here:
25+
//! The following kinds of "mono items" are handled here:
2626
//!
2727
//! - Functions
2828
//! - Methods
@@ -43,24 +43,24 @@
4343
//! -----------------
4444
//! Let's define some terms first:
4545
//!
46-
//! - A "translation item" is something that results in a function or global in
47-
//! the LLVM IR of a codegen unit. Translation items do not stand on their
48-
//! own, they can reference other translation items. For example, if function
49-
//! `foo()` calls function `bar()` then the translation item for `foo()`
50-
//! references the translation item for function `bar()`. In general, the
51-
//! definition for translation item A referencing a translation item B is that
46+
//! - A "mono item" is something that results in a function or global in
47+
//! the LLVM IR of a codegen unit. Mono items do not stand on their
48+
//! own, they can reference other mono items. For example, if function
49+
//! `foo()` calls function `bar()` then the mono item for `foo()`
50+
//! references the mono item for function `bar()`. In general, the
51+
//! definition for mono item A referencing a mono item B is that
5252
//! the LLVM artifact produced for A references the LLVM artifact produced
5353
//! for B.
5454
//!
55-
//! - Translation items and the references between them form a directed graph,
56-
//! where the translation items are the nodes and references form the edges.
57-
//! Let's call this graph the "translation item graph".
55+
//! - Mono items and the references between them form a directed graph,
56+
//! where the mono items are the nodes and references form the edges.
57+
//! Let's call this graph the "mono item graph".
5858
//!
59-
//! - The translation item graph for a program contains all translation items
59+
//! - The mono item graph for a program contains all mono items
6060
//! that are needed in order to produce the complete LLVM IR of the program.
6161
//!
6262
//! The purpose of the algorithm implemented in this module is to build the
63-
//! translation item graph for the current crate. It runs in two phases:
63+
//! mono item graph for the current crate. It runs in two phases:
6464
//!
6565
//! 1. Discover the roots of the graph by traversing the HIR of the crate.
6666
//! 2. Starting from the roots, find neighboring nodes by inspecting the MIR
@@ -69,26 +69,26 @@
6969
//!
7070
//! ### Discovering roots
7171
//!
72-
//! The roots of the translation item graph correspond to the non-generic
72+
//! The roots of the mono item graph correspond to the non-generic
7373
//! syntactic items in the source code. We find them by walking the HIR of the
7474
//! crate, and whenever we hit upon a function, method, or static item, we
75-
//! create a translation item consisting of the items DefId and, since we only
75+
//! create a mono item consisting of the items DefId and, since we only
7676
//! consider non-generic items, an empty type-substitution set.
7777
//!
7878
//! ### Finding neighbor nodes
79-
//! Given a translation item node, we can discover neighbors by inspecting its
79+
//! Given a mono item node, we can discover neighbors by inspecting its
8080
//! MIR. We walk the MIR and any time we hit upon something that signifies a
81-
//! reference to another translation item, we have found a neighbor. Since the
82-
//! translation item we are currently at is always monomorphic, we also know the
81+
//! reference to another mono item, we have found a neighbor. Since the
82+
//! mono item we are currently at is always monomorphic, we also know the
8383
//! concrete type arguments of its neighbors, and so all neighbors again will be
8484
//! monomorphic. The specific forms a reference to a neighboring node can take
8585
//! in MIR are quite diverse. Here is an overview:
8686
//!
8787
//! #### Calling Functions/Methods
88-
//! The most obvious form of one translation item referencing another is a
88+
//! The most obvious form of one mono item referencing another is a
8989
//! function or method call (represented by a CALL terminator in MIR). But
9090
//! calls are not the only thing that might introduce a reference between two
91-
//! function translation items, and as we will see below, they are just a
91+
//! function mono items, and as we will see below, they are just a
9292
//! specialized of the form described next, and consequently will don't get any
9393
//! special treatment in the algorithm.
9494
//!
@@ -112,10 +112,10 @@
112112
//! }
113113
//! ```
114114
//! The MIR of none of these functions will contain an explicit call to
115-
//! `print_val::<i32>`. Nonetheless, in order to translate this program, we need
115+
//! `print_val::<i32>`. Nonetheless, in order to mono this program, we need
116116
//! an instance of this function. Thus, whenever we encounter a function or
117117
//! method in operand position, we treat it as a neighbor of the current
118-
//! translation item. Calls are just a special case of that.
118+
//! mono item. Calls are just a special case of that.
119119
//!
120120
//! #### Closures
121121
//! In a way, closures are a simple case. Since every closure object needs to be
@@ -124,8 +124,8 @@
124124
//! true for closures inlined from other crates.
125125
//!
126126
//! #### Drop glue
127-
//! Drop glue translation items are introduced by MIR drop-statements. The
128-
//! generated translation item will again have drop-glue item neighbors if the
127+
//! Drop glue mono items are introduced by MIR drop-statements. The
128+
//! generated mono item will again have drop-glue item neighbors if the
129129
//! type to be dropped contains nested values that also need to be dropped. It
130130
//! might also have a function item neighbor for the explicit `Drop::drop`
131131
//! implementation of its type.
@@ -150,23 +150,23 @@
150150
//! defined in the source code of that crate. It will also contain monomorphic
151151
//! instantiations of any extern generic functions and of functions marked with
152152
//! #[inline].
153-
//! The collection algorithm handles this more or less transparently. If it is
154-
//! about to create a translation item for something with an external `DefId`,
153+
//! The collection algorithm handles this more or less mono. If it is
154+
//! about to create a mono item for something with an external `DefId`,
155155
//! it will take a look if the MIR for that item is available, and if so just
156156
//! proceed normally. If the MIR is not available, it assumes that the item is
157157
//! just linked to and no node is created; which is exactly what we want, since
158158
//! no machine code should be generated in the current crate for such an item.
159159
//!
160160
//! Eager and Lazy Collection Mode
161161
//! ------------------------------
162-
//! Translation item collection can be performed in one of two modes:
162+
//! Mono item collection can be performed in one of two modes:
163163
//!
164164
//! - Lazy mode means that items will only be instantiated when actually
165165
//! referenced. The goal is to produce the least amount of machine code
166166
//! possible.
167167
//!
168168
//! - Eager mode is meant to be used in conjunction with incremental compilation
169-
//! where a stable set of translation items is more important than a minimal
169+
//! where a stable set of mono items is more important than a minimal
170170
//! one. Thus, eager mode will instantiate drop-glue for every drop-able type
171171
//! in the crate, even of no drop call for that type exists (yet). It will
172172
//! also instantiate default implementations of trait methods, something that
@@ -183,9 +183,9 @@
183183
//! statics we cannot inspect these properly.
184184
//!
185185
//! ### Const Fns
186-
//! Ideally, no translation item should be generated for const fns unless there
186+
//! Ideally, no mono item should be generated for const fns unless there
187187
//! is a call to them that cannot be evaluated at compile time. At the moment
188-
//! this is not implemented however: a translation item will be produced
188+
//! this is not implemented however: a mono item will be produced
189189
//! regardless of whether it is actually needed or not.
190190
191191
use rustc::hir;
@@ -218,18 +218,18 @@ pub enum MonoItemCollectionMode {
218218
Lazy
219219
}
220220

221-
/// Maps every translation item to all translation items it references in its
221+
/// Maps every mono item to all mono items it references in its
222222
/// body.
223223
pub struct InliningMap<'tcx> {
224-
// Maps a source translation item to the range of translation items
224+
// Maps a source mono item to the range of mono items
225225
// accessed by it.
226226
// The two numbers in the tuple are the start (inclusive) and
227227
// end index (exclusive) within the `targets` vecs.
228228
index: FxHashMap<MonoItem<'tcx>, (usize, usize)>,
229229
targets: Vec<MonoItem<'tcx>>,
230230

231-
// Contains one bit per translation item in the `targets` field. That bit
232-
// is true if that translation item needs to be inlined into every CGU.
231+
// Contains one bit per mono item in the `targets` field. That bit
232+
// is true if that mono item needs to be inlined into every CGU.
233233
inlines: BitVector,
234234
}
235235

@@ -300,7 +300,7 @@ pub fn collect_crate_mono_items<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
300300
InliningMap<'tcx>) {
301301
let roots = collect_roots(tcx, mode);
302302

303-
debug!("Building translation item graph, beginning at roots");
303+
debug!("Building mono item graph, beginning at roots");
304304
let mut visited = FxHashSet();
305305
let mut recursion_depths = DefIdMap();
306306
let mut inlining_map = InliningMap::new();
@@ -347,7 +347,7 @@ fn collect_roots<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
347347
roots
348348
}
349349

350-
// Collect all monomorphized translation items reachable from `starting_point`
350+
// Collect all monomorphized items reachable from `starting_point`
351351
fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
352352
starting_point: MonoItem<'tcx>,
353353
visited: &mut FxHashSet<MonoItem<'tcx>>,
@@ -930,7 +930,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
930930
self.output.push(MonoItem::Static(item.id));
931931
}
932932
hir::ItemConst(..) => {
933-
// const items only generate translation items if they are
933+
// const items only generate mono items if they are
934934
// actually used somewhere. Just declaring them is insufficient.
935935
}
936936
hir::ItemFn(..) => {

0 commit comments

Comments
 (0)