Skip to content

Commit 8d82562

Browse files
committed
---
yaml --- r: 94775 b: refs/heads/try c: d2a4a10 h: refs/heads/master i: 94773: 7c56014 94771: 04c8efa 94767: e8c11ba v: v3
1 parent 6451045 commit 8d82562

File tree

27 files changed

+719
-210
lines changed

27 files changed

+719
-210
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: 32c480d63d5f867f44719a83c4f58aa6cec6bea7
5+
refs/heads/try: d2a4a107aea7f078ca0c6f0ef81dde5f02f8e0e1
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libextra/enum_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! This module defines a container which uses an efficient bit mask
1414
//! representation to hold C-like enum variants.
1515
16-
#[deriving(Clone, Eq, IterBytes, ToStr)]
16+
#[deriving(Clone, Eq, IterBytes, ToStr, Encodable, Decodable)]
1717
/// A specialized Set implementation to use enum types.
1818
pub struct EnumSet<E> {
1919
// We must maintain the invariant that no bits are set

branches/try/src/libgreen/lib.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,7 @@ impl SchedPool {
214214
pool.handles.push(sched.make_handle());
215215
let sched = sched;
216216
pool.threads.push(do Thread::start {
217-
let mut sched = sched;
218-
let task = do GreenTask::new(&mut sched.stack_pool, None) {
219-
rtdebug!("boostraping a non-primary scheduler");
220-
};
221-
sched.bootstrap(task);
217+
sched.bootstrap();
222218
});
223219
}
224220

@@ -270,13 +266,7 @@ impl SchedPool {
270266
let ret = sched.make_handle();
271267
self.handles.push(sched.make_handle());
272268
let sched = sched;
273-
self.threads.push(do Thread::start {
274-
let mut sched = sched;
275-
let task = do GreenTask::new(&mut sched.stack_pool, None) {
276-
rtdebug!("boostraping a non-primary scheduler");
277-
};
278-
sched.bootstrap(task);
279-
});
269+
self.threads.push(do Thread::start { sched.bootstrap() });
280270

281271
return ret;
282272
}

branches/try/src/libgreen/sched.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl Scheduler {
171171

172172
// Take a main task to run, and a scheduler to run it in. Create a
173173
// scheduler task and bootstrap into it.
174-
pub fn bootstrap(mut ~self, task: ~GreenTask) {
174+
pub fn bootstrap(mut ~self) {
175175

176176
// Build an Idle callback.
177177
let cb = ~SchedRunner as ~Callback;
@@ -187,18 +187,11 @@ impl Scheduler {
187187
self.idle_callback.get_mut_ref().resume();
188188

189189
// Now, as far as all the scheduler state is concerned, we are inside
190-
// the "scheduler" context. So we can act like the scheduler and resume
191-
// the provided task. Let it think that the currently running task is
192-
// actually the sched_task so it knows where to squirrel it away.
193-
let mut sched_task = self.resume_task_immediately(sched_task, task);
194-
195-
// Now we are back in the scheduler context, having
196-
// successfully run the input task. Start by running the
197-
// scheduler. Grab it out of TLS - performing the scheduler
198-
// action will have given it away.
199-
let sched = sched_task.sched.take_unwrap();
200-
rtdebug!("starting scheduler {}", sched.sched_id());
201-
let mut sched_task = sched.run(sched_task);
190+
// the "scheduler" context. The scheduler immediately hands over control
191+
// to the event loop, and this will only exit once the event loop no
192+
// longer has any references (handles or I/O objects).
193+
rtdebug!("starting scheduler {}", self.sched_id());
194+
let mut sched_task = self.run(sched_task);
202195

203196
// Close the idle callback.
204197
let mut sched = sched_task.sched.take_unwrap();
@@ -548,7 +541,10 @@ impl Scheduler {
548541
// We push the task onto our local queue clone.
549542
assert!(!task.is_sched());
550543
self.work_queue.push(task);
551-
self.idle_callback.get_mut_ref().resume();
544+
match self.idle_callback {
545+
Some(ref mut idle) => idle.resume(),
546+
None => {} // allow enqueuing before the scheduler starts
547+
}
552548

553549
// We've made work available. Notify a
554550
// sleeping scheduler.
@@ -1176,25 +1172,21 @@ mod test {
11761172
let mut sh = special_handle;
11771173
sh.send(Shutdown);
11781174
};
1179-
1175+
normal_sched.enqueue_task(normal_task);
11801176

11811177
let special_task = do GreenTask::new(&mut special_sched.stack_pool,
11821178
None) {
11831179
run(task1);
11841180
run(task3);
11851181
chan.send(());
11861182
};
1187-
1183+
special_sched.enqueue_task(special_task);
11881184

11891185
let normal_sched = normal_sched;
1190-
let normal_thread = do Thread::start {
1191-
normal_sched.bootstrap(normal_task);
1192-
};
1186+
let normal_thread = do Thread::start { normal_sched.bootstrap() };
11931187

11941188
let special_sched = special_sched;
1195-
let special_thread = do Thread::start {
1196-
special_sched.bootstrap(special_task);
1197-
};
1189+
let special_thread = do Thread::start { special_sched.bootstrap() };
11981190

11991191
normal_thread.join();
12001192
special_thread.join();

branches/try/src/librustc/metadata/tydecode.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ pub fn parse_trait_ref_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tc
129129
parse_trait_ref(&mut st, conv)
130130
}
131131

132+
pub fn parse_substs_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx: ty::ctxt,
133+
conv: conv_did) -> ty::substs {
134+
let mut st = parse_state_from_data(data, crate_num, pos, tcx);
135+
parse_substs(&mut st, conv)
136+
}
137+
132138
fn parse_sigil(st: &mut PState) -> ast::Sigil {
133139
match next(st) {
134140
'@' => ast::ManagedSigil,

branches/try/src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ fn enc_opt<T>(w: &mut MemWriter, t: Option<T>, enc_f: |&mut MemWriter, T|) {
140140
}
141141
}
142142

143-
fn enc_substs(w: &mut MemWriter, cx: @ctxt, substs: &ty::substs) {
143+
pub fn enc_substs(w: &mut MemWriter, cx: @ctxt, substs: &ty::substs) {
144144
enc_region_substs(w, cx, &substs.regions);
145145
enc_opt(w, substs.self_ty, |w, t| enc_ty(w, cx, t));
146146
mywrite!(w, "[");

branches/try/src/librustc/middle/astencode.rs

Lines changed: 102 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -450,15 +450,13 @@ impl tr for ast::Def {
450450
// ______________________________________________________________________
451451
// Encoding and decoding of adjustment information
452452

453-
impl tr for ty::AutoAdjustment {
454-
fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::AutoAdjustment {
455-
match *self {
456-
ty::AutoAddEnv(r, s) => ty::AutoAddEnv(r.tr(xcx), s),
457-
ty::AutoDerefRef(ref adr) => {
458-
ty::AutoDerefRef(ty::AutoDerefRef {
459-
autoderefs: adr.autoderefs,
460-
autoref: adr.autoref.map(|ar| ar.tr(xcx)),
461-
})
453+
impl tr for ty::AutoDerefRef {
454+
fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::AutoDerefRef {
455+
ty::AutoDerefRef {
456+
autoderefs: self.autoderefs,
457+
autoref: match self.autoref {
458+
Some(ref autoref) => Some(autoref.tr(xcx)),
459+
None => None
462460
}
463461
}
464462
}
@@ -786,6 +784,8 @@ trait ebml_writer_helpers {
786784
fn emit_tpbt(&mut self,
787785
ecx: &e::EncodeContext,
788786
tpbt: ty::ty_param_bounds_and_ty);
787+
fn emit_substs(&mut self, ecx: &e::EncodeContext, substs: &ty::substs);
788+
fn emit_auto_adjustment(&mut self, ecx: &e::EncodeContext, adj: &ty::AutoAdjustment);
789789
}
790790

791791
impl<'a> ebml_writer_helpers for writer::Encoder<'a> {
@@ -833,6 +833,40 @@ impl<'a> ebml_writer_helpers for writer::Encoder<'a> {
833833
})
834834
})
835835
}
836+
837+
fn emit_substs(&mut self, ecx: &e::EncodeContext, substs: &ty::substs) {
838+
self.emit_opaque(|this| tyencode::enc_substs(this.writer, ecx.ty_str_ctxt(), substs))
839+
}
840+
841+
fn emit_auto_adjustment(&mut self, ecx: &e::EncodeContext, adj: &ty::AutoAdjustment) {
842+
self.emit_enum("AutoAdjustment", |this| {
843+
match *adj {
844+
ty::AutoAddEnv(region, sigil) => {
845+
this.emit_enum_variant("AutoAddEnv", 0, 2, |this| {
846+
this.emit_enum_variant_arg(0, |this| region.encode(this));
847+
this.emit_enum_variant_arg(1, |this| sigil.encode(this));
848+
});
849+
}
850+
851+
ty::AutoDerefRef(ref auto_deref_ref) => {
852+
this.emit_enum_variant("AutoDerefRef", 1, 1, |this| {
853+
this.emit_enum_variant_arg(0, |this| auto_deref_ref.encode(this));
854+
});
855+
}
856+
857+
ty::AutoObject(sigil, region, m, b, def_id, ref substs) => {
858+
this.emit_enum_variant("AutoObject", 2, 6, |this| {
859+
this.emit_enum_variant_arg(0, |this| sigil.encode(this));
860+
this.emit_enum_variant_arg(1, |this| region.encode(this));
861+
this.emit_enum_variant_arg(2, |this| m.encode(this));
862+
this.emit_enum_variant_arg(3, |this| b.encode(this));
863+
this.emit_enum_variant_arg(4, |this| def_id.encode(this));
864+
this.emit_enum_variant_arg(5, |this| this.emit_substs(ecx, substs));
865+
});
866+
}
867+
}
868+
});
869+
}
836870
}
837871

838872
trait write_tag_and_id {
@@ -1023,7 +1057,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10231057
ebml_w.tag(c::tag_table_adjustments, |ebml_w| {
10241058
ebml_w.id(id);
10251059
ebml_w.tag(c::tag_table_val, |ebml_w| {
1026-
(**adj).encode(ebml_w)
1060+
ebml_w.emit_auto_adjustment(ecx, **adj);
10271061
})
10281062
})
10291063
}
@@ -1064,6 +1098,8 @@ trait ebml_decoder_decoder_helpers {
10641098
-> ty::TypeParameterDef;
10651099
fn read_ty_param_bounds_and_ty(&mut self, xcx: @ExtendedDecodeContext)
10661100
-> ty::ty_param_bounds_and_ty;
1101+
fn read_substs(&mut self, xcx: @ExtendedDecodeContext) -> ty::substs;
1102+
fn read_auto_adjustment(&mut self, xcx: @ExtendedDecodeContext) -> ty::AutoAdjustment;
10671103
fn convert_def_id(&mut self,
10681104
xcx: @ExtendedDecodeContext,
10691105
source: DefIdSource,
@@ -1172,6 +1208,61 @@ impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
11721208
})
11731209
}
11741210

1211+
fn read_substs(&mut self, xcx: @ExtendedDecodeContext) -> ty::substs {
1212+
self.read_opaque(|this, doc| {
1213+
tydecode::parse_substs_data(doc.data,
1214+
xcx.dcx.cdata.cnum,
1215+
doc.start,
1216+
xcx.dcx.tcx,
1217+
|s, a| this.convert_def_id(xcx, s, a))
1218+
})
1219+
}
1220+
1221+
fn read_auto_adjustment(&mut self, xcx: @ExtendedDecodeContext) -> ty::AutoAdjustment {
1222+
self.read_enum("AutoAdjustment", |this| {
1223+
let variants = ["AutoAddEnv", "AutoDerefRef", "AutoObject"];
1224+
this.read_enum_variant(variants, |this, i| {
1225+
match i {
1226+
0 => {
1227+
let region: ty::Region =
1228+
this.read_enum_variant_arg(0, |this| Decodable::decode(this));
1229+
let sigil: ast::Sigil =
1230+
this.read_enum_variant_arg(1, |this| Decodable::decode(this));
1231+
1232+
ty:: AutoAddEnv(region.tr(xcx), sigil)
1233+
}
1234+
1 => {
1235+
let auto_deref_ref: ty::AutoDerefRef =
1236+
this.read_enum_variant_arg(0, |this| Decodable::decode(this));
1237+
1238+
ty::AutoDerefRef(auto_deref_ref.tr(xcx))
1239+
}
1240+
2 => {
1241+
let sigil: ast::Sigil =
1242+
this.read_enum_variant_arg(0, |this| Decodable::decode(this));
1243+
let region: Option<ty::Region> =
1244+
this.read_enum_variant_arg(1, |this| Decodable::decode(this));
1245+
let m: ast::Mutability =
1246+
this.read_enum_variant_arg(2, |this| Decodable::decode(this));
1247+
let b: ty::BuiltinBounds =
1248+
this.read_enum_variant_arg(3, |this| Decodable::decode(this));
1249+
let def_id: ast::DefId =
1250+
this.read_enum_variant_arg(4, |this| Decodable::decode(this));
1251+
let substs = this.read_enum_variant_arg(5, |this| this.read_substs(xcx));
1252+
1253+
let region = match region {
1254+
Some(r) => Some(r.tr(xcx)),
1255+
None => None
1256+
};
1257+
1258+
ty::AutoObject(sigil, region, m, b, def_id.tr(xcx), substs)
1259+
}
1260+
_ => fail!("bad enum variant for ty::AutoAdjustment")
1261+
}
1262+
})
1263+
})
1264+
}
1265+
11751266
fn convert_def_id(&mut self,
11761267
xcx: @ExtendedDecodeContext,
11771268
source: tydecode::DefIdSource,
@@ -1289,8 +1380,7 @@ fn decode_side_tables(xcx: @ExtendedDecodeContext,
12891380
vtable_map.get().insert(id, vtable_res);
12901381
}
12911382
c::tag_table_adjustments => {
1292-
let adj: @ty::AutoAdjustment = @Decodable::decode(val_dsr);
1293-
adj.tr(xcx);
1383+
let adj: @ty::AutoAdjustment = @val_dsr.read_auto_adjustment(xcx);
12941384
let mut adjustments = dcx.tcx
12951385
.adjustments
12961386
.borrow_mut();

branches/try/src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,10 @@ impl<'a> GatherLoanCtxt<'a> {
419419
ty::AutoUnsafe(_) => {}
420420
}
421421
}
422+
423+
ty::AutoObject(..) => {
424+
// XXX: Handle @Trait to &Trait casts here?
425+
}
422426
}
423427
}
424428

branches/try/src/librustc/middle/borrowck/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ impl BorrowckCtxt {
490490
adj: @ty::AutoAdjustment)
491491
-> mc::cmt {
492492
match *adj {
493-
ty::AutoAddEnv(..) => {
493+
ty::AutoAddEnv(..) | ty::AutoObject(..) => {
494494
// no autoderefs
495495
mc::cat_expr_unadjusted(self.tcx, self.method_map, expr)
496496
}

0 commit comments

Comments
 (0)