auto merge of #10670 : eddyb/rust/node-u32, r=alexcrichton

### Rationale
There is no reason to support more than 2³² nodes or names at this moment, as compiling something that big (even without considering the quadratic space usage of some analysis passes) would take at least **64GB**.
Meanwhile, some can't (or barely can) compile rustc because it requires almost **1.5GB**.

### Potential problems
Can someone confirm this doesn't affect metadata (de)serialization? I can't tell myself, I know nothing about it.

### Results
Some structures have a size reduction of 25% to 50%: [before](https://gist.github.com/luqmana/3a82a51fa9c86d9191fa) - [after](https://gist.github.com/eddyb/5a75f8973d3d8018afd3).
Sadly, there isn't a massive change in the memory used for compiling stage2 librustc (it doesn't go over **1.4GB** as [before](http://huonw.github.io/isrustfastyet/mem/), but I can barely see the difference).
However, my own testcase (previously peaking at **1.6GB** in typeck) shows a reduction of **200**-**400MB**.
This commit is contained in:
bors
2013-11-26 22:07:44 -08:00
10 changed files with 74 additions and 78 deletions

View File

@@ -18,7 +18,7 @@ use visit::Visitor;
use visit;
use std::hashmap::HashMap;
use std::int;
use std::u32;
use std::local_data;
use std::num;
use std::option;
@@ -382,8 +382,8 @@ pub struct id_range {
impl id_range {
pub fn max() -> id_range {
id_range {
min: int::max_value,
max: int::min_value,
min: u32::max_value,
max: u32::min_value,
}
}
@@ -803,9 +803,9 @@ pub fn display_sctable(table : &SCTable) {
/// Add a value to the end of a vec, return its index
fn idx_push<T>(vec: &mut ~[T], val: T) -> uint {
fn idx_push<T>(vec: &mut ~[T], val: T) -> u32 {
vec.push(val);
vec.len() - 1
(vec.len() - 1) as u32
}
/// Resolve a syntax object to a name, per MTWT.
@@ -917,7 +917,7 @@ pub fn mtwt_outer_mark(ctxt: SyntaxContext) -> Mrk {
/// Push a name... unless it matches the one on top, in which
/// case pop and discard (so two of the same marks cancel)
pub fn xorPush(marks: &mut ~[uint], mark: uint) {
pub fn xorPush(marks: &mut ~[Mrk], mark: Mrk) {
if ((marks.len() > 0) && (getLast(marks) == mark)) {
marks.pop();
} else {
@@ -927,7 +927,7 @@ pub fn xorPush(marks: &mut ~[uint], mark: uint) {
// get the last element of a mutable array.
// FIXME #4903: , must be a separate procedure for now.
pub fn getLast(arr: &~[Mrk]) -> uint {
pub fn getLast(arr: &~[Mrk]) -> Mrk {
*arr.last()
}
@@ -1000,14 +1000,8 @@ mod test {
assert_eq!(s.clone(),~[14]);
}
// convert a list of uints to an @[ident]
// (ignores the interner completely)
fn uints_to_idents (uints: &~[uint]) -> @~[Ident] {
@uints.map(|u| Ident {name:*u, ctxt: EMPTY_CTXT})
}
fn id (u : uint, s: SyntaxContext) -> Ident {
Ident{name:u, ctxt: s}
fn id(n: Name, s: SyntaxContext) -> Ident {
Ident {name: n, ctxt: s}
}
// because of the SCTable, I now need a tidy way of