Skip to content

Commit 146b611

Browse files
committed
Get rid of rust_crate_cache in the runtime
We are no longer generating dynamic tydescs or dicts. Issue #1982
1 parent bc21a5d commit 146b611

10 files changed

+0
-233
lines changed

mk/rt.mk

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ RUNTIME_CS_$(1) := \
4040
rt/rust.cpp \
4141
rt/rust_builtin.cpp \
4242
rt/rust_run_program.cpp \
43-
rt/rust_crate_cache.cpp \
4443
rt/rust_env.cpp \
4544
rt/rust_task_thread.cpp \
4645
rt/rust_scheduler.cpp \

src/rt/rust_crate_cache.cpp

-103
This file was deleted.

src/rt/rust_internal.h

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ struct rust_task;
5555
class rust_log;
5656
class rust_port;
5757
class rust_kernel;
58-
class rust_crate_cache;
5958

6059
struct stk_seg;
6160
struct type_desc;

src/rt/rust_task.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
7171
runtime_sp(0),
7272
sched(thread->sched),
7373
thread(thread),
74-
cache(NULL),
7574
kernel(thread->kernel),
7675
name(name),
7776
list_index(-1),
@@ -445,16 +444,6 @@ rust_task::die() {
445444
transition(&thread->running_tasks, &thread->dead_tasks, NULL, "none");
446445
}
447446

448-
rust_crate_cache *
449-
rust_task::get_crate_cache()
450-
{
451-
if (!cache) {
452-
DLOG(thread, task, "fetching cache for current crate");
453-
cache = thread->get_cache();
454-
}
455-
return cache;
456-
}
457-
458447
void
459448
rust_task::backtrace() {
460449
if (!log_rt_backtrace) return;

src/rt/rust_task.h

-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ rust_task : public kernel_owned<rust_task>, rust_cond
5757
uintptr_t runtime_sp; // Runtime sp while task running.
5858
rust_scheduler *sched;
5959
rust_task_thread *thread;
60-
rust_crate_cache *cache;
6160

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

187186
frame_glue_fns *get_frame_glue_fns(uintptr_t fp);
188-
rust_crate_cache * get_crate_cache();
189187

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

src/rt/rust_task_thread.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ rust_task_thread::rust_task_thread(rust_scheduler *sched,
2424
int id) :
2525
rust_thread(SCHED_STACK_SIZE),
2626
_log(srv, this),
27-
cache(this),
2827
id(id),
2928
should_exit(false),
3029
cached_c_stack(NULL),
@@ -295,11 +294,6 @@ rust_task_thread::start_main_loop() {
295294
}
296295
}
297296

