Skip to content

Commit

Permalink
Step 2 of cdecl task transition.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Holk committed Jun 15, 2011
1 parent 6a3f4ab commit 92bd350
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/rt/main.ll.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@_rust_crate_map_toplevel = external global %0

declare fastcc void @_rust_main(i1* nocapture, %task*, %2* nocapture, %5*);
declare i32 @rust_start(i32, i32, i32, i32, i32)
declare i32 @rust_start(i32, i32, i32, i32)

%tydesc = type { %tydesc**, i32, i32, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*, i8*, i8)* }

Expand All @@ -23,7 +23,6 @@ define void @_rust_main_wrap(i1* nocapture, %task *, %2* nocapture, %5 *)
}

define i32 @"MAIN"(i32, i32) {
; %3 = tail call i32 @rust_start(i32 ptrtoint (void (i1*, %task*, %2*, %5*)* @_rust_main_wrap to i32), i32 %0, i32 %1, i32 ptrtoint (%0* @_rust_crate_map_toplevel to i32))
%3 = tail call i32 @rust_start(i32 0, i32 %0, i32 %1, i32 ptrtoint (%0* @_rust_crate_map_toplevel to i32), i32 ptrtoint (void (i1*, %task*, %2*, %5*)* @_rust_main_wrap to i32))
%3 = tail call i32 @rust_start(i32 ptrtoint (void (i1*, %task*, %2*, %5*)* @_rust_main_wrap to i32), i32 %0, i32 %1, i32 ptrtoint (%0* @_rust_crate_map_toplevel to i32))
ret i32 %3
}
16 changes: 3 additions & 13 deletions src/rt/rust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@ command_line_args : public dom_owned<command_line_args>
}
};

// THIS IS AN UGLY HACK TO MAKE rust_start STILL WORK WITH STAGE0 WHILE WE
// TRANSITION TO ALL-CDECL TASK STARTUP FUNCTIONS.
void FASTCALL
(*real_main)(uintptr_t a, uintptr_t b, uintptr_t c, uintptr_t d) = NULL;

void CDECL fake_main(uintptr_t a, uintptr_t b, uintptr_t c, uintptr_t d)
{
real_main(a, b, c, d);
}

/**
* Main entry point into the Rust runtime. Here we create a Rust service,
* initialize the kernel, create the root domain and run it.
Expand All @@ -104,9 +94,9 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map,
DLOG(dom, dom, "startup: arg[%d] = '%s'", i, args->argv[i]);
}

real_main = (typeof(real_main))main_fn;
if(main_fn) { printf("using fastcall main\n"); }
dom->root_task->start(main_fn ? (uintptr_t)fake_main : main_fn_cdecl,
if(main_fn) { printf("using new cdecl main\n"); }
else { printf("using old cdecl main\n"); }
dom->root_task->start(main_fn ? main_fn : main_fn_cdecl,
(uintptr_t)args->args, sizeof(args->args));

int ret = dom->start_main_loop();
Expand Down

0 comments on commit 92bd350

Please sign in to comment.