Skip to content

Commit bceea83

Browse files
committed
change def's that are always local to use node_id, add --inline opt
1 parent a1b2f34 commit bceea83

File tree

19 files changed

+125
-111
lines changed

19 files changed

+125
-111
lines changed

Makefile.in

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,13 @@ TSREQS := \
410410
FUZZ := $(HBIN3_H_$(CFG_HOST_TRIPLE))/fuzzer$(X)
411411
CARGO := $(HBIN3_H_$(CFG_HOST_TRIPLE))/cargo$(X)
412412
RUSTDOC := $(HBIN3_H_$(CFG_HOST_TRIPLE))/rustdoc$(X)
413-
SERIALIZER := $(HBIN2_H_$(CFG_HOST_TRIPLE))/serializer$(X)
414-
# ^^ Note: we use HBIN2 because that is the only stage for which
415-
# we build a complete rustc by default, and serializer requires
416-
# the complete rustc.
417413

418-
all: rustc $(GENERATED) docs $(FUZZ) $(CARGO) $(RUSTDOC) $(SERIALIZER)
414+
all: rustc $(GENERATED) docs $(FUZZ) $(CARGO) $(RUSTDOC) serializer
415+
416+
serializer: $(HBIN1_H_$(CFG_HOST_TRIPLE))/serializer$(X) \
417+
$(SREQ1_T_$(CFG_HOST_TRIPLE)_H_$(CFG_HOST_TRIPLE))
418+
# ^^ Note: we use HBIN1 because that is built by the snapshot compiler
419+
# and sometimes we need the serializer to build the later stages.
419420

420421
endif
421422

configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,5 +670,6 @@ rm -f config.mk.bak
670670

671671
msg
672672
copy ${CFG_SRC_DIR}Makefile.in ./Makefile
673+
chmod u-w Makefile # it is generated, make it read-only
673674

674675
step_msg "complete"

src/comp/driver/driver.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,10 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
177177
last_uses: last_uses, impl_map: impl_map,
178178
method_map: method_map, dict_map: dict_map};
179179

180+
let ienbld = sess.opts.inline;
180181
let inline_map =
181182
time(time_passes, "inline",
182-
bind inline::instantiate_inlines(ty_cx, maps, crate));
183+
bind inline::instantiate_inlines(ienbld, ty_cx, maps, crate));
183184

