Skip to content

Commit 557190c

Browse files
committed
---
yaml --- r: 3086 b: refs/heads/master c: 491d110 h: refs/heads/master v: v3
1 parent 893c78c commit 557190c

File tree

7 files changed

+44
-117
lines changed

7 files changed

+44
-117
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: c6be352f73927ddf44357aaf87b161b5805263c0
2+
refs/heads/master: 491d1106454c9ffa3950afe27ea3488ef5c19e32

trunk/src/comp/middle/trans.rs

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,31 +2274,6 @@ fn make_free_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
22742274
rslt.bcx.build.RetVoid();
22752275
}
22762276

2277-
fn maybe_free_ivec_heap_part(&@block_ctxt cx, ValueRef v0, ty::t unit_ty)
2278-
-> result {
2279-
auto llunitty = type_of_or_i8(cx, unit_ty);
2280-
2281-
auto stack_len = cx.build.Load(cx.build.InBoundsGEP(v0, [C_int(0),
2282-
C_uint(abi::ivec_elt_len)]));
2283-
auto maybe_on_heap_cx = new_sub_block_ctxt(cx, "maybe_on_heap");
2284-
auto next_cx = new_sub_block_ctxt(cx, "next");
2285-
auto maybe_on_heap = cx.build.ICmp(lib::llvm::LLVMIntEQ, stack_len,
2286-
C_int(0));
2287-
cx.build.CondBr(maybe_on_heap, maybe_on_heap_cx.llbb, next_cx.llbb);
2288-
2289-
// Might be on the heap. Load the heap pointer and free it. (It's ok to
2290-
// free a null pointer.)
2291-
auto stub_ptr = maybe_on_heap_cx.build.PointerCast(v0,
2292-
T_ptr(T_ivec_heap(llunitty)));
2293-
auto heap_ptr = maybe_on_heap_cx.build.Load(
2294-
maybe_on_heap_cx.build.InBoundsGEP(stub_ptr,
2295-
[C_int(0), C_uint(abi::ivec_heap_stub_elt_ptr)]));
2296-
auto after_free_cx = trans_non_gc_free(maybe_on_heap_cx, heap_ptr).bcx;
2297-
after_free_cx.build.Br(next_cx.llbb);
2298-
2299-
ret res(next_cx, C_nil());
2300-
}
2301-
23022277
fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
23032278
// NB: v0 is an *alias* of type t here, not a direct value.
23042279
auto rslt;
@@ -2311,11 +2286,6 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
23112286
rslt = decr_refcnt_maybe_free(cx, v0, v0, t);
23122287
}
23132288

2314-
case (ty::ty_ivec(?tm)) {
2315-
rslt = iter_structural_ty(cx, v0, t, drop_ty);
2316-
rslt = maybe_free_ivec_heap_part(rslt.bcx, v0, tm.ty);
2317-
}
2318-
23192289
case (ty::ty_box(_)) {
23202290
rslt = decr_refcnt_maybe_free(cx, v0, v0, t);
23212291
}
@@ -3718,10 +3688,10 @@ fn trans_vec_append(&@block_ctxt cx, &ty::t t,
37183688
dst, src, skip_null]));
37193689
}
37203690

