Skip to content

Commit 360bee5

Browse files
committed
---
yaml --- r: 13549 b: refs/heads/master c: 88ec259 h: refs/heads/master i: 13547: 6a909f6 v: v3
1 parent 69723e5 commit 360bee5

File tree

5 files changed

+52
-4
lines changed

5 files changed

+52
-4
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: b4484d51c14ec3b70ed8d4b6700bc3536a3ee766
2+
refs/heads/master: 88ec259cee17df6b78ce52b966148f0e03f02270
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/mk/rt.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ RUNTIME_CS_$(1) := \
6262
rt/rust_uv.cpp \
6363
rt/rust_log.cpp \
6464
rt/rust_port_selector.cpp \
65+
rt/rust_util.cpp \
6566
rt/circular_buffer.cpp \
6667
rt/isaac/randport.cpp \
6768
rt/rust_kernel.cpp \

trunk/src/rt/rust_upcall.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,7 @@ upcall_s_str_new_shared(s_str_new_shared_args *args) {
373373
size_t str_fill = args->len + 1;
374374
size_t str_alloc = str_fill;
375375
args->retval = (rust_opaque_box *)
376-
task->kernel->malloc(sizeof(rust_opaque_box) +
377-
vec_size<char>(str_fill),
378-
"str_new_shared");
376+
task->boxed.malloc(&str_body_tydesc, str_fill);
379377
rust_str *str = (rust_str *)box_body(args->retval);
380378
str->body.fill = str_fill;
381379
str->body.alloc = str_alloc;
@@ -425,6 +423,7 @@ upcall_s_str_concat(s_str_concat_args *args) {
425423
rust_vec_box* v = (rust_vec_box*)
426424
task->kernel->malloc(fill + sizeof(rust_vec_box),
427425
"str_concat");
426+
v->header.td = args->lhs->header.td;
428427
v->body.fill = v->body.alloc = fill;
429428
memmove(&v->body.data[0], &lhs->data[0], lhs->fill - 1);
430429
memmove(&v->body.data[lhs->fill - 1], &rhs->data[0], rhs->fill);

trunk/src/rt/rust_util.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "rust_type.h"
2+
#include "rust_shape.h"
3+
4+
5+
// A hardcoded type descriptor for strings, since the runtime needs to
6+
// be able to create them.
7+
8+
struct rust_shape_tables empty_shape_tables;
9+
10+
uint8_t str_body_shape[] = {
11+
shape::SHAPE_UNBOXED_VEC,
12+
0x1, // is_pod
13+
0x1, 0x0, // size field: 1
14+
shape::SHAPE_U8
15+
};
16+
17+
struct type_desc str_body_tydesc = {
18+
0, // unused
19+
1, // size
20+
1, // align
21+
NULL, // take_glue
22+
NULL, // drop_glue
23+
NULL, // free_glue
24+
NULL, // visit_glue
25+
0, // unused
26+
0, // unused
27+
0, // unused
28+
0, // unused
29+
str_body_shape, // shape
30+
&empty_shape_tables, // shape_tables
31+
0, // unused
32+
0, // unused
33+
};
34+
35+
//
36+
// Local Variables:
37+
// mode: C++
38+
// fill-column: 78;
39+
// indent-tabs-mode: nil
40+
// c-basic-offset: 4
41+
// buffer-file-coding-system: utf-8-unix
42+
// End:
43+
//

trunk/src/rt/rust_util.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "rust_task.h"
66
#include "rust_env.h"
77

8+
extern struct type_desc str_body_tydesc;
9+
810
// Inline fn used regularly elsewhere.
911

1012
static inline size_t
@@ -82,6 +84,7 @@ make_str(rust_kernel* kernel, const char* c, size_t strlen,
8284
size_t str_alloc = str_fill;
8385
rust_str *str = (rust_str *)
8486
kernel->malloc(vec_size<char>(str_fill), name);
87+
str->header.td = &str_body_tydesc;
8588
str->body.fill = str_fill;
8689
str->body.alloc = str_alloc;
8790
memcpy(&str->body.data, c, strlen);
@@ -94,6 +97,8 @@ make_str_vec(rust_kernel* kernel, size_t nstrs, char **strs) {
9497
rust_vec_box *v = (rust_vec_box *)
9598
kernel->malloc(vec_size<rust_vec_box*>(nstrs),
9699
"str vec interior");
100+
// FIXME: should have a real td (Issue #2639)
101+
v->header.td = NULL;
97102
v->body.fill = v->body.alloc = sizeof(rust_vec_box*) * nstrs;
98103
for (size_t i = 0; i < nstrs; ++i) {
99104
rust_str *str = make_str(kernel, strs[i],

0 commit comments

Comments
 (0)