Skip to content

Commit e5a62b9

Browse files
committed
---
yaml --- r: 15329 b: refs/heads/try c: 851fde8 h: refs/heads/master i: 15327: 2962ee9 v: v3
1 parent 3109fd8 commit e5a62b9

File tree

7 files changed

+100
-2
lines changed

7 files changed

+100
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 9310015c2584e254349388c0f4a97fcb2abd2b6f
5+
refs/heads/try: 851fde879d85f3b76b42322f46cdc00c5f97e357
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/mk/rt.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ RUNTIME_CS_$(1) := \
7272
rt/rust_box_annihilator.cpp \
7373
rt/memory_region.cpp \
7474
rt/boxed_region.cpp \
75-
rt/arch/$$(HOST_$(1))/context.cpp
75+
rt/arch/$$(HOST_$(1))/context.cpp \
76+
rt/arch/$$(HOST_$(1))/gpr.cpp
7677

7778
RUNTIME_S_$(1) := rt/arch/$$(HOST_$(1))/_context.S \
7879
rt/arch/$$(HOST_$(1))/ccall.S \

branches/try/src/rt/arch/i386/gpr.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "gpr.h"
2+
3+
#define LOAD(rn) do { \
4+
uintptr_t tmp; \
5+
asm("movl %%" #rn ",%0" : "=r" (tmp) :); \
6+
this->rn = tmp; \
7+
} while (0)
8+
9+
void rust_gpr::load() {
10+
LOAD(eax); LOAD(ebx); LOAD(ecx); LOAD(edx);
11+
LOAD(esi); LOAD(edi); LOAD(ebp); LOAD(esi);
12+
}
13+

branches/try/src/rt/arch/i386/gpr.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// General-purpose registers. This structure is used during stack crawling.
2+
3+
#ifndef GPR_H
4+
#define GPR_H
5+
6+
#include "rust_gpr_base.h"
7+
8+
class rust_gpr : public rust_gpr_base {
9+
public:
10+
uintptr_t eax, ebx, ecx, edx, esi, edi, ebp, eip;
11+
12+
inline uintptr_t get_fp() { return ebp; }
13+
inline uintptr_t get_ip() { return eip; }
14+
15+
inline void set_fp(uintptr_t new_fp) { ebp = new_fp; }
16+
inline void set_ip(uintptr_t new_ip) { eip = new_ip; }
17+
18+
void load();
19+
};
20+
21+
#endif
22+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "gpr.h"
2+
3+
#define LOAD(rn) do { \
4+
uintptr_t tmp; \
5+
asm("movq %%" #rn ",%0" : "=r" (tmp) :); \
6+
this->rn = tmp; \
7+
} while (0)
8+
9+
void rust_gpr::load() {
10+
LOAD(rax); LOAD(rbx); LOAD(rcx); LOAD(rdx);
11+
LOAD(rsi); LOAD(rdi); LOAD(rbp); LOAD(rsi);
12+
LOAD(r8); LOAD(r9); LOAD(r10); LOAD(r11);
13+
LOAD(r12); LOAD(r13); LOAD(r14); LOAD(r15);
14+
}
15+

branches/try/src/rt/arch/x86_64/gpr.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// General-purpose registers. This structure is used during stack crawling.
2+
3+
#ifndef GPR_H
4+
#define GPR_H
5+
6+
#include "rust_gpr_base.h"
7+
8+
class rust_gpr : public rust_gpr_base {
9+
public:
10+
uintptr_t rax, rbx, rcx, rdx, rsi, rdi, rbp, rip;
11+
uintptr_t r8, r9, r10, r11, r12, r13, r14, r15;
12+
13+
inline uintptr_t get_fp() { return rbp; }
14+
inline uintptr_t get_ip() { return rip; }
15+
16+
inline void set_fp(uintptr_t new_fp) { rbp = new_fp; }
17+
inline void set_ip(uintptr_t new_ip) { rip = new_ip; }
18+
19+
void load();
20+
};
21+
22+
#endif
23+

branches/try/src/rt/rust_gpr_base.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Base class for architecture-specific general-purpose registers. This
2+
// structure is used during stack crawling.
3+
4+
#ifndef GPR_BASE_H
5+
#define GPR_BASE_H
6+
7+
#include <stdint.h>
8+
9+
class rust_gpr_base {
10+
public:
11+
// Returns the value of a register by number.
12+
inline uintptr_t &get(uint32_t i) {
13+
return reinterpret_cast<uintptr_t *>(this)[i];
14+
}
15+
16+
// Sets the value of a register by number.
17+
inline void set(uint32_t i, uintptr_t val) {
18+
reinterpret_cast<uintptr_t *>(this)[i] = val;
19+
}
20+
};
21+
22+
23+
#endif
24+

0 commit comments

Comments
 (0)