diff options
| author | Eric Reed <ereed@mozilla.com> | 2013-06-25 11:45:44 -0700 |
|---|---|---|
| committer | Eric Reed <ereed@mozilla.com> | 2013-06-25 11:45:44 -0700 |
| commit | 4870dce3ebfd0e988a2e45360c724ebe912c3ad5 (patch) | |
| tree | c676e677bf36924cbf177b0723b4ffe0fc435d40 /src/rt | |
| parent | 794923c99511398bc90400e380dd11770ec8e614 (diff) | |
| parent | e65d0cbabebc73f2c9733a7ed158576c9702e71e (diff) | |
| download | rust-4870dce3ebfd0e988a2e45360c724ebe912c3ad5.tar.gz rust-4870dce3ebfd0e988a2e45360c724ebe912c3ad5.zip | |
Merge remote-tracking branch 'upstream/io' into io
Conflicts: src/rt/rustrt.def.in
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/arch/i386/morestack.S | 2 | ||||
| -rw-r--r-- | src/rt/rust_builtin.cpp | 65 | ||||
| -rw-r--r-- | src/rt/rust_gc_metadata.cpp | 5 | ||||
| -rw-r--r-- | src/rt/rust_log.cpp | 12 | ||||
| -rw-r--r-- | src/rt/rust_task.cpp | 8 | ||||
| -rw-r--r-- | src/rt/rust_type.h | 8 | ||||
| -rw-r--r-- | src/rt/rust_util.h | 10 | ||||
| -rw-r--r-- | src/rt/rustrt.def.in | 8 |
8 files changed, 69 insertions, 49 deletions
diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S index 1b276820805..a95e183a1d1 100644 --- a/src/rt/arch/i386/morestack.S +++ b/src/rt/arch/i386/morestack.S @@ -207,12 +207,14 @@ MORESTACK: subl $12, %esp // Save the return value of the function we allocated space for + movl %edx, 4(%esp) movl %eax, (%esp) call UPCALL_DEL_STACK // And restore it movl (%esp), %eax + movl 4(%esp), %edx addl $12,%esp diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index fe4e75fb8d2..51e2849eb54 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -17,6 +17,7 @@ #include "sync/timer.h" #include "sync/rust_thread.h" #include "rust_abi.h" +#include "vg/valgrind.h" #include <time.h> @@ -67,11 +68,10 @@ rust_env_pairs() { } #endif -extern "C" CDECL void -vec_reserve_shared_actual(type_desc* ty, rust_vec_box** vp, - size_t n_elts) { +extern "C" CDECL void * +rust_local_realloc(rust_opaque_box *ptr, size_t size) { rust_task *task = rust_get_current_task(); - reserve_vec_exact_shared(task, vp, n_elts * ty->size); + return task->boxed.realloc(ptr, size); } // This is completely misnamed. @@ -590,12 +590,18 @@ rust_log_console_on() { log_console_on(); } -extern void log_console_off(rust_env *env); +extern void log_console_off(); extern "C" CDECL void rust_log_console_off() { - rust_task *task = rust_get_current_task(); - log_console_off(task->kernel->env); + log_console_off(); +} + +extern bool should_log_console(); + +extern "C" CDECL uintptr_t +rust_should_log_console() { + return (uintptr_t)should_log_console(); } extern "C" CDECL void @@ -731,17 +737,10 @@ rust_task_deref(rust_task *task) { // Must call on rust stack. extern "C" CDECL void rust_call_tydesc_glue(void *root, size_t *tydesc, size_t glue_index) { -#ifdef _RUST_STAGE0 - void (*glue_fn)(void *, void *, void *, void *) = - (void (*)(void *, void *, void *, void *))tydesc[glue_index]; - if (glue_fn) - glue_fn(0, 0, 0, root); -#else void (*glue_fn)(void *, void *, void *) = (void (*)(void *, void *, void *))tydesc[glue_index]; if (glue_fn) glue_fn(0, 0, root); -#endif } // Don't run on the Rust stack! @@ -761,11 +760,7 @@ public: virtual void run() { record_sp_limit(0); -#ifdef _RUST_STAGE0 - fn.f(NULL, fn.env, NULL); -#else fn.f(fn.env, NULL); -#endif } }; @@ -888,6 +883,12 @@ rust_delete_memory_region(memory_region *region) { } extern "C" CDECL boxed_region* +rust_current_boxed_region() { + rust_task *task = rust_get_current_task(); + return &task->boxed; +} + +extern "C" CDECL boxed_region* rust_new_boxed_region(memory_region *region, uintptr_t poison_on_free) { return new boxed_region(region, poison_on_free); @@ -903,6 +904,11 @@ rust_boxed_region_malloc(boxed_region *region, type_desc *td, size_t size) { return region->malloc(td, size); } +extern "C" CDECL rust_opaque_box* +rust_boxed_region_realloc(boxed_region *region, rust_opaque_box *ptr, size_t size) { + return region->realloc(ptr, size); +} + extern "C" CDECL void rust_boxed_region_free(boxed_region *region, rust_opaque_box *box) { region->free(box); @@ -930,6 +936,11 @@ rust_begin_unwind(uintptr_t token) { #endif } +extern "C" CDECL uintptr_t +rust_running_on_valgrind() { + return RUNNING_ON_VALGRIND; +} + extern int get_num_cpus(); extern "C" CDECL uintptr_t @@ -937,6 +948,24 @@ rust_get_num_cpus() { return get_num_cpus(); } +static lock_and_signal global_args_lock; +static uintptr_t global_args_ptr = 0; + +extern "C" CDECL void +rust_take_global_args_lock() { + global_args_lock.lock(); +} + +extern "C" CDECL void +rust_drop_global_args_lock() { + global_args_lock.unlock(); +} + +extern "C" CDECL uintptr_t* +rust_get_global_args_ptr() { + return &global_args_ptr; +} + // // Local Variables: // mode: C++ diff --git a/src/rt/rust_gc_metadata.cpp b/src/rt/rust_gc_metadata.cpp index fbf0575b31d..e37856255a7 100644 --- a/src/rt/rust_gc_metadata.cpp +++ b/src/rt/rust_gc_metadata.cpp @@ -79,6 +79,11 @@ rust_gc_metadata() { return (void *)global_safe_points; } +extern "C" CDECL void +rust_update_gc_metadata(const void* map) { + update_gc_metadata(map); +} + // // Local Variables: // mode: C++ diff --git a/src/rt/rust_log.cpp b/src/rt/rust_log.cpp index df24f569495..8179c53e96d 100644 --- a/src/rt/rust_log.cpp +++ b/src/rt/rust_log.cpp @@ -43,11 +43,15 @@ log_console_on() { * overridden by the environment. */ void -log_console_off(rust_env *env) { +log_console_off() { scoped_lock with(_log_lock); - if (env->logspec == NULL) { - _log_to_console = false; - } + _log_to_console = false; +} + +bool +should_log_console() { + scoped_lock with(_log_lock); + return _log_to_console; } rust_log::rust_log(rust_sched_loop *sched_loop) : diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index f9b588b7850..fe1b4622137 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -162,11 +162,7 @@ void task_start_wrapper(spawn_args *a) bool threw_exception = false; try { -#ifdef _RUST_STAGE0 - a->f(NULL, a->envptr, a->argptr); -#else a->f(a->envptr, a->argptr); -#endif } catch (rust_task *ex) { assert(ex == task && "Expected this task to be thrown for unwinding"); threw_exception = true; @@ -187,11 +183,7 @@ void task_start_wrapper(spawn_args *a) if(env) { // free the environment (which should be a unique closure). const type_desc *td = env->td; -#ifdef _RUST_STAGE0 - td->drop_glue(NULL, NULL, NULL, box_body(env)); -#else td->drop_glue(NULL, NULL, box_body(env)); -#endif task->kernel->region()->free(env); } diff --git a/src/rt/rust_type.h b/src/rt/rust_type.h index b50c08379de..6d36d2c960a 100644 --- a/src/rt/rust_type.h +++ b/src/rt/rust_type.h @@ -21,19 +21,11 @@ struct rust_opaque_box; // - the main function: has a NULL environment, but uses the void* arg // - unique closures of type fn~(): have a non-NULL environment, but // no arguments (and hence the final void*) is harmless -#ifdef _RUST_STAGE0 -typedef void (*CDECL spawn_fn)(void *, rust_opaque_box*, void *); -#else typedef void (*CDECL spawn_fn)(rust_opaque_box*, void *); -#endif struct type_desc; -#ifdef _RUST_STAGE0 -typedef void CDECL (glue_fn)(void *, void *, const type_desc **, void *); -#else typedef void CDECL (glue_fn)(void *, const type_desc **, void *); -#endif // Corresponds to the boxed data in the @ region. The body follows the // header; you can obtain a ptr via box_body() below. diff --git a/src/rt/rust_util.h b/src/rt/rust_util.h index 5b8378b0ad3..242c2ef0a81 100644 --- a/src/rt/rust_util.h +++ b/src/rt/rust_util.h @@ -57,16 +57,6 @@ vec_data(rust_vec *v) { return reinterpret_cast<T*>(v->data); } -inline void reserve_vec_exact_shared(rust_task* task, rust_vec_box** vpp, - size_t size) { - rust_opaque_box** ovpp = (rust_opaque_box**)vpp; - if (size > (*vpp)->body.alloc) { - *vpp = (rust_vec_box*)task->boxed.realloc( - *ovpp, size + sizeof(rust_vec)); - (*vpp)->body.alloc = size; - } -} - inline void reserve_vec_exact(rust_vec_box** vpp, size_t size) { if (size > (*vpp)->body.alloc) { diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 4d7fa589f6f..b604f60cba6 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -37,6 +37,7 @@ rust_list_dir_wfd_size rust_list_dir_wfd_fp_buf rust_log_console_on rust_log_console_off +rust_should_log_console rust_set_environ rust_unset_sigprocmask rust_sched_current_nonlazy_threads @@ -52,7 +53,7 @@ rust_get_stack_segment rust_get_c_stack rust_log_str start_task -vec_reserve_shared_actual +rust_local_realloc vec_reserve_shared task_clear_event_reject task_wait_event @@ -186,6 +187,7 @@ rust_call_tydesc_glue tdefl_compress_mem_to_heap tinfl_decompress_mem_to_heap rust_gc_metadata +rust_update_gc_metadata rust_uv_ip4_port rust_uv_ip6_port rust_uv_tcp_getpeername @@ -237,6 +239,7 @@ rust_delete_memory_region rust_new_boxed_region rust_delete_boxed_region rust_boxed_region_malloc +rust_boxed_region_realloc rust_boxed_region_free rust_try rust_begin_unwind @@ -247,4 +250,7 @@ rust_valgrind_stack_deregister rust_take_env_lock rust_drop_env_lock rust_update_log_settings +rust_running_on_valgrind rust_get_num_cpus +rust_get_global_args_ptr +rust_current_boxed_region |
