Skip to content

Commit

Permalink
Get rid of rust_crate_cache in the runtime
Browse files Browse the repository at this point in the history
We are no longer generating dynamic tydescs or dicts.

Issue #1982
  • Loading branch information
marijnh committed Mar 15, 2012
1 parent bc21a5d commit 146b611
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 233 deletions.
1 change: 0 additions & 1 deletion mk/rt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ RUNTIME_CS_$(1) := \
rt/rust.cpp \
rt/rust_builtin.cpp \
rt/rust_run_program.cpp \
rt/rust_crate_cache.cpp \
rt/rust_env.cpp \
rt/rust_task_thread.cpp \
rt/rust_scheduler.cpp \
Expand Down
103 changes: 0 additions & 103 deletions src/rt/rust_crate_cache.cpp

This file was deleted.

1 change: 0 additions & 1 deletion src/rt/rust_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ struct rust_task;
class rust_log;
class rust_port;
class rust_kernel;
class rust_crate_cache;

struct stk_seg;
struct type_desc;
Expand Down
11 changes: 0 additions & 11 deletions src/rt/rust_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
runtime_sp(0),
sched(thread->sched),
thread(thread),
cache(NULL),
kernel(thread->kernel),
name(name),
list_index(-1),
Expand Down Expand Up @@ -445,16 +444,6 @@ rust_task::die() {
transition(&thread->running_tasks, &thread->dead_tasks, NULL, "none");
}

rust_crate_cache *
rust_task::get_crate_cache()
{
if (!cache) {
DLOG(thread, task, "fetching cache for current crate");
cache = thread->get_cache();
}
return cache;
}

void
rust_task::backtrace() {
if (!log_rt_backtrace) return;
Expand Down
2 changes: 0 additions & 2 deletions src/rt/rust_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ rust_task : public kernel_owned<rust_task>, rust_cond
uintptr_t runtime_sp; // Runtime sp while task running.
rust_scheduler *sched;
rust_task_thread *thread;
rust_crate_cache *cache;

// Fields known only to the runtime.
rust_kernel *kernel;
Expand Down Expand Up @@ -185,7 +184,6 @@ rust_task : public kernel_owned<rust_task>, rust_cond
void unsupervise();

frame_glue_fns *get_frame_glue_fns(uintptr_t fp);
rust_crate_cache * get_crate_cache();

void *calloc(size_t size, const char *tag);

Expand Down
6 changes: 0 additions & 6 deletions src/rt/rust_task_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ rust_task_thread::rust_task_thread(rust_scheduler *sched,
int id) :
rust_thread(SCHED_STACK_SIZE),
_log(srv, this),
cache(this),
id(id),
should_exit(false),
cached_c_stack(NULL),
Expand Down Expand Up @@ -295,11 +294,6 @@ rust_task_thread::start_main_loop() {
}
}

rust_crate_cache *
rust_task_thread::get_cache() {
return &cache;
}