3721-
// Returns a tuple consisting of a pointer to the newly-reserved space and a
3722-
// block context. Updates the length appropriately.
3691+
// Returns a tuple consisting of a pointer to the length (to be updated), a
3692+
// pointer to the newly-reserved space, and a block context.
37233693
fn reserve_ivec_space(&@block_ctxt cx, TypeRef llunitty, ValueRef v,
3724-
ValueRef len_needed) -> result {
3694+
ValueRef len_needed) -> tup(ValueRef, ValueRef, @block_ctxt) {
37253695
auto stack_len_ptr = cx.build.InBoundsGEP(v, [C_int(0),
37263696
C_uint(abi::ivec_elt_len)]);
37273697
auto stack_len = cx.build.Load(stack_len_ptr);
@@ -3755,7 +3725,7 @@ fn reserve_ivec_space(&@block_ctxt cx, TypeRef llunitty, ValueRef v,
37553725

37563726
// We're definitely on the heap. Check whether we need to resize.
37573727
auto heap_len_ptr = on_heap_cx.build.InBoundsGEP(heap_ptr, [C_int(0),
3758-
C_uint(abi::ivec_heap_elt_len)]);
3728+
C_int(0)]);
37593729
auto heap_len = on_heap_cx.build.Load(heap_len_ptr);
37603730
auto new_heap_len = on_heap_cx.build.Add(heap_len, len_needed);
37613731
auto heap_len_unscaled = on_heap_cx.build.UDiv(heap_len,
@@ -3770,7 +3740,6 @@ fn reserve_ivec_space(&@block_ctxt cx, TypeRef llunitty, ValueRef v,
37703740
// Case (1): We're on the heap and don't need to resize.
37713741
auto heap_data_no_resize = heap_no_resize_cx.build.InBoundsGEP(heap_ptr,
37723742
[C_int(0), C_uint(abi::ivec_heap_elt_elems), heap_len_unscaled]);
3773-
heap_no_resize_cx.build.Store(new_heap_len, heap_len_ptr);
37743743
heap_no_resize_cx.build.Br(next_cx.llbb);
37753744

37763745
// Case (2): We're on the heap and need to resize. This path is rare, so
@@ -3802,7 +3771,6 @@ fn reserve_ivec_space(&@block_ctxt cx, TypeRef llunitty, ValueRef v,
38023771
// Case (3): We're on the stack and don't need to spill.
38033772
auto stack_data_no_spill = stack_no_spill_cx.build.InBoundsGEP(v,
38043773
[C_int(0), C_uint(abi::ivec_elt_elems), stack_len_unscaled]);
3805-
stack_no_spill_cx.build.Store(new_stack_len, stack_len_ptr);
38063774
stack_no_spill_cx.build.Br(next_cx.llbb);
38073775

38083776
// Case (4): We're on the stack and need to spill. Like case (2), this
@@ -3826,12 +3794,16 @@ fn reserve_ivec_space(&@block_ctxt cx, TypeRef llunitty, ValueRef v,
38263794
stack_spill_cx.build.Br(next_cx.llbb);
38273795

38283796
// Phi together the different data pointers to get the result.
3797+
auto len_ptr = next_cx.build.Phi(T_ptr(T_int()),
3798+
[heap_len_ptr, heap_len_ptr, stack_len_ptr, heap_len_ptr_spill],
3799+
[heap_no_resize_cx.llbb, heap_resize_cx.llbb, stack_no_spill_cx.llbb,
3800+
stack_spill_cx.llbb]);
38293801
auto data_ptr = next_cx.build.Phi(T_ptr(llunitty),
38303802
[heap_data_no_resize, heap_data_resize, stack_data_no_spill,
38313803
heap_data_spill],
38323804
[heap_no_resize_cx.llbb, heap_resize_cx.llbb, stack_no_spill_cx.llbb,
38333805
stack_spill_cx.llbb]);
3834-
ret res(next_cx, data_ptr);
3806+
ret tup(len_ptr, data_ptr, next_cx);
38353807
}
38363808

38373809
fn trans_ivec_append(&@block_ctxt cx, &ty::t t, ValueRef lhs, ValueRef rhs)
@@ -3865,9 +3837,11 @@ fn trans_ivec_append(&@block_ctxt cx, &ty::t t, ValueRef lhs, ValueRef rhs)
38653837
auto rhs_data = rhs_len_and_data._1;
38663838
bcx = rhs_len_and_data._2;
38673839

3868-
rslt = reserve_ivec_space(bcx, llunitty, lhs, rhs_len);
3869-
auto lhs_data = rslt.val;
3870-
bcx = rslt.bcx;
3840+
auto lhs_len_ptr_and_data =
3841+
reserve_ivec_space(bcx, llunitty, lhs, rhs_len);
3842+
auto lhs_len_ptr = lhs_len_ptr_and_data._0;
3843+
auto lhs_data = lhs_len_ptr_and_data._1;
3844+
bcx = lhs_len_ptr_and_data._2;
38713845

38723846
// Work out the end pointer.
38733847
auto lhs_unscaled_idx = bcx.build.UDiv(rhs_len, llsize_of(llunitty));
@@ -3901,6 +3875,11 @@ fn trans_ivec_append(&@block_ctxt cx, &ty::t t, ValueRef lhs, ValueRef rhs)
39013875
[C_int(1)]), src_ptr);
39023876
post_copy_cx.build.Br(copy_loop_header_cx.llbb);
39033877

3878+
// Write in the new length.
3879+
auto new_len = next_cx.build.Add(next_cx.build.Load(lhs_len_ptr),
3880+
rhs_len);
3881+
next_cx.build.Store(new_len, lhs_len_ptr);
3882+
39043883
ret res(next_cx, C_nil());
39053884
}
39063885

@@ -5857,8 +5836,11 @@ fn trans_ivec(@block_ctxt bcx, &vec[@ast::expr] args, &ast::ann ann)
58575836
auto rslt = size_of(bcx, unit_ty);
58585837
auto unit_sz = rslt.val;
58595838
bcx = rslt.bcx;
5839+
rslt = align_of(bcx, unit_ty);
5840+
auto unit_align = rslt.val;
5841+
bcx = rslt.bcx;
58605842

