Skip to content

Commit c6ba3fc

Browse files
committed
---
yaml --- r: 12264 b: refs/heads/master c: 413994e h: refs/heads/master v: v3
1 parent 722f126 commit c6ba3fc

17 files changed

+120
-213
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3654ef00782cf9708196fd438ee08c751a5b699b
2+
refs/heads/master: 413994ea3eed976a6fe97f3d6cfeb0c2f453e77f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rt/circular_buffer.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ circular_buffer::circular_buffer(rust_kernel *kernel, size_t unit_sz) :
1212
_unread(0),
1313
_buffer((uint8_t *)kernel->malloc(_buffer_sz, "circular_buffer")) {
1414

15-
A(kernel, unit_sz, "Unit size must be larger than zero.");
15+
assert(unit_sz && "Unit size must be larger than zero.");
1616

1717
KLOG(kernel, mem, "new circular_buffer(buffer_sz=%d, unread=%d)"
1818
"-> circular_buffer=0x%" PRIxPTR,
1919
_buffer_sz, _unread, this);
2020

21-
A(kernel, _buffer, "Failed to allocate buffer.");
21+
assert(_buffer && "Failed to allocate buffer.");
2222
}
2323

2424
circular_buffer::~circular_buffer() {
2525
KLOG(kernel, mem, "~circular_buffer 0x%" PRIxPTR, this);
26-
I(kernel, _buffer);
26+
assert(_buffer);
2727
W(kernel, _unread == 0,
2828
"freeing circular_buffer with %d unread bytes", _unread);
2929
kernel->free(_buffer);
3030
}
3131

3232
size_t
3333
circular_buffer::initial_size() {
34-
I(kernel, unit_sz > 0);
34+
assert(unit_sz > 0);
3535
return INITIAL_CIRCULAR_BUFFER_SIZE_IN_UNITS * unit_sz;
3636
}
3737

