Skip to content

Commit 1d6f178

Browse files
committed
---
yaml --- r: 142844 b: refs/heads/try2 c: 51cb984 h: refs/heads/master v: v3
1 parent 1fea808 commit 1d6f178

File tree

30 files changed

+476
-178
lines changed

30 files changed

+476
-178
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: 3b0258916d28a1215acf9a0c78f6760cc67f935c
8+
refs/heads/try2: 51cb98443cfd053f3d2bdb26465fdb0c9d3a0f74
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ PKG_FILES := \
1919
$(S)LICENSE-APACHE \
2020
$(S)LICENSE-MIT \
2121
$(S)AUTHORS.txt \
22+
$(S)CONTRIBUTING.md \
2223
$(S)README.md \
24+
$(S)RELEASES.txt \
2325
$(S)configure $(S)Makefile.in \
2426
$(S)man \
2527
$(S)doc \

branches/try2/mk/install.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ 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
186187
$(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
187191

188192
# target platform specific variables
189193
# for arm-linux-androidabi

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: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,30 @@ 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};
104+
use lib::llvm::{ModuleRef, ContextRef, ExecutionEngineRef};
105105
use metadata::cstore;
106106

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

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+
113128
pub fn exec(sess: Session,
114129
c: ContextRef,
115130
m: ModuleRef,
@@ -130,7 +145,7 @@ pub mod jit {
130145

131146
debug!("linking: %s", path);
132147

133-
do str::as_c_str(path) |buf_t| {
148+
do path.as_c_str |buf_t| {
134149
if !llvm::LLVMRustLoadCrate(manager, buf_t) {
135150
llvm_err(sess, ~"Could not link");
136151
}
@@ -149,7 +164,7 @@ pub mod jit {
149164
// Next, we need to get a handle on the _rust_main function by
150165
// looking up it's corresponding ValueRef and then requesting that
151166
// the execution engine compiles the function.
152-
let fun = do str::as_c_str("_rust_main") |entry| {
167+
let fun = do "_rust_main".as_c_str |entry| {
153168
llvm::LLVMGetNamedFunction(m, entry)
154169
};
155170
if fun.is_null() {
@@ -163,20 +178,45 @@ pub mod jit {
163178
// closure
164179
let code = llvm::LLVMGetPointerToGlobal(ee, fun);
165180
assert!(!code.is_null());
166-
let closure = sys::Closure {
167-
code: code,
168-
env: ptr::null()
169-
};
170-
let func: &fn() = cast::transmute(closure);
181+
let func: extern "Rust" fn() = cast::transmute(code);
171182
func();
172183

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);
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);
178200
}
179201
}
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 }
180220
}
181221

182222
pub mod write {

branches/try2/src/librustc/rustc.rs

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

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

335-
f(demitter)
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()
336340
} {
337341
result::Ok(_) => { /* fallthrough */ }
338342
result::Err(_) => {

0 commit comments

Comments
 (0)