5861-
auto llalen = bcx.build.Mul(unit_sz, C_uint(abi::ivec_default_length));
5843+
auto llalen = bcx.build.Mul(unit_align, C_uint(abi::ivec_default_length));
58625844

58635845
auto llunitty = type_of_or_i8(bcx, unit_ty);
58645846
auto llvecptr;
@@ -5903,7 +5885,7 @@ fn trans_ivec(@block_ctxt bcx, &vec[@ast::expr] args, &ast::ann ann)
59035885
llfirsteltptr = C_null(T_ptr(llunitty));
59045886
} else {
59055887
auto llheapsz = bcx.build.Add(llsize_of(llheapty), lllen);
5906-
rslt = trans_raw_malloc(bcx, T_ptr(llheapty), llheapsz);
5888+
rslt = trans_raw_malloc(bcx, llheapty, llheapsz);
59075889
bcx = rslt.bcx;
59085890
auto llheapptr = rslt.val;
59095891

@@ -5926,7 +5908,7 @@ fn trans_ivec(@block_ctxt bcx, &vec[@ast::expr] args, &ast::ann ann)
59265908
auto lleltptr;
59275909
if (ty::type_has_dynamic_size(bcx.fcx.lcx.ccx.tcx, unit_ty)) {
59285910
lleltptr = bcx.build.InBoundsGEP(llfirsteltptr,
5929-
[bcx.build.Mul(C_uint(i), unit_sz)]);
5911+
[bcx.build.Mul(C_uint(i), unit_align)]);
59305912
} else {
59315913
lleltptr = bcx.build.InBoundsGEP(llfirsteltptr, [C_uint(i)]);
59325914
}

trunk/src/rt/rust_internal.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,27 @@ struct rust_timer {
206206

207207
#include "rust_util.h"
208208

209+
typedef void FASTCALL (glue_fn)(void *, rust_task *, void *,
210+
const type_desc **, void *);
211+
typedef void FASTCALL (cmp_glue_fn)(void *, rust_task *, void *,
212+
const type_desc **,
213+
void *, void *, int8_t);
214+
215+
209216
struct type_desc {
210217
// First part of type_desc is known to compiler.
211218
// first_param = &descs[1] if dynamic, null if static.
212219
const type_desc **first_param;
213220
size_t size;
214221
size_t align;
215-
uintptr_t copy_glue_off;
216-
uintptr_t drop_glue_off;
217-
uintptr_t free_glue_off;
218-
uintptr_t sever_glue_off; // For GC.
219-
uintptr_t mark_glue_off; // For GC.
220-
uintptr_t obj_drop_glue_off; // For custom destructors.
222+
glue_fn *take_glue;
223+
glue_fn *drop_glue;
224+
glue_fn *free_glue;
225+
glue_fn *sever_glue; // For GC.
226+
glue_fn *mark_glue; // For GC.
227+
glue_fn *obj_drop_glue; // For custom destructors.
221228
uintptr_t is_stateful;
229+
cmp_glue_fn *cmp_glue;
222230

223231
// Residual fields past here are known only to runtime.
224232
UT_hash_handle hh;

trunk/src/rt/rust_upcall.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -581,15 +581,8 @@ extern "C" CDECL void
581581
upcall_ivec_resize(rust_task *task,
582582
rust_ivec *v,
583583
size_t newsz) {
584-
I(task->dom, !v->fill);
585-
586-
size_t new_alloc = next_power_of_two(newsz);
587-
rust_ivec_heap *new_heap_part = (rust_ivec_heap *)
588-
task->realloc(v->payload.ptr, new_alloc);
589-
590-
new_heap_part->fill = newsz;
591-
v->alloc = new_alloc;
592-
v->payload.ptr = new_heap_part;
584+
// TODO
585+
task->fail(4);
593586
}
594587

595588
/**

trunk/src/rt/rust_util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ rust_ivec_heap
197197
union
198198
rust_ivec_payload
199199
{
200-
rust_ivec_heap *ptr; // if on heap
201-
uint8_t data[]; // if on stack
200+
uint8_t data[]; // if on stack
201+
struct rust_ivec_heap *ptr; // if on heap
202202
};
203203

204204
struct

trunk/src/snapshots.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
S 2011-06-14 c3015b8
2-
linux-i386 b091d33519a1bbf6cf12ee1954a1607940ae3915
3-
macos-i386 7d47cece095a7b30f5a3e2467417652d3b2353e5
4-
winnt-i386 27d57fd96d2c328d83fcbf7322035019377ab40f
5-
61
S 2011-06-09 efcf857
72
linux-i386 af8e6dba00bdf290768251d55bdda9cba6752e4f
83
macos-i386 0c45af8b96effa957906d1d6a2e05bffd627aa51

trunk/src/test/run-pass/block-expr-precedence.rs

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)