Skip to content

Commit d67e144

Browse files
committed
rt: get rid of rust_fn and replace with fn_env_pair plus a little cleanup.
1 parent d06e6e7 commit d67e144

File tree

4 files changed

+8
-37
lines changed

4 files changed

+8
-37
lines changed

src/rt/rust_builtin.cpp

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -249,24 +249,16 @@ debug_opaque(type_desc *t, uint8_t *front) {
249249
}
250250
}
251251

252-
// FIXME (#2667) this no longer reflects the actual structure of boxes!
253-
struct rust_box {
254-
RUST_REFCOUNTED(rust_box)
255-
256-
// FIXME (#2667) `data` could be aligned differently from the actual
257-
// box body data
258-
uint8_t data[];
259-
};
260-
261252
extern "C" CDECL void
262-
debug_box(type_desc *t, rust_box *box) {
253+
debug_box(type_desc *t, rust_opaque_box *box) {
263254
rust_task *task = rust_get_current_task();
264255
LOG(task, stdlib, "debug_box(0x%" PRIxPTR ")", box);
265256
debug_tydesc_helper(t);
266257
LOG(task, stdlib, " refcount %" PRIdPTR,
267258
box->ref_count - 1); // -1 because we ref'ed for this call
259+
uint8_t *data = (uint8_t *)box_body(box);
268260
for (uintptr_t i = 0; i < t->size; ++i) {
269-
LOG(task, stdlib, " byte %" PRIdPTR ": 0x%" PRIx8, i, box->data[i]);
261+
LOG(task, stdlib, " byte %" PRIdPTR ": 0x%" PRIx8, i, data[i]);
270262
}
271263
}
272264

@@ -288,20 +280,15 @@ debug_tag(type_desc *t, rust_tag *tag) {
288280
tag->variant[i]);
289281
}
290282

291-
struct rust_fn {
292-
uintptr_t *thunk;
293-
rust_box *closure;
294-
};
295-
296283
extern "C" CDECL void
297-
debug_fn(type_desc *t, rust_fn *fn) {
284+
debug_fn(type_desc *t, fn_env_pair *fn) {
298285
rust_task *task = rust_get_current_task();
299286
LOG(task, stdlib, "debug_fn");
300287
debug_tydesc_helper(t);
301-
LOG(task, stdlib, " thunk at 0x%" PRIxPTR, fn->thunk);
302-
LOG(task, stdlib, " closure at 0x%" PRIxPTR, fn->closure);
303-
if (fn->closure) {
304-
LOG(task, stdlib, " refcount %" PRIdPTR, fn->closure->ref_count);
288+
LOG(task, stdlib, " fn at 0x%" PRIxPTR, fn->f);
289+
LOG(task, stdlib, " env at 0x%" PRIxPTR, fn->env);
290+
if (fn->env) {
291+
LOG(task, stdlib, " refcount %" PRIdPTR, fn->env->ref_count);
305292
}
306293
}
307294

@@ -389,11 +376,6 @@ extern "C" CDECL FILE* rust_get_stdin() {return stdin;}
389376
extern "C" CDECL FILE* rust_get_stdout() {return stdout;}
390377
extern "C" CDECL FILE* rust_get_stderr() {return stderr;}
391378

392-
extern "C" CDECL int
393-
rust_ptr_eq(type_desc *t, rust_box *a, rust_box *b) {
394-
return a == b;
395-
}
396-
397379
#if defined(__WIN32__)
398380
extern "C" CDECL void
399381
get_time(int64_t *sec, int32_t *nsec) {

src/rt/rust_refcount.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@
1717
// Refcounting defines
1818
typedef unsigned long ref_cnt_t;
1919

20-
#define RUST_REFCOUNTED(T) \
21-
RUST_REFCOUNTED_WITH_DTOR(T, delete (T*)this)
22-
23-
#define RUST_REFCOUNTED_WITH_DTOR(T, dtor) \
24-
intptr_t ref_count; \
25-
void ref() { ++ref_count; } \
26-
void deref() { if (--ref_count == 0) { dtor; } }
27-
2820
#define RUST_ATOMIC_REFCOUNT() \
2921
private: \
3022
intptr_t ref_count; \

src/rt/rust_task.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@
168168
#define RED_ZONE_SIZE RZ_MAC_32
169169
#endif
170170

171-
struct rust_box;
172-
173171
struct frame_glue_fns {
174172
uintptr_t mark_glue_off;
175173
uintptr_t drop_glue_off;

src/rt/rustrt.def.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ rust_list_files2
3939
rust_log_console_on
4040
rust_log_console_off
4141
rust_process_wait
42-
rust_ptr_eq
4342
rust_run_program
4443
rust_sched_current_nonlazy_threads
4544
rust_sched_threads

0 commit comments

Comments
 (0)