Skip to content

Commit 355c417

Browse files
committed
rustc: Add some interior vector spill code, untested as of yet
1 parent c3bf7d0 commit 355c417

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/rt/rust_upcall.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,12 +585,23 @@ upcall_ivec_resize(rust_task *task,
585585
task->fail(4);
586586
}
587587

588+
/**
589+
* Spills an interior vector to the heap.
590+
*/
588591
extern "C" CDECL void
589592
upcall_ivec_spill(rust_task *task,
590593
rust_ivec *v,
591594
size_t newsz) {
592-
// TODO
593-
task->fail(4);
595+
size_t new_alloc = next_power_of_two(newsz);
596+
597+
rust_ivec_heap *heap_part = (rust_ivec_heap *)
598+
task->malloc(new_alloc + sizeof(size_t));
599+
heap_part->fill = newsz;
600+
memcpy(&heap_part->data, v->payload.data, v->fill);
601+
602+
v->fill = 0;
603+
v->alloc = new_alloc;
604+
v->payload.ptr = heap_part;
594605
}
595606

596607
//

0 commit comments

Comments
 (0)