提交 f4fa7c8a 编写于 作者: A Alex Crichton

Register new snapshots

上级 e5e865b8
......@@ -133,14 +133,7 @@ unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
}
}
#[cfg(not(test), stage0)]
#[lang="exchange_free"]
#[inline]
unsafe fn exchange_free(ptr: *mut u8) {
deallocate(ptr, 0, 8);
}
#[cfg(not(test), not(stage0))]
#[cfg(not(test))]
#[lang="exchange_free"]
#[inline]
unsafe fn exchange_free(ptr: *mut u8, size: uint, align: uint) {
......
......@@ -30,12 +30,10 @@
use fmt;
use intrinsics;
#[cfg(not(test), stage0)]
use str::raw::c_str_to_static_slice;
#[cold] #[inline(never)] // this is the slow path, always
#[lang="fail_"]
#[cfg(not(test), not(stage0))]
#[cfg(not(test))]
fn fail_(expr: &'static str, file: &'static str, line: uint) -> ! {
format_args!(|args| -> () {
begin_unwind(args, file, line);
......@@ -44,24 +42,9 @@ fn fail_(expr: &'static str, file: &'static str, line: uint) -> ! {
unsafe { intrinsics::abort() }
}
#[cold] #[inline(never)] // this is the slow path, always
#[lang="fail_"]
#[cfg(not(test), stage0)]
fn fail_(expr: *u8, file: *u8, line: uint) -> ! {
unsafe {
let expr = c_str_to_static_slice(expr as *i8);
let file = c_str_to_static_slice(file as *i8);
format_args!(|args| -> () {
begin_unwind(args, file, line);
}, "{}", expr);
intrinsics::abort()
}
}
#[cold]
#[lang="fail_bounds_check"]
#[cfg(not(test), not(stage0))]
#[cfg(not(test))]
fn fail_bounds_check(file: &'static str, line: uint,
index: uint, len: uint) -> ! {
format_args!(|args| -> () {
......@@ -70,28 +53,9 @@ fn fail_bounds_check(file: &'static str, line: uint,
unsafe { intrinsics::abort() }
}
#[cold]
#[lang="fail_bounds_check"]
#[cfg(not(test), stage0)]
fn fail_bounds_check(file: *u8, line: uint, index: uint, len: uint) -> ! {
let file = unsafe { c_str_to_static_slice(file as *i8) };
format_args!(|args| -> () {
begin_unwind(args, file, line);
}, "index out of bounds: the len is {} but the index is {}", len, index);
unsafe { intrinsics::abort() }
}
#[cold]
pub fn begin_unwind(fmt: &fmt::Arguments, file: &'static str, line: uint) -> ! {
#[allow(ctypes)]
#[cfg(stage0)]
extern {
#[link_name = "rust_begin_unwind"]
fn begin_unwind(fmt: &fmt::Arguments, file: &'static str,
line: uint) -> !;
}
#[allow(ctypes)]
#[cfg(not(stage0))]
extern {
#[lang = "begin_unwind"]
fn begin_unwind(fmt: &fmt::Arguments, file: &'static str,
......
......@@ -492,10 +492,6 @@ fn my_fmt_fn(args: &fmt::Arguments) {
use io::Writer;
use io;
#[cfg(stage0)]
use option::None;
#[cfg(stage0)]
use repr;
use result::{Ok, Err};
use str::{Str, StrAllocating};
use str;
......@@ -524,21 +520,6 @@ fn my_fmt_fn(args: &fmt::Arguments) {
#[doc(hidden)]
pub use core::fmt::{secret_pointer};
#[doc(hidden)]
#[cfg(stage0)]
pub fn secret_poly<T: Poly>(x: &T, fmt: &mut Formatter) -> Result {
// FIXME #11938 - UFCS would make us able call the this method
// directly Poly::fmt(x, fmt).
x.fmt(fmt)
}
/// Format trait for the `?` character
#[cfg(stage0)]
pub trait Poly {
/// Formats the value using the given formatter.
fn fmt(&self, &mut Formatter) -> Result;
}
/// The format function takes a precompiled format string and a list of
/// arguments, to return the resulting formatted string.
///
......@@ -562,27 +543,6 @@ pub fn format(args: &Arguments) -> string::String{
str::from_utf8(output.unwrap().as_slice()).unwrap().into_string()
}
#[cfg(stage0)]
impl<T> Poly for T {
fn fmt(&self, f: &mut Formatter) -> Result {
match (f.width, f.precision) {
(None, None) => {
match repr::write_repr(f, self) {
Ok(()) => Ok(()),
Err(..) => Err(WriteError),
}
}
// If we have a specified width for formatting, then we have to make
// this allocation of a new string
_ => {
let s = repr::repr_to_str(self);
f.pad(s.as_slice())
}
}
}
}
impl<'a> Writer for Formatter<'a> {
fn write(&mut self, b: &[u8]) -> io::IoResult<()> {
match (*self).write(b) {
......
......@@ -241,13 +241,6 @@ fn start(argc: int, argv: **u8) -> int {
pub mod fmt;
pub mod cleanup;
/* Unsupported interfaces */
#[unstable]
pub mod repr;
#[unstable]
pub mod reflect;
// Private APIs
#[unstable]
pub mod unstable;
......
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
/*!
Runtime type reflection
*/
#![allow(missing_doc)]
use intrinsics::{Disr, Opaque, TyDesc, TyVisitor};
use mem;
use owned::Box;
/**
* Trait for visitor that wishes to reflect on data. To use this, create a
* struct that encapsulates the set of pointers you wish to walk through a
* data structure, and implement both `MovePtr` for it as well as `TyVisitor`;
* then build a MovePtrAdaptor wrapped around your struct.
*/
pub trait MovePtr {
fn move_ptr(&mut self, adjustment: |*u8| -> *u8);
fn push_ptr(&mut self);
fn pop_ptr(&mut self);
}
/// Helper function for alignment calculation.
#[inline]
pub fn align(size: uint, align: uint) -> uint {
((size + align) - 1u) & !(align - 1u)
}
/// Adaptor to wrap around visitors implementing MovePtr.
pub struct MovePtrAdaptor<V> {
inner: V
}
impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> {
pub fn new(v: V) -> MovePtrAdaptor<V> {
MovePtrAdaptor { inner: v }
}
#[inline]
pub fn bump(&mut self, sz: uint) {
self.inner.move_ptr(|p| ((p as uint) + sz) as *u8)
}
#[inline]
pub fn align(&mut self, a: uint) {
self.inner.move_ptr(|p| align(p as uint, a) as *u8)
}
#[inline]
pub fn align_to<T>(&mut self) {
self.align(mem::min_align_of::<T>());
}
#[inline]
pub fn bump_past<T>(&mut self) {
self.bump(mem::size_of::<T>());
}
pub fn unwrap(self) -> V { self.inner }
}
/// Abstract type-directed pointer-movement using the MovePtr trait
impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
fn visit_bot(&mut self) -> bool {
self.align_to::<()>();
if ! self.inner.visit_bot() { return false; }
self.bump_past::<()>();
true
}
fn visit_nil(&mut self) -> bool {
self.align_to::<()>();
if ! self.inner.visit_nil() { return false; }
self.bump_past::<()>();
true
}
fn visit_bool(&mut self) -> bool {
self.align_to::<bool>();
if ! self.inner.visit_bool() { return false; }
self.bump_past::<bool>();
true
}
fn visit_int(&mut self) -> bool {
self.align_to::<int>();
if ! self.inner.visit_int() { return false; }
self.bump_past::<int>();
true
}
fn visit_i8(&mut self) -> bool {
self.align_to::<i8>();
if ! self.inner.visit_i8() { return false; }
self.bump_past::<i8>();
true
}
fn visit_i16(&mut self) -> bool {
self.align_to::<i16>();
if ! self.inner.visit_i16() { return false; }
self.bump_past::<i16>();
true
}
fn visit_i32(&mut self) -> bool {
self.align_to::<i32>();
if ! self.inner.visit_i32() { return false; }
self.bump_past::<i32>();
true
}
fn visit_i64(&mut self) -> bool {
self.align_to::<i64>();
if ! self.inner.visit_i64() { return false; }
self.bump_past::<i64>();
true
}
fn visit_uint(&mut self) -> bool {
self.align_to::<uint>();
if ! self.inner.visit_uint() { return false; }
self.bump_past::<uint>();
true
}
fn visit_u8(&mut self) -> bool {
self.align_to::<u8>();
if ! self.inner.visit_u8() { return false; }
self.bump_past::<u8>();
true
}
fn visit_u16(&mut self) -> bool {
self.align_to::<u16>();
if ! self.inner.visit_u16() { return false; }
self.bump_past::<u16>();
true
}
fn visit_u32(&mut self) -> bool {
self.align_to::<u32>();
if ! self.inner.visit_u32() { return false; }
self.bump_past::<u32>();
true
}
fn visit_u64(&mut self) -> bool {
self.align_to::<u64>();
if ! self.inner.visit_u64() { return false; }
self.bump_past::<u64>();
true
}
fn visit_f32(&mut self) -> bool {
self.align_to::<f32>();
if ! self.inner.visit_f32() { return false; }
self.bump_past::<f32>();
true
}
fn visit_f64(&mut self) -> bool {
self.align_to::<f64>();
if ! self.inner.visit_f64() { return false; }
self.bump_past::<f64>();
true
}
fn visit_f128(&mut self) -> bool {
self.align_to::<f128>();
if ! self.inner.visit_f128() { return false; }
self.bump_past::<f128>();
true
}
fn visit_char(&mut self) -> bool {
self.align_to::<char>();
if ! self.inner.visit_char() { return false; }
self.bump_past::<char>();
true
}
fn visit_estr_box(&mut self) -> bool {
true
}
fn visit_estr_uniq(&mut self) -> bool {
self.align_to::<~str>();
if ! self.inner.visit_estr_uniq() { return false; }
self.bump_past::<~str>();
true
}
fn visit_estr_slice(&mut self) -> bool {
self.align_to::<&'static str>();
if ! self.inner.visit_estr_slice() { return false; }
self.bump_past::<&'static str>();
true
}
fn visit_estr_fixed(&mut self, n: uint,
sz: uint,
align: uint) -> bool {
self.align(align);
if ! self.inner.visit_estr_fixed(n, sz, align) { return false; }
self.bump(sz);
true
}
fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
self.align_to::<@u8>();
if ! self.inner.visit_box(mtbl, inner) { return false; }
self.bump_past::<@u8>();
true
}
fn visit_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
self.align_to::<Box<u8>>();
if ! self.inner.visit_uniq(mtbl, inner) { return false; }
self.bump_past::<Box<u8>>();
true
}
fn visit_ptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
self.align_to::<*u8>();
if ! self.inner.visit_ptr(mtbl, inner) { return false; }
self.bump_past::<*u8>();
true
}
fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
self.align_to::<&'static u8>();
if ! self.inner.visit_rptr(mtbl, inner) { return false; }
self.bump_past::<&'static u8>();
true
}
fn visit_evec_box(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool {
true
}
fn visit_evec_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
self.align_to::<~[u8]>();
if ! self.inner.visit_evec_uniq(mtbl, inner) { return false; }
self.bump_past::<~[u8]>();
true
}
fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
self.align_to::<&'static [u8]>();
if ! self.inner.visit_evec_slice(mtbl, inner) { return false; }
self.bump_past::<&'static [u8]>();
true
}
fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint,
mtbl: uint, inner: *TyDesc) -> bool {
self.align(align);
if ! self.inner.visit_evec_fixed(n, sz, align, mtbl, inner) {
return false;
}
self.bump(sz);
true
}
fn visit_enter_rec(&mut self, n_fields: uint, sz: uint, align: uint) -> bool {
self.align(align);
if ! self.inner.visit_enter_rec(n_fields, sz, align) { return false; }
true
}
fn visit_rec_field(&mut self, i: uint, name: &str,
mtbl: uint, inner: *TyDesc) -> bool {
unsafe { self.align((*inner).align); }
if ! self.inner.visit_rec_field(i, name, mtbl, inner) {
return false;
}
unsafe { self.bump((*inner).size); }
true
}
fn visit_leave_rec(&mut self, n_fields: uint, sz: uint, align: uint) -> bool {
if ! self.inner.visit_leave_rec(n_fields, sz, align) { return false; }
true
}
fn visit_enter_class(&mut self, name: &str, named_fields: bool, n_fields: uint, sz: uint,
align: uint) -> bool {
self.align(align);
if ! self.inner.visit_enter_class(name, named_fields, n_fields, sz, align) {
return false;
}
true
}
fn visit_class_field(&mut self, i: uint, name: &str, named: bool, mtbl: uint,
inner: *TyDesc) -> bool {
unsafe { self.align((*inner).align); }
if ! self.inner.visit_class_field(i, name, named, mtbl, inner) {
return false;
}
unsafe { self.bump((*inner).size); }
true
}
fn visit_leave_class(&mut self, name: &str, named_fields: bool, n_fields: uint, sz: uint,
align: uint) -> bool {
if ! self.inner.visit_leave_class(name, named_fields, n_fields, sz, align) {
return false;
}
true
}
fn visit_enter_tup(&mut self, n_fields: uint, sz: uint, align: uint) -> bool {
self.align(align);
if ! self.inner.visit_enter_tup(n_fields, sz, align) { return false; }
true
}
fn visit_tup_field(&mut self, i: uint, inner: *TyDesc) -> bool {
unsafe { self.align((*inner).align); }
if ! self.inner.visit_tup_field(i, inner) { return false; }
unsafe { self.bump((*inner).size); }
true
}
fn visit_leave_tup(&mut self, n_fields: uint, sz: uint, align: uint) -> bool {
if ! self.inner.visit_leave_tup(n_fields, sz, align) { return false; }
true
}
fn visit_enter_fn(&mut self, purity: uint, proto: uint,
n_inputs: uint, retstyle: uint) -> bool {
if ! self.inner.visit_enter_fn(purity, proto, n_inputs, retstyle) {
return false
}
true
}
fn visit_fn_input(&mut self, i: uint, mode: uint, inner: *TyDesc) -> bool {
if ! self.inner.visit_fn_input(i, mode, inner) { return false; }
true
}
fn visit_fn_output(&mut self, retstyle: uint, variadic: bool, inner: *TyDesc) -> bool {
if ! self.inner.visit_fn_output(retstyle, variadic, inner) { return false; }
true
}
fn visit_leave_fn(&mut self, purity: uint, proto: uint,
n_inputs: uint, retstyle: uint) -> bool {
if ! self.inner.visit_leave_fn(purity, proto, n_inputs, retstyle) {
return false;
}
true
}
fn visit_enter_enum(&mut self, n_variants: uint,
get_disr: unsafe extern fn(ptr: *Opaque) -> Disr,
sz: uint, align: uint)
-> bool {
self.align(align);
if ! self.inner.visit_enter_enum(n_variants, get_disr, sz, align) {
return false;
}
true
}
fn visit_enter_enum_variant(&mut self, variant: uint,
disr_val: Disr,
n_fields: uint,
name: &str) -> bool {
if ! self.inner.visit_enter_enum_variant(variant, disr_val,
n_fields, name) {
return false;
}
true
}
fn visit_enum_variant_field(&mut self, i: uint, offset: uint, inner: *TyDesc) -> bool {
self.inner.push_ptr();
self.bump(offset);
if ! self.inner.visit_enum_variant_field(i, offset, inner) { return false; }
self.inner.pop_ptr();
true
}
fn visit_leave_enum_variant(&mut self, variant: uint,
disr_val: Disr,
n_fields: uint,
name: &str) -> bool {
if ! self.inner.visit_leave_enum_variant(variant, disr_val,
n_fields, name) {
return false;
}
true
}
fn visit_leave_enum(&mut self, n_variants: uint,
get_disr: unsafe extern fn(ptr: *Opaque) -> Disr,
sz: uint, align: uint) -> bool {
if ! self.inner.visit_leave_enum(n_variants, get_disr, sz, align) {
return false;
}
self.bump(sz);
true
}
fn visit_trait(&mut self, name: &str) -> bool {
self.align_to::<Box<TyVisitor>>();
if ! self.inner.visit_trait(name) { return false; }
self.bump_past::<Box<TyVisitor>>();
true
}
fn visit_param(&mut self, i: uint) -> bool {
if ! self.inner.visit_param(i) { return false; }
true
}
fn visit_self(&mut self) -> bool {
self.align_to::<&'static u8>();
if ! self.inner.visit_self() { return false; }
self.align_to::<&'static u8>();
true
}
}
此差异已折叠。
......@@ -30,7 +30,7 @@
/// stacks are currently not enabled as segmented stacks, but rather one giant
/// stack segment. This means that whenever we run out of stack, we want to
/// truly consider it to be stack overflow rather than allocating a new stack.
#[cfg(not(test), not(stage0))] // in testing, use the original libstd's version
#[cfg(not(test))] // in testing, use the original libstd's version
#[lang = "stack_exhausted"]
extern fn stack_exhausted() {
use option::{Option, None, Some};
......@@ -103,35 +103,6 @@
}
}
#[no_mangle] // - this is called from C code
#[no_split_stack] // - it would be sad for this function to trigger __morestack
#[doc(hidden)] // - Function must be `pub` to get exported, but it's
// irrelevant for documentation purposes.
#[cfg(stage0, not(test))] // in testing, use the original libstd's version
pub extern "C" fn rust_stack_exhausted() {
use option::{Option, None, Some};
use owned::Box;
use rt::local::Local;
use rt::task::Task;
use str::Str;
use intrinsics;
unsafe {
let limit = get_sp_limit();
record_sp_limit(limit - RED_ZONE / 2);
let task: Option<Box<Task>> = Local::try_take();
let name = match task {
Some(ref task) => {
task.name.as_ref().map(|n| n.as_slice())
}
None => None
};
let name = name.unwrap_or("<unknown>");
rterrln!("task '{}' has overflowed its stack", name);
intrinsics::abort();
}
}
#[inline(always)]
pub unsafe fn record_stack_bounds(stack_lo: uint, stack_hi: uint) {
// When the old runtime had segmented stacks, it used a calculation that was
......
......@@ -213,7 +213,6 @@ fn __gcc_personality_v0(version: c_int,
}
#[lang="eh_personality"]
#[cfg(not(stage0))]
extern fn eh_personality(
version: c_int,
actions: uw::_Unwind_Action,
......@@ -227,22 +226,6 @@ fn __gcc_personality_v0(version: c_int,
context)
}
}
#[lang="eh_personality"]
#[no_mangle] // so we can reference it by name from middle/trans/base.rs
#[cfg(stage0)]
pub extern "C" fn rust_eh_personality(
version: c_int,
actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class,
ue_header: *uw::_Unwind_Exception,
context: *uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code
{
unsafe {
__gcc_personality_v0(version, actions, exception_class, ue_header,
context)
}
}
#[no_mangle] // referenced from rust_try.ll
pub extern "C" fn rust_eh_personality_catch(
......@@ -281,7 +264,6 @@ fn __gcc_personality_v0(state: uw::_Unwind_State,
}
#[lang="eh_personality"]
#[cfg(not(stage0))]
extern "C" fn eh_personality(
state: uw::_Unwind_State,
ue_header: *uw::_Unwind_Exception,
......@@ -293,20 +275,6 @@ extern "C" fn eh_personality(
}
}
#[lang="eh_personality"]
#[no_mangle] // so we can reference it by name from middle/trans/base.rs
#[cfg(stage0)]
pub extern "C" fn rust_eh_personality(
state: uw::_Unwind_State,
ue_header: *uw::_Unwind_Exception,
context: *uw::_Unwind_Context
) -> uw::_Unwind_Reason_Code
{
unsafe {
__gcc_personality_v0(state, ue_header, context)
}
}
#[no_mangle] // referenced from rust_try.ll
pub extern "C" fn rust_eh_personality_catch(
state: uw::_Unwind_State,
......@@ -327,20 +295,13 @@ pub extern "C" fn rust_eh_personality_catch(
}
// Entry point of failure from the libcore crate
#[cfg(not(test), not(stage0))]
#[cfg(not(test))]
#[lang = "begin_unwind"]
pub extern fn rust_begin_unwind(msg: &fmt::Arguments,
file: &'static str, line: uint) -> ! {
begin_unwind_fmt(msg, file, line)
}
#[no_mangle]
#[cfg(not(test), stage0)]
pub extern fn rust_begin_unwind(msg: &fmt::Arguments,
file: &'static str, line: uint) -> ! {
begin_unwind_fmt(msg, file, line)
}
/// The entry point for unwinding with a formatted message.
///
/// This is designed to reduce the amount of code required at the call
......
S 2014-05-29 50b8528
freebsd-x86_64 cfa0dcc98a57f03a53bb53df6fd5db02143e2bee
linux-i386 baf7c6ab5792f3d560a0f2adc94d7ff96d0cab3d
linux-x86_64 ed97bc90842b96b95e860b9d21fe1ade3f682fd3
macos-i386 2d0e27f72e34be53b1f16d704e9a3b8bedbdbd31
macos-x86_64 f8912b07014c234ae2d625d6da84c752508a2b04
winnt-i386 0af7b426f57015d8392e00ee9a9d1f2f5eb10761
S 2014-05-16 5327218
freebsd-x86_64 e91e235c808eb7e8a1e82f7e00c874de9b1df345
linux-i386 3a3b7d68ed42a144fa06c9a49c63966da9adeef2
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册