298-
rust_crate_cache *
299-
rust_task_thread::get_cache() {
300-
return &cache;
301-
}
302-
303297
rust_task *
304298
rust_task_thread::create_task(rust_task *spawner, const char *name,
305299
size_t init_stack_sz) {

src/rt/rust_task_thread.h

-33
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,6 @@
1111
#include <windows.h>
1212
#endif
1313

14-
struct rust_task_thread;
15-
16-
struct rust_hashable_dict {
17-
UT_hash_handle hh;
18-
void* fields[0];
19-
};
20-
21-
class rust_crate_cache {
22-
public:
23-
type_desc *get_type_desc(size_t size,
24-
size_t align,
25-
size_t n_descs,
26-
type_desc const **descs,
27-
uintptr_t n_obj_params);
28-
void** get_dict(size_t n_fields, void** dict);
29-
30-
private:
31-
32-
type_desc *type_descs;
33-
rust_hashable_dict *dicts;
34-
35-
public:
36-
37-
rust_task_thread *thread;
38-
size_t idx;
39-
40-
rust_crate_cache(rust_task_thread *thread);
41-
~rust_crate_cache();
42-
void flush();
43-
};
44-
4514
struct rust_task_thread : public kernel_owned<rust_task_thread>,
4615
rust_thread
4716
{
@@ -52,7 +21,6 @@ struct rust_task_thread : public kernel_owned<rust_task_thread>,
5221
// Fields known only by the runtime:
5322
rust_log _log;
5423

55-
rust_crate_cache cache;
5624
const int id;
5725

5826
#ifndef __WIN32__
@@ -108,7 +76,6 @@ struct rust_task_thread : public kernel_owned<rust_task_thread>,
10876
rust_log & get_log();
10977
void fail();
11078

111-
rust_crate_cache *get_cache();
11279
size_t number_of_live_tasks();
11380

11481
void reap_dead_tasks();

src/rt/rust_upcall.cpp

-67
Original file line numberDiff line numberDiff line change
@@ -361,73 +361,6 @@ upcall_free_shared_type_desc(type_desc *td) {
361361
}
362362
}
363363

364-
/**********************************************************************
365-
* Called to intern a task-local type descriptor into the hashtable
366-
* associated with each scheduler.
367-
*/
368-
369-
struct s_get_type_desc_args {
370-
type_desc *retval;
371-
size_t size;
372-
size_t align;
373-
size_t n_descs;
374-
type_desc const **descs;
375-
uintptr_t n_obj_params;
376-
};
377-
378-
extern "C" CDECL void
379-
upcall_s_get_type_desc(s_get_type_desc_args *args) {
380-
rust_task *task = rust_task_thread::get_task();
381-
LOG_UPCALL_ENTRY(task);
382-
383-
LOG(task, cache, "upcall get_type_desc with size=%" PRIdPTR
384-
", align=%" PRIdPTR ", %" PRIdPTR " descs", args->size, args->align,
385-
args->n_descs);
386-
rust_crate_cache *cache = task->get_crate_cache();
387-
type_desc *td = cache->get_type_desc(args->size, args->align, args->n_descs,
388-
args->descs, args->n_obj_params);
389-
LOG(task, cache, "returning tydesc 0x%" PRIxPTR, td);
390-
args->retval = td;
391-
}
392-
393-
extern "C" CDECL type_desc *
394-
upcall_get_type_desc(void *curr_crate, // ignored, legacy compat.
395-
size_t size,
396-
size_t align,
397-
size_t n_descs,
398-
type_desc const **descs,
399-
uintptr_t n_obj_params) {
400-
s_get_type_desc_args args = {0,size,align,n_descs,descs,n_obj_params};
401-
UPCALL_SWITCH_STACK(&args, upcall_s_get_type_desc);
402-
return args.retval;
403-
}
404-
405-
/**********************************************************************
406-
* Called to get a heap-allocated dict. These are interned and kept
407-
* around indefinitely
408-
*/
409-
410-
struct s_intern_dict_args {
411-
size_t n_fields;
412-
void** dict;
413-
void** res;
414-
};
415-
416-
extern "C" CDECL void
417-
upcall_s_intern_dict(s_intern_dict_args *args) {
418-
rust_task *task = rust_task_thread::get_task();
419-
LOG_UPCALL_ENTRY(task);
420-
rust_crate_cache *cache = task->get_crate_cache();
421-
args->res = cache->get_dict(args->n_fields, args->dict);
422-
}
423-
424-
extern "C" CDECL void**
425-
upcall_intern_dict(size_t n_fields, void** dict) {
426-
s_intern_dict_args args = {n_fields, dict, 0 };
427-
UPCALL_SWITCH_STACK(&args, upcall_s_intern_dict);
428-
return args.res;
429-
}
430-
431364
/**********************************************************************/
432365

433366
struct s_vec_grow_args {

src/rt/rustrt.def.in

-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ upcall_free
6565
upcall_validate_box
6666
upcall_create_shared_type_desc
6767
upcall_free_shared_type_desc
68-
upcall_get_type_desc
69-
upcall_intern_dict
7068
upcall_log_type
7169
upcall_malloc
7270
upcall_rust_personality

src/rustc/back/upcall.rs

-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ type upcalls =
1818
mark: ValueRef,
1919
create_shared_type_desc: ValueRef,
2020
free_shared_type_desc: ValueRef,
21-
get_type_desc: ValueRef,
2221
vec_grow: ValueRef,
2322
vec_push: ValueRef,
2423
cmp_type: ValueRef,
@@ -71,12 +70,6 @@ fn declare_upcalls(targ_cfg: @session::config,
7170
T_ptr(tydesc_type)),
7271
free_shared_type_desc:
7372
dv("free_shared_type_desc", [T_ptr(tydesc_type)]),
74-
get_type_desc:
75-
d("get_type_desc",
76-
[T_ptr(T_nil()), size_t,
77-
size_t, size_t,
78-
T_ptr(T_ptr(tydesc_type)), int_t],
79-
T_ptr(tydesc_type)),
8073
vec_grow:
8174
dv("vec_grow", [T_ptr(T_ptr(opaque_vec_t)), int_t]),
8275
vec_push:

0 commit comments

Comments
 (0)