about summary refs log tree commit diff
path: root/src/boot
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2010-06-25 16:59:29 -0700
committerGraydon Hoare <graydon@mozilla.com>2010-06-25 16:59:29 -0700
commitd601b357ecbb1fa33dc10c177bb557868be07deb (patch)
tree067e93c9dbb44db651b6278feb01d22251ae43d7 /src/boot
parent2a2474d497ae19472b4366f6d8d62e9a516787c3 (diff)
downloadrust-d601b357ecbb1fa33dc10c177bb557868be07deb.tar.gz
rust-d601b357ecbb1fa33dc10c177bb557868be07deb.zip
Debug GC glue enough that marking passes.
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/be/x86.ml49
1 files changed, 33 insertions, 16 deletions
diff --git a/src/boot/be/x86.ml b/src/boot/be/x86.ml
index 16c5f7ea0d3..d90869f3127 100644
--- a/src/boot/be/x86.ml
+++ b/src/boot/be/x86.ml
@@ -758,11 +758,6 @@ let crawl_stack_calling_glue
   let skip_jmp_fix = new_fixup "skip jump" in
   let exit_jmp_fix = new_fixup "exit jump" in
 
-    mov (rc edx) (c task_ptr);          (* switch back to rust stack    *)
-    mov
-      (rc esp)
-      (c (edx_n Abi.task_field_rust_sp));
-
     push (ro ebp);                      (* save ebp at entry            *)
 
     mark repeat_jmp_fix;
@@ -810,10 +805,7 @@ let crawl_stack_calling_glue
 let gc_glue
     (e:Il.emitter)
     : unit =
-  (* Mark pass. *)
-  crawl_stack_calling_glue e Abi.frame_glue_fns_field_mark;
 
-  (* Sweep pass. *)
   let emit = Il.emit e in
   let mov dst src = emit (Il.umov dst src) in
   let push x = emit (Il.Push x) in
@@ -824,11 +816,26 @@ let gc_glue
   let ecx_n = word_n (Il.Hreg ecx) in
   let codefix fix = Il.CodePtr (Il.ImmPtr (fix, Il.CodeTy)) in
   let mark fix = Il.emit_full e (Some fix) [] Il.Dead in
-
   let repeat_jmp_fix = new_fixup "repeat jump" in
   let skip_jmp_fix = new_fixup "skip jump" in
   let exit_jmp_fix = new_fixup "exit jump" in
 
+    mov (rc edx) (c task_ptr);          (* switch back to rust stack    *)
+    mov
+      (rc esp)
+      (c (edx_n Abi.task_field_rust_sp));
+
+    (* Mark pass. *)
+    save_callee_saves e;
+    push (ro eax);
+    crawl_stack_calling_glue e Abi.frame_glue_fns_field_mark;
+
+    (* For now, stop after marking; sweep is still buggy. *)
+    pop (rc eax);
+    restore_callee_saves e;
+    Il.emit e Il.Ret;
+
+    (* Sweep pass. *)
     mov (rc edx) (c task_ptr);
     mov (rc edx) (c (edx_n Abi.task_field_gc_alloc_chain));
     mark repeat_jmp_fix;
@@ -896,13 +903,23 @@ let unwind_glue
     (nabi:nabi)
     (exit_task_fixup:fixup)
     : unit =
-  crawl_stack_calling_glue e Abi.frame_glue_fns_field_drop;
-  let callee =
-    Abi.load_fixup_codeptr
-      e (h eax) exit_task_fixup false nabi.nabi_indirect
-  in
-    emit_c_call
-      e (rc eax) (h edx) (h ecx) nabi false callee [| (c task_ptr) |];
+
+  let emit = Il.emit e in
+  let mov dst src = emit (Il.umov dst src) in
+  let edx_n = word_n (Il.Hreg edx) in
+
+    mov (rc edx) (c task_ptr);          (* switch back to rust stack    *)
+    mov
+      (rc esp)
+      (c (edx_n Abi.task_field_rust_sp));
+
+    crawl_stack_calling_glue e Abi.frame_glue_fns_field_drop;
+    let callee =
+      Abi.load_fixup_codeptr
+        e (h eax) exit_task_fixup false nabi.nabi_indirect
+    in
+      emit_c_call
+        e (rc eax) (h edx) (h ecx) nabi false callee [| (c task_ptr) |];
 ;;