From d601b357ecbb1fa33dc10c177bb557868be07deb Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 25 Jun 2010 16:59:29 -0700 Subject: [PATCH] Debug GC glue enough that marking passes. --- src/boot/be/x86.ml | 49 +++++++++++++++++++++++++++++++--------------- 1 file 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) |]; ;;