Skip to content

Commit f791bca

Browse files
committed
---
yaml --- r: 64284 b: refs/heads/snap-stage3 c: 48aa18d h: refs/heads/master v: v3
1 parent cf79766 commit f791bca

File tree

10 files changed

+85
-46
lines changed

10 files changed

+85
-46
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d582eeb1ec8e77234a26475bd70bf12a933b4efa
4+
refs/heads/snap-stage3: 48aa18d26a5d3a06bb83fa0aec842a0d88801bc4
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/etc/vim/ftplugin/rust.vim

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,4 @@ if exists("g:ftplugin_rust_source_path")
3333
let &l:path=g:ftplugin_rust_source_path . ',' . &l:path
3434
endif
3535

36-
if exists("g:loaded_delimitMate")
37-
if exists("b:delimitMate_excluded_regions")
38-
let b:rust_original_delimitMate_excluded_regions = b:delimitMate_excluded_regions
39-
endif
40-
let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate'
41-
endif
42-
43-
let b:undo_ftplugin = "setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd< | if exists('b:rust_original_delimitMate_excluded_regions') | let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions | unlet b:rust_original_delimitMate_excluded_regions | elseif exists('b:delimitMate_excluded_regions') | unlet b:delimitMate_excluded_regions | endif"
36+
let b:undo_ftplugin = "setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd<"

branches/snap-stage3/src/etc/vim/syntax/rust.vim

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,6 @@ syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\(f\|f32\|f64\)\>
113113
syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9_]\+\)\>"
114114
syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9_]\+\)\(f\|f32\|f64\)\>"
115115

116-
" For the benefit of delimitMate
117-
syn region rustLifetimeCandidate display start=/&'\%(\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'\)\@!/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustLifetime
118-
syn region rustGenericRegion display start=/<\%('\|[^[cntrl:][:space:][:punct:]]\)\@=')\S\@=/ end=/>/ contains=rustGenericLifetimeCandidate
119-
syn region rustGenericLifetimeCandidate display start=/\%(<\|,\s*\)\@<='/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustLifetime
120-
121116
"rustLifetime must appear before rustCharacter, or chars will get the lifetime highlighting
122117
syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*"
123118
syn match rustCharacter "'\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'"

branches/snap-stage3/src/librustc/back/link.rs

Lines changed: 52 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,41 @@ 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+
fn engine_key(_: ~Engine) {}
204+
205+
#[cfg(not(stage0))]
206+
fn set_engine(engine: ~Engine) {
207+
unsafe { local_data::set(engine_key, engine) }
208+
}
209+
#[cfg(stage0)]
210+
fn set_engine(_: ~Engine) {}
211+
212+
#[cfg(not(stage0))]
213+
pub fn consume_engine() -> Option<~Engine> {
214+
unsafe { local_data::pop(engine_key) }
215+
}
180216
}
181217

182218
pub mod write {

branches/snap-stage3/src/librustc/middle/lint.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,6 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) {
745745
_ => ()
746746
}
747747
}
748-
ast::ty_ptr(ref mt) => { check_ty(cx, mt.ty) }
749748
_ => ()
750749
}
751750
}

branches/snap-stage3/src/libstd/unstable/global.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ avoid hitting the mutex.
2828
use cast::{transmute};
2929
use clone::Clone;
3030
use kinds::Send;
31-
use libc::{c_void, intptr_t};
31+
use libc::{c_void};
3232
use option::{Option, Some, None};
3333
use ops::Drop;
3434
use unstable::sync::{Exclusive, exclusive};
@@ -228,7 +228,7 @@ fn key_ptr<T:Send>(key: GlobalDataKey<T>) -> uint {
228228
}
229229

230230
extern {
231-
fn rust_get_global_data_ptr() -> *mut intptr_t;
231+
fn rust_get_global_data_ptr() -> *mut int;
232232
}
233233

234234
#[test]

branches/snap-stage3/src/rt/rust_builtin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ rust_register_exit_function(spawn_fn runner, fn_env_pair *f) {
769769
task->kernel->register_exit_function(runner, f);
770770
}
771771

772-
extern "C" intptr_t*
772+
extern "C" void *
773773
rust_get_global_data_ptr() {
774774
rust_task *task = rust_get_current_task();
775775
return &task->kernel->global_data;

branches/snap-stage3/src/rt/rust_kernel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class rust_kernel {
124124

125125
public:
126126
struct rust_env *env;
127-
intptr_t global_data;
127+
uintptr_t global_data;
128128

129129
rust_kernel(rust_env *env);
130130

branches/snap-stage3/src/test/compile-fail/lint-ctypes.rs renamed to branches/snap-stage3/src/test/compile-fail/warn-ctypes-err-attr.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// error-pattern:found rust type
1112
#[deny(ctypes)];
1213

13-
use std::libc;
14-
15-
#[nolink]
16-
extern {
17-
pub fn bare_type1(size: int); //~ ERROR: found rust type
18-
pub fn bare_type2(size: uint); //~ ERROR: found rust type
19-
pub fn ptr_type1(size: *int); //~ ERROR: found rust type
20-
pub fn ptr_type2(size: *uint); //~ ERROR: found rust type
21-
22-
pub fn good1(size: *libc::c_int);
23-
pub fn good2(size: *libc::c_uint);
14+
mod libc {
15+
#[nolink]
16+
pub extern {
17+
pub fn malloc(size: int) -> *u8;
18+
}
2419
}
2520

2621
fn main() {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags:-D ctypes
12+
// error-pattern:found rust type
13+
mod libc {
14+
#[nolink]
15+
extern {
16+
pub fn malloc(size: int) -> *u8;
17+
}
18+
}
19+
20+
fn main() {
21+
}

0 commit comments

Comments
 (0)