Skip to content

Commit 5d5fe9d

Browse files
committed
---
yaml --- r: 15283 b: refs/heads/try c: 28a0e9c h: refs/heads/master i: 15281: 93d82e5 15279: 78578c0 v: v3
1 parent bb6d151 commit 5d5fe9d

File tree

5 files changed

+30
-9
lines changed

5 files changed

+30
-9
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: 21be1379d561b6679a8a2ea47dce88f948c5acca
5+
refs/heads/try: 28a0e9c9992836becb9cb231343f95e691a642a3
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rt/rust_upcall.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,27 @@ upcall_shared_realloc(void *ptr, size_t size) {
291291

292292
/**********************************************************************/
293293

294+
struct s_str_new_args {
295+
const char *cstr;
296+
size_t len;
297+
rust_str *retval;
298+
};
299+
300+
extern "C" CDECL void
301+
upcall_s_str_new(s_str_new_args *args) {
302+
rust_task *task = rust_get_current_task();
303+
LOG_UPCALL_ENTRY(task);
304+
args->retval = make_str(task->kernel, args->cstr, args->len, "str_new");
305+
}
306+
307+
extern "C" CDECL rust_str*
308+
upcall_str_new(const char *cstr, size_t len) {
309+
s_str_new_args args = { cstr, len, 0 };
310+
UPCALL_SWITCH_STACK(&args, upcall_s_str_new);
311+
return args.retval;
312+
}
313+
314+
294315
struct s_vec_grow_args {
295316
rust_vec** vp;
296317
size_t new_sz;

branches/try/src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ upcall_shared_malloc
6969
upcall_shared_free
7070
upcall_shared_realloc
7171
upcall_vec_grow
72+
upcall_str_new
7273
upcall_str_concat
7374
upcall_call_shim_on_c_stack
7475
upcall_call_shim_on_rust_stack

branches/try/src/rustc/back/upcall.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type upcalls =
1717
shared_realloc: ValueRef,
1818
mark: ValueRef,
1919
vec_grow: ValueRef,
20+
str_new: ValueRef,
2021
str_concat: ValueRef,
2122
cmp_type: ValueRef,
2223
log_type: ValueRef,
@@ -64,6 +65,8 @@ fn declare_upcalls(targ_cfg: @session::config,
6465
d("mark", [T_ptr(T_i8())], int_t),
6566
vec_grow:
6667
dv("vec_grow", [T_ptr(T_ptr(opaque_vec_t)), int_t]),
68+
str_new:
69+
d("str_new", [T_ptr(T_i8()), int_t], T_ptr(opaque_vec_t)),
6770
str_concat:
6871
d("str_concat", [T_ptr(opaque_vec_t), T_ptr(opaque_vec_t)],
6972
T_ptr(opaque_vec_t)),

branches/try/src/rustc/middle/trans/tvec.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,11 @@ fn trans_vec(bcx: block, args: [@ast::expr], id: ast::node_id,
131131

132132
fn trans_str(bcx: block, s: str, dest: dest) -> block {
133133
let _icx = bcx.insn_ctxt("tvec::trans_str");
134-
let veclen = str::len(s) + 1u; // +1 for \0
135-
let {bcx: bcx, val: sptr, _} =
136-
alloc(bcx, ty::mk_str(bcx.tcx()), veclen);
137-
138134
let ccx = bcx.ccx();
139-
let llcstr = C_cstr(ccx, s);
140-
call_memmove(bcx, get_dataptr(bcx, sptr, T_i8()), llcstr,
141-
C_uint(ccx, veclen));
142-
ret base::store_in_dest(bcx, sptr, dest);
135+
let cs = PointerCast(bcx, C_cstr(ccx, s), T_ptr(T_i8()));
136+
let len = C_uint(ccx, str::len(s));
137+
let n = Call(bcx, ccx.upcalls.str_new, [cs, len]);
138+
ret base::store_in_dest(bcx, n, dest);
143139
}
144140

145141
fn trans_append(bcx: block, vec_ty: ty::t, lhsptr: ValueRef,

0 commit comments

Comments
 (0)