rust_task *
rust_task_thread::create_task(rust_task *spawner, const char *name,
size_t init_stack_sz) {
Expand Down
33 changes: 0 additions & 33 deletions src/rt/rust_task_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,6 @@
#include <windows.h>
#endif

struct rust_task_thread;

struct rust_hashable_dict {
UT_hash_handle hh;
void* fields[0];
};

class rust_crate_cache {
public:
type_desc *get_type_desc(size_t size,
size_t align,
size_t n_descs,
type_desc const **descs,
uintptr_t n_obj_params);
void** get_dict(size_t n_fields, void** dict);

private:

type_desc *type_descs;
rust_hashable_dict *dicts;

public:

rust_task_thread *thread;
size_t idx;

rust_crate_cache(rust_task_thread *thread);
~rust_crate_cache();
void flush();
};

struct rust_task_thread : public kernel_owned<rust_task_thread>,
rust_thread
{
Expand All @@ -52,7 +21,6 @@ struct rust_task_thread : public kernel_owned<rust_task_thread>,
// Fields known only by the runtime:
rust_log _log;

rust_crate_cache cache;
const int id;

#ifndef __WIN32__
Expand Down Expand Up @@ -108,7 +76,6 @@ struct rust_task_thread : public kernel_owned<rust_task_thread>,
rust_log & get_log();
void fail();

rust_crate_cache *get_cache();
size_t number_of_live_tasks();

void reap_dead_tasks();
Expand Down
67 changes: 0 additions & 67 deletions src/rt/rust_upcall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,73 +361,6 @@ upcall_free_shared_type_desc(type_desc *td) {
}
}

/**********************************************************************
* Called to intern a task-local type descriptor into the hashtable
* associated with each scheduler.
*/

struct s_get_type_desc_args {
type_desc *retval;
size_t size;
size_t align;
size_t n_descs;
type_desc const **descs;
uintptr_t n_obj_params;
};

extern "C" CDECL void
upcall_s_get_type_desc(s_get_type_desc_args *args) {
rust_task *task = rust_task_thread::get_task();
LOG_UPCALL_ENTRY(task);

LOG(task, cache, "upcall get_type_desc with size=%" PRIdPTR
", align=%" PRIdPTR ", %" PRIdPTR " descs", args->size, args->align,
args->n_descs);
rust_crate_cache *cache = task->get_crate_cache();
type_desc *td = cache->get_type_desc(args->size, args->align, args->n_descs,
args->descs, args->n_obj_params);
LOG(task, cache, "returning tydesc 0x%" PRIxPTR, td);
args->retval = td;
}

extern "C" CDECL type_desc *
upcall_get_type_desc(void *curr_crate, // ignored, legacy compat.
size_t size,
size_t align,
size_t n_descs,
type_desc const **descs,
uintptr_t n_obj_params) {
s_get_type_desc_args args = {0,size,align,n_descs,descs,n_obj_params};
UPCALL_SWITCH_STACK(&args, upcall_s_get_type_desc);
return args.retval;
}

/**********************************************************************
* Called to get a heap-allocated dict. These are interned and kept
* around indefinitely
*/

struct s_intern_dict_args {
size_t n_fields;
void** dict;
void** res;
};

extern "C" CDECL void
upcall_s_intern_dict(s_intern_dict_args *args) {
rust_task *task = rust_task_thread::get_task();
LOG_UPCALL_ENTRY(task);
rust_crate_cache *cache = task->get_crate_cache();
args->res = cache->get_dict(args->n_fields, args->dict);
}

extern "C" CDECL void**
upcall_intern_dict(size_t n_fields, void** dict) {
s_intern_dict_args args = {n_fields, dict, 0 };
UPCALL_SWITCH_STACK(&args, upcall_s_intern_dict);
return args.res;
}

/**********************************************************************/

struct s_vec_grow_args {
Expand Down
2 changes: 0 additions & 2 deletions src/rt/rustrt.def.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ upcall_free
upcall_validate_box
upcall_create_shared_type_desc
upcall_free_shared_type_desc
upcall_get_type_desc
upcall_intern_dict
upcall_log_type
upcall_malloc
upcall_rust_personality
Expand Down
7 changes: 0 additions & 7 deletions src/rustc/back/upcall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type upcalls =
mark: ValueRef,
create_shared_type_desc: ValueRef,
free_shared_type_desc: ValueRef,
get_type_desc: ValueRef,
vec_grow: ValueRef,
vec_push: ValueRef,
cmp_type: ValueRef,
Expand Down Expand Up @@ -71,12 +70,6 @@ fn declare_upcalls(targ_cfg: @session::config,
T_ptr(tydesc_type)),
free_shared_type_desc:
dv("free_shared_type_desc", [T_ptr(tydesc_type)]),
get_type_desc:
d("get_type_desc",
[T_ptr(T_nil()), size_t,
size_t, size_t,
T_ptr(T_ptr(tydesc_type)), int_t],
T_ptr(tydesc_type)),
vec_grow:
dv("vec_grow", [T_ptr(T_ptr(opaque_vec_t)), int_t]),
vec_push:
Expand Down

0 comments on commit 146b611

Please sign in to comment.