mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-25 06:03:16 +00:00
Remove runtime vector builtins
This commit is contained in:
parent
533becef2f
commit
d1b3ed8c3f
@ -9,26 +9,6 @@ type dummy = int;
|
||||
|
||||
native "rust" mod rustrt {
|
||||
type vbuf;
|
||||
fn vec_buf[T](v: vec[T], offset: uint) -> vbuf;
|
||||
fn vec_len[T](v: vec[T]) -> uint;
|
||||
|
||||
/**
|
||||
* Sometimes we modify the vec internal data via vec_buf and need to
|
||||
* update the vec's fill length accordingly.
|
||||
*/
|
||||
fn vec_len_set[T](v: vec[T], n: uint);
|
||||
|
||||
/**
|
||||
* The T in vec_alloc[T, U] is the type of the vec to allocate. The
|
||||
* U is the type of an element in the vec. So to allocate a vec[U] we
|
||||
* want to invoke this as vec_alloc[vec[U], U].
|
||||
*/
|
||||
fn vec_alloc[T, U](n_elts: uint) -> vec[U];
|
||||
fn vec_alloc_mut[T, U](n_elts: uint) -> vec[mutable U];
|
||||
fn refcount[T](v: vec[T]) -> uint;
|
||||
fn vec_print_debug_info[T](v: vec[T]);
|
||||
fn vec_from_vbuf[T](v: vbuf, n_elts: uint) -> vec[T];
|
||||
fn unsafe_vec_to_mut[T](v: vec[T]) -> vec[mutable T];
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
|
@ -120,74 +120,6 @@ unsupervise(rust_task *task) {
|
||||
task->unsupervise();
|
||||
}
|
||||
|
||||
extern "C" CDECL rust_vec*
|
||||
vec_alloc(rust_task *task, type_desc *t, type_desc *elem_t, size_t n_elts)
|
||||
{
|
||||
LOG(task, mem, "vec_alloc %" PRIdPTR " elements of size %" PRIdPTR,
|
||||
n_elts, elem_t->size);
|
||||
size_t fill = n_elts * elem_t->size;
|
||||
size_t alloc = next_power_of_two(sizeof(rust_vec) + fill);
|
||||
void *mem = task->malloc(alloc, "rust_vec", t->is_stateful ? t : NULL);
|
||||
if (!mem) {
|
||||
task->fail();
|
||||
return NULL;
|
||||
}
|
||||
rust_vec *vec = new (mem) rust_vec(alloc, 0, NULL);
|
||||
return vec;
|
||||
}
|
||||
|
||||
extern "C" CDECL rust_vec*
|
||||
vec_alloc_mut(rust_task *task, type_desc *t, type_desc *elem_t, size_t n_elts)
|
||||
{
|
||||
return vec_alloc(task, t, elem_t, n_elts);
|
||||
}
|
||||
|
||||
extern "C" CDECL void *
|
||||
vec_buf(rust_task *task, type_desc *ty, rust_vec *v, size_t offset)
|
||||
{
|
||||
return (void *)&v->data[ty->size * offset];
|
||||
}
|
||||
|
||||
extern "C" CDECL size_t
|
||||
vec_len(rust_task *task, type_desc *ty, rust_vec *v)
|
||||
{
|
||||
return v->fill / ty->size;
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
vec_len_set(rust_task *task, type_desc *ty, rust_vec *v, size_t len)
|
||||
{
|
||||
LOG(task, stdlib, "vec_len_set(0x%" PRIxPTR ", %" PRIdPTR ") on vec with "
|
||||
"alloc = %" PRIdPTR
|
||||
", fill = %" PRIdPTR
|
||||
", len = %" PRIdPTR
|
||||
". New fill is %" PRIdPTR,
|
||||
v, len, v->alloc, v->fill, v->fill / ty->size, len * ty->size);
|
||||
v->fill = len * ty->size;
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
vec_print_debug_info(rust_task *task, type_desc *ty, rust_vec *v)
|
||||
{
|
||||
LOG(task, stdlib,
|
||||
"vec_print_debug_info(0x%" PRIxPTR ")"
|
||||
" with tydesc 0x%" PRIxPTR
|
||||
" (size = %" PRIdPTR ", align = %" PRIdPTR ")"
|
||||
" alloc = %" PRIdPTR ", fill = %" PRIdPTR ", len = %" PRIdPTR
|
||||
" , data = ...",
|
||||
v,
|
||||
ty,
|
||||
ty->size,
|
||||
ty->align,
|
||||
v->alloc,
|
||||
v->fill,
|
||||
v->fill / ty->size);
|
||||
|
||||
for (size_t i = 0; i < v->fill; ++i) {
|
||||
LOG(task, stdlib, " %" PRIdPTR ": 0x%" PRIxPTR, i, v->data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Helper for str_alloc and str_from_vec. Returns NULL as failure. */
|
||||
static rust_vec*
|
||||
vec_alloc_with_data(rust_task *task,
|
||||
@ -202,22 +134,6 @@ vec_alloc_with_data(rust_task *task,
|
||||
return new (mem) rust_vec(alloc, fill * elt_size, (uint8_t*)d);
|
||||
}
|
||||
|
||||
extern "C" CDECL rust_vec*
|
||||
vec_from_vbuf(rust_task *task, type_desc *ty, void *vbuf, size_t n_elts)
|
||||
{
|
||||
return vec_alloc_with_data(task, n_elts, n_elts * ty->size, ty->size,
|
||||
vbuf);
|
||||
}
|
||||
|
||||
extern "C" CDECL rust_vec*
|
||||
unsafe_vec_to_mut(rust_task *task, type_desc *ty, rust_vec *v)
|
||||
{
|
||||
if (v->ref_count != CONST_REFCOUNT) {
|
||||
v->ref();
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
extern "C" CDECL rust_str*
|
||||
str_alloc(rust_task *task, size_t n_bytes)
|
||||
{
|
||||
|
@ -71,7 +71,6 @@ take_chan
|
||||
task_sleep
|
||||
task_yield
|
||||
task_join
|
||||
unsafe_vec_to_mut
|
||||
unsupervise
|
||||
upcall_chan_target_task
|
||||
upcall_clone_chan
|
||||
@ -113,11 +112,4 @@ upcall_take_task
|
||||
upcall_take_chan
|
||||
upcall_vec_append
|
||||
upcall_yield
|
||||
vec_alloc
|
||||
vec_alloc_mut
|
||||
vec_buf
|
||||
vec_from_vbuf
|
||||
vec_len
|
||||
vec_len_set
|
||||
vec_print_debug_info
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user