Skip to content

Commit ff1e5cc

Browse files
committed
---
yaml --- r: 138559 b: refs/heads/try2 c: f432723 h: refs/heads/master i: 138557: 9def617 138555: ffd5dbc 138551: 9d9db11 138543: c5562d9 138527: 853d741 138495: c8ead27 v: v3
1 parent cbb55ae commit ff1e5cc

37 files changed

+268
-759
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: a3dbd07979e02bdb4868ba02e468e7d5715af0a2
8+
refs/heads/try2: f4327230fa348283f4b9c81aed76cd0759983965
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ do
678678
LLVM_BUILD_DIR=${CFG_BUILD_DIR}llvm/$t
679679
if [ ! -z "$CFG_DISABLE_OPTIMIZE_LLVM" ]
680680
then
681-
LLVM_DBG_OPTS="--enable-debug-symbols --disable-optimized"
681+
LLVM_DBG_OPTS=""
682682
# Just use LLVM straight from its build directory to
683683
# avoid 'make install' time
684684
LLVM_INST_DIR=$LLVM_BUILD_DIR/Debug+Asserts

branches/try2/src/libcore/hash.rs

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -186,46 +186,42 @@ fn SipState(key0: u64, key1: u64) -> SipState {
186186
state
187187
}
188188

189-
// sadly, these macro definitions can't appear later,
190-
// because they're needed in the following defs;
191-
// this design could be improved.
192-
193-
macro_rules! u8to64_le (
194-
($buf:expr, $i:expr) =>
195-
($buf[0+$i] as u64 |
196-
$buf[1+$i] as u64 << 8 |
197-
$buf[2+$i] as u64 << 16 |
198-
$buf[3+$i] as u64 << 24 |
199-
$buf[4+$i] as u64 << 32 |
200-
$buf[5+$i] as u64 << 40 |
201-
$buf[6+$i] as u64 << 48 |
202-
$buf[7+$i] as u64 << 56)
203-
)
204-
205-
macro_rules! rotl (
206-
($x:expr, $b:expr) =>
207-
(($x << $b) | ($x >> (64 - $b)))
208-
)
209-
210-
macro_rules! compress (
211-
($v0:expr, $v1:expr, $v2:expr, $v3:expr) =>
212-
({
213-
$v0 += $v1; $v1 = rotl!($v1, 13); $v1 ^= $v0;
214-
$v0 = rotl!($v0, 32);
215-
$v2 += $v3; $v3 = rotl!($v3, 16); $v3 ^= $v2;
216-
$v0 += $v3; $v3 = rotl!($v3, 21); $v3 ^= $v0;
217-
$v2 += $v1; $v1 = rotl!($v1, 17); $v1 ^= $v2;
218-
$v2 = rotl!($v2, 32);
219-
})
220-
)
221-
222189

