Removing the synchronized memory region from tasks.
This commit is contained in:
parent
a0f45f4456
commit
dcd2563a3a
@ -11,49 +11,23 @@ inline void *operator new(size_t size, rust_kernel *kernel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void *operator new(size_t size, rust_task *task) {
|
inline void *operator new(size_t size, rust_task *task) {
|
||||||
return task->malloc(size, memory_region::LOCAL);
|
return task->malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void *operator new[](size_t size, rust_task *task) {
|
inline void *operator new[](size_t size, rust_task *task) {
|
||||||
return task->malloc(size, memory_region::LOCAL);
|
return task->malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void *operator new(size_t size, rust_task &task) {
|
inline void *operator new(size_t size, rust_task &task) {
|
||||||
return task.malloc(size, memory_region::LOCAL);
|
return task.malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void *operator new[](size_t size, rust_task &task) {
|
inline void *operator new[](size_t size, rust_task &task) {
|
||||||
return task.malloc(size, memory_region::LOCAL);
|
return task.malloc(size);
|
||||||
}
|
|
||||||
|
|
||||||
inline void *operator new(size_t size, rust_task *task,
|
|
||||||
memory_region::memory_region_type type) {
|
|
||||||
return task->malloc(size, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void *operator new[](size_t size, rust_task *task,
|
|
||||||
memory_region::memory_region_type type) {
|
|
||||||
return task->malloc(size, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void *operator new(size_t size, rust_task &task,
|
|
||||||
memory_region::memory_region_type type) {
|
|
||||||
return task.malloc(size, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void *operator new[](size_t size, rust_task &task,
|
|
||||||
memory_region::memory_region_type type) {
|
|
||||||
return task.malloc(size, type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void operator delete(void *mem, rust_task *task) {
|
inline void operator delete(void *mem, rust_task *task) {
|
||||||
task->free(mem, memory_region::LOCAL);
|
task->free(mem);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator delete(void *mem, rust_task *task,
|
|
||||||
memory_region::memory_region_type type) {
|
|
||||||
task->free(mem, type);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,6 @@ private:
|
|||||||
const bool _synchronized;
|
const bool _synchronized;
|
||||||
lock_and_signal _lock;
|
lock_and_signal _lock;
|
||||||
public:
|
public:
|
||||||
enum memory_region_type {
|
|
||||||
LOCAL = 0x1, SYNCHRONIZED = 0x2
|
|
||||||
};
|
|
||||||
memory_region(rust_srv *srv, bool synchronized);
|
memory_region(rust_srv *srv, bool synchronized);
|
||||||
memory_region(memory_region *parent);
|
memory_region(memory_region *parent);
|
||||||
void *malloc(size_t size);
|
void *malloc(size_t size);
|
||||||
|
@ -42,7 +42,7 @@ last_os_error(rust_task *task) {
|
|||||||
#endif
|
#endif
|
||||||
size_t fill = strlen(buf) + 1;
|
size_t fill = strlen(buf) + 1;
|
||||||
size_t alloc = next_power_of_two(sizeof(rust_str) + fill);
|
size_t alloc = next_power_of_two(sizeof(rust_str) + fill);
|
||||||
void *mem = task->malloc(alloc, memory_region::LOCAL);
|
void *mem = task->malloc(alloc);
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
task->fail(1);
|
task->fail(1);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -74,7 +74,7 @@ rust_getcwd(rust_task *task) {
|
|||||||
|
|
||||||
size_t fill = strlen(cbuf) + 1;
|
size_t fill = strlen(cbuf) + 1;
|
||||||
size_t alloc = next_power_of_two(sizeof(rust_str) + fill);
|
size_t alloc = next_power_of_two(sizeof(rust_str) + fill);
|
||||||
void *mem = task->malloc(alloc, memory_region::LOCAL);
|
void *mem = task->malloc(alloc);
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
task->fail(1);
|
task->fail(1);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -201,7 +201,7 @@ vec_alloc_with_data(rust_task *task,
|
|||||||
{
|
{
|
||||||
rust_scheduler *sched = task->sched;
|
rust_scheduler *sched = task->sched;
|
||||||
size_t alloc = next_power_of_two(sizeof(rust_vec) + (n_elts * elt_size));
|
size_t alloc = next_power_of_two(sizeof(rust_vec) + (n_elts * elt_size));
|
||||||
void *mem = task->malloc(alloc, memory_region::LOCAL);
|
void *mem = task->malloc(alloc);
|
||||||
if (!mem) return NULL;
|
if (!mem) return NULL;
|
||||||
return new (mem) rust_vec(sched, alloc, fill * elt_size, (uint8_t*)d);
|
return new (mem) rust_vec(sched, alloc, fill * elt_size, (uint8_t*)d);
|
||||||
}
|
}
|
||||||
@ -635,8 +635,9 @@ ivec_reserve(rust_task *task, type_desc *ty, rust_ivec *v, size_t n_elems)
|
|||||||
v->payload.ptr = heap_part;
|
v->payload.ptr = heap_part;
|
||||||
} else {
|
} else {
|
||||||
// On heap; resize.
|
// On heap; resize.
|
||||||
heap_part = (rust_ivec_heap *)task->realloc(v->payload.ptr,
|
heap_part = (rust_ivec_heap *)
|
||||||
new_alloc + sizeof(size_t));
|
task->realloc(v->payload.ptr,
|
||||||
|
new_alloc + sizeof(size_t));
|
||||||
v->payload.ptr = heap_part;
|
v->payload.ptr = heap_part;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
#include "rust_srv.h"
|
#include "rust_srv.h"
|
||||||
|
|
||||||
rust_srv::rust_srv() :
|
rust_srv::rust_srv() :
|
||||||
local_region(this, false),
|
local_region(this, false) {
|
||||||
synchronized_region(this, true) {
|
|
||||||
// Nop.
|
// Nop.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// -*- c++ -*-
|
||||||
#ifndef RUST_SRV_H
|
#ifndef RUST_SRV_H
|
||||||
#define RUST_SRV_H
|
#define RUST_SRV_H
|
||||||
|
|
||||||
@ -6,7 +7,6 @@
|
|||||||
class rust_srv {
|
class rust_srv {
|
||||||
public:
|
public:
|
||||||
memory_region local_region;
|
memory_region local_region;
|
||||||
memory_region synchronized_region;
|
|
||||||
virtual void log(char const *msg);
|
virtual void log(char const *msg);
|
||||||
virtual void fatal(char const *expression,
|
virtual void fatal(char const *expression,
|
||||||
char const *file,
|
char const *file,
|
||||||
|
@ -73,7 +73,6 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
|
|||||||
running_on(-1),
|
running_on(-1),
|
||||||
pinned_on(-1),
|
pinned_on(-1),
|
||||||
local_region(&sched->srv->local_region),
|
local_region(&sched->srv->local_region),
|
||||||
synchronized_region(&sched->srv->synchronized_region),
|
|
||||||
_on_wakeup(NULL)
|
_on_wakeup(NULL)
|
||||||
{
|
{
|
||||||
LOGPTR(sched, "new task", (uintptr_t)this);
|
LOGPTR(sched, "new task", (uintptr_t)this);
|
||||||
@ -326,7 +325,7 @@ rust_task::malloc(size_t sz, type_desc *td)
|
|||||||
if (td) {
|
if (td) {
|
||||||
sz += sizeof(gc_alloc);
|
sz += sizeof(gc_alloc);
|
||||||
}
|
}
|
||||||
void *mem = malloc(sz, memory_region::LOCAL);
|
void *mem = local_region.malloc(sz);
|
||||||
if (!mem)
|
if (!mem)
|
||||||
return mem;
|
return mem;
|
||||||
if (td) {
|
if (td) {
|
||||||
@ -353,7 +352,7 @@ rust_task::realloc(void *data, size_t sz, bool is_gc)
|
|||||||
gc_alloc *gcm = (gc_alloc*)(((char *)data) - sizeof(gc_alloc));
|
gc_alloc *gcm = (gc_alloc*)(((char *)data) - sizeof(gc_alloc));
|
||||||
unlink_gc(gcm);
|
unlink_gc(gcm);
|
||||||
sz += sizeof(gc_alloc);
|
sz += sizeof(gc_alloc);
|
||||||
gcm = (gc_alloc*) realloc((void*)gcm, sz, memory_region::LOCAL);
|
gcm = (gc_alloc*) local_region.realloc((void*)gcm, sz);
|
||||||
DLOG(sched, task, "task %s @0x%" PRIxPTR
|
DLOG(sched, task, "task %s @0x%" PRIxPTR
|
||||||
" reallocated %d GC bytes = 0x%" PRIxPTR,
|
" reallocated %d GC bytes = 0x%" PRIxPTR,
|
||||||
name, (uintptr_t)this, sz, gcm);
|
name, (uintptr_t)this, sz, gcm);
|
||||||
@ -362,7 +361,7 @@ rust_task::realloc(void *data, size_t sz, bool is_gc)
|
|||||||
link_gc(gcm);
|
link_gc(gcm);
|
||||||
data = (void*) &(gcm->data);
|
data = (void*) &(gcm->data);
|
||||||
} else {
|
} else {
|
||||||
data = realloc(data, sz, memory_region::LOCAL);
|
data = local_region.realloc(data, sz);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -379,9 +378,11 @@ rust_task::free(void *p, bool is_gc)
|
|||||||
DLOG(sched, mem,
|
DLOG(sched, mem,
|
||||||
"task %s @0x%" PRIxPTR " freeing GC memory = 0x%" PRIxPTR,
|
"task %s @0x%" PRIxPTR " freeing GC memory = 0x%" PRIxPTR,
|
||||||
name, (uintptr_t)this, gcm);
|
name, (uintptr_t)this, gcm);
|
||||||
free(gcm, memory_region::LOCAL);
|
DLOG(sched, mem, "rust_task::free(0x%" PRIxPTR ")", gcm);
|
||||||
|
local_region.free(gcm);
|
||||||
} else {
|
} else {
|
||||||
free(p, memory_region::LOCAL);
|
DLOG(sched, mem, "rust_task::free(0x%" PRIxPTR ")", p);
|
||||||
|
local_region.free(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,52 +474,9 @@ bool rust_task::can_schedule(int id)
|
|||||||
(pinned_on == -1 || pinned_on == id);
|
(pinned_on == -1 || pinned_on == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
rust_task::malloc(size_t size, memory_region::memory_region_type type) {
|
|
||||||
if (type == memory_region::LOCAL) {
|
|
||||||
return local_region.malloc(size);
|
|
||||||
} else if (type == memory_region::SYNCHRONIZED) {
|
|
||||||
return synchronized_region.malloc(size);
|
|
||||||
}
|
|
||||||
I(sched, false);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
void *
|
||||||
rust_task::calloc(size_t size) {
|
rust_task::calloc(size_t size) {
|
||||||
return calloc(size, memory_region::LOCAL);
|
return local_region.calloc(size);
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
rust_task::calloc(size_t size, memory_region::memory_region_type type) {
|
|
||||||
if (type == memory_region::LOCAL) {
|
|
||||||
return local_region.calloc(size);
|
|
||||||
} else if (type == memory_region::SYNCHRONIZED) {
|
|
||||||
return synchronized_region.calloc(size);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
rust_task::realloc(void *mem, size_t size,
|
|
||||||
memory_region::memory_region_type type) {
|
|
||||||
if (type == memory_region::LOCAL) {
|
|
||||||
return local_region.realloc(mem, size);
|
|
||||||
} else if (type == memory_region::SYNCHRONIZED) {
|
|
||||||
return synchronized_region.realloc(mem, size);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
rust_task::free(void *mem, memory_region::memory_region_type type) {
|
|
||||||
DLOG(sched, mem, "rust_task::free(0x%" PRIxPTR ")", mem);
|
|
||||||
if (type == memory_region::LOCAL) {
|
|
||||||
local_region.free(mem);
|
|
||||||
} else if (type == memory_region::SYNCHRONIZED) {
|
|
||||||
synchronized_region.free(mem);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rust_task::pin() {
|
void rust_task::pin() {
|
||||||
|
@ -81,7 +81,6 @@ rust_task : public maybe_proxy<rust_task>,
|
|||||||
int pinned_on;
|
int pinned_on;
|
||||||
|
|
||||||
memory_region local_region;
|
memory_region local_region;
|
||||||
memory_region synchronized_region;
|
|
||||||
|
|
||||||
class wakeup_callback {
|
class wakeup_callback {
|
||||||
public:
|
public:
|
||||||
@ -153,12 +152,7 @@ rust_task : public maybe_proxy<rust_task>,
|
|||||||
|
|
||||||
bool can_schedule(int worker);
|
bool can_schedule(int worker);
|
||||||
|
|
||||||
void *malloc(size_t size, memory_region::memory_region_type type);
|
|
||||||
void *calloc(size_t size);
|
void *calloc(size_t size);
|
||||||
void *calloc(size_t size, memory_region::memory_region_type type);
|
|
||||||
void *realloc(void *mem, size_t size,
|
|
||||||
memory_region::memory_region_type type);
|
|
||||||
void free(void *mem, memory_region::memory_region_type type);
|
|
||||||
|
|
||||||
void pin();
|
void pin();
|
||||||
void pin(int id);
|
void pin(int id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user