@@ -40,8 +40,8 @@ circular_buffer::initial_size() {
4040
*/
4141
void
4242
circular_buffer::transfer(void *dst) {
43-
I(kernel, dst);
44-
I(kernel, _unread <= _buffer_sz);
43+
assert(dst);
44+
assert(_unread <= _buffer_sz);
4545

4646
uint8_t *ptr = (uint8_t *) dst;
4747

@@ -53,13 +53,13 @@ circular_buffer::transfer(void *dst) {
5353
} else {
5454
head_sz = _buffer_sz - _next;
5555
}
56-
I(kernel, _next + head_sz <= _buffer_sz);
56+
assert(_next + head_sz <= _buffer_sz);
5757
memcpy(ptr, _buffer + _next, head_sz);
5858

5959
// Then copy any other items from the beginning of the buffer
60-
I(kernel, _unread >= head_sz);
60+
assert(_unread >= head_sz);
6161
size_t tail_sz = _unread - head_sz;
62-
I(kernel, head_sz + tail_sz <= _buffer_sz);
62+
assert(head_sz + tail_sz <= _buffer_sz);
6363
memcpy(ptr + head_sz, _buffer, tail_sz);
6464
}
6565

@@ -69,9 +69,9 @@ circular_buffer::transfer(void *dst) {
6969
*/
7070
void
7171
circular_buffer::enqueue(void *src) {
72-
I(kernel, src);
73-
I(kernel, _unread <= _buffer_sz);
74-
I(kernel, _buffer);
72+
assert(src);
73+
assert(_unread <= _buffer_sz);
74+
assert(_buffer);
7575

7676
// Grow if necessary.
7777
if (_unread == _buffer_sz) {
@@ -82,20 +82,20 @@ circular_buffer::enqueue(void *src) {
8282
"unread: %d, next: %d, buffer_sz: %d, unit_sz: %d",
8383
_unread, _next, _buffer_sz, unit_sz);
8484

85-
I(kernel, _unread < _buffer_sz);
86-
I(kernel, _unread + unit_sz <= _buffer_sz);
85+
assert(_unread < _buffer_sz);
86+
assert(_unread + unit_sz <= _buffer_sz);
8787

8888
// Copy data
8989
size_t dst_idx = _next + _unread;
90-
I(kernel, dst_idx >= _buffer_sz || dst_idx + unit_sz <= _buffer_sz);
90+
assert(dst_idx >= _buffer_sz || dst_idx + unit_sz <= _buffer_sz);
9191
if (dst_idx >= _buffer_sz) {
9292
dst_idx -= _buffer_sz;
9393

94-
I(kernel, _next >= unit_sz);
95-
I(kernel, dst_idx <= _next - unit_sz);
94+
assert(_next >= unit_sz);
95+
assert(dst_idx <= _next - unit_sz);
9696
}
9797

98-
I(kernel, dst_idx + unit_sz <= _buffer_sz);
98+
assert(dst_idx + unit_sz <= _buffer_sz);
9999
memcpy(&_buffer[dst_idx], src, unit_sz);
100100
_unread += unit_sz;
101101

@@ -109,17 +109,17 @@ circular_buffer::enqueue(void *src) {
109109
*/
110110
void
111111
circular_buffer::dequeue(void *dst) {
112-
I(kernel, unit_sz > 0);
113-
I(kernel, _unread >= unit_sz);
114-
I(kernel, _unread <= _buffer_sz);
115-
I(kernel, _buffer);
112+
assert(unit_sz > 0);
113+
assert(_unread >= unit_sz);
114+
assert(_unread <= _buffer_sz);
115+
assert(_buffer);
116116

117117
KLOG(kernel, mem,
118118
"circular_buffer dequeue "
119119
"unread: %d, next: %d, buffer_sz: %d, unit_sz: %d",
120120
_unread, _next, _buffer_sz, unit_sz);
121121

122-
I(kernel, _next + unit_sz <= _buffer_sz);
122+
assert(_next + unit_sz <= _buffer_sz);
123123
if (dst != NULL) {
124124
memcpy(dst, &_buffer[_next], unit_sz);
125125
}
@@ -153,7 +153,7 @@ circular_buffer::grow() {
153153
void
154154
circular_buffer::shrink() {
155155
size_t new_buffer_sz = _buffer_sz / 2;
156-
I(kernel, initial_size() <= new_buffer_sz);
156+
assert(initial_size() <= new_buffer_sz);
157157
KLOG(kernel, mem, "circular_buffer is shrinking to %d bytes",
158158
new_buffer_sz);
159159
void *new_buffer = kernel->malloc(new_buffer_sz,

trunk/src/rt/memory_region.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void memory_region::free(void *mem) {
5555
# endif
5656

5757
if (_live_allocations < 1) {
58-
_srv->fatal("live_allocs < 1", __FILE__, __LINE__, "");
58+
assert(false && "live_allocs < 1");
5959
}
6060
release_alloc(mem);
6161
maybe_poison(mem);
@@ -88,7 +88,7 @@ memory_region::realloc(void *mem, size_t orig_size) {
8888
alloc->index, _allocation_list[alloc->index], alloc);
8989
printf("realloc: ptr 0x%" PRIxPTR " (%s) is not in allocation_list\n",
9090
(uintptr_t) get_data(alloc), alloc->tag);
91-
_srv->fatal("not in allocation_list", __FILE__, __LINE__, "");
91+
assert(false && "not in allocation_list");
9292
}
9393
else {
9494
_allocation_list[newMem->index] = newMem;
@@ -166,8 +166,8 @@ memory_region::~memory_region() {
166166
# endif
167167

168168
if (_live_allocations > 0) {
169-
_srv->fatal(msg, __FILE__, __LINE__,
170-
"%d objects", _live_allocations);
169+
fprintf(stderr, "%s\n", msg);
170+
assert(false);
171171
}
172172
if (_synchronized) { _lock.unlock(); }
173173
}
@@ -184,7 +184,7 @@ memory_region::release_alloc(void *mem) {
184184
if (_allocation_list[alloc->index] != alloc) {
185185
printf("free: ptr 0x%" PRIxPTR " (%s) is not in allocation_list\n",
186186
(uintptr_t) get_data(alloc), alloc->tag);
187-
_srv->fatal("not in allocation_list", __FILE__, __LINE__, "");
187+
assert(false && "not in allocation_list");
188188
}
189189
else {
190190
// printf("freed index %d\n", index);

trunk/src/rt/rust_builtin.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,7 @@ rust_get_sched_id() {
450450
extern "C" CDECL rust_sched_id
451451
rust_new_sched(uintptr_t threads) {
452452
rust_task *task = rust_sched_loop::get_task();
453-
A(task->sched_loop, threads > 0,
454-
"Can't create a scheduler with no threads, silly!");
453+
assert(threads > 0 && "Can't create a scheduler with no threads, silly!");
455454
return task->kernel->create_scheduler(threads);
456455
}
457456

@@ -606,36 +605,31 @@ rust_dbg_lock_create() {
606605

607606
extern "C" CDECL void
608607
rust_dbg_lock_destroy(lock_and_signal *lock) {
609-
rust_task *task = rust_sched_loop::get_task();
610-
I(task->sched_loop, lock);
608+
assert(lock);
611609
delete lock;
612610
}
613611

614612
extern "C" CDECL void
615613
rust_dbg_lock_lock(lock_and_signal *lock) {
616-
rust_task *task = rust_sched_loop::get_task();
617-
I(task->sched_loop, lock);
614+
assert(lock);
618615
lock->lock();
619616
}
620617

621618
extern "C" CDECL void
622619
rust_dbg_lock_unlock(lock_and_signal *lock) {
623-
rust_task *task = rust_sched_loop::get_task();
624-
I(task->sched_loop, lock);
620+
assert(lock);
625621
lock->unlock();
626622
}
627623

628624
extern "C" CDECL void
629625
rust_dbg_lock_wait(lock_and_signal *lock) {
630-
rust_task *task = rust_sched_loop::get_task();
631-
I(task->sched_loop, lock);
626+
assert(lock);
632627
lock->wait();
633628
}
634629

635630
extern "C" CDECL void
636631
rust_dbg_lock_signal(lock_and_signal *lock) {
637-
rust_task *task = rust_sched_loop::get_task();
638-
I(task->sched_loop, lock);
632+
assert(lock);
639633
lock->signal();
640634
}
641635

trunk/src/rt/rust_internal.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@ typedef intptr_t rust_sched_id;
2424
typedef intptr_t rust_task_id;
2525
typedef intptr_t rust_port_id;
2626

27-
#define I(dom, e) ((e) ? (void)0 : \
28-
(dom)->srv->fatal(#e, __FILE__, __LINE__, ""))
29-
30-
#define W(dom, e, s, ...) ((e) ? (void)0 : \
31-
(dom)->srv->warning(#e, __FILE__, __LINE__, s, ## __VA_ARGS__))
32-
33-
#define A(dom, e, s, ...) ((e) ? (void)0 : \
34-
(dom)->srv->fatal(#e, __FILE__, __LINE__, s, ## __VA_ARGS__))
35-
36-
#define K(srv, e, s, ...) ((e) ? (void)0 : \
37-
srv->fatal(#e, __FILE__, __LINE__, s, ## __VA_ARGS__))
38-
3927
#define PTR "0x%" PRIxPTR
4028

4129
// This drives our preemption scheme.

trunk/src/rt/rust_kernel.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ rust_kernel::create_scheduler(size_t num_threads) {
6767
// the scheduler reaper.
6868
bool start_reaper = sched_table.empty();
6969
id = max_sched_id++;
70-
K(srv, id != INTPTR_MAX, "Hit the maximum scheduler id");
70+
assert(id != INTPTR_MAX && "Hit the maximum scheduler id");
7171
sched = new (this, "rust_scheduler")
72-
rust_scheduler(this, srv, num_threads, id, true);
72+
rust_scheduler(this, srv, num_threads, id);
7373
bool is_new = sched_table
7474
.insert(std::pair<rust_sched_id,
7575
rust_scheduler*>(id, sched)).second;
76-
A(this, is_new, "Reusing a sched id?");
76+
assert(is_new && "Reusing a sched id?");
7777
if (start_reaper) {
7878
sched_reaper.start();
7979
}
@@ -118,7 +118,7 @@ rust_kernel::wait_for_schedulers()
118118
rust_sched_id id = join_list.back();
119119
join_list.pop_back();
120120
sched_map::iterator iter = sched_table.find(id);
121-
I(this, iter != sched_table.end());
121+
assert(iter != sched_table.end());
122122
rust_scheduler *sched = iter->second;
123123
sched_table.erase(iter);
124124
sched->join_task_threads();
@@ -175,7 +175,7 @@ rust_kernel::fail() {
175175
rust_task_id
176176
rust_kernel::generate_task_id() {
177177
rust_task_id id = sync::increment(max_task_id);
178-
K(srv, id != INTPTR_MAX, "Hit the maximum task id");
178+
assert(id != INTPTR_MAX && "Hit the maximum task id");
179179
return id;
180180
}
181181

@@ -189,7 +189,7 @@ rust_kernel::register_port(rust_port *port) {
189189
port_table.put(new_port_id, port);
190190
new_live_ports = port_table.count();
191191
}
192-
K(srv, new_port_id != INTPTR_MAX, "Hit the maximum port id");
192+
assert(new_port_id != INTPTR_MAX && "Hit the maximum port id");
193193
KLOG_("Registered port %" PRIdPTR, new_port_id);
194194
KLOG_("Total outstanding ports: %d", new_live_ports);
195195
return new_port_id;
@@ -233,7 +233,7 @@ rust_kernel::win32_require(LPCTSTR fn, BOOL ok) {
233233
(LPTSTR) &buf, 0, NULL );
234234
KLOG_ERR_(dom, "%s failed with error %ld: %s", fn, err, buf);
235235
LocalFree((HLOCAL)buf);
236-
I(this, ok);
236+
assert(ok);
237237
}
238238
}
239239
#endif

trunk/src/rt/rust_port.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void rust_port::end_detach() {
5151
// Just take the lock to make sure that the thread that signaled
5252
// the detach_cond isn't still holding it
5353
scoped_lock with(ref_lock);
54-
I(task->sched_loop, ref_count == 0);
54+
assert(ref_count == 0);
5555
}
5656

5757
void rust_port::send(void *sptr) {
@@ -61,8 +61,8 @@ void rust_port::send(void *sptr) {
6161

6262
buffer.enqueue(sptr);
6363

64-
A(kernel, !buffer.is_empty(),
65-
"rust_chan::transmit with nothing to send.");
64+
assert(!buffer.is_empty() &&
65+
"rust_chan::transmit with nothing to send.");
6666

6767
if (task->blocked_on(this)) {
6868
KLOG(kernel, comm, "dequeued in rendezvous_ptr");

trunk/src/rt/rust_port_selector.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ rust_port_selector::select(rust_task *task, rust_port **dptr,
1010
rust_port **ports,
1111
size_t n_ports, uintptr_t *yield) {
1212

13-
I(task->sched_loop, this->ports == NULL);
14-
I(task->sched_loop, this->n_ports == 0);
15-
I(task->sched_loop, dptr != NULL);
16-
I(task->sched_loop, ports != NULL);
17-
I(task->sched_loop, n_ports != 0);
18-
I(task->sched_loop, yield != NULL);
13+
assert(this->ports == NULL);
14+
assert(this->n_ports == 0);
15+
assert(dptr != NULL);
16+
assert(ports != NULL);
17+
assert(n_ports != 0);
18+
assert(yield != NULL);
1919

2020
*yield = false;
2121
size_t locks_taken = 0;
@@ -31,7 +31,7 @@ rust_port_selector::select(rust_task *task, rust_port **dptr,
3131
for (size_t i = 0; i < n_ports; i++) {
3232
size_t k = (i + j) % n_ports;
3333
rust_port *port = ports[k];
34-
I(task->sched_loop, port != NULL);
34+
assert(port != NULL);
3535

3636
port->lock.lock();
3737
locks_taken++;
@@ -46,7 +46,7 @@ rust_port_selector::select(rust_task *task, rust_port **dptr,
4646
if (!found_msg) {
4747
this->ports = ports;
4848
this->n_ports = n_ports;
49-
I(task->sched_loop, task->rendezvous_ptr == NULL);
49+
assert(task->rendezvous_ptr == NULL);
5050
task->rendezvous_ptr = (uintptr_t*)dptr;
5151
task->block(this, "waiting for select rendezvous");
5252

trunk/src/rt/rust_sched_launcher.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,3 @@ rust_thread_sched_launcher::rust_thread_sched_launcher(rust_scheduler *sched,
1616
rust_thread(SCHED_STACK_SIZE) {
1717
}
1818

19-
rust_manual_sched_launcher::rust_manual_sched_launcher(rust_scheduler *sched,
20-
rust_srv *srv, int id)
21-
: rust_sched_launcher(sched, srv, id) {
22-
}
23-
24-
rust_sched_launcher *
25-
rust_thread_sched_launcher_factory::create(rust_scheduler *sched, int id) {
26-
rust_srv *srv = sched->srv->clone();
27-
return new(sched->kernel, "rust_thread_sched_launcher")
28-
rust_thread_sched_launcher(sched, srv, id);
29-
}
30-
31-
rust_sched_launcher *
32-
rust_manual_sched_launcher_factory::create(rust_scheduler *sched, int id) {
33-
assert(launcher == NULL && "I can only track one sched_launcher");
34-
rust_srv *srv = sched->srv->clone();
35-
return new(sched->kernel, "rust_manual_sched_launcher")
36-
rust_manual_sched_launcher(sched, srv, id);
37-
}

0 commit comments

Comments
 (0)