From 67d1f0a9aafaa7dcd63b86032127ab660e630c46 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 25 Jun 2010 15:43:55 -0700 Subject: [PATCH] Emit gc glue and rearrange crate glue offsets slightly to have a regular order. --- src/boot/be/abi.ml | 1 + src/boot/be/x86.ml | 1 + src/boot/llvm/llabi.ml | 5 +++-- src/boot/llvm/llfinal.ml | 5 +++-- src/boot/me/semant.ml | 4 ++++ src/boot/me/trans.ml | 9 +++++++-- src/rt/rust_internal.h | 11 +++++++---- 7 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/boot/be/abi.ml b/src/boot/be/abi.ml index 4d2a90cd32e..1a432086a65 100644 --- a/src/boot/be/abi.ml +++ b/src/boot/be/abi.ml @@ -145,6 +145,7 @@ type abi = abi_activate: (Il.emitter -> unit); abi_yield: (Il.emitter -> unit); abi_unwind: (Il.emitter -> Common.nabi -> Common.fixup -> unit); + abi_gc: (Il.emitter -> unit); abi_get_next_pc_thunk: ((Il.reg (* output *) * Common.fixup (* thunk in objfile *) diff --git a/src/boot/be/x86.ml b/src/boot/be/x86.ml index aa0ec2c767c..57382c882cb 100644 --- a/src/boot/be/x86.ml +++ b/src/boot/be/x86.ml @@ -1627,6 +1627,7 @@ let (abi:Abi.abi) = Abi.abi_activate = activate_glue; Abi.abi_yield = yield_glue; Abi.abi_unwind = unwind_glue; + Abi.abi_gc = gc_glue; Abi.abi_get_next_pc_thunk = Some get_next_pc_thunk; Abi.abi_sp_reg = (Il.Hreg esp); diff --git a/src/boot/llvm/llabi.ml b/src/boot/llvm/llabi.ml index fd5d92776a6..6a2c6a05f69 100644 --- a/src/boot/llvm/llabi.ml +++ b/src/boot/llvm/llabi.ml @@ -23,9 +23,10 @@ let declare_abi (llctx:Llvm.llcontext) (llmod:Llvm.llmodule) : abi = i32; (* ptrdiff_t debug_info_off *) i32; (* size_t debug_info_sz *) i32; (* size_t activate_glue_off *) - i32; (* size_t main_exit_task_glue_off *) - i32; (* size_t unwind_glue_off *) i32; (* size_t yield_glue_off *) + i32; (* size_t unwind_glue_off *) + i32; (* size_t gc_glue_off *) + i32; (* size_t main_exit_task_glue_off *) i32; (* int n_rust_syms *) i32; (* int n_c_syms *) i32 (* int n_libs *) diff --git a/src/boot/llvm/llfinal.ml b/src/boot/llvm/llfinal.ml index 64ea3d37a1e..fd65fa6b089 100644 --- a/src/boot/llvm/llfinal.ml +++ b/src/boot/llvm/llfinal.ml @@ -53,9 +53,10 @@ let finalize_module Llvm.const_int i32 0; (* ptrdiff_t debug_info_off *) Llvm.const_int i32 0; (* size_t debug_info_sz *) activate_glue_off; (* size_t activate_glue_off *) - exit_task_glue_off; (* size_t main_exit_task_glue_off *) - Llvm.const_int i32 0; (* size_t unwind_glue_off *) yield_glue_off; (* size_t yield_glue_off *) + Llvm.const_int i32 0; (* size_t unwind_glue_off *) + Llvm.const_int i32 0; (* size_t gc_glue_off *) + exit_task_glue_off; (* size_t main_exit_task_glue_off *) Llvm.const_int i32 rust_fn_count; (* int n_rust_syms *) Llvm.const_int i32 c_fn_count; (* int n_c_syms *) Llvm.const_int i32 0 (* int n_libs *) diff --git a/src/boot/me/semant.ml b/src/boot/me/semant.ml index b2ce7b793e0..41e6a55a630 100644 --- a/src/boot/me/semant.ml +++ b/src/boot/me/semant.ml @@ -30,6 +30,7 @@ type glue = | GLUE_write of Ast.ty | GLUE_read of Ast.ty | GLUE_unwind + | GLUE_gc | GLUE_get_next_pc | GLUE_mark_frame of node_id (* node is the frame *) | GLUE_drop_frame of node_id (* node is the frame *) @@ -135,6 +136,7 @@ type ctxt = ctxt_spill_fixups: (node_id,fixup) Hashtbl.t; ctxt_abi: Abi.abi; ctxt_activate_fixup: fixup; + ctxt_gc_fixup: fixup; ctxt_yield_fixup: fixup; ctxt_unwind_fixup: fixup; ctxt_exit_task_fixup: fixup; @@ -218,6 +220,7 @@ let new_ctxt sess abi crate = ctxt_activate_fixup = new_fixup "activate glue"; ctxt_yield_fixup = new_fixup "yield glue"; ctxt_unwind_fixup = new_fixup "unwind glue"; + ctxt_gc_fixup = new_fixup "gc glue"; ctxt_exit_task_fixup = new_fixup "exit-task glue"; ctxt_debug_aranges_fixup = new_fixup "debug_aranges section"; @@ -1989,6 +1992,7 @@ let glue_str (cx:ctxt) (g:glue) : string = | GLUE_write ty -> "glue$write$" ^ (ty_str ty) | GLUE_read ty -> "glue$read$" ^ (ty_str ty) | GLUE_unwind -> "glue$unwind" + | GLUE_gc -> "glue$gc" | GLUE_get_next_pc -> "glue$get_next_pc" | GLUE_mark_frame i -> "glue$mark_frame$" ^ (item_str cx i) | GLUE_drop_frame i -> "glue$drop_frame$" ^ (item_str cx i) diff --git a/src/boot/me/trans.ml b/src/boot/me/trans.ml index af9a849b140..a00f0b251f9 100644 --- a/src/boot/me/trans.ml +++ b/src/boot/me/trans.ml @@ -4891,9 +4891,10 @@ let trans_visitor Asm.WORD (word_ty_mach, Asm.M_SZ cx.ctxt_debug_info_fixup); crate_rel_word cx.ctxt_activate_fixup; - crate_rel_word cx.ctxt_exit_task_fixup; - crate_rel_word cx.ctxt_unwind_fixup; crate_rel_word cx.ctxt_yield_fixup; + crate_rel_word cx.ctxt_unwind_fixup; + crate_rel_word cx.ctxt_gc_fixup; + crate_rel_word cx.ctxt_exit_task_fixup; tab_sz cx.ctxt_required_rust_sym_num; tab_sz cx.ctxt_required_c_sym_num; @@ -4915,6 +4916,10 @@ let trans_visitor (fun e -> abi.Abi.abi_unwind e nabi_rust (upcall_fixup "upcall_exit")); + emit_aux_global_glue cx GLUE_gc + cx.ctxt_gc_fixup + abi.Abi.abi_gc; + ignore (get_exit_task_glue ()); begin diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h index c393b210a30..3c4fde2a24c 100644 --- a/src/rt/rust_internal.h +++ b/src/rt/rust_internal.h @@ -263,9 +263,10 @@ rust_crate size_t debug_info_sz; // Size of .debug_info. ptrdiff_t activate_glue_off; - ptrdiff_t exit_task_glue_off; - ptrdiff_t unwind_glue_off; ptrdiff_t yield_glue_off; + ptrdiff_t unwind_glue_off; + ptrdiff_t gc_glue_off; + ptrdiff_t exit_task_glue_off; public: @@ -278,9 +279,11 @@ public: uintptr_t get_image_base() const; ptrdiff_t get_relocation_diff() const; activate_glue_ty get_activate_glue() const; - uintptr_t get_exit_task_glue() const; - uintptr_t get_unwind_glue() const; uintptr_t get_yield_glue() const; + uintptr_t get_unwind_glue() const; + uintptr_t get_gc_glue() const; + uintptr_t get_exit_task_glue() const; + struct mem_area { rust_dom *dom;