184185
let (llmod, link_meta) =
185186
time(time_passes, "translation",
@@ -363,6 +364,7 @@ fn build_session_options(match: getopts::match,
363364
lint_opts += [(lint::ctypes, false)];
364365
}
365366
let monomorphize = opt_present(match, "monomorphize");
367+
let inline = opt_present(match, "inline");
366368

367369
let output_type =
368370
if parse_only || no_trans {
@@ -441,6 +443,7 @@ fn build_session_options(match: getopts::match,
441443
no_trans: no_trans,
442444
no_asm_comments: no_asm_comments,
443445
monomorphize: monomorphize,
446+
inline: inline,
444447
warn_unused_imports: warn_unused_imports};
445448
ret sopts;
446449
}
@@ -511,6 +514,7 @@ fn opts() -> [getopts::opt] {
511514
optflag("no-verify"),
512515
optflag("no-lint-ctypes"),
513516
optflag("monomorphize"),
517+
optflag("inline"),
514518
optmulti("cfg"), optflag("test"),
515519
optflag("lib"), optflag("bin"), optflag("static"), optflag("gc"),
516520
optflag("no-asm-comments"),

src/comp/driver/session.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type options =
4646
no_trans: bool,
4747
no_asm_comments: bool,
4848
monomorphize: bool,
49+
inline: bool,
4950
warn_unused_imports: bool};
5051

5152
type crate_metadata = {name: str, data: [u8]};

src/comp/metadata/astencode.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,24 +354,22 @@ impl of tr for ast::def {
354354
fn tr(xcx: extended_decode_ctxt) -> ast::def {
355355
alt self {
356356
ast::def_fn(did, p) { ast::def_fn(did.tr(xcx), p) }
357-
ast::def_self(did) { ast::def_self(did.tr(xcx)) }
357+
ast::def_self(nid) { ast::def_self(xcx.tr_id(nid)) }
358358
ast::def_mod(did) { ast::def_mod(did.tr(xcx)) }
359359
ast::def_native_mod(did) { ast::def_native_mod(did.tr(xcx)) }
360360
ast::def_const(did) { ast::def_const(did.tr(xcx)) }
361-
ast::def_arg(did, m) { ast::def_arg(did.tr_intern(xcx), m) }
362-
ast::def_local(did) { ast::def_local(did.tr_intern(xcx)) }
361+
ast::def_arg(nid, m) { ast::def_arg(xcx.tr_id(nid), m) }
362+
ast::def_local(nid) { ast::def_local(xcx.tr_id(nid)) }
363363
ast::def_variant(e_did, v_did) {
364364
ast::def_variant(e_did.tr(xcx), v_did.tr(xcx))
365365
}
366366
ast::def_ty(did) { ast::def_ty(did.tr(xcx)) }
367367
ast::def_prim_ty(p) { ast::def_prim_ty(p) }
368368
ast::def_ty_param(did, v) { ast::def_ty_param(did.tr(xcx), v) }
369-
ast::def_binding(did) { ast::def_binding(did.tr(xcx)) }
369+
ast::def_binding(nid) { ast::def_binding(xcx.tr_id(nid)) }
370370
ast::def_use(did) { ast::def_use(did.tr(xcx)) }
371-
ast::def_upvar(did, def, node_id) {
372-
ast::def_upvar(did.tr_intern(xcx),
373-
@(*def).tr(xcx),
374-
xcx.tr_id(node_id))
371+
ast::def_upvar(nid1, def, nid2) {
372+
ast::def_upvar(xcx.tr_id(nid1), @(*def).tr(xcx), xcx.tr_id(nid2))
375373
}
376374
ast::def_class(did) {
377375
ast::def_class(did.tr(xcx))

src/comp/metadata/astencode_gen.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8009,20 +8009,20 @@ fn serialize_161<S: std::serialization::serializer>(s: S,
80098009

80108010
s.emit_enum("syntax::ast::def",
80118011
/*syntax::ast::def_id*//*syntax::ast::purity*/
8012+
/*syntax::ast::node_id*/
80128013
/*syntax::ast::def_id*/
80138014
/*syntax::ast::def_id*/
80148015
/*syntax::ast::def_id*/
8015-
/*syntax::ast::def_id*/
8016-
/*syntax::ast::def_id*/
8016+
/*syntax::ast::node_id*/
80178017
/*syntax::ast::mode<syntax::ast::rmode>*/
8018-
/*syntax::ast::def_id*/
8018+
/*syntax::ast::node_id*/
80198019
/*syntax::ast::def_id*//*syntax::ast::def_id*/
80208020
/*syntax::ast::def_id*/
80218021
/*syntax::ast::prim_ty*/
80228022
/*syntax::ast::def_id*//*uint*/
8023+
/*syntax::ast::node_id*/
80238024
/*syntax::ast::def_id*/
8024-
/*syntax::ast::def_id*/
8025-
/*syntax::ast::def_id*//*@syntax::ast::def*/
8025+
/*syntax::ast::node_id*//*@syntax::ast::def*/
80268026
/*syntax::ast::node_id*/
80278027
/*syntax::ast::def_id*/
80288028
/*syntax::ast::def_id*//*syntax::ast::def_id*/
@@ -8052,8 +8052,8 @@ fn serialize_161<S: std::serialization::serializer>(s: S,
80528052
{
80538053
s.emit_enum_variant_arg(0u,
80548054
{||
8055-
serialize_162(s,
8056-
v0)
8055+
serialize_27(s,
8056+
v0)
80578057
})
80588058
}
80598059
})
@@ -8101,8 +8101,8 @@ fn serialize_161<S: std::serialization::serializer>(s: S,
81018101
{
81028102
s.emit_enum_variant_arg(0u,
81038103
{||
8104-
serialize_162(s,
8105-
v0)
8104+
serialize_27(s,
8105+
v0)
81068106
});
81078107
s.emit_enum_variant_arg(1u,
81088108
{||
@@ -8118,8 +8118,8 @@ fn serialize_161<S: std::serialization::serializer>(s: S,
81188118
{
81198119
s.emit_enum_variant_arg(0u,
81208120
{||
8121-
serialize_162(s,
8122-
v0)
8121+
serialize_27(s,
8122+
v0)
81238123
})
81248124
}
81258125
})
@@ -8192,8 +8192,8 @@ fn serialize_161<S: std::serialization::serializer>(s: S,
81928192
{
81938193
s.emit_enum_variant_arg(0u,
81948194
{||
8195-
serialize_162(s,
8196-
v0)
8195+
serialize_27(s,
8196+
v0)
81978197
})
81988198
}
81998199
})
@@ -8216,8 +8216,8 @@ fn serialize_161<S: std::serialization::serializer>(s: S,
82168216
{
82178217
s.emit_enum_variant_arg(0u,
82188218
{||
8219-
serialize_162(s,
8220-
v0)
8219+
serialize_27(s,
8220+
v0)
82218221
});
82228222
s.emit_enum_variant_arg(1u,
82238223
{||
@@ -8367,18 +8367,18 @@ fn deserialize_161<S: std::serialization::deserializer>(s: S) ->
83678367
s.read_enum("syntax::ast::def",
83688368
/*syntax::ast::def_id*//*syntax::ast::purity*/
83698369

8370-
/*syntax::ast::def_id*/
8370+
/*syntax::ast::node_id*/
83718371

83728372
/*syntax::ast::def_id*/
83738373

83748374
/*syntax::ast::def_id*/
83758375

83768376
/*syntax::ast::def_id*/
83778377

8378-
/*syntax::ast::def_id*/
8378+
/*syntax::ast::node_id*/
83798379
/*syntax::ast::mode<syntax::ast::rmode>*/
83808380

8381-
/*syntax::ast::def_id*/
8381+
/*syntax::ast::node_id*/
83828382

83838383
/*syntax::ast::def_id*//*syntax::ast::def_id*/
83848384

@@ -8388,11 +8388,11 @@ fn deserialize_161<S: std::serialization::deserializer>(s: S) ->
83888388

83898389
/*syntax::ast::def_id*//*uint*/
83908390

8391-
/*syntax::ast::def_id*/
8391+
/*syntax::ast::node_id*/
83928392

83938393
/*syntax::ast::def_id*/
83948394

8395-
/*syntax::ast::def_id*//*@syntax::ast::def*/
8395+
/*syntax::ast::node_id*//*@syntax::ast::def*/
83968396
/*syntax::ast::node_id*/
83978397

83988398
/*syntax::ast::def_id*/
@@ -8416,7 +8416,7 @@ fn deserialize_161<S: std::serialization::deserializer>(s: S) ->
84168416
1u {
84178417
syntax::ast::def_self(s.read_enum_variant_arg(0u,
84188418
{||
8419-
deserialize_162(s)
8419+
deserialize_27(s)
84208420
}))
84218421
}
84228422
2u {
@@ -8440,7 +8440,7 @@ fn deserialize_161<S: std::serialization::deserializer>(s: S) ->
84408440
5u {
84418441
syntax::ast::def_arg(s.read_enum_variant_arg(0u,
84428442
{||
8443-
deserialize_162(s)
8443+
deserialize_27(s)
84448444
}),
84458445
s.read_enum_variant_arg(1u,
84468446
{||
@@ -8450,7 +8450,7 @@ fn deserialize_161<S: std::serialization::deserializer>(s: S) ->
84508450
6u {
84518451
syntax::ast::def_local(s.read_enum_variant_arg(0u,
84528452
{||
8453-
deserialize_162(s)
8453+
deserialize_27(s)
84548454
}))
84558455
}
84568456
7u {
@@ -8488,7 +8488,7 @@ fn deserialize_161<S: std::serialization::deserializer>(s: S) ->
84888488
11u {
84898489
syntax::ast::def_binding(s.read_enum_variant_arg(0u,
84908490
{||
8491-
deserialize_162(s)
8491+
deserialize_27(s)
84928492
}))
84938493
}
84948494
12u {
@@ -8500,7 +8500,7 @@ fn deserialize_161<S: std::serialization::deserializer>(s: S) ->
85008500
13u {
85018501
syntax::ast::def_upvar(s.read_enum_variant_arg(0u,
85028502
{||
8503-
deserialize_162(s)
8503+
deserialize_27(s)
85048504
}),
85058505
s.read_enum_variant_arg(1u,
85068506
{||

src/comp/middle/inline.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ enum ctxt = {
1818
mutable to_process: [@ast::item]
1919
};
2020

21-
fn instantiate_inlines(tcx: ty::ctxt,
21+
fn instantiate_inlines(enabled: bool,
22+
tcx: ty::ctxt,
2223
maps: maps,
2324
crate: @ast::crate) -> inline_map {
2425
let vt = visit::mk_vt(@{
@@ -31,7 +32,7 @@ fn instantiate_inlines(tcx: ty::ctxt,
3132
let inline_map = ast_util::new_def_id_hash();
3233
let cx = ctxt({tcx: tcx, maps: maps,
3334
inline_map: inline_map, mutable to_process: []});
34-
visit::visit_crate(*crate, cx, vt);
35+
if enabled { visit::visit_crate(*crate, cx, vt); }
3536
while !vec::is_empty(cx.to_process) {
3637
let to_process = [];
3738
to_process <-> cx.to_process;

src/comp/middle/last_use.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,15 @@ fn clear_in_current(cx: ctx, my_def: node_id, to: bool) {
288288
fn clear_def_if_path(cx: ctx, d: def, to: bool)
289289
-> option<node_id> {
290290
alt d {
291-
def_local(def_id) {
292-
clear_in_current(cx, def_id.node, to);
293-
some(def_id.node)
291+
def_local(nid) {
292+
clear_in_current(cx, nid, to);
293+
some(nid)
294294
}
295-
def_arg(def_id, m) {
295+
def_arg(nid, m) {
296296
alt ty::resolved_mode(cx.tcx, m) {
297297
by_copy | by_move {
298-
clear_in_current(cx, def_id.node, to);
299-
some(def_id.node)
298+
clear_in_current(cx, nid, to);
299+
some(nid)
300300
}
301301
by_ref | by_val | by_mutbl_ref {
302302
none

0 commit comments

Comments
 (0)