about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-08-09 23:35:51 -0700
committerBrian Anderson <banderson@mozilla.com>2013-08-16 13:24:25 -0700
commitda7d79dfbe46bf017e654598e481c6cc3a818af8 (patch)
tree87061a03757790b4b5443abbd013bcf86f2f01d7
parent8861ba6159fb93839c9c7d778aa26f0316f6b717 (diff)
downloadrust-da7d79dfbe46bf017e654598e481c6cc3a818af8.tar.gz
rust-da7d79dfbe46bf017e654598e481c6cc3a818af8.zip
rt: Remove rust_stack
-rw-r--r--mk/rt.mk1
-rw-r--r--src/rt/rust_builtin.cpp10
-rw-r--r--src/rt/rust_stack.cpp105
-rw-r--r--src/rt/rust_stack.h54
4 files changed, 10 insertions, 160 deletions
diff --git a/mk/rt.mk b/mk/rt.mk
index 6caa67e1a25..e6969a79f5a 100644
--- a/mk/rt.mk
+++ b/mk/rt.mk
@@ -69,7 +69,6 @@ RUNTIME_CXXS_$(1)_$(2) := \
               rt/rust_builtin.cpp \
               rt/rust_run_program.cpp \
               rt/rust_rng.cpp \
-              rt/rust_stack.cpp \
               rt/rust_upcall.cpp \
               rt/rust_uv.cpp \
               rt/rust_crate_map.cpp \
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 080dae7d7af..c95a4737d17 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -681,6 +681,16 @@ rust_drop_env_lock() {
     env_lock.unlock();
 }
 
+extern "C" CDECL unsigned int
+rust_valgrind_stack_register(void *start, void *end) {
+  return VALGRIND_STACK_REGISTER(start, end);
+}
+
+extern "C" CDECL void
+rust_valgrind_stack_deregister(unsigned int id) {
+  VALGRIND_STACK_DEREGISTER(id);
+}
+
 //
 // Local Variables:
 // mode: C++
diff --git a/src/rt/rust_stack.cpp b/src/rt/rust_stack.cpp
deleted file mode 100644
index a609ac57324..00000000000
--- a/src/rt/rust_stack.cpp
+++ /dev/null
@@ -1,105 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-
-#include "rust_stack.h"
-#include "vg/valgrind.h"
-#include "vg/memcheck.h"
-
-#include <cstdio>
-
-#ifdef _LP64
-const uintptr_t canary_value = 0xABCDABCDABCDABCD;
-#else
-const uintptr_t canary_value = 0xABCDABCD;
-#endif
-
-void
-register_valgrind_stack(stk_seg *stk) {
-    stk->valgrind_id =
-        VALGRIND_STACK_REGISTER(&stk->data[0],
-                                stk->end);
-}
-
-void
-reuse_valgrind_stack(stk_seg *stk, uint8_t *sp) {
-    // Establish that the stack is accessible.  This must be done when reusing
-    // old stack segments, since the act of popping the stack previously
-    // caused valgrind to consider the whole thing inaccessible.
-    assert(sp >= stk->data && sp <= (uint8_t*) stk->end
-           && "Stack pointer must be inside stack segment");
-    size_t sz = stk->end - (uintptr_t)sp;
-    (void) VALGRIND_MAKE_MEM_UNDEFINED(sp, sz);
-    (void) sz;
-}
-
-void
-deregister_valgrind_stack(stk_seg *stk) {
-    VALGRIND_STACK_DEREGISTER(stk->valgrind_id);
-}
-
-void
-add_stack_canary(stk_seg *stk) {
-    stk->canary = canary_value;
-}
-
-void
-check_stack_canary(stk_seg *stk) {
-    assert(stk->canary == canary_value && "Somebody killed the canary");
-}
-
-// XXX: Duplication here between the local and exchange heap constructors
-
-stk_seg *
-create_stack(memory_region *region, size_t sz) {
-    size_t total_sz = sizeof(stk_seg) + sz;
-    stk_seg *stk = (stk_seg *)region->malloc(total_sz, "stack");
-    memset(stk, 0, sizeof(stk_seg));
-    stk->end = (uintptr_t) &stk->data[sz];
-    stk->is_big = 0;
-    add_stack_canary(stk);
-    register_valgrind_stack(stk);
-    return stk;
-}
-
-void
-destroy_stack(memory_region *region, stk_seg *stk) {
-    deregister_valgrind_stack(stk);
-    region->free(stk);
-}
-
-stk_seg *
-create_exchange_stack(rust_exchange_alloc *exchange, size_t sz) {
-    size_t total_sz = sizeof(stk_seg) + sz;
-    stk_seg *stk = (stk_seg *)exchange->malloc(total_sz);
-    memset(stk, 0, sizeof(stk_seg));
-    stk->end = (uintptr_t) &stk->data[sz];
-    stk->is_big = 0;
-    add_stack_canary(stk);
-    register_valgrind_stack(stk);
-    return stk;
-}
-
-void
-destroy_exchange_stack(rust_exchange_alloc *exchange, stk_seg *stk) {
-    deregister_valgrind_stack(stk);
-    exchange->free(stk);
-}
-
-
-extern "C" CDECL unsigned int
-rust_valgrind_stack_register(void *start, void *end) {
-  return VALGRIND_STACK_REGISTER(start, end);
-}
-
-extern "C" CDECL void
-rust_valgrind_stack_deregister(unsigned int id) {
-  VALGRIND_STACK_DEREGISTER(id);
-}
diff --git a/src/rt/rust_stack.h b/src/rt/rust_stack.h
deleted file mode 100644
index 3b34b91e309..00000000000
--- a/src/rt/rust_stack.h
+++ /dev/null
@@ -1,54 +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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#ifndef RUST_STACK_H
-#define RUST_STACK_H
-
-#include "rust_globals.h"
-#include "rust_exchange_alloc.h"
-#include "memory_region.h"
-
-struct rust_task;
-
-struct stk_seg {
-    stk_seg *prev;
-    stk_seg *next;
-    uintptr_t end;
-    unsigned int valgrind_id;
-    uint8_t is_big;
-
-    rust_task *task;
-    uintptr_t canary;
-
-    uint8_t data[];
-};
-
-stk_seg *
-create_stack(memory_region *region, size_t sz);
-
-void
-destroy_stack(memory_region *region, stk_seg *stk);
-
-stk_seg *
-create_exchange_stack(rust_exchange_alloc *exchange, size_t sz);
-
-void
-destroy_exchange_stack(rust_exchange_alloc *exchange, stk_seg *stk);
-
-// Must be called before each time a stack is reused to tell valgrind
-// that the stack is accessible.
-void
-reuse_valgrind_stack(stk_seg *stk, uint8_t *sp);
-
-// Run a sanity check
-void
-check_stack_canary(stk_seg *stk);
-
-#endif /* RUST_STACK_H */