Skip to content

Commit bcb9269

Browse files
committed
rt: cleanup passing around of rust_env
1 parent bee45f0 commit bcb9269

File tree

6 files changed

+7
-11
lines changed

6 files changed

+7
-11
lines changed

Diff for: src/rt/rust_kernel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
rust_kernel::rust_kernel(rust_env *env) :
1313
_region(env, true),
14-
_log(env, NULL),
14+
_log(NULL),
1515
max_task_id(0),
1616
max_port_id(0),
1717
rval(0),

Diff for: src/rt/rust_log.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ log_console_off(rust_env *env) {
4040
}
4141
}
4242

43-
rust_log::rust_log(rust_env *env, rust_sched_loop *sched_loop) :
44-
_env(env),
43+
rust_log::rust_log(rust_sched_loop *sched_loop) :
4544
_sched_loop(sched_loop) {
4645
}
4746

Diff for: src/rt/rust_log.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ struct rust_task;
4040
class rust_log {
4141

4242
public:
43-
rust_log(rust_env *env, rust_sched_loop *sched_loop);
43+
rust_log(rust_sched_loop *sched_loop);
4444
virtual ~rust_log();
4545

4646
void trace_ln(rust_task *task, uint32_t level, char *message);
4747
void trace_ln(char *prefix, char *message);
4848
bool is_tracing(uint32_t type_bits);
4949

5050
private:
51-
rust_env *_env;
5251
rust_sched_loop *_sched_loop;
5352
bool _use_labels;
5453
void trace_ln(rust_task *task, char *message);

Diff for: src/rt/rust_sched_loop.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const size_t C_STACK_SIZE = 1024*1024;
1818
bool rust_sched_loop::tls_initialized = false;
1919

2020
rust_sched_loop::rust_sched_loop(rust_scheduler *sched,int id) :
21-
_log(env, this),
21+
_log(this),
2222
id(id),
2323
should_exit(false),
2424
cached_c_stack(NULL),
@@ -28,8 +28,7 @@ rust_sched_loop::rust_sched_loop(rust_scheduler *sched,int id) :
2828
sched(sched),
2929
log_lvl(log_debug),
3030
min_stack_size(kernel->env->min_stack_size),
31-
env(kernel->env),
32-
local_region(env, false),
31+
local_region(kernel->env, false),
3332
// TODO: calculate a per scheduler name.
3433
name("main")
3534
{
@@ -277,7 +276,7 @@ rust_sched_loop::create_task(rust_task *spawner, const char *name) {
277276
rust_task *task =
278277
new (this->kernel, "rust_task")
279278
rust_task (this, task_state_newborn,
280-
spawner, name, env->min_stack_size);
279+
spawner, name, kernel->env->min_stack_size);
281280
DLOG(this, task, "created task: " PTR ", spawner: %s, name: %s",
282281
task, spawner ? spawner->name : "null", name);
283282

Diff for: src/rt/rust_sched_loop.h

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ struct rust_sched_loop
7979
uint32_t log_lvl;
8080

8181
size_t min_stack_size;
82-
rust_env *env;
8382
memory_region local_region;
8483

8584
randctx rctx;

Diff for: src/rt/rust_task.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ rust_task::new_stack(size_t requested_sz) {
513513
size_t rust_stk_sz = get_next_stack_size(min_sz,
514514
current_sz, requested_sz);
515515

516-
if (total_stack_sz + rust_stk_sz > sched_loop->env->max_stack_size) {
516+
if (total_stack_sz + rust_stk_sz > kernel->env->max_stack_size) {
517517
LOG_ERR(this, task, "task %" PRIxPTR " ran out of stack", this);
518518
fail();
519519
}

0 commit comments

Comments
 (0)