Skip to content

Commit 72d129d

Browse files
committed
---
yaml --- r: 142845 b: refs/heads/try2 c: e56b369 h: refs/heads/master i: 142843: 1fea808 v: v3
1 parent 1d6f178 commit 72d129d

36 files changed

+210
-555
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: 51cb98443cfd053f3d2bdb26465fdb0c9d3a0f74
8+
refs/heads/try2: e56b3691c87c24fc335fa8a293f1bf2e13a01ad9
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/dist.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ PKG_FILES := \
1919
$(S)LICENSE-APACHE \
2020
$(S)LICENSE-MIT \
2121
$(S)AUTHORS.txt \
22-
$(S)CONTRIBUTING.md \
2322
$(S)README.md \
24-
$(S)RELEASES.txt \
2523
$(S)configure $(S)Makefile.in \
2624
$(S)man \
2725
$(S)doc \

branches/try2/mk/install.mk

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,7 @@ uninstall:
183183
do rm -f $$i ; \
184184
done
185185
$(Q)rm -Rf $(PHL)/rustc
186-
$(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rust.1
187186
$(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rustc.1
188-
$(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rustdoc.1
189-
$(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rusti.1
190-
$(Q)rm -f $(PREFIX_ROOT)/share/man/man1/rustpkg.1
191187

192188
# target platform specific variables
193189
# for arm-linux-androidabi

branches/try2/src/libextra/bitv.rs

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,38 @@ impl Set<uint> for BitvSet {
718718
*value < self.bitv.storage.len() * uint::bits && self.bitv.get(*value)
719719
}
720720

721+
fn insert(&mut self, value: uint) -> bool {
722+
if self.contains(&value) {
723+
return false;
724+
}
725+
let nbits = self.capacity();
726+
if value >= nbits {
727+
let newsize = num::max(value, nbits * 2) / uint::bits + 1;
728+
assert!(newsize > self.bitv.storage.len());
729+
self.bitv.storage.grow(newsize, &0);
730+
}
731+
self.size += 1;
732+
self.bitv.set(value, true);
733+
return true;
734+
}
735+
736+
fn remove(&mut self, value: &uint) -> bool {
737+
if !self.contains(value) {
738+
return false;
739+
}
740+
self.size -= 1;
741+
self.bitv.set(*value, false);
742+
743+
// Attempt to truncate our storage
744+
let mut i = self.bitv.storage.len();
745+
while i > 1 && self.bitv.storage[i - 1] == 0 {
746+
i -= 1;
747+
}
748+
self.bitv.storage.truncate(i);
749+
750+
return true;
751+
}
752+
721753
fn is_disjoint(&self, other: &BitvSet) -> bool {
722754
for self.intersection(other) |_| {
723755
return false;
@@ -784,40 +816,6 @@ impl Set<uint> for BitvSet {
784816
}
785817
}
786818

787-
impl MutableSet<uint> for BitvSet {
788-
fn insert(&mut self, value: uint) -> bool {
789-
if self.contains(&value) {
790-
return false;
791-
}
792-
let nbits = self.capacity();
793-
if value >= nbits {
794-
let newsize = num::max(value, nbits * 2) / uint::bits + 1;
795-
assert!(newsize > self.bitv.storage.len());
796-
self.bitv.storage.grow(newsize, &0);
797-
}
798-
self.size += 1;
799-
self.bitv.set(value, true);
800-
return true;
801-
}
802-
803-
fn remove(&mut self, value: &uint) -> bool {
804-
if !self.contains(value) {
805-
return false;
806-
}
807-
self.size -= 1;
808-
self.bitv.set(*value, false);
809-
810-
// Attempt to truncate our storage
811-
let mut i = self.bitv.storage.len();
812-
while i > 1 && self.bitv.storage[i - 1] == 0 {
813-
i -= 1;
814-
}
815-
self.bitv.storage.truncate(i);
816-
817-
return true;
818-
}
819-
}
820-
821819
impl BitvSet {
822820
/// Visits each of the words that the two bit vectors (self and other)
823821
/// both have in common. The three yielded arguments are (bit location,

branches/try2/src/libextra/smallintmap.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818

1919
use std::cmp;
20-
use std::iterator::{Iterator,IteratorUtil,ZipIterator,Counter,EnumerateIterator,FilterMapIterator};
20+
use std::container::{Container, Mutable, Map, Set};
21+
use std::iterator::*;
2122
use std::uint;
2223
use std::util::replace;
2324
use std::vec::{VecIterator,VecMutIterator,VecRevIterator,VecMutRevIterator};
@@ -67,9 +68,7 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
6768
None
6869
}
6970
}
70-
}
7171

72-
impl<V> MutableMap<uint, V> for SmallIntMap<V> {
7372
/// Return a mutable reference to the value corresponding to the key
7473
fn find_mut<'a>(&'a mut self, key: &uint) -> Option<&'a mut V> {
7574
if *key < self.v.len() {
@@ -350,6 +349,14 @@ impl Set<uint> for SmallIntSet {
350349
/// Return true if the set contains a value
351350
fn contains(&self, value: &uint) -> bool { self.map.contains_key(value) }
352351

352+
/// Add a value to the set. Return true if the value was not already
353+
/// present in the set.
354+
fn insert(&mut self, value: uint) -> bool { self.map.insert(value, ()) }
355+
356+
/// Remove a value from the set. Return true if the value was
357+
/// present in the set.
358+
fn remove(&mut self, value: &uint) -> bool { self.map.remove(value) }
359+
353360
/// Return true if the set has no elements in common with `other`.
354361
/// This is equivalent to checking for an empty uintersection.
355362
fn is_disjoint(&self, other: &SmallIntSet) -> bool {
@@ -405,16 +412,6 @@ impl Set<uint> for SmallIntSet {
405412
}
406413
}
407414

408-
impl MutableSet<uint> for SmallIntSet {
409-
/// Add a value to the set. Return true if the value was not already
410-
/// present in the set.
411-
fn insert(&mut self, value: uint) -> bool { self.map.insert(value, ()) }
412-
413-
/// Remove a value from the set. Return true if the value was
414-
/// present in the set.
415-
fn remove(&mut self, value: &uint) -> bool { self.map.remove(value) }
416-
}
417-
418415
impl SmallIntSet {
419416
/// Create an empty SmallIntSet
420417
pub fn new() -> SmallIntSet { SmallIntSet{map: SmallIntMap::new()} }

branches/try2/src/libextra/treemap.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
124124
}
125125
}
126126
}
127-
}
128127

129-
impl<K: TotalOrd, V> MutableMap<K, V> for TreeMap<K, V> {
130128
/// Return a mutable reference to the value corresponding to the key
131129
#[inline]
132130
fn find_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V> {
@@ -295,6 +293,16 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
295293
self.map.contains_key(value)
296294
}
297295

296+
/// Add a value to the set. Return true if the value was not already
297+
/// present in the set.
298+
#[inline]
299+
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
300+
301+
/// Remove a value from the set. Return true if the value was
302+
/// present in the set.
303+
#[inline]
304+
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
305+
298306
/// Return true if the set has no elements in common with `other`.
299307
/// This is equivalent to checking for an empty intersection.
300308
fn is_disjoint(&self, other: &TreeSet<T>) -> bool {
@@ -467,18 +475,6 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
467475
}
468476
}
469477

470-
impl<T: TotalOrd> MutableSet<T> for TreeSet<T> {
471-
/// Add a value to the set. Return true if the value was not already
472-
/// present in the set.
473-
#[inline]
474-
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
475-
476-
/// Remove a value from the set. Return true if the value was
477-
/// present in the set.
478-
#[inline]
479-
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
480-
}
481-
482478
impl<T: TotalOrd> TreeSet<T> {
483479
/// Create an empty TreeSet
484480
#[inline]

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

Lines changed: 16 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,15 @@ pub mod jit {
101101
use back::link::llvm_err;
102102
use driver::session::Session;
103103
use lib::llvm::llvm;
104-
use lib::llvm::{ModuleRef, ContextRef, ExecutionEngineRef};
104+
use lib::llvm::{ModuleRef, ContextRef};
105105
use metadata::cstore;
106106

107107
use std::cast;
108-
use std::local_data;
108+
use std::ptr;
109+
use std::str;
110+
use std::sys;
109111
use std::unstable::intrinsics;
110112

111-
struct LLVMJITData {
112-
ee: ExecutionEngineRef,
113-
llcx: ContextRef
114-
}
115-
116-
pub trait Engine {}
117-
impl Engine for LLVMJITData {}
118-
119-
impl Drop for LLVMJITData {
120-
fn drop(&self) {
121-
unsafe {
122-
llvm::LLVMDisposeExecutionEngine(self.ee);
123-
llvm::LLVMContextDispose(self.llcx);
124-
}
125-
}
126-
}
127-
128113
pub fn exec(sess: Session,
129114
c: ContextRef,
130115
m: ModuleRef,
@@ -145,7 +130,7 @@ pub mod jit {
145130

146131
debug!("linking: %s", path);
147132

148-
do path.as_c_str |buf_t| {
133+
do str::as_c_str(path) |buf_t| {
149134
if !llvm::LLVMRustLoadCrate(manager, buf_t) {
150135
llvm_err(sess, ~"Could not link");
151136
}
@@ -164,7 +149,7 @@ pub mod jit {
164149
// Next, we need to get a handle on the _rust_main function by
165150
// looking up it's corresponding ValueRef and then requesting that
166151
// the execution engine compiles the function.
167-
let fun = do "_rust_main".as_c_str |entry| {
152+
let fun = do str::as_c_str("_rust_main") |entry| {
168153
llvm::LLVMGetNamedFunction(m, entry)
169154
};
170155
if fun.is_null() {
@@ -178,45 +163,20 @@ pub mod jit {
178163
// closure
179164
let code = llvm::LLVMGetPointerToGlobal(ee, fun);
180165
assert!(!code.is_null());
181-
let func: extern "Rust" fn() = cast::transmute(code);
166+
let closure = sys::Closure {
167+
code: code,
168+
env: ptr::null()
169+
};
170+
let func: &fn() = cast::transmute(closure);
182171
func();
183172

184-
// Currently there is no method of re-using the executing engine
185-
// from LLVM in another call to the JIT. While this kinda defeats
186-
// the purpose of having a JIT in the first place, there isn't
187-
// actually much code currently which would re-use data between
188-
// different invocations of this. Additionally, the compilation
189-
// model currently isn't designed to support this scenario.
190-
//
191-
// We can't destroy the engine/context immediately here, however,
192-
// because of annihilation. The JIT code contains drop glue for any
193-
// types defined in the crate we just ran, and if any of those boxes
194-
// are going to be dropped during annihilation, the drop glue must
195-
// be run. Hence, we need to transfer ownership of this jit engine
196-
// to the caller of this function. To be convenient for now, we
197-
// shove it into TLS and have someone else remove it later on.
198-
let data = ~LLVMJITData { ee: ee, llcx: c };
199-
set_engine(data as ~Engine);
173+
// Sadly, there currently is no interface to re-use this execution
174+
// engine, so it's disposed of here along with the context to
175+
// prevent leaks.
176+
llvm::LLVMDisposeExecutionEngine(ee);
177+
llvm::LLVMContextDispose(c);
200178
}
201179
}
202-
203-
// The stage1 compiler won't work, but that doesn't really matter. TLS
204-
// changed only very recently to allow storage of owned values.
205-
fn engine_key(_: ~Engine) {}
206-
207-
#[cfg(not(stage0))]
208-
fn set_engine(engine: ~Engine) {
209-
unsafe { local_data::set(engine_key, engine) }
210-
}
211-
#[cfg(stage0)]
212-
fn set_engine(_: ~Engine) {}
213-
214-
#[cfg(not(stage0))]
215-
pub fn consume_engine() -> Option<~Engine> {
216-
unsafe { local_data::pop(engine_key) }
217-
}
218-
#[cfg(stage0)]
219-
pub fn consume_engine() -> Option<~Engine> { None }
220180
}
221181

222182
pub mod write {

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub fn lazily_emit_tydesc_glue(ccx: @mut CrateContext,
230230
field: uint,
231231
ti: @mut tydesc_info) {
232232
let _icx = push_ctxt("lazily_emit_tydesc_glue");
233-
let llfnty = Type::glue_fn();
233+
let llfnty = Type::glue_fn(type_of::type_of(ccx, ti.ty).ptr_to());
234234

235235
if lazily_emit_simplified_tydesc_glue(ccx, field, ti) {
236236
return;
@@ -323,7 +323,20 @@ pub fn call_tydesc_glue_full(bcx: block,
323323
}
324324
};
325325

326-
let llrawptr = PointerCast(bcx, v, Type::i8p());
326+
// When static type info is available, avoid casting parameter unless the
327+
// glue is using a simplified type, because the function already has the
328+
// right type. Otherwise cast to generic pointer.
329+
let llrawptr = if static_ti.is_none() || static_glue_fn.is_none() {
330+
PointerCast(bcx, v, Type::i8p())
331+
} else {
332+
let ty = static_ti.get().ty;
333+
let simpl = simplified_glue_type(ccx.tcx, field, ty);
334+
if simpl != ty {
335+
PointerCast(bcx, v, type_of(ccx, simpl).ptr_to())
336+
} else {
337+
v
338+
}
339+
};
327340

328341
let llfn = {
329342
match static_glue_fn {
@@ -709,13 +722,14 @@ pub fn make_generic_glue_inner(ccx: @mut CrateContext,
709722
// requirement since in many contexts glue is invoked indirectly and
710723
// the caller has no idea if it's dealing with something that can be
711724
// passed by value.
725+
//
726+
// llfn is expected be declared to take a parameter of the appropriate
727+
// type, so we don't need to explicitly cast the function parameter.
712728

713729
let bcx = top_scope_block(fcx, None);
714730
let lltop = bcx.llbb;
715731
let rawptr0_arg = fcx.arg_pos(0u);
716732
let llrawptr0 = unsafe { llvm::LLVMGetParam(llfn, rawptr0_arg as c_uint) };
717-
let llty = type_of(ccx, t);
718-
let llrawptr0 = PointerCast(bcx, llrawptr0, llty.ptr_to());
719733
let bcx = helper(bcx, llrawptr0, t);
720734

721735
finish_fn(fcx, lltop, bcx);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,20 @@ impl Type {
187187
None => ()
188188
}
189189

190-
let ty = Type::glue_fn();
190+
let ty = Type::glue_fn(Type::i8p());
191191
cx.tn.associate_type("glue_fn", &ty);
192192

193193
return ty;
194194
}
195195

196-
pub fn glue_fn() -> Type {
197-
Type::func([ Type::nil().ptr_to(), Type::i8p() ],
196+
pub fn glue_fn(t: Type) -> Type {
197+
Type::func([ Type::nil().ptr_to(), t ],
198198
&Type::void())
199199
}
200200

201201
pub fn tydesc(arch: Architecture) -> Type {
202202
let mut tydesc = Type::named_struct("tydesc");
203-
let glue_fn_ty = Type::glue_fn().ptr_to();
203+
let glue_fn_ty = Type::glue_fn(Type::i8p()).ptr_to();
204204

205205
let int_ty = Type::int(arch);
206206

0 commit comments

Comments
 (0)