Skip to content

Commit

Permalink
One exit_task_glue to rule them all.
Browse files Browse the repository at this point in the history
  • Loading branch information
cixtor committed May 18, 2011
1 parent 6a4a85f commit 96516e9
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export CFG_LLVM_ROOT

LLVM_AS := $(CFG_LLVM_BINDIR)/llvm-as

LLC := $(CFG_LLVM_BINDIR)/llc

######################################################################
# Single-target rules
Expand Down
7 changes: 6 additions & 1 deletion mk/rt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -63,14 +65,17 @@ 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)


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: $@)
Expand Down
11 changes: 11 additions & 0 deletions src/rt/new_exit.ll
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion src/rt/rust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
5 changes: 0 additions & 5 deletions src/rt/rust_crate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/rt/rust_dom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion src/rt/rust_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ class rust_crate {
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
{
Expand Down Expand Up @@ -358,6 +357,8 @@ rust_crate_cache : public dom_owned<rust_crate_cache>,
void flush();
};

extern "C" void rust_new_exit_task_glue();

#include "rust_dwarf.h"

class
Expand Down
2 changes: 1 addition & 1 deletion src/rt/test/rust_test_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 96516e9

Please sign in to comment.