Skip to content

Commit 078832f

Browse files
committed
---
yaml --- r: 139229 b: refs/heads/try2 c: a692777 h: refs/heads/master i: 139227: f0af8b3 v: v3
1 parent 30e95c5 commit 078832f

File tree

3 files changed

+46
-64
lines changed

3 files changed

+46
-64
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: d1778767cca290e844d5aa9d044dcc2f9edc9d8c
8+
refs/heads/try2: a692777224150e2dadb5ec02c6ecd5c10ce0dd98
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +0,0 @@
1-
.text
2-
3-
#if defined(__APPLE__) || defined(_WIN32)
4-
#define RECORD_SP_LIMIT _record_sp_limit
5-
#define GET_SP_LIMIT _get_sp_limit
6-
#define GET_SP _get_sp
7-
#else
8-
#define RECORD_SP_LIMIT record_sp_limit
9-
#define GET_SP_LIMIT get_sp_limit
10-
#define GET_SP get_sp
11-
#endif
12-
13-
.globl RECORD_SP_LIMIT
14-
.globl GET_SP_LIMIT
15-
.globl GET_SP
16-
17-
#if defined(__linux__) || defined(__FreeBSD__)
18-
RECORD_SP_LIMIT:
19-
movl 4(%esp), %eax
20-
movl %eax, %gs:48
21-
ret
22-
#endif
23-
24-
#if defined(__APPLE__)
25-
RECORD_SP_LIMIT:
26-
movl $0x48+90*4, %eax
27-
movl 4(%esp), %ecx
28-
movl %ecx, %gs:(%eax)
29-
ret
30-
#endif
31-
32-
#if defined(_WIN32)
33-
RECORD_SP_LIMIT:
34-
movl 4(%esp), %eax
35-
movl %eax, %fs:0x14
36-
ret
37-
#endif
38-
39-
#if defined(__linux__) || defined(__FreeBSD__)
40-
GET_SP_LIMIT:
41-
movl %gs:48, %eax
42-
ret
43-
#endif
44-
45-
#if defined(__APPLE__)
46-
GET_SP_LIMIT:
47-
movl $0x48+90*4, %ecx
48-
movl %gs:(%ecx), %eax
49-
ret
50-
#endif
51-
52-
#if defined(_WIN32)
53-
GET_SP_LIMIT:
54-
movl %fs:0x14, %eax
55-
ret
56-
#endif
57-
58-
GET_SP:
59-
movl %esp, %eax
60-
ret

branches/try2/src/rt/arch/i386/sp.h

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,56 @@
1616
#include "../../rust_globals.h"
1717

1818
// Gets a pointer to the vicinity of the current stack pointer
19-
extern "C" uintptr_t get_sp();
19+
extern "C" ALWAYS_INLINE uintptr_t get_sp() {
20+
uintptr_t sp;
21+
asm volatile (
22+
"movl %%esp, %0"
23+
: "=m"(sp));
24+
return sp;
25+
}
2026

2127
// Gets the pointer to the end of the Rust stack from a platform-
2228
// specific location in the thread control block
23-
extern "C" CDECL uintptr_t get_sp_limit();
29+
extern "C" CDECL ALWAYS_INLINE uintptr_t get_sp_limit() {
30+
uintptr_t limit;
31+
32+
#if defined(__linux__) || defined(__FreeBSD__)
33+
asm volatile (
34+
"movl %%gs:48, %0"
35+
: "=r"(limit));
36+
#elif defined(__APPLE__)
37+
asm volatile (
38+
"movl $0x48+90*4, %%ecx\n\t"
39+
"movl %%gs:(%%ecx), %0"
40+
: "=r"(limit)
41+
:: "ecx");
42+
#elif defined(_WIN32)
43+
asm volatile (
44+
"movl %%fs:0x14, %0"
45+
: "=r"(limit));
46+
#endif
47+
48+
return limit;
49+
}
2450

2551
// Records the pointer to the end of the Rust stack in a platform-
2652
// specific location in the thread control block
27-
extern "C" CDECL void record_sp_limit(void *limit);
53+
extern "C" CDECL ALWAYS_INLINE void record_sp_limit(void *limit) {
54+
#if defined(__linux__) || defined(__FreeBSD__)
55+
asm volatile (
56+
"movl %0, %%gs:48"
57+
:: "r"(limit));
58+
#elif defined(__APPLE__)
59+
asm volatile (
60+
"movl $0x48+90*4, %%eax\n\t"
61+
"movl %0, %%gs:(%%eax)"
62+
:: "r"(limit)
63+
: "eax");
64+
#elif defined(_WIN32)
65+
asm volatile (
66+
"movl %0, %%fs:0x14"
67+
:: "r"(limit));
68+
#endif
69+
}
2870

2971
#endif

0 commit comments

Comments
 (0)