File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 55//! and definition contexts*. J. Funct. Program. 22, 2 (March 2012), 181-216.
66//! DOI=10.1017/S0956796812000093 <https://doi.org/10.1017/S0956796812000093>
77
8+ // Hygiene data is stored in a global variable and accessed via TLS, which
9+ // means that accesses are somewhat expensive. (`HygieneData::with`
10+ // encapsulates a single access.) Therefore, on hot code paths it is worth
11+ // ensuring that multiple HygieneData accesses are combined into a single
12+ // `HygieneData::with`.
13+ //
14+ // This explains why `HygieneData`, `SyntaxContext` and `Mark` have interfaces
15+ // with a certain amount of redundancy in them. For example,
16+ // `SyntaxContext::outer_expn_info` combines `SyntaxContext::outer` and
17+ // `Mark::expn_info` so that two `HygieneData` accesses can be performed within
18+ // a single `HygieneData::with` call.
19+ //
20+ // It also explains why many functions appear in `HygieneData` and again in
21+ // `SyntaxContext` or `Mark`. For example, `HygieneData::outer` and
22+ // `SyntaxContext::outer` do the same thing, but the former is for use within a
23+ // `HygieneData::with` call while the latter is for use outside such a call.
24+ // When modifying this file it is important to understand this distinction,
25+ // because getting it wrong can lead to nested `HygieneData::with` calls that
26+ // trigger runtime aborts. (Fortunately these are obvious and easy to fix.)
27+
828use crate :: GLOBALS ;
929use crate :: Span ;
1030use crate :: edition:: Edition ;
You can’t perform that action at this time.
0 commit comments