Skip to content

Commit 1ae4180

Browse files
committed
---
yaml --- r: 11187 b: refs/heads/master c: 48eda22 h: refs/heads/master i: 11185: 69ead63 11183: 47cfe4c v: v3
1 parent da32ccd commit 1ae4180

File tree

21 files changed

+188
-117
lines changed

21 files changed

+188
-117
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 17110fb28bf7e73fbefc05a1d112e2203bd5e7de
2+
refs/heads/master: 48eda22835e58ec1f14f6333e444ccc8a32244b7
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/configure

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ opt docs 1 "build documentation"
262262
opt optimize 1 "build optimized rust code"
263263
opt optimize-cxx 1 "build optimized C++ code"
264264
opt optimize-llvm 1 "build optimized LLVM"
265-
opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
266265
opt manage-submodules 1 "let the build manage the git submodules"
267266
opt mingw-cross 0 "cross-compile for win32 using mingw"
268267
opt clang 0 "prefer clang to gcc for building the runtime"

trunk/mk/llvm.mk

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
2-
ifdef CFG_ENABLE_FAST_MAKE
3-
LLVM_DEPS := $(S)/.gitmodules
4-
else
51
# Recursive wildcard function
62
# http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html
73
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
84
$(filter $(subst *,%,$2),$d))
95

106
# This is just a rough approximation of LLVM deps
117
LLVM_DEPS=$(call rwildcard,$(CFG_LLVM_SRC_DIR),*cpp *hpp)
12-
endif
138

149
define DEF_LLVM_RULES
1510

