From e3419f9c45476f27e1c89edff5ab557039cdd384 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 22 Aug 2013 22:42:36 -0700 Subject: rt: Memory regions are never synchronized now --- src/libstd/rt/local_heap.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/libstd/rt') diff --git a/src/libstd/rt/local_heap.rs b/src/libstd/rt/local_heap.rs index bca1b4a70f4..aa8c5dd4674 100644 --- a/src/libstd/rt/local_heap.rs +++ b/src/libstd/rt/local_heap.rs @@ -40,12 +40,10 @@ impl LocalHeap { #[fixed_stack_segment] #[inline(never)] pub fn new() -> LocalHeap { unsafe { - // Don't need synchronization for the single-threaded local heap - let synchronized = false as uintptr_t; // XXX: These usually come from the environment let detailed_leaks = false as uintptr_t; let poison_on_free = false as uintptr_t; - let region = rust_new_memory_region(synchronized, detailed_leaks, poison_on_free); + let region = rust_new_memory_region(detailed_leaks, poison_on_free); assert!(region.is_not_null()); let boxed = rust_new_boxed_region(region, poison_on_free); assert!(boxed.is_not_null()); @@ -109,8 +107,7 @@ pub fn live_allocs() -> *raw::Box<()> { extern { #[fast_ffi] - fn rust_new_memory_region(synchronized: uintptr_t, - detailed_leaks: uintptr_t, + fn rust_new_memory_region(detailed_leaks: uintptr_t, poison_on_free: uintptr_t) -> *MemoryRegion; #[fast_ffi] fn rust_delete_memory_region(region: *MemoryRegion); -- cgit 1.4.1-3-g733a5 From 4541c6cfe3ee875020329f888c39ea75183b23d1 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 22 Aug 2013 22:55:11 -0700 Subject: rt: Remove exit_status helpers --- src/libstd/rt/util.rs | 21 +++++---------------- src/rt/rust_builtin.cpp | 15 --------------- src/rt/rustrt.def.in | 2 -- 3 files changed, 5 insertions(+), 33 deletions(-) (limited to 'src/libstd/rt') diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs index 1f29830aa04..f2ede8872c2 100644 --- a/src/libstd/rt/util.rs +++ b/src/libstd/rt/util.rs @@ -14,6 +14,7 @@ use libc; use option::{Some, None}; use os; use str::StrSlice; +use unstable::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst}; #[cfg(target_os="macos")] use unstable::running_on_valgrind; @@ -129,24 +130,12 @@ memory and partly incapable of presentation to others.", } } -pub fn set_exit_status(code: int) { - #[fixed_stack_segment]; #[inline(never)]; - unsafe { - return rust_set_exit_status_newrt(code as libc::uintptr_t); - } +static mut EXIT_STATUS: AtomicInt = INIT_ATOMIC_INT; - extern { - fn rust_set_exit_status_newrt(code: libc::uintptr_t); - } +pub fn set_exit_status(code: int) { + unsafe { EXIT_STATUS.store(code, SeqCst) } } pub fn get_exit_status() -> int { - #[fixed_stack_segment]; #[inline(never)]; - unsafe { - return rust_get_exit_status_newrt() as int; - } - - extern { - fn rust_get_exit_status_newrt() -> libc::uintptr_t; - } + unsafe { EXIT_STATUS.load(SeqCst) } } diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 784693755c5..3a2a8e89415 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -653,21 +653,6 @@ rust_get_global_args_ptr() { return &global_args_ptr; } -static lock_and_signal exit_status_lock; -static uintptr_t exit_status = 0; - -extern "C" CDECL void -rust_set_exit_status_newrt(uintptr_t code) { - scoped_lock with(exit_status_lock); - exit_status = code; -} - -extern "C" CDECL uintptr_t -rust_get_exit_status_newrt() { - scoped_lock with(exit_status_lock); - return exit_status; -} - static lock_and_signal change_dir_lock; extern "C" CDECL void diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 5100e732308..54b6dc2c602 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -191,8 +191,6 @@ rust_get_num_cpus rust_get_global_args_ptr rust_take_global_args_lock rust_drop_global_args_lock -rust_set_exit_status_newrt -rust_get_exit_status_newrt rust_take_change_dir_lock rust_drop_change_dir_lock rust_get_test_int -- cgit 1.4.1-3-g733a5 From b72c43739d37b9a495bdbd64852198ba1f7f0807 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 22 Aug 2013 23:23:51 -0700 Subject: rt: Remove old precise GC code --- mk/rt.mk | 1 - src/libstd/rt/mod.rs | 3 -- src/rt/rust_gc_metadata.cpp | 95 --------------------------------------------- src/rt/rust_gc_metadata.h | 26 ------------- src/rt/rustrt.def.in | 2 - 5 files changed, 127 deletions(-) delete mode 100644 src/rt/rust_gc_metadata.cpp delete mode 100644 src/rt/rust_gc_metadata.h (limited to 'src/libstd/rt') diff --git a/mk/rt.mk b/mk/rt.mk index e249c8cc657..915848e6abd 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -71,7 +71,6 @@ RUNTIME_CXXS_$(1)_$(2) := \ rt/rust_upcall.cpp \ rt/rust_uv.cpp \ rt/rust_crate_map.cpp \ - rt/rust_gc_metadata.cpp \ rt/rust_util.cpp \ rt/rust_log.cpp \ rt/isaac/randport.cpp \ diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 8b3e65b57ab..ead0fb63793 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -224,10 +224,7 @@ pub fn init(argc: int, argv: **u8, crate_map: *u8) { args::init(argc, argv); env::init(); logging::init(crate_map); - rust_update_gc_metadata(crate_map); } - - externfn!(fn rust_update_gc_metadata(crate_map: *u8)); } /// One-time runtime cleanup. diff --git a/src/rt/rust_gc_metadata.cpp b/src/rt/rust_gc_metadata.cpp deleted file mode 100644 index e37856255a7..00000000000 --- a/src/rt/rust_gc_metadata.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include "rust_gc_metadata.h" -#include "rust_crate_map.h" -#include "rust_globals.h" - -#include -#include - -struct safe_point { - uintptr_t safe_point_loc; - uintptr_t safe_point_meta; - uintptr_t function_meta; -}; - -struct update_gc_entry_args { - std::vector *safe_points; -}; - -static void -update_gc_entry(const mod_entry *entry, void *cookie) { - update_gc_entry_args *args = (update_gc_entry_args *)cookie; - if (!strcmp(entry->name, "_gc_module_metadata")) { - uintptr_t *next = (uintptr_t *)entry->state; - uint32_t num_safe_points = *(uint32_t *)next; - next++; - - for (uint32_t i = 0; i < num_safe_points; i++) { - safe_point sp = { next[0], next[1], next[2] }; - next += 3; - - args->safe_points->push_back(sp); - } - } -} - -static bool -cmp_safe_point(safe_point a, safe_point b) { - return a.safe_point_loc < b.safe_point_loc; -} - -uintptr_t *global_safe_points = 0; - -void -update_gc_metadata(const void* map) { - std::vector safe_points; - update_gc_entry_args args = { &safe_points }; - - // Extract list of safe points from each module. - iter_crate_map((const cratemap *)map, update_gc_entry, (void *)&args); - std::sort(safe_points.begin(), safe_points.end(), cmp_safe_point); - - // Serialize safe point list into format expected by runtime. - global_safe_points = - (uintptr_t *)malloc((safe_points.size()*3 + 1)*sizeof(uintptr_t)); - if (!global_safe_points) return; - - uintptr_t *next = global_safe_points; - *next = safe_points.size(); - next++; - for (uint32_t i = 0; i < safe_points.size(); i++) { - next[0] = safe_points[i].safe_point_loc; - next[1] = safe_points[i].safe_point_meta; - next[2] = safe_points[i].function_meta; - next += 3; - } -} - -extern "C" CDECL void * -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++ -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/rt/rust_gc_metadata.h b/src/rt/rust_gc_metadata.h deleted file mode 100644 index d8d98e75b93..00000000000 --- a/src/rt/rust_gc_metadata.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#ifndef RUST_GC_METADATA_H -#define RUST_GC_METADATA_H - -void update_gc_metadata(const void* map); - -// -// Local Variables: -// mode: C++ -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// - -#endif /* RUST_GC_METADATA_H */ diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index f6c15925598..6e95d96012b 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -130,8 +130,6 @@ rust_lock_little_lock rust_unlock_little_lock 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 -- cgit 1.4.1-3-g733a5