223190
impl io::Writer for SipState {
224191

225192
// Methods for io::writer
226193
#[inline(always)]
227194
fn write(&self, msg: &[const u8]) {
228195

196+
macro_rules! u8to64_le (
197+
($buf:expr, $i:expr) =>
198+
($buf[0+$i] as u64 |
199+
$buf[1+$i] as u64 << 8 |
200+
$buf[2+$i] as u64 << 16 |
201+
$buf[3+$i] as u64 << 24 |
202+
$buf[4+$i] as u64 << 32 |
203+
$buf[5+$i] as u64 << 40 |
204+
$buf[6+$i] as u64 << 48 |
205+
$buf[7+$i] as u64 << 56)
206+
);
207+
208+
macro_rules! rotl (
209+
($x:expr, $b:expr) =>
210+
(($x << $b) | ($x >> (64 - $b)))
211+
);
212+
213+
macro_rules! compress (
214+
($v0:expr, $v1:expr, $v2:expr, $v3:expr) =>
215+
({
216+
$v0 += $v1; $v1 = rotl!($v1, 13); $v1 ^= $v0;
217+
$v0 = rotl!($v0, 32);
218+
$v2 += $v3; $v3 = rotl!($v3, 16); $v3 ^= $v2;
219+
$v0 += $v3; $v3 = rotl!($v3, 21); $v3 ^= $v0;
220+
$v2 += $v1; $v1 = rotl!($v1, 17); $v1 ^= $v2;
221+
$v2 = rotl!($v2, 32);
222+
})
223+
);
224+
229225
let length = msg.len();
230226
self.length += length;
231227

branches/try2/src/libcore/rt.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! Runtime calls emitted by the compiler.
1212
1313
use cast::transmute;
14-
use libc::{c_char, c_uchar, c_void, size_t, uintptr_t};
14+
use libc::{c_char, c_uchar, c_void, size_t, uintptr_t, c_int};
1515
use managed::raw::BoxRepr;
1616
use str;
1717
use sys;
@@ -121,6 +121,21 @@ pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str {
121121
str::raw::from_buf_len(ptr, len)
122122
}
123123

124+
#[lang="start"]
125+
pub fn start(main: *u8, argc: int, argv: *c_char,
126+
crate_map: *u8) -> int {
127+
128+
extern {
129+
fn rust_start(main: *c_void, argc: c_int, argv: *c_char,
130+
crate_map: *c_void) -> c_int;
131+
}
132+
133+
unsafe {
134+
return rust_start(main as *c_void, argc as c_int, argv,
135+
crate_map as *c_void) as int;
136+
}
137+
}
138+
124139
// Local Variables:
125140
// mode: rust;
126141
// fill-column: 78;

branches/try2/src/libcore/str.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -590,40 +590,6 @@ pub pure fn split_str_nonempty(s: &a/str, sep: &b/str) -> ~[~str] {
590590
result
591591
}
592592

593-
/// Levenshtein Distance between two strings
594-
pub fn levdistance(s: &str, t: &str) -> uint {
595-
596-
let slen = str::len(s);
597-
let tlen = str::len(t);
598-
599-
if slen == 0 { return tlen; }
600-
if tlen == 0 { return slen; }
601-
602-
let mut dcol = vec::from_fn(tlen + 1, |x| x);
603-
604-
for str::each_chari(s) |i, sc| {
605-
606-
let mut current = i;
607-
dcol[0] = current + 1;
608-
609-
for str::each_chari(t) |j, tc| {
610-
611-
let mut next = dcol[j + 1];
612-
613-
if sc == tc {
614-
dcol[j + 1] = current;
615-
} else {
616-
dcol[j + 1] = ::cmp::min(current, next);
617-
dcol[j + 1] = ::cmp::min(dcol[j + 1], dcol[j]) + 1;
618-
}
619-
620-
current = next;
621-
}
622-
}
623-
624-
return dcol[tlen];
625-
}
626-
627593
/**
628594
* Splits a string into a vector of the substrings separated by LF ('\n')
629595
*/

branches/try2/src/librustc/back/link.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,6 @@ pub fn link_binary(sess: Session,
838838
}
839839
}
840840
841-
// Always want the runtime linked in
842-
cc_args.push(~"-lrustrt");
843-
844841
// On linux librt and libdl are an indirect dependencies via rustrt,
845842
// and binutils 2.22+ won't add them automatically
846843
if sess.targ_cfg.os == session::os_linux {
@@ -880,6 +877,9 @@ pub fn link_binary(sess: Session,
880877
cc_args.push(~"-lmorestack");
881878
}
882879

880+
// Always want the runtime linked in
881+
cc_args.push(~"-lrustrt");
882+
883883
// FIXME (#2397): At some point we want to rpath our guesses as to where
884884
// extern libraries might live, based on the addl_lib_search_paths
885885
cc_args.push_all(rpath::get_rpath_flags(sess, &output));

branches/try2/src/librustc/middle/lang_items.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,18 @@ pub enum LangItem {
7575
ReturnToMutFnLangItem, // 31
7676
CheckNotBorrowedFnLangItem, // 32
7777
StrDupUniqFnLangItem, // 33
78+
79+
StartFnLangItem, // 34
7880
}
7981

8082
pub struct LanguageItems {
81-
items: [ Option<def_id> * 34 ]
83+
items: [ Option<def_id> * 35 ]
8284
}
8385

8486
pub impl LanguageItems {
8587
static pub fn new(&self) -> LanguageItems {
8688
LanguageItems {
87-
items: [ None, ..34 ]
89+
items: [ None, ..35 ]
8890
}
8991
}
9092

@@ -136,6 +138,8 @@ pub impl LanguageItems {
136138
32 => "check_not_borrowed",
137139
33 => "strdup_uniq",
138140

141+
34 => "start",
142+
139143
_ => "???"
140144
}
141145
}
@@ -248,6 +252,9 @@ pub impl LanguageItems {
248252
pub fn strdup_uniq_fn(&const self) -> def_id {
249253
self.items[StrDupUniqFnLangItem as uint].get()
250254
}
255+
pub fn start_fn(&const self) -> def_id {
256+
self.items[StartFnLangItem as uint].get()
257+
}
251258
}
252259

253260
fn LanguageItemCollector(crate: @crate,
@@ -296,6 +303,7 @@ fn LanguageItemCollector(crate: @crate,
296303
item_refs.insert(@~"check_not_borrowed",
297304
CheckNotBorrowedFnLangItem as uint);
298305
item_refs.insert(@~"strdup_uniq", StrDupUniqFnLangItem as uint);
306+
item_refs.insert(@~"start", StartFnLangItem as uint);
299307

300308
LanguageItemCollector {
301309
crate: crate,

branches/try2/src/librustc/middle/resolve.rs

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4816,42 +4816,6 @@ pub impl Resolver {
48164816
}
48174817
}
48184818
4819-
fn find_best_match_for_name(@mut self, name: &str) -> Option<~str> {
4820-
let mut maybes: ~[~str] = ~[];
4821-
let mut values: ~[uint] = ~[];
4822-
4823-
let mut j = self.value_ribs.len();
4824-
while j != 0 {
4825-
j -= 1;
4826-
let rib = self.value_ribs.get_elt(j);
4827-
for rib.bindings.each_entry |e| {
4828-
vec::push(&mut maybes, copy *self.session.str_of(e.key));
4829-
vec::push(&mut values, uint::max_value);
4830-
}
4831-
}
4832-
4833-
let mut smallest = 0;
4834-
for vec::eachi(maybes) |i, &other| {
4835-
4836-
values[i] = str::levdistance(name, other);
4837-
4838-
if values[i] <= values[smallest] {
4839-
smallest = i;
4840-
}
4841-
}
4842-
4843-
if vec::len(values) > 0 &&
4844-
values[smallest] != uint::max_value &&
4845-
values[smallest] < str::len(name) + 2 &&
4846-
maybes[smallest] != name.to_owned() {
4847-
4848-
Some(vec::swap_remove(&mut maybes, smallest))
4849-
4850-
} else {
4851-
None
4852-
}
4853-
}
4854-
48554819
fn name_exists_in_scope_struct(@mut self, name: &str) -> bool {
48564820
let mut i = self.type_ribs.len();
48574821
while i != 0 {
@@ -4918,20 +4882,9 @@ pub impl Resolver {
49184882
wrong_name));
49194883
}
49204884
else {
4921-
match self.find_best_match_for_name(wrong_name) {
4922-
4923-
Some(m) => {
4924-
self.session.span_err(expr.span,
4925-
fmt!("unresolved name: `%s`. \
4926-
Did you mean: `%s`?",
4927-
wrong_name, m));
4928-
}
4929-
None => {
4930-
self.session.span_err(expr.span,
4931-
fmt!("unresolved name: `%s`.",
4885+
self.session.span_err(expr.span,
4886+
fmt!("unresolved name: %s",
49324887
wrong_name));
4933-
}
4934-
}
49354888
}
49364889
}
49374890
}

branches/try2/src/librustc/middle/trans/_match.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ use syntax::ast_util;
172172
use syntax::codemap::span;
173173
use syntax::print::pprust::pat_to_str;
174174

175+
pub fn macros() {
176+
// FIXME(#3114): Macro import/export.
177+
include!("macros.rs");
178+
}
179+
175180
// An option identifying a literal: either a unit-like struct or an
176181
// expression.
177182
pub enum Lit {

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,7 +2267,7 @@ pub fn create_main_wrapper(ccx: @CrateContext,
22672267
fn main_name() -> ~str { return ~"WinMain@16"; }
22682268
#[cfg(unix)]
22692269
fn main_name() -> ~str { return ~"main"; }
2270-
let llfty = T_fn(~[ccx.int_type, ccx.int_type], ccx.int_type);
2270+
let llfty = T_fn(~[ccx.int_type, T_ptr(T_i8())], ccx.int_type);
22712271
22722272
// FIXME #4404 android JNI hacks
22732273
let llfn = if *ccx.sess.building_library {
@@ -2285,33 +2285,50 @@ pub fn create_main_wrapper(ccx: @CrateContext,
22852285
llvm::LLVMPositionBuilderAtEnd(bld, llbb);
22862286
}
22872287
let crate_map = ccx.crate_map;
2288-
let start_ty = T_fn(~[val_ty(rust_main), ccx.int_type, ccx.int_type,
2289-
val_ty(crate_map)], ccx.int_type);
2290-
let start = decl_cdecl_fn(ccx.llmod, ~"rust_start", start_ty);
2288+
let start_def_id = ccx.tcx.lang_items.start_fn();
2289+
let start_fn = if start_def_id.crate == ast::local_crate {
2290+
ccx.sess.bug(~"start lang item is never in the local crate")
2291+
} else {
2292+
let start_fn_type = csearch::get_type(ccx.tcx,
2293+
start_def_id).ty;
2294+
trans_external_path(ccx, start_def_id, start_fn_type)
2295+
};
2296+
2297+
let retptr = unsafe {
2298+
llvm::LLVMBuildAlloca(bld, ccx.int_type, noname())
2299+
};
22912300
22922301
let args = unsafe {
2302+
let opaque_rust_main = llvm::LLVMBuildPointerCast(
2303+
bld, rust_main, T_ptr(T_i8()), noname());
2304+
let opaque_crate_map = llvm::LLVMBuildPointerCast(
2305+
bld, crate_map, T_ptr(T_i8()), noname());
2306+
22932307
if *ccx.sess.building_library {
22942308
~[
2295-
rust_main,
2309+
retptr,
2310+
C_null(T_opaque_box_ptr(ccx)),
2311+
opaque_rust_main,
22962312
llvm::LLVMConstInt(T_i32(), 0u as c_ulonglong, False),
22972313
llvm::LLVMConstInt(T_i32(), 0u as c_ulonglong, False),
2298-
crate_map
2314+
opaque_crate_map
22992315
]
23002316
} else {
23012317
~[
2302-
rust_main,
2318+
retptr,
2319+
C_null(T_opaque_box_ptr(ccx)),
2320+
opaque_rust_main,
23032321
llvm::LLVMGetParam(llfn, 0 as c_uint),
23042322
llvm::LLVMGetParam(llfn, 1 as c_uint),
2305-
crate_map
2323+
opaque_crate_map
23062324
]
23072325
}
23082326
};
23092327
2310-
let result = unsafe {
2311-
llvm::LLVMBuildCall(bld, start, vec::raw::to_ptr(args),
2312-
args.len() as c_uint, noname())
2313-
};
23142328
unsafe {
2329+
llvm::LLVMBuildCall(bld, start_fn, vec::raw::to_ptr(args),
2330+
args.len() as c_uint, noname());
2331+
let result = llvm::LLVMBuildLoad(bld, retptr, noname());
23152332
llvm::LLVMBuildRet(bld, result);
23162333
}
23172334
}

branches/try2/src/librustc/middle/trans/controlflow.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ use middle::trans::datum::*;
1818

1919
use core::str;
2020

21+
pub fn macros() {
22+
// FIXME(#3114): Macro import/export.
23+
include!("macros.rs");
24+
}
25+
2126
pub fn trans_block(bcx: block, b: &ast::blk, dest: expr::Dest) -> block {
2227
let _icx = bcx.insn_ctxt("trans_block");
2328
let mut bcx = bcx;

0 commit comments

Comments
 (0)