Skip to content

Commit d21a26c

Browse files
committed
---
yaml --- r: 14341 b: refs/heads/try c: d23cd8f h: refs/heads/master i: 14339: f079661 v: v3
1 parent 015ee4e commit d21a26c

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: a3fdd8c93f9aab540fc4edc0984e79c7dee467a5
5+
refs/heads/try: d23cd8f52fbfb41844b27c5e65cb620c34c7af59
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rt/rust_upcall.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ upcall_vec_grow(rust_vec** vp, size_t new_sz) {
434434
// Copy elements from one vector to another,
435435
// dealing with reference counts
436436
static inline void
437-
copy_elements(rust_task *task, type_desc *elem_t,
437+
copy_elements(type_desc *elem_t,
438438
void *pdst, void *psrc, size_t n) {
439439
char *dst = (char *)pdst, *src = (char *)psrc;
440440
memmove(dst, src, n);
@@ -454,12 +454,10 @@ extern "C" CDECL void
454454
upcall_vec_push(rust_vec** vp, type_desc* elt_ty, void* elt) {
455455
// NB: This runs entirely on the Rust stack because it invokes take glue
456456

457-
rust_task *task = rust_task_thread::get_task();
458-
459457
size_t new_sz = (*vp)->fill + elt_ty->size;
460-
reserve_vec(task, vp, new_sz);
458+
reserve_vec_fast(vp, new_sz);
461459
rust_vec* v = *vp;
462-
copy_elements(task, elt_ty, &v->data[0] + v->fill,
460+
copy_elements(elt_ty, &v->data[0] + v->fill,
463461
elt, elt_ty->size);
464462
v->fill += elt_ty->size;
465463
}

branches/try/src/rt/rust_util.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,18 @@ inline void reserve_vec(rust_task* task, rust_vec** vpp, size_t size) {
189189
reserve_vec_exact(task, vpp, next_power_of_two(size));
190190
}
191191

192+
// Call this when you don't already have a task pointer and it will
193+
// avoid hitting the TLS if it doesn't have to
194+
inline void reserve_vec_fast(rust_vec **vpp, size_t size) {
195+
size_t new_size = next_power_of_two(size);
196+
if (new_size > (*vpp)->alloc) {
197+
rust_task *task = rust_task_thread::get_task();
198+
size_t alloc_size = new_size + sizeof(rust_vec);
199+
*vpp = (rust_vec*)task->kernel->realloc(*vpp, alloc_size);
200+
(*vpp)->alloc = new_size;
201+
}
202+
}
203+
192204
typedef rust_vec rust_str;
193205

194206
inline rust_str *

0 commit comments

Comments
 (0)