about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJyun-Yan You <jyyou@cs.nctu.edu.tw>2013-03-19 13:34:12 +0800
committerJyun-Yan You <jyyou.tw@gmail.com>2013-04-04 18:53:58 +0800
commitfdf48a7b52de948b3ec4ba187539a6164a56edcb (patch)
treebf36275edf4ce9dcde64757554985817e874bbd5
parent99b156e78a592e8195ae7918a1ad958abef96050 (diff)
downloadrust-fdf48a7b52de948b3ec4ba187539a6164a56edcb.tar.gz
rust-fdf48a7b52de948b3ec4ba187539a6164a56edcb.zip
rt: improve mips backend
-rw-r--r--src/libcore/rt/context.rs1
-rw-r--r--src/librustc/driver/driver.rs2
-rw-r--r--src/rt/arch/mips/_context.S3
-rw-r--r--src/rt/arch/mips/ccall.S29
-rw-r--r--src/rt/arch/mips/context.cpp1
-rw-r--r--src/rt/sync/rust_thread.cpp3
6 files changed, 27 insertions, 12 deletions
diff --git a/src/libcore/rt/context.rs b/src/libcore/rt/context.rs
index 224f28a0329..9dc9f5da8c1 100644
--- a/src/libcore/rt/context.rs
+++ b/src/libcore/rt/context.rs
@@ -189,6 +189,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
 
     regs[4] = arg as uint;
     regs[29] = sp as uint;
+    regs[25] = fptr as uint;
     regs[31] = fptr as uint;
 }
 
diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs
index 809a4a591ac..3b1401ae1d2 100644
--- a/src/librustc/driver/driver.rs
+++ b/src/librustc/driver/driver.rs
@@ -89,7 +89,7 @@ pub fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
         abi::X86 => (~"little",~"x86",~"32"),
         abi::X86_64 => (~"little",~"x86_64",~"64"),
         abi::Arm => (~"little",~"arm",~"32"),
-        abi::Mips => (~"little",~"arm",~"32")
+        abi::Mips => (~"big",~"mips",~"32")
     };
 
     return ~[ // Target bindings.
diff --git a/src/rt/arch/mips/_context.S b/src/rt/arch/mips/_context.S
index c926a03798d..6d8207d97d0 100644
--- a/src/rt/arch/mips/_context.S
+++ b/src/rt/arch/mips/_context.S
@@ -51,7 +51,6 @@ swap_registers:
         lw $2, 2 * 4($5)
         lw $3, 3 * 4($5)
         lw $4, 4 * 4($5)
-        lw $5, 5 * 4($5)
         lw $6, 6 * 4($5)
         lw $7, 7 * 4($5)
 
@@ -82,6 +81,8 @@ swap_registers:
         lw $30, 30 * 4($5)
         lw $31, 31 * 4($5)
 
+        lw $5, 5 * 4($5)
+
         jr $31
         nop
 .end swap_registers
diff --git a/src/rt/arch/mips/ccall.S b/src/rt/arch/mips/ccall.S
index f41d8e721f6..abbbad164fd 100644
--- a/src/rt/arch/mips/ccall.S
+++ b/src/rt/arch/mips/ccall.S
@@ -5,30 +5,39 @@
 
 .text
 
+.align 2
 .globl __morestack
 .hidden __morestack
-.align 2
+.cfi_sections .eh_frame_entry
+.cfi_startproc
 .set nomips16
 .ent __morestack
 __morestack:
         .set noreorder
         .set nomacro
-        move $7, $29
-        move $29, $6
 
-        sw $7, 0($29)
-        sw $31, -4($29)
+        addiu $29, $29, -8
+        sw $31, 4($29)
+        sw $30, 0($29)
 
-        addiu $29, $29, -24
+        .cfi_def_cfa_offset 8
+        .cfi_offset 31, -4
+        .cfi_offset 30, -8
+
+        move $30, $29
+        .cfi_def_cfa_register 30
+
+        move $29, $6
         move $25, $5
         jalr $25
         nop
-        addiu $29, $29, 24
+        move $29, $30
 
-        lw $31, -4($29)
-        lw $7, 0($29)
+        lw $30, 0($29)
+        lw $31, 4($29)
+        addiu $29, $29, 8
 
-        move $29, $7
         jr $31
         nop
 .end __morestack
+.cfi_endproc
diff --git a/src/rt/arch/mips/context.cpp b/src/rt/arch/mips/context.cpp
index d8c3c38daa6..7347a92e98b 100644
--- a/src/rt/arch/mips/context.cpp
+++ b/src/rt/arch/mips/context.cpp
@@ -40,6 +40,7 @@ void context::call(void *f, void *arg, void *stack)
 
   regs.data[4] = (uint32_t)arg;
   regs.data[29] = (uint32_t)sp;
+  regs.data[25] = (uint32_t)f;
   regs.data[31] = (uint32_t)f;
 
   // Last base pointer on the stack should be 0
diff --git a/src/rt/sync/rust_thread.cpp b/src/rt/sync/rust_thread.cpp
index 70fa08d7f2e..99613da9b0d 100644
--- a/src/rt/sync/rust_thread.cpp
+++ b/src/rt/sync/rust_thread.cpp
@@ -41,6 +41,9 @@ rust_thread::start() {
 #if defined(__WIN32__)
    thread = CreateThread(NULL, stack_sz, rust_thread_start, this, 0, NULL);
 #else
+   if (stack_sz < PTHREAD_STACK_MIN) {
+      stack_sz = PTHREAD_STACK_MIN;
+   }
    pthread_attr_t attr;
    CHECKED(pthread_attr_init(&attr));
    CHECKED(pthread_attr_setstacksize(&attr, stack_sz));