1 From a9007e9f6b6a42a77520172ab67467be5eb2e3ed Mon Sep 17 00:00:00 2001
2 From: Leandro Lucarella <llucax@gmail.com>
3 Date: Mon, 16 Aug 2010 12:26:32 -0300
4 Subject: [PATCH 4/4] Use the right attributes when appending to an empty array
7 http://www.dsource.org/projects/tango/ticket/1971
9 tango/core/rt/compiler/dmd/rt/lifetime.d | 12 ++++++++++--
10 tango/core/rt/compiler/gdc/lifetime.d | 12 ++++++++++--
11 tango/core/rt/compiler/ldc/rt/lifetime.d | 12 ++++++++++--
12 3 files changed, 30 insertions(+), 6 deletions(-)
14 diff --git a/tango/core/rt/compiler/dmd/rt/lifetime.d b/tango/core/rt/compiler/dmd/rt/lifetime.d
15 index 022e452..0caf5db 100644
16 --- a/tango/core/rt/compiler/dmd/rt/lifetime.d
17 +++ b/tango/core/rt/compiler/dmd/rt/lifetime.d
18 @@ -779,7 +779,11 @@ extern (C) long _d_arrayappendT(TypeInfo ti, Array *px, byte[] y)
19 version (D_HavePointerMap) {
20 pm = ti.next.pointermap();
22 - newdata = cast(byte *)gc_malloc(newCapacity(newlength, sizeelem) + 1, info.attr, pm);
23 + uint attr = info.attr;
24 + // If this is the first allocation, set the NO_SCAN attribute appropriately
25 + if (info.base is null && ti.next.flags() == 0)
26 + attr = BlkAttr.NO_SCAN;
27 + newdata = cast(byte *)gc_malloc(newCapacity(newlength, sizeelem) + 1, attr, pm);
28 memcpy(newdata, px.data, length * sizeelem);
31 @@ -884,7 +888,11 @@ extern (C) byte[] _d_arrayappendcT(TypeInfo ti, ref byte[] x, ...)
32 version (D_HavePointerMap) {
33 pm = ti.next.pointermap();
35 - newdata = cast(byte *)gc_malloc(newcap + 1, info.attr, pm);
36 + uint attr = info.attr;
37 + // If this is the first allocation, set the NO_SCAN attribute appropriately
38 + if (info.base is null && ti.next.flags() == 0)
39 + attr = BlkAttr.NO_SCAN;
40 + newdata = cast(byte *)gc_malloc(newcap + 1, attr, pm);
41 memcpy(newdata, x.ptr, length * sizeelem);
42 (cast(void**)(&x))[1] = newdata;
44 diff --git a/tango/core/rt/compiler/gdc/lifetime.d b/tango/core/rt/compiler/gdc/lifetime.d
45 index 9e3da08..5d1e28e 100644
46 --- a/tango/core/rt/compiler/gdc/lifetime.d
47 +++ b/tango/core/rt/compiler/gdc/lifetime.d
48 @@ -753,7 +753,11 @@ extern (C) Array _d_arrayappendT(TypeInfo ti, Array *px, byte[] y)
52 - newdata = cast(byte *)gc_malloc(newCapacity(newlength, sizeelem) + 1, info.attr);
53 + uint attr = info.attr;
54 + // If this is the first allocation, set the NO_SCAN attribute appropriately
55 + if (info.base is null && ti.next.flags() == 0)
56 + attr = BlkAttr.NO_SCAN;
57 + newdata = cast(byte *)gc_malloc(newCapacity(newlength, sizeelem) + 1, attr);
58 memcpy(newdata, px.data, length * sizeelem);
61 @@ -853,7 +857,11 @@ extern (C) byte[] _d_arrayappendcTp(TypeInfo ti, ref byte[] x, void *argp)
62 debug(PRINTF) printf("_d_arrayappendcTp(length = %d, newlength = %d, cap = %d)\n", length, newlength, info.size);
63 auto newcap = newCapacity(newlength, sizeelem);
64 assert(newcap >= newlength * sizeelem);
65 - newdata = cast(byte *)gc_malloc(newcap + 1, info.attr);
66 + uint attr = info.attr;
67 + // If this is the first allocation, set the NO_SCAN attribute appropriately
68 + if (info.base is null && ti.next.flags() == 0)
69 + attr = BlkAttr.NO_SCAN;
70 + newdata = cast(byte *)gc_malloc(newcap + 1, attr);
71 memcpy(newdata, x.ptr, length * sizeelem);
72 (cast(void**)(&x))[1] = newdata;
74 diff --git a/tango/core/rt/compiler/ldc/rt/lifetime.d b/tango/core/rt/compiler/ldc/rt/lifetime.d
75 index 05e8c32..d736c18 100644
76 --- a/tango/core/rt/compiler/ldc/rt/lifetime.d
77 +++ b/tango/core/rt/compiler/ldc/rt/lifetime.d
78 @@ -776,7 +776,11 @@ extern (C) long _d_arrayappendT(TypeInfo ti, Array *px, byte[] y)
82 - newdata = cast(byte *)gc_malloc(newCapacity(newlength, sizeelem) + 1, info.attr);
83 + uint attr = info.attr;
84 + // If this is the first allocation, set the NO_SCAN attribute appropriately
85 + if (info.base is null && ti.next.flags() == 0)
86 + attr = BlkAttr.NO_SCAN;
87 + newdata = cast(byte *)gc_malloc(newCapacity(newlength, sizeelem) + 1, attr);
88 memcpy(newdata, px.data, length * sizeelem);
91 @@ -877,7 +881,11 @@ extern (C) byte[] _d_arrayappendcT(TypeInfo ti, ref byte[] x, ...)
92 debug(PRINTF) printf("_d_arrayappendcT(length = %d, newlength = %d, cap = %d)\n", length, newlength, info.size);
93 auto newcap = newCapacity(newlength, sizeelem);
94 assert(newcap >= newlength * sizeelem);
95 - newdata = cast(byte *)gc_malloc(newcap + 1, info.attr);
96 + uint attr = info.attr;
97 + // If this is the first allocation, set the NO_SCAN attribute appropriately
98 + if (info.base is null && ti.next.flags() == 0)
99 + attr = BlkAttr.NO_SCAN;
100 + newdata = cast(byte *)gc_malloc(newcap + 1, attr);
101 memcpy(newdata, x.ptr, length * sizeelem);
102 (cast(void**)(&x))[1] = newdata;