diff options
| author | Eric Holk <eholk@mozilla.com> | 2011-07-18 12:02:26 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-07-21 11:51:22 -0700 |
| commit | 3ae4dcd41e72d197e3882835253745f79588b04a (patch) | |
| tree | 38b0fa41afe156057c8913f779fda2e4ca0b08ac /src/rt/rust.cpp | |
| parent | a44fb04d57400f70ad58c1e35fc9dd9a7c43de07 (diff) | |
| download | rust-3ae4dcd41e72d197e3882835253745f79588b04a.tar.gz rust-3ae4dcd41e72d197e3882835253745f79588b04a.zip | |
Lots of work on memory tracking and channels.
We're trying to get closer to doing correct move semantics for channel operations. This involves a lot of cleanup (such as removing the unused sched parameter from rust_vec constructor) and making circular_buffer kernel_owned. Added tagging for memory allocations. This means we give a string tag to everything we allocate. If we leak something and TRACK_ALLOCATIONS is enabled, then it's much easier now to tell exactly what is leaking.
Diffstat (limited to 'src/rt/rust.cpp')
| -rw-r--r-- | src/rt/rust.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp index 76cef811e75..c487bee954c 100644 --- a/src/rt/rust.cpp +++ b/src/rt/rust.cpp @@ -24,12 +24,14 @@ command_line_args : public kernel_owned<command_line_args> LPCWSTR cmdline = GetCommandLineW(); LPWSTR *wargv = CommandLineToArgvW(cmdline, &argc); kernel->win32_require("CommandLineToArgvW", wargv != NULL); - argv = (char **) kernel->malloc(sizeof(char*) * argc); + argv = (char **) kernel->malloc(sizeof(char*) * argc, + "win32 command line"); for (int i = 0; i < argc; ++i) { int n_chars = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL); kernel->win32_require("WideCharToMultiByte(0)", n_chars != 0); - argv[i] = (char *) kernel->malloc(n_chars); + argv[i] = (char *) kernel->malloc(n_chars, + "win32 command line arg"); n_chars = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, argv[i], n_chars, NULL, NULL); kernel->win32_require("WideCharToMultiByte(1)", n_chars != 0); @@ -38,14 +40,14 @@ command_line_args : public kernel_owned<command_line_args> #endif size_t vec_fill = sizeof(rust_str *) * argc; size_t vec_alloc = next_power_of_two(sizeof(rust_vec) + vec_fill); - void *mem = kernel->malloc(vec_alloc); - args = new (mem) rust_vec(task->sched, vec_alloc, 0, NULL); + void *mem = kernel->malloc(vec_alloc, "command line"); + args = new (mem) rust_vec(vec_alloc, 0, NULL); rust_str **strs = (rust_str**) &args->data[0]; for (int i = 0; i < argc; ++i) { size_t str_fill = strlen(argv[i]) + 1; size_t str_alloc = next_power_of_two(sizeof(rust_str) + str_fill); - mem = kernel->malloc(str_alloc); - strs[i] = new (mem) rust_str(task->sched, str_alloc, str_fill, + mem = kernel->malloc(str_alloc, "command line arg"); + strs[i] = new (mem) rust_str(str_alloc, str_fill, (uint8_t const *)argv[i]); } args->fill = vec_fill; @@ -106,7 +108,8 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) { kernel->start(); rust_scheduler *sched = kernel->get_scheduler(); command_line_args *args - = new (kernel) command_line_args(sched->root_task, argc, argv); + = new (kernel, "main command line args") + command_line_args(sched->root_task, argc, argv); DLOG(sched, dom, "startup: %d args in 0x%" PRIxPTR, args->argc, (uintptr_t)args->args); |
