Skip to content

Commit 7d35da1

Browse files
committed
---
yaml --- r: 13127 b: refs/heads/master c: 45933ca h: refs/heads/master i: 13125: 26b4ba8 13123: 3575c6c 13119: 0d6dbec v: v3
1 parent f7649b5 commit 7d35da1

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
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: 508ccca014fcc3a8ef241868ea05e36058b3e61c
2+
refs/heads/master: 45933ca485dbe8ce8434da476931f532197a70cb
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/middle/trans/base.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,32 @@ fn malloc_boxed(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} {
384384
ret {box: box, body: body};
385385
}
386386

387+
fn malloc_unique_raw(bcx: block, t: ty::t) -> ValueRef {
388+
let _icx = bcx.insn_ctxt("malloc_unique_box_raw");
389+
let ccx = bcx.ccx();
390+
391+
// Grab the TypeRef type of box_ptr, because that's what trans_raw_malloc
392+
// wants.
393+
let box_ptr = ty::mk_imm_uniq(ccx.tcx, t);
394+
let llty = type_of(ccx, box_ptr);
395+
396+
// Get the tydesc for the body:
397+
let mut static_ti = none;
398+
let lltydesc = get_tydesc(ccx, t, static_ti);
399+
lazily_emit_all_tydesc_glue(ccx, static_ti);
400+
401+
// Allocate space:
402+
let rval = Call(bcx, ccx.upcalls.exchange_malloc, [lltydesc]);
403+
ret PointerCast(bcx, rval, llty);
404+
}
405+
406+
fn malloc_unique(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} {
407+
let _icx = bcx.insn_ctxt("malloc_unique_box");
408+
let box = malloc_unique_raw(bcx, t);
409+
let body = GEPi(bcx, box, [0u, abi::box_field_body]);
410+
ret {box: box, body: body};
411+
}
412+
387413
// Type descriptor and type glue stuff
388414

389415
fn get_tydesc_simple(ccx: @crate_ctxt, t: ty::t) -> ValueRef {

0 commit comments

Comments
 (0)