about summary refs log tree commit diff
path: root/src/rt/rust.cpp
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-06-27 19:15:03 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-06-28 16:12:33 -0700
commit49a8cb34d2b6e3f7af4a7cbe842fe48ffa0245eb (patch)
treefb74a37b34ec7334f273e1bc59c18d2daf439583 /src/rt/rust.cpp
parentf6f945fed5c8d1061d80b444331910df29afa392 (diff)
downloadrust-49a8cb34d2b6e3f7af4a7cbe842fe48ffa0245eb.tar.gz
rust-49a8cb34d2b6e3f7af4a7cbe842fe48ffa0245eb.zip
Removed dom_owned, splitting things between task_owned and kernel_owned. Had to re-xfail a few tests brson recently un-xfailed.
Diffstat (limited to 'src/rt/rust.cpp')
-rw-r--r--src/rt/rust.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp
index 2a491b61150..293d8562e4b 100644
--- a/src/rt/rust.cpp
+++ b/src/rt/rust.cpp
@@ -1,19 +1,21 @@
 #include "rust_internal.h"
 
 struct
-command_line_args : public dom_owned<command_line_args>
+command_line_args : public kernel_owned<command_line_args>
 {
-    rust_dom *dom;
+    rust_kernel *kernel;
+    rust_task *task;
     int argc;
     char **argv;
 
     // vec[str] passed to rust_task::start.
     rust_vec *args;
 
-    command_line_args(rust_dom *dom,
+    command_line_args(rust_task *task,
                       int sys_argc,
                       char **sys_argv)
-        : dom(dom),
+        : kernel(task->kernel),
+          task(task),
           argc(sys_argc),
           argv(sys_argv),
           args(NULL)
@@ -21,7 +23,7 @@ command_line_args : public dom_owned<command_line_args>
 #if defined(__WIN32__)
         LPCWSTR cmdline = GetCommandLineW();
         LPWSTR *wargv = CommandLineToArgvW(cmdline, &argc);
-        dom->win32_require("CommandLineToArgvW", wargv != NULL);
+        task->dom->win32_require("CommandLineToArgvW", wargv != NULL);
         argv = (char **) dom->malloc(sizeof(char*) * argc);
         for (int i = 0; i < argc; ++i) {
             int n_chars = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1,
@@ -36,14 +38,14 @@ command_line_args : public dom_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 = dom->malloc(vec_alloc);
-        args = new (mem) rust_vec(dom, vec_alloc, 0, NULL);
+        void *mem = kernel->malloc(vec_alloc);
+        args = new (mem) rust_vec(task->dom, 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 = dom->malloc(str_alloc);
-            strs[i] = new (mem) rust_str(dom, str_alloc, str_fill,
+            mem = kernel->malloc(str_alloc);
+            strs[i] = new (mem) rust_str(task->dom, str_alloc, str_fill,
                                          (uint8_t const *)argv[i]);
         }
         args->fill = vec_fill;
@@ -58,15 +60,15 @@ command_line_args : public dom_owned<command_line_args>
             // Drop the args we've had pinned here.
             rust_str **strs = (rust_str**) &args->data[0];
             for (int i = 0; i < argc; ++i)
-                dom->free(strs[i]);
-            dom->free(args);
+                kernel->free(strs[i]);
+            kernel->free(args);
         }
 
 #ifdef __WIN32__
         for (int i = 0; i < argc; ++i) {
-            dom->free(argv[i]);
+            task->free(argv[i]);
         }
-        dom->free(argv);
+        task->free(argv);
 #endif
     }
 };
@@ -97,7 +99,8 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
     rust_kernel *kernel = new rust_kernel(srv);
     kernel->start();
     rust_dom *dom = kernel->get_domain();
-    command_line_args *args = new (dom) command_line_args(dom, argc, argv);
+    command_line_args *args 
+        = new (kernel) command_line_args(dom->root_task, argc, argv);
 
     DLOG(dom, dom, "startup: %d args in 0x%" PRIxPTR,
              args->argc, (uintptr_t)args->args);