Removed TypeOpaque from DMD.

Changed runtime functions taking opaque[] to void[].
Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[].
Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86.
Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing.
Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way...
Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8.
Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
This commit is contained in:
Tomas Lindquist Olsen
2008-10-22 14:55:33 +02:00
parent 50484db204
commit f7ea1da010
25 changed files with 506 additions and 624 deletions

View File

@@ -36,6 +36,12 @@
private import util.utf;
//debug = apply;
debug(apply)
{
extern(C) int printf(char*, ...);
}
/**********************************************
*/
@@ -356,6 +362,7 @@ extern (C) int _aApplydc2(dchar[] aa, dg2_t dg)
char c;
d = aa[i];
debug(apply) printf("d = %u\n", d);
if (d & ~0x7F)
{
char[4] buf;
@@ -363,6 +370,7 @@ extern (C) int _aApplydc2(dchar[] aa, dg2_t dg)
auto b = toUTF8(buf, d);
foreach (char c2; b)
{
debug(apply) printf("c2 = %d\n", c2);
result = dg(&i, cast(void *)&c2);
if (result)
return result;

View File

@@ -63,13 +63,6 @@ static size_t[] prime_list = [
// 8_589_934_513UL, 17_179_869_143UL
];
// This is the type of the return value for dynamic arrays.
struct Array
{
size_t length;
void* ptr;
}
struct aaA
{
aaA *left;
@@ -449,7 +442,7 @@ void _aaDel(AA aa, TypeInfo keyti, void *pkey)
* Produce array of values from aa.
*/
Array _aaValues(AA aa, size_t keysize, size_t valuesize)
void[] _aaValues(AA aa, size_t keysize, size_t valuesize)
in
{
assert(keysize == aligntsize(keysize));
@@ -457,7 +450,7 @@ in
body
{
size_t resi;
Array a;
void[] a;
void _aaValues_x(aaA* e)
{
@@ -480,9 +473,10 @@ body
if (aa)
{
a.length = _aaLen(aa);
a.ptr = cast(byte*) gc_malloc(a.length * valuesize,
auto len = _aaLen(aa);
auto ptr = cast(byte*) gc_malloc(len * valuesize,
valuesize < (void*).sizeof ? BlkAttr.NO_SCAN : 0);
a = ptr[0 .. len];
resi = 0;
foreach (e; aa.b)
{
@@ -593,7 +587,7 @@ body
* Produce array of N byte keys from aa.
*/
Array _aaKeys(AA aa, size_t keysize)
void[] _aaKeys(AA aa, size_t keysize)
{
byte[] res;
size_t resi;
@@ -617,7 +611,7 @@ Array _aaKeys(AA aa, size_t keysize)
auto len = _aaLen(aa);
if (!len)
return Array();
return null;
res = (cast(byte*) gc_malloc(len * keysize,
!(aa.keyti.flags() & 1) ? BlkAttr.NO_SCAN : 0)) [0 .. len * keysize];
resi = 0;
@@ -628,7 +622,7 @@ Array _aaKeys(AA aa, size_t keysize)
}
assert(resi == len);
return Array(len, res.ptr);
return res.ptr[0 .. len];
}

View File

@@ -55,12 +55,6 @@ private
}
struct Array
{
size_t length;
void* ptr;
}
/**********************************************
* Reverse array of chars.
* Handled separately because embedded multibyte encodings should not be
@@ -92,6 +86,9 @@ extern (C) char[] _adReverseChar(char[] a)
}
uint stridelo = UTF8stride[clo];
// don't barf on invalid strides, just ignore it
if (stridelo == 0xFF)
stridelo = 1;
uint stridehi = 1;
while ((chi & 0xC0) == 0x80)
@@ -245,7 +242,7 @@ unittest
* Support for array.reverse property.
*/
extern (C) Array _adReverse(Array a, size_t szelem)
extern (C) void[] _adReverse(void[] a, size_t szelem)
out (result)
{
assert(result.ptr is a.ptr);
@@ -287,7 +284,7 @@ extern (C) Array _adReverse(Array a, size_t szelem)
//gc_free(tmp);
}
}
return Array(a.length, a.ptr);
return a.ptr[0 .. a.length];
}
unittest
@@ -375,7 +372,7 @@ extern (C) wchar[] _adSortWchar(wchar[] a)
* Support for array equality test.
*/
extern (C) int _adEq(Array a1, Array a2, TypeInfo ti)
extern (C) int _adEq(void[] a1, void[] a2, TypeInfo ti)
{
debug(adi) printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length);
@@ -405,7 +402,7 @@ unittest
* Support for array compare test.
*/
extern (C) int _adCmp(Array a1, Array a2, TypeInfo ti)
extern (C) int _adCmp(void[] a1, void[] a2, TypeInfo ti)
{
debug(adi) printf("adCmp()\n");
@@ -442,7 +439,7 @@ unittest
* Support for array compare test.
*/
extern (C) int _adCmpChar(Array a1, Array a2)
extern (C) int _adCmpChar(void[] a1, void[] a2)
{
version(D_InlineAsm_X86)
{

View File

@@ -64,7 +64,8 @@ LIB_DEST=..
targets : lib sharedlib doc
all : lib sharedlib doc
lib : ldc.bclib ldc.clib ldc.lib
#lib : ldc.bclib ldc.clib ldc.lib
lib : ldc.clib ldc.lib
sharedlib : ldc.sharedlib
doc : ldc.doc
@@ -218,14 +219,14 @@ ALL_DOCS=
######################################################
ldc.bclib : $(LIB_TARGET_BC_ONLY)
#ldc.bclib : $(LIB_TARGET_BC_ONLY)
ldc.clib : $(LIB_TARGET_C_ONLY)
ldc.lib : $(LIB_TARGET_FULL)
ldc.sharedlib : $(LIB_TARGET_SHARED)
$(LIB_TARGET_BC_ONLY) : $(ALL_OBJS_O)
$(RM) $@
$(LC) $@ $(ALL_OBJS_BC)
#$(LIB_TARGET_BC_ONLY) : $(ALL_OBJS_O)
# $(RM) $@
# $(LC) $@ $(ALL_OBJS_BC)
$(LIB_TARGET_FULL) : $(ALL_OBJS_O)
@@ -250,7 +251,7 @@ ldc.doc : $(ALL_DOCS)
clean :
find . -name "*.di" | xargs $(RM)
$(RM) $(ALL_OBJS_BC)
# $(RM) $(ALL_OBJS_BC)
$(RM) $(ALL_OBJS_O)
$(RM) $(ALL_DOCS)
$(RM) $(LIB_MASK)

View File

@@ -1092,17 +1092,12 @@ extern (C) void* _d_arrayliteralT(TypeInfo ti, size_t length, ...)
/**
* Support for array.dup property.
*/
struct Array2
{
size_t length;
void* ptr;
}
/**
*
*/
extern (C) Array2 _adDupT(TypeInfo ti, Array2 a)
extern (C) void[] _adDupT(TypeInfo ti, void[] a)
out (result)
{
auto sizeelem = ti.next.tsize(); // array element size
@@ -1110,17 +1105,16 @@ out (result)
}
body
{
Array2 r;
void* ptr;
if (a.length)
{
auto sizeelem = ti.next.tsize(); // array element size
auto size = a.length * sizeelem;
r.ptr = gc_malloc(size, !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN : 0);
r.length = a.length;
memcpy(r.ptr, a.ptr, size);
ptr = gc_malloc(size, !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN : 0);
memcpy(ptr, a.ptr, size);
}
return r;
return ptr[0 .. a.length];
}

View File

@@ -17,12 +17,6 @@
private import tango.stdc.stdlib;
struct Array
{
size_t length;
void* ptr;
}
private TypeInfo tiglobal;
extern (C) int cmp(void* p1, void* p2)
@@ -30,7 +24,7 @@ extern (C) int cmp(void* p1, void* p2)
return tiglobal.compare(p1, p2);
}
extern (C) Array _adSort(Array a, TypeInfo ti)
extern (C) void[] _adSort(void[] a, TypeInfo ti)
{
synchronized
{