trunk/mk/rt.mk

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,11 @@ rt/$(1)/$(CFG_RUNTIME): $$(RUNTIME_OBJS_$(1)) $$(MKFILE_DEPS) \
158158
# FIXME: For some reason libuv's makefiles can't figure out the correct definition
159159
# of CC on the mingw I'm using, so we are explicitly using gcc. Also, we
160160
# have to list environment variables first on windows... mysterious
161-
162-
ifdef CFG_ENABLE_FAST_MAKE
163-
LIBUV_DEPS := $$(S)/.gitmodules
164-
else
165-
LIBUV_DEPS := $$(wildcard \
166-
$$(S)src/libuv/* \
167-
$$(S)src/libuv/*/* \
168-
$$(S)src/libuv/*/*/* \
169-
$$(S)src/libuv/*/*/*/*)
170-
endif
171-
172-
$$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS)
161+
$$(LIBUV_LIB_$(1)): $$(wildcard \
162+
$$(S)src/libuv/* \
163+
$$(S)src/libuv/*/* \
164+
$$(S)src/libuv/*/*/* \
165+
$$(S)src/libuv/*/*/*/*)
173166
$$(Q)$$(MAKE) -C $$(S)mk/libuv/$$(LIBUV_ARCH_$(1))/$$(LIBUV_OSTYPE_$(1)) \
174167
CFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1)))" \
175168
LDFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1)))" \

trunk/src/comp/driver/diagnostic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ fn emit(cmsp: option<(codemap::codemap, span)>,
175175
msg: str, lvl: level) {
176176
alt cmsp {
177177
some((cm, sp)) {
178+
let sp = codemap::adjust_span(cm,sp);
178179
let ss = codemap::span_to_str(sp, cm);
179180
let lines = codemap::span_to_lines(sp, cm);
180181
print_diagnostic(ss, lvl, msg);

trunk/src/comp/syntax/codemap.rs

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ type file_pos = {ch: uint, byte: uint};
88
* compiler.
99
*/
1010

11-
type file_substr_ = {lo: uint, hi: uint, col: uint, line: uint};
12-
type file_substr = option<file_substr_>;
11+
enum file_substr {
12+
fss_none,
13+
fss_internal(span),
14+
fss_external({filename: str, line: uint, col: uint})
15+
}
1316

1417
type filemap =
1518
@{name: filename, substr: file_substr, src: @str,
@@ -33,16 +36,14 @@ fn new_filemap_w_substr(filename: filename, substr: file_substr,
3336
fn new_filemap(filename: filename, src: @str,
3437
start_pos_ch: uint, start_pos_byte: uint)
3538
-> filemap {
36-
ret new_filemap_w_substr(filename, none, src,
39+
ret new_filemap_w_substr(filename, fss_none, src,
3740
start_pos_ch, start_pos_byte);
3841
}
3942

40-
fn get_substr_info(cm: codemap, lo: uint, hi: uint)
41-
-> (filename, file_substr_)
43+
fn mk_substr_filename(cm: codemap, sp: span) -> str
4244
{
43-
let pos = lookup_char_pos(cm, lo);
44-
let name = #fmt("<%s:%u:%u>", pos.file.name, pos.line, pos.col);
45-
ret (name, {lo: lo, hi: hi, col: pos.col, line: pos.line});
45+
let pos = lookup_char_pos(cm, sp.lo);
46+
ret #fmt("<%s:%u:%u>", pos.file.name, pos.line, pos.col);
4647
}
4748

4849
fn next_line(file: filemap, chpos: uint, byte_pos: uint) {
@@ -89,26 +90,66 @@ fn lookup_byte_pos(map: codemap, pos: uint) -> loc {
8990
ret lookup_pos(map, pos, lookup);
9091
}
9192

93+
fn lookup_char_pos_adj(map: codemap, pos: uint)
94+
-> {filename: str, line: uint, col: uint, file: option<filemap>}
95+
{
96+
let loc = lookup_char_pos(map, pos);
97+
alt (loc.file.substr) {
98+
fss_none {
99+
{filename: loc.file.name, line: loc.line, col: loc.col,
100+
file: some(loc.file)}
101+
}
102+
fss_internal(sp) {
103+
lookup_char_pos_adj(map, sp.lo + (pos - loc.file.start_pos.ch))
104+
}
105+
fss_external(eloc) {
106+
{filename: eloc.filename,
107+
line: eloc.line + loc.line - 1u,
108+
col: if loc.line == 1u {eloc.col + loc.col} else {loc.col},
109+
file: none}
110+
}
111+
}
112+
}
113+
114+
fn adjust_span(map: codemap, sp: span) -> span {
115+
fn lookup(pos: file_pos) -> uint { ret pos.ch; }
116+
let line = lookup_line(map, sp.lo, lookup);
117+
alt (line.fm.substr) {
118+
fss_none {sp}
119+
fss_internal(s) {
120+
adjust_span(map, {lo: s.lo + (sp.lo - line.fm.start_pos.ch),
121+
hi: s.lo + (sp.hi - line.fm.start_pos.ch),
122+
expn_info: sp.expn_info})}
123+
fss_external(_) {sp}
124+
}
125+
}
126+
92127
enum expn_info_ {
93128
expanded_from({call_site: span,
94129
callie: {name: str, span: option<span>}})
95130
}
96131
type expn_info = option<@expn_info_>;
97132
type span = {lo: uint, hi: uint, expn_info: expn_info};
98133

99-
fn span_to_str(sp: span, cm: codemap) -> str {
134+
fn span_to_str_no_adj(sp: span, cm: codemap) -> str {
100135
let lo = lookup_char_pos(cm, sp.lo);
101136
let hi = lookup_char_pos(cm, sp.hi);
102137
ret #fmt("%s:%u:%u: %u:%u", lo.file.name,
103138
lo.line, lo.col, hi.line, hi.col)
104139
}
105140

141+
fn span_to_str(sp: span, cm: codemap) -> str {
142+
let lo = lookup_char_pos_adj(cm, sp.lo);
143+
let hi = lookup_char_pos_adj(cm, sp.hi);
144+
ret #fmt("%s:%u:%u: %u:%u", lo.filename,
145+
lo.line, lo.col, hi.line, hi.col)
146+
}
147+
106148
type file_lines = {file: filemap, lines: [uint]};
107149

108150
fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
109151
let lo = lookup_char_pos(cm, sp.lo);
110152
let hi = lookup_char_pos(cm, sp.hi);
111-
// FIXME: Check for filemap?
112153
let lines = [];
113154
uint::range(lo.line - 1u, hi.line as uint) {|i| lines += [i]; };
114155
ret @{file: lo.file, lines: lines};

trunk/src/comp/syntax/ext/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import std::map::hashmap;
55
import syntax::ast::{crate, expr_, expr_mac, mac_invoc};
66
import syntax::fold::*;
77
import syntax::ext::base::*;
8-
import syntax::ext::qquote::{expand_qquote,qq_helper};
8+
import syntax::ext::qquote::{qq_helper};
99
import syntax::parse::parser::parse_expr_from_source_str;
1010

1111
import codemap::{span, expanded_from};

trunk/src/comp/syntax/ext/qquote.rs

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,6 @@ fn expand_ast(ecx: ext_ctxt, _sp: span,
143143
}
144144
}
145145
let body = get_mac_body(ecx,_sp,body);
146-
fn finish<T: qq_helper>(ecx: ext_ctxt, body: ast::mac_body_,
147-
f: fn (p: parser) -> T)
148-
-> @ast::expr
149-
{
150-
let cm = ecx.session().parse_sess.cm;
151-
let str = @codemap::span_to_snippet(body.span, cm);
152-
let (fname, ss) = codemap::get_substr_info
153-
(cm, body.span.lo, body.span.hi);
154-
let node = parse_from_source_str
155-
(f, fname, some(ss), str,
156-
ecx.session().opts.cfg, ecx.session().parse_sess);
157-
ret expand_qquote(ecx, node.span(), *str, node);
158-
}
159146

160147
ret alt what {
161148
"expr" {finish(ecx, body, parser::parse_expr)}
@@ -182,23 +169,33 @@ fn parse_item(p: parser) -> @ast::item {
182169
}
183170
}
184171

185-
fn expand_qquote<N: qq_helper>
186-
(ecx: ext_ctxt, sp: span, str: str, node: N)
172+
fn finish<T: qq_helper>
173+
(ecx: ext_ctxt, body: ast::mac_body_, f: fn (p: parser) -> T)
187174
-> @ast::expr
188175
{
176+
let cm = ecx.session().parse_sess.cm;
177+
let str = @codemap::span_to_snippet(body.span, cm);
178+
let fname = codemap::mk_substr_filename(cm, body.span);
179+
let node = parse_from_source_str
180+
(f, fname, codemap::fss_internal(body.span), str,
181+
ecx.session().opts.cfg, ecx.session().parse_sess);
182+
let loc = codemap::lookup_char_pos(cm, body.span.lo);
183+
184+
let sp = node.span();
189185
let qcx = gather_anti_quotes(sp.lo, node);
190186
let cx = qcx;
191-
let prev = 0u;
192-
for {lo: lo, _} in cx.gather {
193-
assert lo > prev;
194-
prev = lo;
187+
188+
// assert that the vector is sorted by position:
189+
uint::range(1u, vec::len(cx.gather)) {|i|
190+
assert cx.gather[i-1u].lo < cx.gather[i].lo;
195191
}
192+
196193
let str2 = "";
197194
enum state {active, skip(uint), blank};
198195
let state = active;
199196
let i = 0u, j = 0u;
200197
let g_len = vec::len(cx.gather);
201-
str::chars_iter(str) {|ch|
198+
str::chars_iter(*str) {|ch|
202199
if (j < g_len && i == cx.gather[j].lo) {
203200
assert ch == '$';
204201
let repl = #fmt("$%u ", j);
@@ -228,8 +225,12 @@ fn expand_qquote<N: qq_helper>
228225
["syntax", "parse", "parser",
229226
"parse_from_source_str"],
230227
[node.mk_parse_fn(cx,sp),
231-
mk_str(cx,sp, "<anon>"),
232-
mk_path(cx,sp, ["option","none"]),
228+
mk_str(cx,sp, fname),
229+
mk_call(cx,sp,
230+
["syntax","ext","qquote", "mk_file_substr"],
231+
[mk_str(cx,sp, loc.file.name),
232+
mk_uint(cx,sp, loc.line),
233+
mk_uint(cx,sp, loc.col)]),
233234
mk_unary(cx,sp, ast::box(ast::imm),
234235
mk_str(cx,sp, str2)),
235236
mk_access_(cx,sp,
@@ -306,6 +307,10 @@ fn print_expr(expr: @ast::expr) {
306307
stdout.write_str("\n");
307308
}
308309

310+
fn mk_file_substr(fname: str, line: uint, col: uint) -> codemap::file_substr {
311+
codemap::fss_external({filename: fname, line: line, col: col})
312+
}
313+
309314
// Local Variables:
310315
// mode: rust
311316
// fill-column: 78;

trunk/src/comp/syntax/parse/lexer.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ impl reader for reader {
4343
let next = str::char_range_at(*self.src, self.pos);
4444
self.pos = next.next;
4545
self.curr = next.ch;
46-
} else { self.curr = -1 as char; }
46+
} else {
47+
if (self.curr != -1 as char) {
48+
self.col += 1u;
49+
self.chpos += 1u;
50+
self.curr = -1 as char;
51+
}
52+
}
4753
}
4854
fn fatal(m: str) -> ! {
4955
self.span_diagnostic.span_fatal(

trunk/src/comp/syntax/parse/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import std::{io, fs};
22
import either::{left, right};
33
import std::map::{hashmap, new_str_hash};
44
import token::can_begin_expr;
5-
import codemap::span;
5+
import codemap::{span,fss_none};
66
import util::interner;
77
import ast::{node_id, spanned};
88
import ast_util::{mk_sp, ident_to_path};
@@ -2607,7 +2607,7 @@ fn parse_crate_from_source_file(input: str, cfg: ast::crate_cfg,
26072607

26082608
fn parse_expr_from_source_str(name: str, source: @str, cfg: ast::crate_cfg,
26092609
sess: parse_sess) -> @ast::expr {
2610-
let p = new_parser_from_source_str(sess, cfg, name, none, source);
2610+
let p = new_parser_from_source_str(sess, cfg, name, fss_none, source);
26112611
let r = parse_expr(p);
26122612
sess.chpos = p.reader.chpos;
26132613
sess.byte_pos = sess.byte_pos + p.reader.pos;
@@ -2629,7 +2629,7 @@ fn parse_from_source_str<T>(f: fn (p: parser) -> T,
26292629

26302630
fn parse_crate_from_source_str(name: str, source: @str, cfg: ast::crate_cfg,
26312631
sess: parse_sess) -> @ast::crate {
2632-
let p = new_parser_from_source_str(sess, cfg, name, none, source);
2632+
let p = new_parser_from_source_str(sess, cfg, name, fss_none, source);
26332633
let r = parse_crate_mod(p, cfg);
26342634
sess.chpos = p.reader.chpos;
26352635
sess.byte_pos = sess.byte_pos + p.reader.pos;

trunk/src/rt/rust_stack.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
#include "vg/valgrind.h"
44
#include "vg/memcheck.h"
55

6+
// A value that goes at the end of the stack and must not be touched
7+
const uint8_t stack_canary[] = {0xAB, 0xCD, 0xAB, 0xCD,
8+
0xAB, 0xCD, 0xAB, 0xCD,
9+
0xAB, 0xCD, 0xAB, 0xCD,
10+
0xAB, 0xCD, 0xAB, 0xCD};
11+
612
void
7-
register_valgrind_stack(stk_seg *stk) {
13+
config_valgrind_stack(stk_seg *stk) {
814
stk->valgrind_id =
915
VALGRIND_STACK_REGISTER(&stk->data[0],
1016
stk->end);
11-
}
12-
13-
void
14-
prepare_valgrind_stack(stk_seg *stk) {
1517
#ifndef NVALGRIND
1618
// Establish that the stack is accessible. This must be done when reusing
1719
// old stack segments, since the act of popping the stack previously
@@ -23,7 +25,7 @@ prepare_valgrind_stack(stk_seg *stk) {
2325
}
2426

2527
void
26-
deregister_valgrind_stack(stk_seg *stk) {
28+
unconfig_valgrind_stack(stk_seg *stk) {
2729
VALGRIND_STACK_DEREGISTER(stk->valgrind_id);
2830
}
2931

trunk/src/rt/rust_stack.h

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,31 @@ struct stk_seg {
1313
uint8_t data[];
1414
};
1515

16-
// A value that goes at the end of the stack and must not be touched
17-
const uint8_t stack_canary[] = {0xAB, 0xCD, 0xAB, 0xCD,
18-
0xAB, 0xCD, 0xAB, 0xCD,
19-
0xAB, 0xCD, 0xAB, 0xCD,
20-
0xAB, 0xCD, 0xAB, 0xCD};
21-
22-
// Used by create_stack
23-
void
24-
register_valgrind_stack(stk_seg *stk);
25-
26-
// Used by destroy_stack
27-
void
28-
deregister_valgrind_stack(stk_seg *stk);
29-
30-
// Used by create_stack
31-
void
32-
add_stack_canary(stk_seg *stk);
33-
3416
template <class T>
3517
stk_seg *
3618
create_stack(T allocer, size_t sz) {
37-
size_t total_sz = sizeof(stk_seg) + sz + sizeof(stack_canary);
19+
size_t total_sz = sizeof(stk_seg) + sz;
3820
stk_seg *stk = (stk_seg *)allocer->malloc(total_sz, "stack");
3921
memset(stk, 0, sizeof(stk_seg));
4022
stk->end = (uintptr_t) &stk->data[sz];
41-
add_stack_canary(stk);
42-
register_valgrind_stack(stk);
4323
return stk;
4424
}
4525

4626
template <class T>
4727
void
4828
destroy_stack(T allocer, stk_seg *stk) {
49-
deregister_valgrind_stack(stk);
5029
allocer->free(stk);
5130
}
5231

53-
// Must be called before each time a stack is reused to tell valgrind
54-
// that the stack is accessible.
5532
void
56-
prepare_valgrind_stack(stk_seg *stk);
33+
config_valgrind_stack(stk_seg *stk);
34+
35+
void
36+
unconfig_valgrind_stack(stk_seg *stk);
37+
38+
void
39+
add_stack_canary(stk_seg *stk);
5740

58-
// Run a sanity check
5941
void
6042
check_stack_canary(stk_seg *stk);
6143

0 commit comments

Comments
 (0)