auto merge of #16263 : brson/rust/morestack, r=alexcrichton
This commit is contained in:
commit
b09a02b415
@ -1,23 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// ignore-test newsched transition
|
||||
// error-pattern:fail
|
||||
fn getbig(i: int) {
|
||||
if i != 0 {
|
||||
getbig(i - 1);
|
||||
} else {
|
||||
fail!();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
getbig(100000);
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// ignore-test newsched transition
|
||||
// error-pattern:explicit failure
|
||||
|
||||
// This time we're testing that the stack limits are restored
|
||||
// correctly after calling into the C stack and unwinding.
|
||||
// See the hack in upcall_call_shim_on_c_stack where it messes
|
||||
// with the stack limit.
|
||||
|
||||
extern crate libc;
|
||||
use std::task;
|
||||
|
||||
mod rustrt {
|
||||
extern crate libc;
|
||||
|
||||
extern {
|
||||
pub fn rust_get_argc() -> libc::c_int;
|
||||
}
|
||||
}
|
||||
|
||||
fn getbig_call_c_and_fail(i: int) {
|
||||
if i != 0 {
|
||||
getbig_call_c_and_fail(i - 1);
|
||||
} else {
|
||||
unsafe {
|
||||
rustrt::rust_get_argc();
|
||||
fail!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct and_then_get_big_again {
|
||||
x:int,
|
||||
}
|
||||
|
||||
impl Drop for and_then_get_big_again {
|
||||
fn drop(&mut self) {
|
||||
fn getbig(i: int) {
|
||||
if i != 0 {
|
||||
getbig(i - 1);
|
||||
}
|
||||
}
|
||||
getbig(10000);
|
||||
}
|
||||
}
|
||||
|
||||
fn and_then_get_big_again(x:int) -> and_then_get_big_again {
|
||||
and_then_get_big_again {
|
||||
x: x
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
task::spawn(proc() {
|
||||
let r = and_then_get_big_again(4);
|
||||
getbig_call_c_and_fail(10000);
|
||||
});
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// ignore-test newsched transition
|
||||
// error-pattern:explicit failure
|
||||
|
||||
// Just testing unwinding
|
||||
|
||||
use std::task;
|
||||
|
||||
fn getbig_and_fail(i: int) {
|
||||
let _r = and_then_get_big_again(5);
|
||||
if i != 0 {
|
||||
getbig_and_fail(i - 1);
|
||||
} else {
|
||||
fail!();
|
||||
}
|
||||
}
|
||||
|
||||
struct and_then_get_big_again {
|
||||
x:int,
|
||||
}
|
||||
|
||||
impl Drop for and_then_get_big_again {
|
||||
fn drop(&mut self) {
|
||||
fn getbig(i: int) {
|
||||
if i != 0 {
|
||||
getbig(i - 1);
|
||||
}
|
||||
}
|
||||
getbig(100);
|
||||
}
|
||||
}
|
||||
|
||||
fn and_then_get_big_again(x:int) -> and_then_get_big_again {
|
||||
and_then_get_big_again {
|
||||
x: x
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
task::spawn(proc() {
|
||||
getbig_and_fail(400);
|
||||
});
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// ignore-test newsched transition
|
||||
// error-pattern:explicit failure
|
||||
|
||||
// Just testing unwinding
|
||||
|
||||
use std::task;
|
||||
|
||||
fn getbig_and_fail(i: int) {
|
||||
let r = and_then_get_big_again(5);
|
||||
if i != 0 {
|
||||
getbig_and_fail(i - 1);
|
||||
} else {
|
||||
fail!();
|
||||
}
|
||||
}
|
||||
|
||||
struct and_then_get_big_again {
|
||||
x:int,
|
||||
}
|
||||
|
||||
impl Drop for and_then_get_big_again {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
fn and_then_get_big_again(x:int) -> and_then_get_big_again {
|
||||
and_then_get_big_again {
|
||||
x: x
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
task::spawn(proc() {
|
||||
getbig_and_fail(1);
|
||||
});
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// ignore-test newsched transition
|
||||
|
||||
fn getbig(i: int) {
|
||||
if i != 0 {
|
||||
getbig(i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
getbig(100000);
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// ignore-test newsched transition
|
||||
|
||||
fn getbig(i: int) -> int {
|
||||
let m = if i >= 0 {
|
||||
let j = getbig(i - 1);
|
||||
let k = getbig(j - 1);
|
||||
k
|
||||
} else {
|
||||
0
|
||||
};
|
||||
m
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
getbig(10000);
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// ignore-test newsched transition
|
||||
|
||||
// Here we're testing that all of the argument registers, argument
|
||||
// stack slots, and return value are preserved across split stacks.
|
||||
fn getbig(a0: int,
|
||||
a1: int,
|
||||
a2: int,
|
||||
a3: int,
|
||||
a4: int,
|
||||
a5: int,
|
||||
a6: int,
|
||||
a7: int,
|
||||
a8: int,
|
||||
a9: int) -> int {
|
||||
|
||||
assert_eq!(a0 + 1, a1);
|
||||
assert_eq!(a1 + 1, a2);
|
||||
assert_eq!(a2 + 1, a3);
|
||||
assert_eq!(a3 + 1, a4);
|
||||
assert_eq!(a4 + 1, a5);
|
||||
assert_eq!(a5 + 1, a6);
|
||||
assert_eq!(a6 + 1, a7);
|
||||
assert_eq!(a7 + 1, a8);
|
||||
assert_eq!(a8 + 1, a9);
|
||||
if a0 != 0 {
|
||||
let j = getbig(a0 - 1,
|
||||
a1 - 1,
|
||||
a2 - 1,
|
||||
a3 - 1,
|
||||
a4 - 1,
|
||||
a5 - 1,
|
||||
a6 - 1,
|
||||
a7 - 1,
|
||||
a8 - 1,
|
||||
a9 - 1);
|
||||
assert_eq!(j, a0 - 1);
|
||||
}
|
||||
return a0;
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let a = 1000;
|
||||
getbig(a, a+1, a+2, a+3, a+4, a+5, a+6, a+7, a+8, a+9);
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// ignore-test newsched transition
|
||||
|
||||
// This is testing for stack frames greater than 256 bytes,
|
||||
// for which function prologues are generated differently
|
||||
|
||||
struct Biggy {
|
||||
a00: u64,
|
||||
a01: u64,
|
||||
a02: u64,
|
||||
a03: u64,
|
||||
a04: u64,
|
||||
a05: u64,
|
||||
a06: u64,
|
||||
a07: u64,
|
||||
a08: u64,
|
||||
a09: u64,
|
||||
a10: u64,
|
||||
a11: u64,
|
||||
a12: u64,
|
||||
a13: u64,
|
||||
a14: u64,
|
||||
a15: u64,
|
||||
a16: u64,
|
||||
a17: u64,
|
||||
a18: u64,
|
||||
a19: u64,
|
||||
a20: u64,
|
||||
a21: u64,
|
||||
a22: u64,
|
||||
a23: u64,
|
||||
a24: u64,
|
||||
a25: u64,
|
||||
a26: u64,
|
||||
a27: u64,
|
||||
a28: u64,
|
||||
a29: u64,
|
||||
a30: u64,
|
||||
a31: u64,
|
||||
a32: u64,
|
||||
a33: u64,
|
||||
a34: u64,
|
||||
a35: u64,
|
||||
a36: u64,
|
||||
a37: u64,
|
||||
a38: u64,
|
||||
a39: u64,
|
||||
}
|
||||
|
||||
|
||||
fn getbig(i: Biggy) {
|
||||
if i.a00 != 0u64 {
|
||||
getbig(Biggy{a00: i.a00 - 1u64,.. i});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
getbig(Biggy {
|
||||
a00: 10000u64,
|
||||
a01: 10000u64,
|
||||
a02: 10000u64,
|
||||
a03: 10000u64,
|
||||
a04: 10000u64,
|
||||
a05: 10000u64,
|
||||
a06: 10000u64,
|
||||
a07: 10000u64,
|
||||
a08: 10000u64,
|
||||
a09: 10000u64,
|
||||
a10: 10000u64,
|
||||
a11: 10000u64,
|
||||
a12: 10000u64,
|
||||
a13: 10000u64,
|
||||
a14: 10000u64,
|
||||
a15: 10000u64,
|
||||
a16: 10000u64,
|
||||
a17: 10000u64,
|
||||
a18: 10000u64,
|
||||
a19: 10000u64,
|
||||
a20: 10000u64,
|
||||
a21: 10000u64,
|
||||
a22: 10000u64,
|
||||
a23: 10000u64,
|
||||
a24: 10000u64,
|
||||
a25: 10000u64,
|
||||
a26: 10000u64,
|
||||
a27: 10000u64,
|
||||
a28: 10000u64,
|
||||
a29: 10000u64,
|
||||
a30: 10000u64,
|
||||
a31: 10000u64,
|
||||
a32: 10000u64,
|
||||
a33: 10000u64,
|
||||
a34: 10000u64,
|
||||
a35: 10000u64,
|
||||
a36: 10000u64,
|
||||
a37: 10000u64,
|
||||
a38: 10000u64,
|
||||
a39: 10000u64,
|
||||
});
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// ignore-test newsched transition
|
||||
|
||||
// This test will call __morestack with various minimum stack sizes
|
||||
|
||||
use std::task;
|
||||
|
||||
fn getbig(i: int) {
|
||||
if i != 0 {
|
||||
getbig(i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let mut sz = 400u;
|
||||
while sz < 500u {
|
||||
task::try(|| getbig(200) );
|
||||
sz += 1u;
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
// 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.
|
||||
|
||||
// ignore-test newsched transition
|
||||
|
||||
// This test attempts to force the dynamic linker to resolve
|
||||
// external symbols as close to the red zone as possible.
|
||||
|
||||
extern crate rand;
|
||||
|
||||
use std::task;
|
||||
|
||||
mod rustrt {
|
||||
extern crate libc;
|
||||
|
||||
extern {
|
||||
pub fn debug_get_stk_seg() -> *u8;
|
||||
|
||||
pub fn rust_get_sched_id() -> libc::intptr_t;
|
||||
pub fn rust_get_argc() -> libc::c_int;
|
||||
pub fn get_task_id() -> libc::intptr_t;
|
||||
pub fn rust_get_task();
|
||||
}
|
||||
}
|
||||
|
||||
fn calllink01() { unsafe { rustrt::rust_get_sched_id(); } }
|
||||
fn calllink02() { unsafe { rustrt::rust_get_argc(); } }
|
||||
fn calllink08() { unsafe { rustrt::get_task_id(); } }
|
||||
fn calllink10() { unsafe { rustrt::rust_get_task(); } }
|
||||
|
||||
fn runtest(f: extern fn(), frame_backoff: u32) {
|
||||
runtest2(f, frame_backoff, 0 as *u8);
|
||||
}
|
||||
|
||||
fn runtest2(f: extern fn(), frame_backoff: u32, last_stk: *u8) -> u32 {
|
||||
unsafe {
|
||||
let curr_stk = rustrt::debug_get_stk_seg();
|
||||
if (last_stk != curr_stk && last_stk != 0 as *u8) {
|
||||
// We switched stacks, go back and try to hit the dynamic linker
|
||||
frame_backoff
|
||||
} else {
|
||||
let frame_backoff = runtest2(f, frame_backoff, curr_stk);
|
||||
if frame_backoff > 1u32 {
|
||||
frame_backoff - 1u32
|
||||
} else if frame_backoff == 1u32 {
|
||||
f();
|
||||
0u32
|
||||
} else {
|
||||
0u32
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
use rand::Rng;
|
||||
let fns = vec!(
|
||||
calllink01,
|
||||
calllink02,
|
||||
calllink08,
|
||||
calllink10
|
||||
);
|
||||
let mut rng = rand::task_rng();
|
||||
|
||||
for f in fns.iter() {
|
||||
let f = *f;
|
||||
let sz = rng.gen::<u32>() % 256u32 + 256u32;
|
||||
let frame_backoff = rng.gen::<u32>() % 10u32 + 1u32;
|
||||
task::try(|| runtest(f, frame_backoff) );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user