Skip to content

Commit fdf48a7

Browse files
committed
rt: improve mips backend
1 parent 99b156e commit fdf48a7

File tree

6 files changed

+27
-12
lines changed

6 files changed

+27
-12
lines changed

src/libcore/rt/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
189189

190190
regs[4] = arg as uint;
191191
regs[29] = sp as uint;
192+
regs[25] = fptr as uint;
192193
regs[31] = fptr as uint;
193194
}
194195

src/librustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
8989
abi::X86 => (~"little",~"x86",~"32"),
9090
abi::X86_64 => (~"little",~"x86_64",~"64"),
9191
abi::Arm => (~"little",~"arm",~"32"),
92-
abi::Mips => (~"little",~"arm",~"32")
92+
abi::Mips => (~"big",~"mips",~"32")
9393
};
9494

9595
return ~[ // Target bindings.

src/rt/arch/mips/_context.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ swap_registers:
5151
lw $2, 2 * 4($5)
5252
lw $3, 3 * 4($5)
5353
lw $4, 4 * 4($5)
54-
lw $5, 5 * 4($5)
5554
lw $6, 6 * 4($5)
5655
lw $7, 7 * 4($5)
5756

@@ -82,6 +81,8 @@ swap_registers:
8281
lw $30, 30 * 4($5)
8382
lw $31, 31 * 4($5)
8483

84+
lw $5, 5 * 4($5)
85+
8586
jr $31
8687
nop
8788
.end swap_registers

src/rt/arch/mips/ccall.S

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,39 @@
55

66
.text
77

8+
.align 2
89
.globl __morestack
910
.hidden __morestack
10-
.align 2
11+
.cfi_sections .eh_frame_entry
12+
.cfi_startproc
1113
.set nomips16
1214
.ent __morestack
1315
__morestack:
1416
.set noreorder
1517
.set nomacro
16-
move $7, $29
17-
move $29, $6
1818

19-
sw $7, 0($29)
20-
sw $31, -4($29)
19+
addiu $29, $29, -8
20+
sw $31, 4($29)
21+
sw $30, 0($29)
2122

22-
addiu $29, $29, -24
23+
.cfi_def_cfa_offset 8
24+
.cfi_offset 31, -4
25+
.cfi_offset 30, -8
26+
27+
move $30, $29
28+
.cfi_def_cfa_register 30
29+
30+
move $29, $6
2331
move $25, $5
2432
jalr $25
2533
nop
26-
addiu $29, $29, 24
34+
move $29, $30
2735

28-
lw $31, -4($29)
29-
lw $7, 0($29)
36+
lw $30, 0($29)
37+
lw $31, 4($29)
38+
addiu $29, $29, 8
3039

31-
move $29, $7
3240
jr $31
3341
nop
3442
.end __morestack
43+
.cfi_endproc

src/rt/arch/mips/context.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ void context::call(void *f, void *arg, void *stack)
4040

4141
regs.data[4] = (uint32_t)arg;
4242
regs.data[29] = (uint32_t)sp;
43+
regs.data[25] = (uint32_t)f;
4344
regs.data[31] = (uint32_t)f;
4445

4546
// Last base pointer on the stack should be 0

src/rt/sync/rust_thread.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ rust_thread::start() {
4141
#if defined(__WIN32__)
4242
thread = CreateThread(NULL, stack_sz, rust_thread_start, this, 0, NULL);
4343
#else
44+
if (stack_sz < PTHREAD_STACK_MIN) {
45+
stack_sz = PTHREAD_STACK_MIN;
46+
}
4447
pthread_attr_t attr;
4548
CHECKED(pthread_attr_init(&attr));
4649
CHECKED(pthread_attr_setstacksize(&attr, stack_sz));

0 commit comments

Comments
 (0)