about summary refs log tree commit diff
path: root/src/rt/arch
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-06-15 18:16:17 -0700
committerEric Holk <eholk@mozilla.com>2011-06-15 18:16:59 -0700
commit67360ae61808453d308496f90e0b3faa3e8efee3 (patch)
tree7df5f198272c57aeebf35e9a22aa03cd12f33e0b /src/rt/arch
parentc4f9bd94700188678893659580f3b7aa80da3b7d (diff)
Fixed a problem where spawn arguments were getting lost again. Also, fixed up stack alignment, which closes #496
Diffstat (limited to 'src/rt/arch')
-rw-r--r--src/rt/arch/i386/context.cpp6
-rw-r--r--src/rt/arch/i386/context.h8
2 files changed, 13 insertions, 1 deletions
diff --git a/src/rt/arch/i386/context.cpp b/src/rt/arch/i386/context.cpp
index 8f5dbacbcf4..c1c8ba2167b 100644
--- a/src/rt/arch/i386/context.cpp
+++ b/src/rt/arch/i386/context.cpp
@@ -36,10 +36,14 @@ void context::swap(context &out)
 void context::call(void *f, void *arg, void *stack) {
   // set up the trampoline frame
   uint32_t *sp = (uint32_t *)stack;
+
+  // Shift the stack pointer so the alignment works out right.
+  sp = align_down(sp) - 2;
+
   *--sp = (uint32_t)this;
   *--sp = (uint32_t)arg;
-  *--sp = 0xdeadbeef; //(uint32_t)ctx_trampoline1;
   *--sp = 0xdeadbeef;
+  *--sp = 0xca11ab1e;
 
   regs.esp = (uint32_t)sp;
   regs.eip = (uint32_t)f;
diff --git a/src/rt/arch/i386/context.h b/src/rt/arch/i386/context.h
index 0ddbee6988f..5329016450a 100644
--- a/src/rt/arch/i386/context.h
+++ b/src/rt/arch/i386/context.h
@@ -32,4 +32,12 @@ public:
   void call(void *f, void *arg, void *sp);
 };
 
+template<typename T>
+T align_down(T sp)
+{
+    // There is no platform we care about that needs more than a
+    // 16-byte alignment.
+    return (T)((int)sp & ~(16 - 1));
+}
+
 #endif