Skip to content

Commit 754fdb8

Browse files
committed
Remove morestack support
Removed some time ago!
1 parent 2bd8dd6 commit 754fdb8

File tree

5 files changed

+6
-98
lines changed

5 files changed

+6
-98
lines changed

src/arch/i686.S

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,6 @@ GLOBAL(__stacker_stack_pointer):
99
mov %esp, %eax
1010
ret
1111

12-
#if defined(LINUX)
13-
GLOBAL(__stacker_morestack_stack_limit):
14-
mov %gs:0x30, %eax
15-
ret
16-
17-
GLOBAL(__stacker_set_morestack_stack_limit):
18-
mov 4(%esp), %eax
19-
mov %eax, %gs:0x30
20-
ret
21-
#elif defined(APPLE)
22-
GLOBAL(__stacker_morestack_stack_limit):
23-
mov %gs:0x1b0, %eax
24-
ret
25-
26-
GLOBAL(__stacker_set_morestack_stack_limit):
27-
mov 4(%esp), %eax
28-
mov %eax, %gs:0x1b0
29-
ret
30-
#elif defined(WINDOWS)
31-
GLOBAL(__stacker_morestack_stack_limit):
32-
mov $0, %eax
33-
ret
34-
35-
GLOBAL(__stacker_set_morestack_stack_limit):
36-
ret
37-
38-
GLOBAL(__stacker_get_tib_32):
39-
mov %fs:0x18, %eax
40-
ret
41-
#else
42-
#error "unsupported arch"
43-
#endif
44-
4512
GLOBAL(__stacker_switch_stacks):
4613
push %ebp
4714
mov %esp, %ebp

src/arch/i686.asm

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ __stacker_stack_pointer PROC
1111
RET
1212
__stacker_stack_pointer ENDP
1313

14-
__stacker_morestack_stack_limit PROC
15-
MOV EAX, 0
16-
RET
17-
__stacker_morestack_stack_limit ENDP
18-
19-
__stacker_set_morestack_stack_limit PROC
20-
RET
21-
__stacker_set_morestack_stack_limit ENDP
22-
2314
__stacker_get_tib_32 PROC
2415
ASSUME FS:NOTHING
2516
MOV EAX, FS:[24]

src/arch/x86_64.S

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,6 @@ GLOBAL(__stacker_stack_pointer):
1919
#define ARG3 %rdx
2020
#endif
2121

22-
#if defined(LINUX)
23-
GLOBAL(__stacker_morestack_stack_limit):
24-
movq %fs:0x70, %rax
25-
ret
26-
27-
GLOBAL(__stacker_set_morestack_stack_limit):
28-
movq %rdi, %fs:0x70
29-
ret
30-
#elif defined(APPLE)
31-
GLOBAL(__stacker_morestack_stack_limit):
32-
movq %gs:0x330, %rax
33-
ret
34-
35-
GLOBAL(__stacker_set_morestack_stack_limit):
36-
movq %rdi, %gs:0x330
37-
ret
38-
#elif defined(WINDOWS)
39-
GLOBAL(__stacker_morestack_stack_limit):
40-
movq $0, %rax
41-
ret
42-
43-
GLOBAL(__stacker_set_morestack_stack_limit):
44-
ret
45-
46-
GLOBAL(__stacker_get_tib_64):
47-
mov %gs:0x30, %rax
48-
ret
49-
#else
50-
#error "unsupported arch"
51-
#endif
52-
5322
GLOBAL(__stacker_switch_stacks):
5423
push %rbp
5524
mov %rsp, %rbp

src/arch/x86_64.asm

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ __stacker_stack_pointer PROC
99
RET
1010
__stacker_stack_pointer ENDP
1111

12-
__stacker_morestack_stack_limit PROC
13-
MOV RAX, 0
14-
RET
15-
__stacker_morestack_stack_limit ENDP
16-
17-
__stacker_set_morestack_stack_limit PROC
18-
RET
19-
__stacker_set_morestack_stack_limit ENDP
20-
2112
__stacker_switch_stacks PROC
2213
PUSH RBP
2314
MOV RBP, RSP

src/lib.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ extern crate libc;
3131
use std::cell::Cell;
3232

