Skip to content

Commit f8fb399

Browse files
committed
---
yaml --- r: 2150 b: refs/heads/master c: 880be6a h: refs/heads/master v: v3
1 parent b051d0d commit f8fb399

25 files changed

+464
-638
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 6511d471bafd446026462ce0dba8ef5e2ebf462f
2+
refs/heads/master: 880be6a94013ba0b7791b0ca1b6e16104f2f0a1c

trunk/src/boot/me/trans.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,12 +2664,12 @@ let trans_visitor
26642664
nabi_rust (upcall_fixup name) args);
26652665

26662666
and trans_log_int lev (a:Ast.atom) : unit =
2667-
trans_void_upcall "upcall_log_int" [| simm (Int64.of_int lev);
2668-
trans_atom a |]
2667+
trans_void_upcall "upcall_log_int_rustboot" [| simm (Int64.of_int lev);
2668+
trans_atom a |]
26692669

26702670
and trans_log_str lev (a:Ast.atom) : unit =
2671-
trans_void_upcall "upcall_log_str" [| simm (Int64.of_int lev);
2672-
trans_atom a |]
2671+
trans_void_upcall "upcall_log_str_rustboot" [| simm (Int64.of_int lev);
2672+
trans_atom a |]
26732673

26742674
and trans_spawn
26752675
((*initializing*)_:bool)

trunk/src/rt/circular_buffer.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@ circular_buffer::circular_buffer(rust_dom *dom, size_t unit_sz) :
1414

1515
A(dom, unit_sz, "Unit size must be larger than zero.");
1616

17-
DLOG(dom, rust_log::MEM | rust_log::COMM,
18-
"new circular_buffer(buffer_sz=%d, unread=%d)"
19-
"-> circular_buffer=0x%" PRIxPTR,
20-
_buffer_sz, _unread, this);
17+
DLOG(dom, mem, "new circular_buffer(buffer_sz=%d, unread=%d)"
18+
"-> circular_buffer=0x%" PRIxPTR,
19+
_buffer_sz, _unread, this);
2120

2221
A(dom, _buffer, "Failed to allocate buffer.");
2322
}
2423

