One exit_task_glue to rule them all.

This commit is contained in:
Rafael Ávila de Espíndola 2011-05-18 15:43:48 -04:00
parent 6a4a85f452
commit 96516e9ca2
8 changed files with 23 additions and 10 deletions

View File

@ -163,6 +163,7 @@ export CFG_LLVM_ROOT
LLVM_AS := $(CFG_LLVM_BINDIR)/llvm-as
LLC := $(CFG_LLVM_BINDIR)/llc
######################################################################
# Single-target rules

View File

@ -31,6 +31,8 @@ RUNTIME_CS := rt/sync/timer.cpp \
rt/test/rust_test_runtime.cpp \
rt/test/rust_test_util.cpp
RUNTIME_LL := rt/new_exit.ll
RUNTIME_HDR := rt/globals.h \
rt/rust.h \
rt/rust_dwarf.h \
@ -63,7 +65,7 @@ RUNTIME_HDR := rt/globals.h \
RUNTIME_DEF := rt/rustrt$(CFG_DEF_SUFFIX)
RUNTIME_INCS := -I $(S)src/rt/isaac -I $(S)src/rt/uthash
RUNTIME_OBJS := $(RUNTIME_CS:.cpp=.o)
RUNTIME_OBJS := $(RUNTIME_CS:.cpp=.o) $(RUNTIME_LL:.ll=.o)
RUNTIME_LIBS := $(CFG_GCCISH_POST_LIB_FLAGS)
@ -71,6 +73,9 @@ rt/%.o: rt/%.cpp $(MKFILES)
@$(call E, compile: $@)
$(Q)$(call CFG_COMPILE_C, $@, $(RUNTIME_INCS)) $<
rt/%.o: rt/%.ll $(MKFILES)
@$(call E, llc: $@)
$(Q)$(LLC) -filetype=obj -relocation-model=pic -march=x86 -o $@ $<
rt/$(CFG_RUNTIME): $(RUNTIME_OBJS) $(MKFILES) $(RUNTIME_HDR) $(RUNTIME_DEF)
@$(call E, link: $@)

11
src/rt/new_exit.ll Normal file
View File

@ -0,0 +1,11 @@
declare fastcc i32 @rust_native_rust_1(i32, i32)
declare i32 @upcall_exit(i32)
define void @rust_new_exit_task_glue(i32, i32, i32, i32, i32) {
entry:
%5 = inttoptr i32 %0 to void (i32, i32, i32, i32)*
tail call fastcc void %5(i32 %1, i32 %2, i32 %3, i32 %4)
%6 = tail call fastcc i32 @rust_native_rust_1(i32 ptrtoint (i32 (i32)* @upcall_exit to i32), i32 %2)
ret void
}

View File

@ -99,7 +99,7 @@ rust_start(uintptr_t main_fn, rust_crate const *crate, int argc,
}
uintptr_t main_args[4] = {0, 0, 0, (uintptr_t)args->args};
dom->root_task->start(crate->get_exit_task_glue(),
dom->root_task->start((uintptr_t)rust_new_exit_task_glue,
main_fn,
(uintptr_t)&main_args, sizeof(main_args));

View File

@ -16,11 +16,6 @@ rust_crate::get_activate_glue() const {
return (activate_glue_ty) ((uintptr_t)this + activate_glue_off);
}
uintptr_t
rust_crate::get_exit_task_glue() const {
return ((uintptr_t)this + exit_task_glue_off);
}
uintptr_t
rust_crate::get_unwind_glue() const {
return ((uintptr_t)this + unwind_glue_off);

View File

@ -263,7 +263,7 @@ rust_dom::start_main_loop() {
DLOG(this, dom, "started domain loop");
DLOG(this, dom, "activate glue: " PTR ", exit glue: " PTR,
root_crate->get_activate_glue(), root_crate->get_exit_task_glue());
root_crate->get_activate_glue(), rust_new_exit_task_glue);
while (number_of_live_tasks() > 0) {
A(this, kernel->is_deadlocked() == false, "deadlock");

View File

@ -251,7 +251,6 @@ public:
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
{
@ -358,6 +357,8 @@ public:
void flush();
};
extern "C" void rust_new_exit_task_glue();
#include "rust_dwarf.h"
class

View File

@ -53,7 +53,7 @@ rust_task_test::worker::run() {
rust_handle<rust_dom> *handle =
kernel->create_domain(crate, "test");
rust_dom *domain = handle->referent();
domain->root_task->start(crate->get_exit_task_glue(),
domain->root_task->start((uintptr_t)rust_new_exit_task_glue,
(uintptr_t)&task_entry, (uintptr_t)NULL, 0);
domain->start_main_loop();
kernel->destroy_domain(domain);