3333
extern {
34-
fn __stacker_morestack_stack_limit() -> usize;
35-
fn __stacker_set_morestack_stack_limit(limit: usize);
3634
fn __stacker_stack_pointer() -> usize;
3735
fn __stacker_switch_stacks(new_stack: usize,
3836
fnptr: *const u8,
@@ -41,7 +39,7 @@ extern {
4139

4240
thread_local! {
4341
static STACK_LIMIT: Cell<usize> = Cell::new(unsafe {
44-
guess_os_morestack_stack_limit()
42+
guess_os_stack_limit()
4543
})
4644
}
4745

@@ -79,7 +77,6 @@ unsafe fn grow_the_stack<R, F: FnOnce() -> R>(stack_size: usize, f: F) -> R {
7977
struct Context<F: FnOnce() -> R, R> {
8078
thunk: Option<F>,
8179
ret: Option<R>,
82-
new_limit: usize,
8380
}
8481

8582
// Align to 16-bytes (see below for why)
@@ -90,19 +87,15 @@ unsafe fn grow_the_stack<R, F: FnOnce() -> R>(stack_size: usize, f: F) -> R {
9087
let new_limit = stack.as_ptr() as usize + 32 * 1024;
9188

9289
// Save off the old stack limits
93-
let old_morestack_limit = __stacker_morestack_stack_limit();
9490
let old_limit = get_stack_limit();
9591

96-
// Prepare stack limits for the stack switch, note that the morestack stack
97-
// limit will be set to a real value once we've switched threads.
98-
__stacker_set_morestack_stack_limit(0);
92+
// Prepare stack limits for the stack switch
9993
set_stack_limit(new_limit);
10094

10195
// Set up the arguments and do the actual stack switch.
10296
let mut cx: Context<F, R> = Context {
10397
thunk: Some(f),
10498
ret: None,
105-
new_limit: new_limit,
10699
};
107100

108101
// Make sure the stack is 16-byte aligned which should be enough for all
@@ -121,14 +114,11 @@ unsafe fn grow_the_stack<R, F: FnOnce() -> R>(stack_size: usize, f: F) -> R {
121114

122115
// Once we've returned reset bothe stack limits and then return value same
123116
// value the closure returned.
124-
__stacker_set_morestack_stack_limit(old_morestack_limit);
125117
set_stack_limit(old_limit);
126118
return cx.ret.unwrap();
127119

128120
unsafe extern fn doit<R, F: FnOnce() -> R>(cx: &mut Context<F, R>) {
129-
__stacker_set_morestack_stack_limit(cx.new_limit);
130121
cx.ret = Some(cx.thunk.take().unwrap()());
131-
__stacker_set_morestack_stack_limit(0);
132122
}
133123
}
134124

@@ -138,7 +128,7 @@ cfg_if! {
138128
//
139129
// https://github.com/adobe/webkit/blob/0441266/Source/WTF/wtf
140130
// /StackBounds.cpp
141-
unsafe fn guess_os_morestack_stack_limit() -> usize {
131+
unsafe fn guess_os_stack_limit() -> usize {
142132
#[cfg(target_pointer_width = "32")]
143133
extern {
144134
#[link_name = "__stacker_get_tib_32"]
@@ -159,7 +149,7 @@ cfg_if! {
159149
} else if #[cfg(target_os = "linux")] {
160150
use std::mem;
161151

162-
unsafe fn guess_os_morestack_stack_limit() -> usize {
152+
unsafe fn guess_os_stack_limit() -> usize {
163153
let mut attr: libc::pthread_attr_t = mem::zeroed();
164154
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
165155
assert_eq!(libc::pthread_getattr_np(libc::pthread_self(),
@@ -174,12 +164,12 @@ cfg_if! {
174164
} else if #[cfg(target_os = "macos")] {
175165
use libc::{c_void, pthread_t, size_t};
176166

177-
unsafe fn guess_os_morestack_stack_limit() -> usize {
167+
unsafe fn guess_os_stack_limit() -> usize {
178168
libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize -
179169
libc::pthread_get_stacksize_np(libc::pthread_self()) as usize
180170
}
181171
} else {
182-
unsafe fn guess_os_morestack_stack_limit() -> usize {
172+
unsafe fn guess_os_stack_limit() -> usize {
183173
panic!("cannot guess the stack limit on this platform");
184174
}
185175
}

0 commit comments

Comments
 (0)