2524
circular_buffer::~circular_buffer() {
26-
DLOG(dom, rust_log::MEM, "~circular_buffer 0x%" PRIxPTR, this);
25+
DLOG(dom, mem, "~circular_buffer 0x%" PRIxPTR, this);
2726
I(dom, _buffer);
2827
W(dom, _unread == 0,
2928
"freeing circular_buffer with %d unread bytes", _unread);
@@ -79,10 +78,9 @@ circular_buffer::enqueue(void *src) {
7978
grow();
8079
}
8180

82-
DLOG(dom, rust_log::MEM | rust_log::COMM,
83-
"circular_buffer enqueue "
84-
"unread: %d, next: %d, buffer_sz: %d, unit_sz: %d",
85-
_unread, _next, _buffer_sz, unit_sz);
81+
DLOG(dom, mem, "circular_buffer enqueue "
82+
"unread: %d, next: %d, buffer_sz: %d, unit_sz: %d",
83+
_unread, _next, _buffer_sz, unit_sz);
8684

8785
I(dom, _unread < _buffer_sz);
8886
I(dom, _unread + unit_sz <= _buffer_sz);
@@ -101,8 +99,7 @@ circular_buffer::enqueue(void *src) {
10199
memcpy(&_buffer[dst_idx], src, unit_sz);
102100
_unread += unit_sz;
103101

104-
DLOG(dom, rust_log::MEM | rust_log::COMM,
105-
"circular_buffer pushed data at index: %d", dst_idx);
102+
DLOG(dom, mem, "circular_buffer pushed data at index: %d", dst_idx);
106103
}
107104

108105
/**
@@ -117,7 +114,7 @@ circular_buffer::dequeue(void *dst) {
117114
I(dom, _unread <= _buffer_sz);
118115
I(dom, _buffer);
119116

120-
DLOG(dom, rust_log::MEM | rust_log::COMM,
117+
DLOG(dom, mem,
121118
"circular_buffer dequeue "
122119
"unread: %d, next: %d, buffer_sz: %d, unit_sz: %d",
123120
_unread, _next, _buffer_sz, unit_sz);
@@ -126,8 +123,7 @@ circular_buffer::dequeue(void *dst) {
126123
if (dst != NULL) {
127124
memcpy(dst, &_buffer[_next], unit_sz);
128125
}
129-
DLOG(dom, rust_log::MEM | rust_log::COMM,
130-
"shifted data from index %d", _next);
126+
DLOG(dom, mem, "shifted data from index %d", _next);
131127
_unread -= unit_sz;
132128
_next += unit_sz;
133129
if (_next == _buffer_sz) {
@@ -144,8 +140,7 @@ void
144140
circular_buffer::grow() {
145141
size_t new_buffer_sz = _buffer_sz * 2;
146142
I(dom, new_buffer_sz <= MAX_CIRCULAR_BUFFER_SIZE);
147-
DLOG(dom, rust_log::MEM | rust_log::COMM,
148-
"circular_buffer is growing to %d bytes", new_buffer_sz);
143+
DLOG(dom, mem, "circular_buffer is growing to %d bytes", new_buffer_sz);
149144
void *new_buffer = dom->malloc(new_buffer_sz);
150145
transfer(new_buffer);
151146
dom->free(_buffer);
@@ -158,8 +153,7 @@ void
158153
circular_buffer::shrink() {
159154
size_t new_buffer_sz = _buffer_sz / 2;
160155
I(dom, initial_size() <= new_buffer_sz);
161-
DLOG(dom, rust_log::MEM | rust_log::COMM,
162-
"circular_buffer is shrinking to %d bytes", new_buffer_sz);
156+
DLOG(dom, mem, "circular_buffer is shrinking to %d bytes", new_buffer_sz);
163157
void *new_buffer = dom->malloc(new_buffer_sz);
164158
transfer(new_buffer);
165159
dom->free(_buffer);

trunk/src/rt/rust.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,22 @@ rust_start(uintptr_t main_fn, rust_crate const *crate, int argc,
8282

8383
if (crate->abi_tag != ABI_X86_RUSTBOOT_CDECL)
8484
update_log_settings(crate_map, getenv("RUST_LOG"));
85+
else
86+
update_log_settings(NULL, getenv("RUST_LOG"));
8587
rust_srv *srv = new rust_srv();
8688
rust_kernel *kernel = new rust_kernel(srv);
8789
kernel->start();
8890
rust_handle<rust_dom> *handle = kernel->create_domain(crate, "main");
8991
rust_dom *dom = handle->referent();
9092
command_line_args *args = new (dom) command_line_args(dom, argc, argv);
9193

92-
DLOG(dom, rust_log::DOM, "startup: %d args in 0x%" PRIxPTR,
94+
DLOG(dom, dom, "startup: %d args in 0x%" PRIxPTR,
9395
args->argc, (uintptr_t)args->args);
9496
for (int i = 0; i < args->argc; i++) {
95-
DLOG(dom, rust_log::DOM,
96-
"startup: arg[%d] = '%s'", i, args->argv[i]);
97+
DLOG(dom, dom, "startup: arg[%d] = '%s'", i, args->argv[i]);
9798
}
9899

99-
if (dom->_log.is_tracing(rust_log::DWARF)) {
100+
if (log_rt_dwarf) {
100101
rust_crate_reader create_reader(dom, crate);
101102
}
102103

trunk/src/rt/rust_builtin.cpp

Lines changed: 52 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
extern "C" CDECL rust_str*
77
last_os_error(rust_task *task) {
88
rust_dom *dom = task->dom;
9-
LOG(task, rust_log::TASK, "last_os_error()");
9+
LOG(task, task, "last_os_error()");
1010

1111
#if defined(__WIN32__)
1212
LPTSTR buf;
@@ -91,9 +91,8 @@ extern "C" CDECL rust_vec*
9191
vec_alloc(rust_task *task, type_desc *t, type_desc *elem_t, size_t n_elts)
9292
{
9393
rust_dom *dom = task->dom;
94-
LOG(task, rust_log::MEM | rust_log::STDLIB,
95-
"vec_alloc %" PRIdPTR " elements of size %" PRIdPTR,
96-
n_elts, elem_t->size);
94+
LOG(task, mem, "vec_alloc %" PRIdPTR " elements of size %" PRIdPTR,
95+
n_elts, elem_t->size);
9796
size_t fill = n_elts * elem_t->size;
9897
size_t alloc = next_power_of_two(sizeof(rust_vec) + fill);
9998
void *mem = task->malloc(alloc, t->is_stateful ? t : NULL);
@@ -126,37 +125,34 @@ vec_len(rust_task *task, type_desc *ty, rust_vec *v)
126125
extern "C" CDECL void
127126
vec_len_set(rust_task *task, type_desc *ty, rust_vec *v, size_t len)
128127
{
129-
LOG(task, rust_log::STDLIB,
130-
"vec_len_set(0x%" PRIxPTR ", %" PRIdPTR ") on vec with "
131-
"alloc = %" PRIdPTR
132-
", fill = %" PRIdPTR
133-
", len = %" PRIdPTR
134-
". New fill is %" PRIdPTR,
135-
v, len, v->alloc, v->fill, v->fill / ty->size, len * ty->size);
128+
LOG(task, stdlib, "vec_len_set(0x%" PRIxPTR ", %" PRIdPTR ") on vec with "
129+
"alloc = %" PRIdPTR
130+
", fill = %" PRIdPTR
131+
", len = %" PRIdPTR
132+
". New fill is %" PRIdPTR,
133+
v, len, v->alloc, v->fill, v->fill / ty->size, len * ty->size);
136134
v->fill = len * ty->size;
137135
}
138136

139137
extern "C" CDECL void
140138
vec_print_debug_info(rust_task *task, type_desc *ty, rust_vec *v)
141139
{
142-
LOG(task, rust_log::STDLIB,
143-
"vec_print_debug_info(0x%" PRIxPTR ")"
144-
" with tydesc 0x%" PRIxPTR
145-
" (size = %" PRIdPTR ", align = %" PRIdPTR ")"
146-
" alloc = %" PRIdPTR ", fill = %" PRIdPTR ", len = %" PRIdPTR
147-
" , data = ...",
148-
v,
149-
ty,
150-
ty->size,
151-
ty->align,
152-
v->alloc,
153-
v->fill,
154-
v->fill / ty->size);
140+
LOG(task, stdlib,
141+
"vec_print_debug_info(0x%" PRIxPTR ")"
142+
" with tydesc 0x%" PRIxPTR
143+
" (size = %" PRIdPTR ", align = %" PRIdPTR ")"
144+
" alloc = %" PRIdPTR ", fill = %" PRIdPTR ", len = %" PRIdPTR
145+
" , data = ...",
146+
v,
147+
ty,
148+
ty->size,
149+
ty->align,
150+
v->alloc,
151+
v->fill,
152+
v->fill / ty->size);
155153

156154
for (size_t i = 0; i < v->fill; ++i) {
157-
LOG(task, rust_log::STDLIB,
158-
" %" PRIdPTR ": 0x%" PRIxPTR,
159-
i, v->data[i]);
155+
LOG(task, stdlib, " %" PRIdPTR ": 0x%" PRIxPTR, i, v->data[i]);
160156
}
161157
}
162158

@@ -306,29 +302,27 @@ task_sleep(rust_task *task, size_t time_in_us) {
306302
static void
307303
debug_tydesc_helper(rust_task *task, type_desc *t)
308304
{
309-
LOG(task, rust_log::STDLIB,
310-
" size %" PRIdPTR ", align %" PRIdPTR
311-
", stateful %" PRIdPTR ", first_param 0x%" PRIxPTR,
312-
t->size, t->align, t->is_stateful, t->first_param);
305+
LOG(task, stdlib, " size %" PRIdPTR ", align %" PRIdPTR
306+
", stateful %" PRIdPTR ", first_param 0x%" PRIxPTR,
307+
t->size, t->align, t->is_stateful, t->first_param);
313308
}
314309

315310
extern "C" CDECL void
316311
debug_tydesc(rust_task *task, type_desc *t)
317312
{
318-
LOG(task, rust_log::STDLIB, "debug_tydesc");
313+
LOG(task, stdlib, "debug_tydesc");
319314
debug_tydesc_helper(task, t);
320315
}
321316

322317
extern "C" CDECL void
323318
debug_opaque(rust_task *task, type_desc *t, uint8_t *front)
324319
{
325-
LOG(task, rust_log::STDLIB, "debug_opaque");
320+
LOG(task, stdlib, "debug_opaque");
326321
debug_tydesc_helper(task, t);
327322
// FIXME may want to actually account for alignment. `front` may not
328323
// indeed be the front byte of the passed-in argument.
329324
for (uintptr_t i = 0; i < t->size; ++front, ++i) {
330-
LOG(task, rust_log::STDLIB,
331-
" byte %" PRIdPTR ": 0x%" PRIx8, i, *front);
325+
LOG(task, stdlib, " byte %" PRIdPTR ": 0x%" PRIx8, i, *front);
332326
}
333327
}
334328

@@ -340,15 +334,14 @@ struct rust_box : rc_base<rust_box> {
340334
extern "C" CDECL void
341335
debug_box(rust_task *task, type_desc *t, rust_box *box)
342336
{
343-
LOG(task, rust_log::STDLIB, "debug_box(0x%" PRIxPTR ")", box);
337+
LOG(task, stdlib, "debug_box(0x%" PRIxPTR ")", box);
344338
debug_tydesc_helper(task, t);
345-
LOG(task, rust_log::STDLIB, " refcount %" PRIdPTR,
346-
box->ref_count == CONST_REFCOUNT
347-
? CONST_REFCOUNT
348-
: box->ref_count - 1); // -1 because we ref'ed for this call
339+
LOG(task, stdlib, " refcount %" PRIdPTR,
340+
box->ref_count == CONST_REFCOUNT
341+
? CONST_REFCOUNT
342+
: box->ref_count - 1); // -1 because we ref'ed for this call
349343
for (uintptr_t i = 0; i < t->size; ++i) {
350-
LOG(task, rust_log::STDLIB,
351-
" byte %" PRIdPTR ": 0x%" PRIx8, i, box->data[i]);
344+
LOG(task, stdlib, " byte %" PRIdPTR ": 0x%" PRIx8, i, box->data[i]);
352345
}
353346
}
354347

@@ -360,14 +353,13 @@ struct rust_tag {
360353
extern "C" CDECL void
361354
debug_tag(rust_task *task, type_desc *t, rust_tag *tag)
362355
{
363-
LOG(task, rust_log::STDLIB, "debug_tag");
356+
LOG(task, stdlib, "debug_tag");
364357
debug_tydesc_helper(task, t);
365-
LOG(task, rust_log::STDLIB,
366-
" discriminant %" PRIdPTR, tag->discriminant);
358+
LOG(task, stdlib, " discriminant %" PRIdPTR, tag->discriminant);
367359

368360
for (uintptr_t i = 0; i < t->size - sizeof(tag->discriminant); ++i)
369-
LOG(task, rust_log::STDLIB,
370-
" byte %" PRIdPTR ": 0x%" PRIx8, i, tag->variant[i]);
361+
LOG(task, stdlib, " byte %" PRIdPTR ": 0x%" PRIx8, i,
362+
tag->variant[i]);
371363
}
372364

373365
struct rust_obj {
@@ -379,19 +371,17 @@ extern "C" CDECL void
379371
debug_obj(rust_task *task, type_desc *t, rust_obj *obj,
380372
size_t nmethods, size_t nbytes)
381373
{
382-
LOG(task, rust_log::STDLIB,
383-
"debug_obj with %" PRIdPTR " methods", nmethods);
374+
LOG(task, stdlib, "debug_obj with %" PRIdPTR " methods", nmethods);
384375
debug_tydesc_helper(task, t);
385-
LOG(task, rust_log::STDLIB, " vtbl at 0x%" PRIxPTR, obj->vtbl);
386-
LOG(task, rust_log::STDLIB, " body at 0x%" PRIxPTR, obj->body);
376+
LOG(task, stdlib, " vtbl at 0x%" PRIxPTR, obj->vtbl);
377+
LOG(task, stdlib, " body at 0x%" PRIxPTR, obj->body);
387378

388379
for (uintptr_t *p = obj->vtbl; p < obj->vtbl + nmethods; ++p)
389-
LOG(task, rust_log::STDLIB, " vtbl word: 0x%" PRIxPTR, *p);
380+
LOG(task, stdlib, " vtbl word: 0x%" PRIxPTR, *p);
390381

391382
for (uintptr_t i = 0; i < nbytes; ++i)
392-
LOG(task, rust_log::STDLIB,
393-
" body byte %" PRIdPTR ": 0x%" PRIxPTR,
394-
i, obj->body->data[i]);
383+
LOG(task, stdlib, " body byte %" PRIdPTR ": 0x%" PRIxPTR,
384+
i, obj->body->data[i]);
395385
}
396386

397387
struct rust_fn {
@@ -402,13 +392,12 @@ struct rust_fn {
402392
extern "C" CDECL void
403393
debug_fn(rust_task *task, type_desc *t, rust_fn *fn)
404394
{
405-
LOG(task, rust_log::STDLIB, "debug_fn");
395+
LOG(task, stdlib, "debug_fn");
406396
debug_tydesc_helper(task, t);
407-
LOG(task, rust_log::STDLIB, " thunk at 0x%" PRIxPTR, fn->thunk);
408-
LOG(task, rust_log::STDLIB, " closure at 0x%" PRIxPTR, fn->closure);
397+
LOG(task, stdlib, " thunk at 0x%" PRIxPTR, fn->thunk);
398+
LOG(task, stdlib, " closure at 0x%" PRIxPTR, fn->closure);
409399
if (fn->closure) {
410-
LOG(task, rust_log::STDLIB, " refcount %" PRIdPTR,
411-
fn->closure->ref_count);
400+
LOG(task, stdlib, " refcount %" PRIdPTR, fn->closure->ref_count);
412401
}
413402
}
414403

@@ -418,17 +407,17 @@ debug_ptrcast(rust_task *task,
418407
type_desc *to_ty,
419408
void *ptr)
420409
{
421-
LOG(task, rust_log::STDLIB, "debug_ptrcast from");
410+
LOG(task, stdlib, "debug_ptrcast from");
422411
debug_tydesc_helper(task, from_ty);
423-
LOG(task, rust_log::STDLIB, "to");
412+
LOG(task, stdlib, "to");
424413
debug_tydesc_helper(task, to_ty);
425414
return ptr;
426415
}
427416

428417
extern "C" CDECL void
429418
debug_trap(rust_task *task, rust_str *s)
430419
{
431-
LOG(task, rust_log::STDLIB, "trapping: %s", s->data);
420+
LOG(task, stdlib, "trapping: %s", s->data);
432421
// FIXME: x86-ism.
433422
__asm__("int3");
434423
}

trunk/src/rt/rust_chan.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ rust_chan::rust_chan(rust_task *task,
1313
if (port) {
1414
associate(port);
1515
}
16-
LOG(task, rust_log::MEM | rust_log::COMM,
17-
"new rust_chan(task=0x%" PRIxPTR
18-
", port=0x%" PRIxPTR ") -> chan=0x%" PRIxPTR,
19-
(uintptr_t) task, (uintptr_t) port, (uintptr_t) this);
16+
LOG(task, comm, "new rust_chan(task=0x%" PRIxPTR
17+
", port=0x%" PRIxPTR ") -> chan=0x%" PRIxPTR,
18+
(uintptr_t) task, (uintptr_t) port, (uintptr_t) this);
2019
}
2120

2221
rust_chan::~rust_chan() {
23-
LOG(task, rust_log::MEM | rust_log::COMM,
24-
"del rust_chan(task=0x%" PRIxPTR ")", (uintptr_t) this);
22+
LOG(task, comm, "del rust_chan(task=0x%" PRIxPTR ")", (uintptr_t) this);
2523

2624
A(task->dom, is_associated() == false,
2725
"Channel must be disassociated before being freed.");
@@ -33,7 +31,7 @@ rust_chan::~rust_chan() {
3331
void rust_chan::associate(maybe_proxy<rust_port> *port) {
3432
this->port = port;
3533
if (port->is_proxy() == false) {
36-
LOG(task, rust_log::TASK,
34+
LOG(task, task,
3735
"associating chan: 0x%" PRIxPTR " with port: 0x%" PRIxPTR,
3836
this, port);
3937
this->port->referent()->chans.push(this);
@@ -51,7 +49,7 @@ void rust_chan::disassociate() {
5149
A(task->dom, is_associated(), "Channel must be associated with a port.");
5250

5351
if (port->is_proxy() == false) {
54-
LOG(task, rust_log::TASK,
52+
LOG(task, task,
5553
"disassociating chan: 0x%" PRIxPTR " from port: 0x%" PRIxPTR,
5654
this, port->referent());
5755
port->referent()->chans.swap_delete(this);
@@ -84,7 +82,7 @@ void rust_chan::send(void *sptr) {
8482
} else {
8583
rust_port *target_port = port->referent();
8684
if (target_port->task->blocked_on(target_port)) {
87-
DLOG(dom, rust_log::COMM, "dequeued in rendezvous_ptr");
85+
DLOG(dom, comm, "dequeued in rendezvous_ptr");
8886
buffer.dequeue(target_port->task->rendezvous_ptr);
8987
target_port->task->rendezvous_ptr = 0;
9088
target_port->task->wakeup(target_port);

0 commit comments

Comments
 (0)