Skip to content

Commit b2e7676

Browse files
committed
---
yaml --- r: 142838 b: refs/heads/try2 c: 6b37b5b h: refs/heads/master v: v3
1 parent f7042eb commit b2e7676

File tree

27 files changed

+196
-444
lines changed

27 files changed

+196
-444
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: 247ad4515de0d2e32168eff780561bc3970a3f41
8+
refs/heads/try2: 6b37b5bab74a87c4f05274e6a49d9e28a4c0f4e1
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/src/libextra/bitv.rs

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -718,38 +718,6 @@ 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-
753721
fn is_disjoint(&self, other: &BitvSet) -> bool {
754722
for self.intersection(other) |_| {
755723
return false;
@@ -816,6 +784,40 @@ impl Set<uint> for BitvSet {
816784
}
817785
}
818786

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+
819821
impl BitvSet {
820822
/// Visits each of the words that the two bit vectors (self and other)
821823
/// both have in common. The three yielded arguments are (bit location,

branches/try2/src/libextra/smallintmap.rs

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

1818

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

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

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-
360353
/// Return true if the set has no elements in common with `other`.
361354
/// This is equivalent to checking for an empty uintersection.
362355
fn is_disjoint(&self, other: &SmallIntSet) -> bool {
@@ -412,6 +405,16 @@ impl Set<uint> for SmallIntSet {
412405
}
413406
}
414407

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+
415418
impl SmallIntSet {
416419
/// Create an empty SmallIntSet
417420
pub fn new() -> SmallIntSet { SmallIntSet{map: SmallIntMap::new()} }

branches/try2/src/libextra/treemap.rs

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

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

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-
306298
/// Return true if the set has no elements in common with `other`.
307299
/// This is equivalent to checking for an empty intersection.
308300
fn is_disjoint(&self, other: &TreeSet<T>) -> bool {
@@ -475,6 +467,18 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
475467
}
476468
}
477469

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+
478482
impl<T: TotalOrd> TreeSet<T> {
479483
/// Create an empty TreeSet
480484
#[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/rustc.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,7 @@ pub fn monitor(f: ~fn(diagnostic::Emitter)) {
332332

333333
let _finally = finally { ch: ch };
334334

335-
f(demitter);
336-
337-
// Due reasons explain in #7732, if there was a jit execution context it
338-
// must be consumed and passed along to our parent task.
339-
back::link::jit::consume_engine()
335+
f(demitter)
340336
} {
341337
result::Ok(_) => { /* fallthrough */ }
342338
result::Err(_) => {

0 commit comments

Comments
 (0)