Skip to content

Commit 7c7753d

Browse files
committed
Auto merge of #40752 - frewsxcv:rollup, r=frewsxcv
Rollup of 6 pull requests - Successful merges: #39891, #40518, #40542, #40617, #40678, #40696 - Failed merges:
2 parents c62e532 + 9307418 commit 7c7753d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1711
-931
lines changed

src/ci/docker/dist-x86-linux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ RUN yum upgrade -y && yum install -y \
66
curl \
77
bzip2 \
88
gcc \
9+
gcc-c++ \
910
make \
1011
glibc-devel \
1112
perl \

src/ci/docker/dist-x86-linux/build-gcc.sh

+7-5
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ set -ex
1313

1414
source shared.sh
1515

16-
curl https://ftp.gnu.org/gnu/gcc/gcc-4.7.4/gcc-4.7.4.tar.bz2 | tar xjf -
17-
cd gcc-4.7.4
16+
GCC=4.8.5
17+
18+
curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.bz2 | tar xjf -
19+
cd gcc-$GCC
1820
./contrib/download_prerequisites
1921
mkdir ../gcc-build
2022
cd ../gcc-build
21-
hide_output ../gcc-4.7.4/configure \
23+
hide_output ../gcc-$GCC/configure \
2224
--prefix=/rustroot \
2325
--enable-languages=c,c++
2426
hide_output make -j10
@@ -27,5 +29,5 @@ ln -nsf gcc /rustroot/bin/cc
2729

2830
cd ..
2931
rm -rf gcc-build
30-
rm -rf gcc-4.7.4
31-
yum erase -y gcc binutils
32+
rm -rf gcc-$GCC
33+
yum erase -y gcc gcc-c++ binutils

src/librustc/hir/def_id.rs

+53
Original file line numberDiff line numberDiff line change
@@ -78,33 +78,86 @@ impl serialize::UseSpecializedDecodable for CrateNum {
7878
/// A DefIndex is an index into the hir-map for a crate, identifying a
7979
/// particular definition. It should really be considered an interned
8080
/// shorthand for a particular DefPath.
81+
///
82+
/// At the moment we are allocating the numerical values of DefIndexes into two
83+
/// ranges: the "low" range (starting at zero) and the "high" range (starting at
84+
/// DEF_INDEX_HI_START). This allows us to allocate the DefIndexes of all
85+
/// item-likes (Items, TraitItems, and ImplItems) into one of these ranges and
86+
/// consequently use a simple array for lookup tables keyed by DefIndex and
87+
/// known to be densely populated. This is especially important for the HIR map.
88+
///
89+
/// Since the DefIndex is mostly treated as an opaque ID, you probably
90+
/// don't have to care about these ranges.
8191
#[derive(Clone, Debug, Eq, Ord, PartialOrd, PartialEq, RustcEncodable,
8292
RustcDecodable, Hash, Copy)]
8393
pub struct DefIndex(u32);
8494

8595
impl DefIndex {
96+
#[inline]
8697
pub fn new(x: usize) -> DefIndex {
8798
assert!(x < (u32::MAX as usize));
8899
DefIndex(x as u32)
89100
}
90101

102+
#[inline]
91103
pub fn from_u32(x: u32) -> DefIndex {
92104
DefIndex(x)
93105
}
94106

107+
#[inline]
95108
pub fn as_usize(&self) -> usize {
96109
self.0 as usize
97110
}
98111

112+
#[inline]
99113
pub fn as_u32(&self) -> u32 {
100114
self.0
101115
}
116+
117+
#[inline]
118+
pub fn address_space(&self) -> DefIndexAddressSpace {
119+
if self.0 < DEF_INDEX_HI_START.0 {
120+
DefIndexAddressSpace::Low
121+
} else {
122+
DefIndexAddressSpace::High
123+
}
124+
}
125+
126+
/// Converts this DefIndex into a zero-based array index.
127+
/// This index is the offset within the given "range" of the DefIndex,
128+
/// that is, if the DefIndex is part of the "high" range, the resulting
129+
/// index will be (DefIndex - DEF_INDEX_HI_START).
130+
#[inline]
131+
pub fn as_array_index(&self) -> usize {
132+
(self.0 & !DEF_INDEX_HI_START.0) as usize
133+
}
102134
}
103135

136+
/// The start of the "high" range of DefIndexes.
137+
const DEF_INDEX_HI_START: DefIndex = DefIndex(1 << 31);
138+
104139
/// The crate root is always assigned index 0 by the AST Map code,
105140
/// thanks to `NodeCollector::new`.
106141
pub const CRATE_DEF_INDEX: DefIndex = DefIndex(0);
107142

143+
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
144+
pub enum DefIndexAddressSpace {
145+
Low = 0,
146+
High = 1,
147+
}
148+
149+
impl DefIndexAddressSpace {
150+
#[inline]
151+
pub fn index(&self) -> usize {
152+
*self as usize
153+
}
154+
155+
#[inline]
156+
pub fn start(&self) -> usize {
157+
self.index() * DEF_INDEX_HI_START.as_usize()
158+
}
159+
}
160+
108161
/// A DefId identifies a particular *definition*, by combining a crate
109162
/// index and a def index.
110163
#[derive(Clone, Eq, Ord, PartialOrd, PartialEq, RustcEncodable, RustcDecodable, Hash, Copy)]

0 commit comments

Comments
 (0)