More delicious dead code removal from runtime, upcalls.
This commit is contained in:
parent
4f792f2dbb
commit
79c9e13073
3
mk/rt.mk
3
mk/rt.mk
@ -8,9 +8,7 @@ RUNTIME_CS := rt/sync/timer.cpp \
|
||||
rt/rust.cpp \
|
||||
rt/rust_builtin.cpp \
|
||||
rt/rust_run_program.cpp \
|
||||
rt/rust_crate.cpp \
|
||||
rt/rust_crate_cache.cpp \
|
||||
rt/rust_crate_reader.cpp \
|
||||
rt/rust_comm.cpp \
|
||||
rt/rust_dom.cpp \
|
||||
rt/rust_task.cpp \
|
||||
@ -37,7 +35,6 @@ RUNTIME_S := rt/activate_glue.s rt/yield_glue.s
|
||||
|
||||
RUNTIME_HDR := rt/globals.h \
|
||||
rt/rust.h \
|
||||
rt/rust_dwarf.h \
|
||||
rt/rust_internal.h \
|
||||
rt/rust_util.h \
|
||||
rt/rust_chan.h \
|
||||
|
@ -6,13 +6,13 @@ import trans::ModuleRef;
|
||||
import trans::TypeRef;
|
||||
import trans::ValueRef;
|
||||
|
||||
import trans::T_crate;
|
||||
import trans::T_f32;
|
||||
import trans::T_f64;
|
||||
import trans::T_fn;
|
||||
import trans::T_i8;
|
||||
import trans::T_i32;
|
||||
import trans::T_int;
|
||||
import trans::T_nil;
|
||||
import trans::T_opaque_chan_ptr;
|
||||
import trans::T_opaque_port_ptr;
|
||||
import trans::T_opaque_vec_ptr;
|
||||
@ -51,8 +51,6 @@ type upcalls = rec(
|
||||
ValueRef new_str,
|
||||
ValueRef new_vec,
|
||||
ValueRef vec_grow,
|
||||
ValueRef require_rust_sym,
|
||||
ValueRef require_c_sym,
|
||||
ValueRef get_type_desc,
|
||||
ValueRef new_task,
|
||||
ValueRef start_task,
|
||||
@ -109,18 +107,9 @@ fn declare_upcalls(type_names tn, ModuleRef llmod) -> @upcalls {
|
||||
vec_grow=d("vec_grow", [T_opaque_vec_ptr(), T_size_t(),
|
||||
T_ptr(T_int()), T_ptr(T_tydesc(tn))],
|
||||
T_opaque_vec_ptr()),
|
||||
require_rust_sym=d("require_rust_sym",
|
||||
[T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
|
||||
T_size_t(), T_ptr(T_i8()),
|
||||
T_ptr(T_ptr(T_i8()))],
|
||||
T_int()),
|
||||
require_c_sym=d("require_c_sym",
|
||||
[T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
|
||||
T_ptr(T_i8()), T_ptr(T_i8())],
|
||||
T_int()),
|
||||
get_type_desc=d("get_type_desc",
|
||||
[T_ptr(T_crate(tn)), T_size_t(), T_size_t(),
|
||||
T_size_t(), T_ptr(T_ptr(T_tydesc(tn)))],
|
||||
[T_ptr(T_nil()), T_size_t(), T_size_t(),
|
||||
T_size_t(), T_ptr(T_ptr(T_tydesc(tn)))],
|
||||
T_ptr(T_tydesc(tn))),
|
||||
new_task=d("new_task", [T_ptr(T_str())], T_taskptr(tn)),
|
||||
start_task=d("start_task", [T_taskptr(tn),
|
||||
|
@ -95,7 +95,6 @@ state type crate_ctxt = rec(session::session sess,
|
||||
ModuleRef llmod,
|
||||
target_data td,
|
||||
type_names tn,
|
||||
ValueRef crate_ptr,
|
||||
hashmap[str, ValueRef] externs,
|
||||
hashmap[str, ValueRef] intrinsics,
|
||||
hashmap[ast::def_id, ValueRef] item_ids,
|
||||
@ -482,31 +481,6 @@ fn T_chan(TypeRef t) -> TypeRef {
|
||||
ret T_struct([T_int()]); // Refcount
|
||||
}
|
||||
|
||||
fn T_crate(&type_names tn) -> TypeRef {
|
||||
auto s = "crate";
|
||||
if (tn.name_has_type(s)) {
|
||||
ret tn.get_type(s);
|
||||
}
|
||||
|
||||
auto t = T_struct([T_int(), // ptrdiff_t image_base_off
|
||||
T_int(), // uintptr_t self_addr
|
||||
T_int(), // ptrdiff_t debug_abbrev_off
|
||||
T_int(), // size_t debug_abbrev_sz
|
||||
T_int(), // ptrdiff_t debug_info_off
|
||||
T_int(), // size_t debug_info_sz
|
||||
T_int(), // size_t activate_glue
|
||||
T_int(), // size_t yield_glue
|
||||
T_int(), // size_t unwind_glue
|
||||
T_int(), // size_t pad
|
||||
T_int(), // size_t pad
|
||||
T_int(), // int n_rust_syms
|
||||
T_int(), // int n_c_syms
|
||||
T_int() // int n_libs
|
||||
]);
|
||||
tn.associate(s, t);
|
||||
ret t;
|
||||
}
|
||||
|
||||
fn T_taskptr(&type_names tn) -> TypeRef {
|
||||
ret T_ptr(T_task(tn));
|
||||
}
|
||||
@ -1670,11 +1644,11 @@ fn get_derived_tydesc(&@block_ctxt cx, &ty::t t, bool escapes,
|
||||
T_ptr(T_ptr(T_tydesc(bcx.fcx.lcx.ccx.tn))));
|
||||
auto td_val = bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.get_type_desc,
|
||||
[bcx.fcx.lltaskptr,
|
||||
bcx.fcx.lcx.ccx.crate_ptr,
|
||||
sz.val,
|
||||
align.val,
|
||||
C_int((1u + n_params) as int),
|
||||
lltydescsptr]);
|
||||
C_null(T_ptr(T_nil())),
|
||||
sz.val,
|
||||
align.val,
|
||||
C_int((1u + n_params) as int),
|
||||
lltydescsptr]);
|
||||
v = td_val;
|
||||
} else {
|
||||
auto llparamtydescs = alloca(bcx,
|
||||
@ -7615,35 +7589,10 @@ fn i2p(ValueRef v, TypeRef t) -> ValueRef {
|
||||
}
|
||||
|
||||
fn create_typedefs(&@crate_ctxt cx) {
|
||||
llvm::LLVMAddTypeName(cx.llmod, str::buf("crate"), T_crate(cx.tn));
|
||||
llvm::LLVMAddTypeName(cx.llmod, str::buf("task"), T_task(cx.tn));
|
||||
llvm::LLVMAddTypeName(cx.llmod, str::buf("tydesc"), T_tydesc(cx.tn));
|
||||
}
|
||||
|
||||
fn create_crate_constant(ValueRef crate_ptr, @glue_fns glues) {
|
||||
|
||||
let ValueRef crate_addr = p2i(crate_ptr);
|
||||
|
||||
let ValueRef crate_val =
|
||||
C_struct([C_null(T_int()), // ptrdiff_t image_base_off
|
||||
p2i(crate_ptr), // uintptr_t self_addr
|
||||
C_null(T_int()), // ptrdiff_t debug_abbrev_off
|
||||
C_null(T_int()), // size_t debug_abbrev_sz
|
||||
C_null(T_int()), // ptrdiff_t debug_info_off
|
||||
C_null(T_int()), // size_t debug_info_sz
|
||||
C_null(T_int()), // size_t pad
|
||||
C_null(T_int()), // size_t pad2
|
||||
C_null(T_int()), // size_t pad3
|
||||
C_null(T_int()), // size_t pad4
|
||||
C_null(T_int()), // size_t pad5
|
||||
C_null(T_int()), // int n_rust_syms
|
||||
C_null(T_int()), // int n_c_syms
|
||||
C_null(T_int()) // int n_libs
|
||||
]);
|
||||
|
||||
llvm::LLVMSetInitializer(crate_ptr, crate_val);
|
||||
}
|
||||
|
||||
fn find_main_fn(&@crate_ctxt cx) -> ValueRef {
|
||||
auto e = sep() + "main";
|
||||
let ValueRef v = C_nil();
|
||||
@ -7668,7 +7617,7 @@ fn find_main_fn(&@crate_ctxt cx) -> ValueRef {
|
||||
fail;
|
||||
}
|
||||
|
||||
fn trans_main_fn(@local_ctxt cx, ValueRef llcrate, ValueRef crate_map) {
|
||||
fn trans_main_fn(@local_ctxt cx, ValueRef crate_map) {
|
||||
auto T_main_args = [T_int(), T_int()];
|
||||
auto T_rust_start_args = [T_int(), T_int(), T_int(), T_int()];
|
||||
|
||||
@ -7693,7 +7642,7 @@ fn trans_main_fn(@local_ctxt cx, ValueRef llcrate, ValueRef crate_map) {
|
||||
// Emit the moral equivalent of:
|
||||
//
|
||||
// main(int argc, char **argv) {
|
||||
// rust_start(&_rust.main, &crate, argc, argv);
|
||||
// rust_start(&_rust.main, argc, argv);
|
||||
// }
|
||||
//
|
||||
|
||||
@ -8002,15 +7951,12 @@ fn make_common_glue(&session::session sess, &str output) {
|
||||
llvm::LLVMSetTarget(llmod, str::buf(x86::get_target_triple()));
|
||||
auto td = mk_target_data(x86::get_data_layout());
|
||||
auto tn = mk_type_names();
|
||||
let ValueRef crate_ptr =
|
||||
llvm::LLVMAddGlobal(llmod, T_crate(tn), str::buf("rust_crate"));
|
||||
|
||||
auto intrinsics = declare_intrinsics(llmod);
|
||||
|
||||
llvm::LLVMSetModuleInlineAsm(llmod, str::buf(x86::get_module_asm()));
|
||||
|
||||
auto glues = make_glues(llmod, tn);
|
||||
create_crate_constant(crate_ptr, glues);
|
||||
|
||||
link::write::run_passes(sess, llmod, output);
|
||||
}
|
||||
@ -8076,8 +8022,6 @@ fn trans_crate(&session::session sess, &@ast::crate crate,
|
||||
llvm::LLVMSetTarget(llmod, str::buf(x86::get_target_triple()));
|
||||
auto td = mk_target_data(x86::get_data_layout());
|
||||
auto tn = mk_type_names();
|
||||
let ValueRef crate_ptr =
|
||||
llvm::LLVMAddGlobal(llmod, T_crate(tn), str::buf("rust_crate"));
|
||||
|
||||
auto intrinsics = declare_intrinsics(llmod);
|
||||
|
||||
@ -8095,7 +8039,6 @@ fn trans_crate(&session::session sess, &@ast::crate crate,
|
||||
llmod = llmod,
|
||||
td = td,
|
||||
tn = tn,
|
||||
crate_ptr = crate_ptr,
|
||||
externs = new_str_hash[ValueRef](),
|
||||
intrinsics = intrinsics,
|
||||
item_ids = new_def_hash[ValueRef](),
|
||||
@ -8135,7 +8078,7 @@ fn trans_crate(&session::session sess, &@ast::crate crate,
|
||||
trans_vec_append_glue(cx, crate.span);
|
||||
auto crate_map = create_crate_map(ccx);
|
||||
if (!sess.get_opts().shared) {
|
||||
trans_main_fn(cx, crate_ptr, crate_map);
|
||||
trans_main_fn(cx, crate_map);
|
||||
}
|
||||
|
||||
emit_tydescs(ccx);
|
||||
|
@ -93,10 +93,6 @@ new_rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
||||
DLOG(dom, dom, "startup: arg[%d] = '%s'", i, args->argv[i]);
|
||||
}
|
||||
|
||||
if (log_rt_dwarf) {
|
||||
rust_crate_reader create_reader(dom);
|
||||
}
|
||||
|
||||
uintptr_t main_args[4] = {0, 0, 0, (uintptr_t)args->args};
|
||||
dom->root_task->start(main_fn,
|
||||
(uintptr_t)&main_args, sizeof(main_args));
|
||||
@ -118,8 +114,7 @@ new_rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
||||
}
|
||||
|
||||
extern "C" CDECL int
|
||||
rust_start(uintptr_t main_fn, rust_crate const *crate, int argc,
|
||||
char **argv, void* crate_map) {
|
||||
rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
||||
return new_rust_start(main_fn, argc, argv, crate_map);
|
||||
}
|
||||
|
||||
|
@ -1,51 +0,0 @@
|
||||
|
||||
#include "rust_internal.h"
|
||||
|
||||
uintptr_t
|
||||
rust_crate::get_image_base() const {
|
||||
return ((uintptr_t)this + image_base_off);
|
||||
}
|
||||
|
||||
ptrdiff_t
|
||||
rust_crate::get_relocation_diff() const {
|
||||
return ((uintptr_t)this - self_addr);
|
||||
}
|
||||
|
||||
rust_crate::mem_area::mem_area(rust_dom *dom, uintptr_t pos, size_t sz)
|
||||
: dom(dom),
|
||||
base(pos),
|
||||
lim(pos + sz)
|
||||
{
|
||||
DLOG(dom, mem, "new mem_area [0x%" PRIxPTR ",0x%" PRIxPTR "]",
|
||||
base, lim);
|
||||
}
|
||||
|
||||
rust_crate::mem_area
|
||||
rust_crate::get_debug_info(rust_dom *dom) const {
|
||||
if (debug_info_off)
|
||||
return mem_area(dom,
|
||||
((uintptr_t)this + debug_info_off),
|
||||
debug_info_sz);
|
||||
else
|
||||
return mem_area(dom, 0, 0);
|
||||
}
|
||||
|
||||
rust_crate::mem_area
|
||||
rust_crate::get_debug_abbrev(rust_dom *dom) const {
|
||||
if (debug_abbrev_off)
|
||||
return mem_area(dom,
|
||||
((uintptr_t)this + debug_abbrev_off),
|
||||
debug_abbrev_sz);
|
||||
else
|
||||
return mem_area(dom, 0, 0);
|
||||
}
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
// fill-column: 78;
|
||||
// indent-tabs-mode: nil
|
||||
// c-basic-offset: 4
|
||||
// buffer-file-coding-system: utf-8-unix
|
||||
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// End:
|
@ -1,15 +1,6 @@
|
||||
|
||||
#include "rust_internal.h"
|
||||
|
||||
static inline void
|
||||
adjust_disp(uintptr_t &disp, const void *oldp, const void *newp)
|
||||
{
|
||||
if (disp) {
|
||||
disp += (uintptr_t)oldp;
|
||||
disp -= (uintptr_t)newp;
|
||||
}
|
||||
}
|
||||
|
||||
type_desc *
|
||||
rust_crate_cache::get_type_desc(size_t size,
|
||||
size_t align,
|
||||
@ -47,10 +38,8 @@ rust_crate_cache::get_type_desc(size_t size,
|
||||
return td;
|
||||
}
|
||||
|
||||
rust_crate_cache::rust_crate_cache(rust_dom *dom,
|
||||
rust_crate const *crate)
|
||||
rust_crate_cache::rust_crate_cache(rust_dom *dom)
|
||||
: type_descs(NULL),
|
||||
crate(crate),
|
||||
dom(dom),
|
||||
idx(0)
|
||||
{
|
||||
|
@ -1,79 +0,0 @@
|
||||
|
||||
#include "rust_internal.h"
|
||||
|
||||
rust_crate_reader::abbrev::abbrev(rust_dom *dom,
|
||||
uintptr_t body_off,
|
||||
size_t body_sz,
|
||||
uintptr_t tag,
|
||||
uint8_t has_children) :
|
||||
dom(dom),
|
||||
body_off(body_off),
|
||||
tag(tag),
|
||||
has_children(has_children),
|
||||
idx(0)
|
||||
{}
|
||||
|
||||
bool
|
||||
rust_crate_reader::attr::is_numeric() const
|
||||
{
|
||||
switch (form) {
|
||||
case DW_FORM_ref_addr:
|
||||
case DW_FORM_addr:
|
||||
case DW_FORM_data4:
|
||||
case DW_FORM_data1:
|
||||
case DW_FORM_flag:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
rust_crate_reader::attr::is_string() const
|
||||
{
|
||||
return form == DW_FORM_string;
|
||||
}
|
||||
|
||||
size_t
|
||||
rust_crate_reader::attr::get_ssz(rust_dom *dom) const
|
||||
{
|
||||
I(dom, is_string());
|
||||
return val.str.sz;
|
||||
}
|
||||
|
||||
char const *
|
||||
rust_crate_reader::attr::get_str(rust_dom *dom) const
|
||||
{
|
||||
I(dom, is_string());
|
||||
return val.str.s;
|
||||
}
|
||||
|
||||
uintptr_t
|
||||
rust_crate_reader::attr::get_num(rust_dom *dom) const
|
||||
{
|
||||
I(dom, is_numeric());
|
||||
return val.num;
|
||||
}
|
||||
|
||||
bool
|
||||
rust_crate_reader::attr::is_unknown() const {
|
||||
return !(is_numeric() || is_string());
|
||||
}
|
||||
|
||||
rust_crate_reader::rust_crate_reader(rust_dom *dom)
|
||||
: dom(dom)
|
||||
{
|
||||
DLOG(dom, mem, "crate_reader on crate: 0x%" PRIxPTR, this);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
// fill-column: 78;
|
||||
// indent-tabs-mode: nil
|
||||
// c-basic-offset: 4
|
||||
// buffer-file-coding-system: utf-8-unix
|
||||
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// End:
|
@ -16,7 +16,7 @@ rust_dom::rust_dom(rust_kernel *kernel,
|
||||
running_tasks(this, "running"),
|
||||
blocked_tasks(this, "blocked"),
|
||||
dead_tasks(this, "dead"),
|
||||
caches(this),
|
||||
cache(this),
|
||||
root_task(NULL),
|
||||
curr_task(NULL),
|
||||
rval(0),
|
||||
@ -42,9 +42,6 @@ rust_dom::~rust_dom() {
|
||||
#ifndef __WIN32__
|
||||
pthread_attr_destroy(&attr);
|
||||
#endif
|
||||
while (caches.length()) {
|
||||
delete caches.pop();
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void new_rust_activate_glue(rust_task *)
|
||||
@ -341,24 +338,8 @@ rust_dom::start_main_loop() {
|
||||
|
||||
|
||||
rust_crate_cache *
|
||||
rust_dom::get_cache(rust_crate const *crate) {
|
||||
DLOG(this, cache, "looking for crate-cache for crate 0x%" PRIxPTR, crate);
|
||||
rust_crate_cache *cache = NULL;
|
||||
for (size_t i = 0; i < caches.length(); ++i) {
|
||||
rust_crate_cache *c = caches[i];
|
||||
if (c->crate == crate) {
|
||||
cache = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!cache) {
|
||||
DLOG(this, cache,
|
||||
"making new crate-cache for crate 0x%" PRIxPTR, crate);
|
||||
cache = new (this) rust_crate_cache(this, crate);
|
||||
caches.push(cache);
|
||||
}
|
||||
cache->ref();
|
||||
return cache;
|
||||
rust_dom::get_cache() {
|
||||
return &cache;
|
||||
}
|
||||
|
||||
rust_task *
|
||||
|
@ -1,6 +1,31 @@
|
||||
#ifndef RUST_DOM_H
|
||||
#define RUST_DOM_H
|
||||
|
||||
struct rust_dom;
|
||||
|
||||
class
|
||||
rust_crate_cache
|
||||
{
|
||||
public:
|
||||
type_desc *get_type_desc(size_t size,
|
||||
size_t align,
|
||||
size_t n_descs,
|
||||
type_desc const **descs);
|
||||
|
||||
private:
|
||||
|
||||
type_desc *type_descs;
|
||||
|
||||
public:
|
||||
|
||||
rust_dom *dom;
|
||||
size_t idx;
|
||||
|
||||
rust_crate_cache(rust_dom *dom);
|
||||
~rust_crate_cache();
|
||||
void flush();
|
||||
};
|
||||
|
||||
struct rust_dom : public kernel_owned<rust_dom>, rc_base<rust_dom>
|
||||
{
|
||||
// Fields known to the compiler:
|
||||
@ -19,7 +44,7 @@ struct rust_dom : public kernel_owned<rust_dom>, rc_base<rust_dom>
|
||||
rust_task_list blocked_tasks;
|
||||
rust_task_list dead_tasks;
|
||||
|
||||
ptr_vec<rust_crate_cache> caches;
|
||||
rust_crate_cache cache;
|
||||
|
||||
randctx rctx;
|
||||
rust_task *root_task;
|
||||
@ -65,7 +90,7 @@ struct rust_dom : public kernel_owned<rust_dom>, rc_base<rust_dom>
|
||||
void win32_require(LPCTSTR fn, BOOL ok);
|
||||
#endif
|
||||
|
||||
rust_crate_cache *get_cache(rust_crate const *crate);
|
||||
rust_crate_cache *get_cache();
|
||||
size_t number_of_live_tasks();
|
||||
|
||||
void reap_dead_tasks();
|
||||
|
@ -1,198 +0,0 @@
|
||||
#ifndef RUST_DWARF_H
|
||||
#define RUST_DWARF_H
|
||||
|
||||
enum
|
||||
dw_form
|
||||
{
|
||||
DW_FORM_addr = 0x01,
|
||||
DW_FORM_block2 = 0x03,
|
||||
DW_FORM_block4 = 0x04,
|
||||
DW_FORM_data2 = 0x05,
|
||||
DW_FORM_data4 = 0x06,
|
||||
DW_FORM_data8 = 0x07,
|
||||
DW_FORM_string = 0x08,
|
||||
DW_FORM_block = 0x09,
|
||||
DW_FORM_block1 = 0x0a,
|
||||
DW_FORM_data1 = 0x0b,
|
||||
DW_FORM_flag = 0x0c,
|
||||
DW_FORM_sdata = 0x0d,
|
||||
DW_FORM_strp = 0x0e,
|
||||
DW_FORM_udata = 0x0f,
|
||||
DW_FORM_ref_addr = 0x10,
|
||||
DW_FORM_ref1 = 0x11,
|
||||
DW_FORM_ref2 = 0x12,
|
||||
DW_FORM_ref4 = 0x13,
|
||||
DW_FORM_ref8 = 0x14,
|
||||
DW_FORM_ref_udata = 0x15,
|
||||
DW_FORM_indirect = 0x16
|
||||
};
|
||||
|
||||
enum
|
||||
dw_at
|
||||
{
|
||||
DW_AT_sibling = 0x01,
|
||||
DW_AT_location = 0x02,
|
||||
DW_AT_name = 0x03,
|
||||
DW_AT_ordering = 0x09,
|
||||
DW_AT_byte_size = 0x0b,
|
||||
DW_AT_bit_offset = 0x0c,
|
||||
DW_AT_bit_size = 0x0d,
|
||||
DW_AT_stmt_list = 0x10,
|
||||
DW_AT_low_pc = 0x11,
|
||||
DW_AT_high_pc = 0x12,
|
||||
DW_AT_language = 0x13,
|
||||
DW_AT_discr = 0x15,
|
||||
DW_AT_discr_value = 0x16,
|
||||
DW_AT_visibility = 0x17,
|
||||
DW_AT_import = 0x18,
|
||||
DW_AT_string_length = 0x19,
|
||||
DW_AT_common_reference = 0x1a,
|
||||
DW_AT_comp_dir = 0x1b,
|
||||
DW_AT_const_value = 0x1c,
|
||||
DW_AT_containing_type = 0x1d,
|
||||
DW_AT_default_value = 0x1e,
|
||||
DW_AT_inline = 0x20,
|
||||
DW_AT_is_optional = 0x21,
|
||||
DW_AT_lower_bound = 0x22,
|
||||
DW_AT_producer = 0x25,
|
||||
DW_AT_prototyped = 0x27,
|
||||
DW_AT_return_addr = 0x2a,
|
||||
DW_AT_start_scope = 0x2c,
|
||||
DW_AT_bit_stride = 0x2e,
|
||||
DW_AT_upper_bound = 0x2f,
|
||||
DW_AT_abstract_origin = 0x31,
|
||||
DW_AT_accessibility = 0x32,
|
||||
DW_AT_address_class = 0x33,
|
||||
DW_AT_artificial = 0x34,
|
||||
DW_AT_base_types = 0x35,
|
||||
DW_AT_calling_convention = 0x36,
|
||||
DW_AT_count = 0x37,
|
||||
DW_AT_data_member_location = 0x38,
|
||||
DW_AT_decl_column = 0x39,
|
||||
DW_AT_decl_file = 0x3a,
|
||||
DW_AT_decl_line = 0x3b,
|
||||
DW_AT_declaration = 0x3c,
|
||||
DW_AT_discr_list = 0x3d,
|
||||
DW_AT_encoding = 0x3e,
|
||||
DW_AT_external = 0x3f,
|
||||
DW_AT_frame_base = 0x40,
|
||||
DW_AT_friend = 0x41,
|
||||
DW_AT_identifier_case = 0x42,
|
||||
DW_AT_macro_info = 0x43,
|
||||
DW_AT_namelist_item = 0x44,
|
||||
DW_AT_priority = 0x45,
|
||||
DW_AT_segment = 0x46,
|
||||
DW_AT_specification = 0x47,
|
||||
DW_AT_static_link = 0x48,
|
||||
DW_AT_type = 0x49,
|
||||
DW_AT_use_location = 0x4a,
|
||||
DW_AT_variable_parameter = 0x4b,
|
||||
DW_AT_virtuality = 0x4c,
|
||||
DW_AT_vtable_elem_location = 0x4d,
|
||||
DW_AT_allocated = 0x4e,
|
||||
DW_AT_associated = 0x4f,
|
||||
DW_AT_data_location = 0x50,
|
||||
DW_AT_byte_stride = 0x51,
|
||||
DW_AT_entry_pc = 0x52,
|
||||
DW_AT_use_UTF8 = 0x53,
|
||||
DW_AT_extension = 0x54,
|
||||
DW_AT_ranges = 0x55,
|
||||
DW_AT_trampoline = 0x56,
|
||||
DW_AT_call_column = 0x57,
|
||||
DW_AT_call_file = 0x58,
|
||||
DW_AT_call_line = 0x59,
|
||||
DW_AT_description = 0x5a,
|
||||
DW_AT_binary_scale = 0x5b,
|
||||
DW_AT_decimal_scale = 0x5c,
|
||||
DW_AT_small = 0x5d,
|
||||
DW_AT_decimal_sign = 0x5e,
|
||||
DW_AT_digit_count = 0x5f,
|
||||
DW_AT_picture_string = 0x60,
|
||||
DW_AT_mutable = 0x61,
|
||||
DW_AT_threads_scaled = 0x62,
|
||||
DW_AT_explicit = 0x63,
|
||||
DW_AT_object_pointer = 0x64,
|
||||
DW_AT_endianity = 0x65,
|
||||
DW_AT_elemental = 0x66,
|
||||
DW_AT_pure = 0x67,
|
||||
DW_AT_recursive = 0x68,
|
||||
DW_AT_lo_user = 0x2000,
|
||||
DW_AT_hi_user = 0x3fff
|
||||
};
|
||||
|
||||
enum
|
||||
dw_tag
|
||||
{
|
||||
DW_TAG_array_type = 0x01,
|
||||
DW_TAG_class_type = 0x02,
|
||||
DW_TAG_entry_point = 0x03,
|
||||
DW_TAG_enumeration_type = 0x04,
|
||||
DW_TAG_formal_parameter = 0x05,
|
||||
DW_TAG_imported_declaration = 0x08,
|
||||
DW_TAG_label = 0x0a,
|
||||
DW_TAG_lexical_block = 0x0b,
|
||||
DW_TAG_member = 0x0d,
|
||||
DW_TAG_pointer_type = 0x0f,
|
||||
DW_TAG_reference_type = 0x10,
|
||||
DW_TAG_compile_unit = 0x11,
|
||||
DW_TAG_string_type = 0x12,
|
||||
DW_TAG_structure_type = 0x13,
|
||||
DW_TAG_subroutine_type = 0x15,
|
||||
DW_TAG_typedef = 0x16,
|
||||
DW_TAG_union_type = 0x17,
|
||||
DW_TAG_unspecified_parameters = 0x18,
|
||||
DW_TAG_variant = 0x19,
|
||||
DW_TAG_common_block = 0x1a,
|
||||
DW_TAG_common_inclusion = 0x1b,
|
||||
DW_TAG_inheritance = 0x1c,
|
||||
DW_TAG_inlined_subroutine = 0x1d,
|
||||
DW_TAG_module = 0x1e,
|
||||
DW_TAG_ptr_to_member_type = 0x1f,
|
||||
DW_TAG_set_type = 0x20,
|
||||
DW_TAG_subrange_type = 0x21,
|
||||
DW_TAG_with_stmt = 0x22,
|
||||
DW_TAG_access_declaration = 0x23,
|
||||
DW_TAG_base_type = 0x24,
|
||||
DW_TAG_catch_block = 0x25,
|
||||
DW_TAG_const_type = 0x26,
|
||||
DW_TAG_constant = 0x27,
|
||||
DW_TAG_enumerator = 0x28,
|
||||
DW_TAG_file_type = 0x29,
|
||||
DW_TAG_friend = 0x2a,
|
||||
DW_TAG_namelist = 0x2b,
|
||||
DW_TAG_namelist_item = 0x2c,
|
||||
DW_TAG_packed_type = 0x2d,
|
||||
DW_TAG_subprogram = 0x2e,
|
||||
DW_TAG_template_type_parameter = 0x2f,
|
||||
DW_TAG_template_value_parameter = 0x30,
|
||||
DW_TAG_thrown_type = 0x31,
|
||||
DW_TAG_try_block = 0x32,
|
||||
DW_TAG_variant_part = 0x33,
|
||||
DW_TAG_variable = 0x34,
|
||||
DW_TAG_volatile_type = 0x35,
|
||||
DW_TAG_dwarf_procedure = 0x36,
|
||||
DW_TAG_restrict_type = 0x37,
|
||||
DW_TAG_interface_type = 0x38,
|
||||
DW_TAG_namespace = 0x39,
|
||||
DW_TAG_imported_module = 0x3a,
|
||||
DW_TAG_unspecified_type = 0x3b,
|
||||
DW_TAG_partial_unit = 0x3c,
|
||||
DW_TAG_imported_unit = 0x3d,
|
||||
DW_TAG_condition = 0x3f,
|
||||
DW_TAG_shared_type = 0x40,
|
||||
DW_TAG_lo_user = 0x4080,
|
||||
DW_TAG_hi_user = 0xffff,
|
||||
};
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
// fill-column: 78;
|
||||
// indent-tabs-mode: nil
|
||||
// c-basic-offset: 4
|
||||
// buffer-file-coding-system: utf-8-unix
|
||||
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// End:
|
||||
//
|
||||
|
||||
#endif
|
@ -54,7 +54,6 @@ class rust_port;
|
||||
class rust_chan;
|
||||
struct rust_token;
|
||||
class rust_kernel;
|
||||
class rust_crate;
|
||||
class rust_crate_cache;
|
||||
|
||||
struct stk_seg;
|
||||
@ -204,63 +203,8 @@ struct rust_timer {
|
||||
|
||||
#include "rust_util.h"
|
||||
|
||||
// Crates.
|
||||
|
||||
template<typename T> T*
|
||||
crate_rel(rust_crate const *crate, T *t) {
|
||||
return (T*)(((uintptr_t)crate) + ((ptrdiff_t)t));
|
||||
}
|
||||
|
||||
template<typename T> T const*
|
||||
crate_rel(rust_crate const *crate, T const *t) {
|
||||
return (T const*)(((uintptr_t)crate) + ((ptrdiff_t)t));
|
||||
}
|
||||
|
||||
typedef void CDECL (*activate_glue_ty)(rust_task *);
|
||||
|
||||
class rust_crate {
|
||||
// The following fields are emitted by the compiler for the static
|
||||
// rust_crate object inside each compiled crate.
|
||||
|
||||
ptrdiff_t image_base_off; // (Loaded image base) - this.
|
||||
uintptr_t self_addr; // Un-relocated addres of 'this'.
|
||||
|
||||
ptrdiff_t debug_abbrev_off; // Offset from this to .debug_abbrev.
|
||||
size_t debug_abbrev_sz; // Size of .debug_abbrev.
|
||||
|
||||
ptrdiff_t debug_info_off; // Offset from this to .debug_info.
|
||||
size_t debug_info_sz; // Size of .debug_info.
|
||||
|
||||
ptrdiff_t pad;
|
||||
ptrdiff_t pad2;
|
||||
ptrdiff_t pad3;
|
||||
ptrdiff_t pad4;
|
||||
ptrdiff_t pad5;
|
||||
|
||||
public:
|
||||
|
||||
size_t pad6;
|
||||
size_t pad7;
|
||||
size_t pad8;
|
||||
|
||||
// Crates are immutable, constructed by the compiler.
|
||||
|
||||
uintptr_t get_image_base() const;
|
||||
ptrdiff_t get_relocation_diff() const;
|
||||
|
||||
struct mem_area
|
||||
{
|
||||
rust_dom *dom;
|
||||
uintptr_t base;
|
||||
uintptr_t lim;
|
||||
mem_area(rust_dom *dom, uintptr_t pos, size_t sz);
|
||||
};
|
||||
|
||||
mem_area get_debug_info(rust_dom *dom) const;
|
||||
mem_area get_debug_abbrev(rust_dom *dom) const;
|
||||
};
|
||||
|
||||
|
||||
struct type_desc {
|
||||
// First part of type_desc is known to compiler.
|
||||
// first_param = &descs[1] if dynamic, null if static.
|
||||
@ -281,80 +225,6 @@ struct type_desc {
|
||||
const type_desc *descs[];
|
||||
};
|
||||
|
||||
class
|
||||
rust_crate_cache : public dom_owned<rust_crate_cache>,
|
||||
public rc_base<rust_crate_cache>
|
||||
{
|
||||
public:
|
||||
type_desc *get_type_desc(size_t size,
|
||||
size_t align,
|
||||
size_t n_descs,
|
||||
type_desc const **descs);
|
||||
|
||||
private:
|
||||
|
||||
type_desc *type_descs;
|
||||
|
||||
public:
|
||||
|
||||
rust_crate const *crate;
|
||||
rust_dom *dom;
|
||||
size_t idx;
|
||||
|
||||
rust_crate_cache(rust_dom *dom,
|
||||
rust_crate const *crate);
|
||||
~rust_crate_cache();
|
||||
void flush();
|
||||
};
|
||||
|
||||
#include "rust_dwarf.h"
|
||||
|
||||
class
|
||||
rust_crate_reader
|
||||
{
|
||||
struct
|
||||
abbrev : dom_owned<abbrev>
|
||||
{
|
||||
rust_dom *dom;
|
||||
uintptr_t body_off;
|
||||
size_t body_sz;
|
||||
uintptr_t tag;
|
||||
uint8_t has_children;
|
||||
size_t idx;
|
||||
abbrev(rust_dom *dom, uintptr_t body_off, size_t body_sz,
|
||||
uintptr_t tag, uint8_t has_children);
|
||||
};
|
||||
|
||||
rust_dom *dom;
|
||||
size_t idx;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
struct
|
||||
attr
|
||||
{
|
||||
dw_form form;
|
||||
dw_at at;
|
||||
union {
|
||||
struct {
|
||||
char const *s;
|
||||
size_t sz;
|
||||
} str;
|
||||
uintptr_t num;
|
||||
} val;
|
||||
|
||||
bool is_numeric() const;
|
||||
bool is_string() const;
|
||||
size_t get_ssz(rust_dom *dom) const;
|
||||
char const *get_str(rust_dom *dom) const;
|
||||
uintptr_t get_num(rust_dom *dom) const;
|
||||
bool is_unknown() const;
|
||||
};
|
||||
|
||||
rust_crate_reader(rust_dom *dom);
|
||||
};
|
||||
|
||||
// An alarm can be put into a wait queue and the task will be notified
|
||||
// when the wait queue is flushed.
|
||||
|
||||
|
@ -209,7 +209,6 @@ size_t log_rt_comm;
|
||||
size_t log_rt_task;
|
||||
size_t log_rt_dom;
|
||||
size_t log_rt_trace;
|
||||
size_t log_rt_dwarf;
|
||||
size_t log_rt_cache;
|
||||
size_t log_rt_upcall;
|
||||
size_t log_rt_timer;
|
||||
@ -224,7 +223,6 @@ static const mod_entry _rt_module_map[] =
|
||||
{"rt.task", &log_rt_task},
|
||||
{"rt.dom", &log_rt_dom},
|
||||
{"rt.trace", &log_rt_trace},
|
||||
{"rt.dwarf", &log_rt_dwarf},
|
||||
{"rt.cache", &log_rt_cache},
|
||||
{"rt.upcall", &log_rt_upcall},
|
||||
{"rt.timer", &log_rt_timer},
|
||||
|
@ -66,7 +66,6 @@ extern size_t log_rt_comm;
|
||||
extern size_t log_rt_task;
|
||||
extern size_t log_rt_dom;
|
||||
extern size_t log_rt_trace;
|
||||
extern size_t log_rt_dwarf;
|
||||
extern size_t log_rt_cache;
|
||||
extern size_t log_rt_upcall;
|
||||
extern size_t log_rt_timer;
|
||||
|
@ -131,8 +131,6 @@ rust_task::~rust_task()
|
||||
(ref_count == 1 && this == dom->root_task));
|
||||
|
||||
del_stk(dom, stk);
|
||||
if (cache)
|
||||
cache->deref();
|
||||
}
|
||||
|
||||
extern "C" void rust_new_exit_task_glue();
|
||||
@ -597,18 +595,11 @@ rust_task::unblock() {
|
||||
}
|
||||
|
||||
rust_crate_cache *
|
||||
rust_task::get_crate_cache(rust_crate const *curr_crate)
|
||||
rust_task::get_crate_cache()
|
||||
{
|
||||
if (cache && cache->crate != curr_crate) {
|
||||
DLOG(dom, task, "switching task crate-cache to crate 0x%"
|
||||
PRIxPTR, curr_crate);
|
||||
cache->deref();
|
||||
cache = NULL;
|
||||
}
|
||||
|
||||
if (!cache) {
|
||||
DLOG(dom, task, "fetching cache for current crate");
|
||||
cache = dom->get_cache(curr_crate);
|
||||
cache = dom->get_cache();
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ rust_task : public maybe_proxy<rust_task>,
|
||||
uintptr_t get_fp();
|
||||
uintptr_t get_previous_fp(uintptr_t fp);
|
||||
frame_glue_fns *get_frame_glue_fns(uintptr_t fp);
|
||||
rust_crate_cache * get_crate_cache(rust_crate const *curr_crate);
|
||||
rust_crate_cache * get_crate_cache();
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -438,7 +438,7 @@ upcall_vec_grow(rust_task *task,
|
||||
|
||||
extern "C" CDECL type_desc *
|
||||
upcall_get_type_desc(rust_task *task,
|
||||
rust_crate const *curr_crate,
|
||||
void *curr_crate, // ignored, legacy compat.
|
||||
size_t size,
|
||||
size_t align,
|
||||
size_t n_descs,
|
||||
@ -447,7 +447,7 @@ upcall_get_type_desc(rust_task *task,
|
||||
LOG(task, cache, "upcall get_type_desc with size=%" PRIdPTR
|
||||
", align=%" PRIdPTR ", %" PRIdPTR " descs", size, align,
|
||||
n_descs);
|
||||
rust_crate_cache *cache = task->get_crate_cache(curr_crate);
|
||||
rust_crate_cache *cache = task->get_crate_cache();
|
||||
type_desc *td = cache->get_type_desc(size, align, n_descs, descs);
|
||||
LOG(task, cache, "returning tydesc 0x%" PRIxPTR, td);
|
||||
return td;
|
||||
|
@ -10,7 +10,7 @@ rust_test::name() {
|
||||
return "untitled";
|
||||
}
|
||||
|
||||
rust_test_suite::rust_test_suite(rust_crate *crate) : crate(crate) {
|
||||
rust_test_suite::rust_test_suite() {
|
||||
tests.append(new rust_domain_test());
|
||||
tests.append(new rust_task_test(this));
|
||||
tests.append(new rust_array_list_test());
|
||||
|
@ -13,9 +13,8 @@ public:
|
||||
|
||||
class rust_test_suite : public rust_test {
|
||||
public:
|
||||
rust_crate *crate;
|
||||
array_list<rust_test*> tests;
|
||||
rust_test_suite(rust_crate *crate);
|
||||
rust_test_suite();
|
||||
virtual ~rust_test_suite();
|
||||
bool run();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user