Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:D-Programming-Language/druntime
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Sep 1, 2011
2 parents 623eab3 + 3440de4 commit 08687bd
Show file tree
Hide file tree
Showing 54 changed files with 484 additions and 385 deletions.
1 change: 1 addition & 0 deletions changelog.dd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $(VERSION 055, mmm dd, 2011, =================================================,
$(RUNTIMEBUGSFIXED
$(LI $(BUGZILLA 5967): Mangling of ArgClose for variadic function is swapped)
$(LI $(BUGZILLA 6493): Source code for the doc of core.time points to std.datetime.)
$(LI $(BUGZILLA 6466): core.demangle incorrect demangling of variables)
)
)
$(VERSION 054, mmm dd, 2011, =================================================,
Expand Down
64 changes: 32 additions & 32 deletions import/object.di
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ class TypeInfo
hash_t getHash(in void* p);
equals_t equals(in void* p1, in void* p2);
int compare(in void* p1, in void* p2);
@property size_t tsize();
@property size_t tsize() nothrow pure;
void swap(void* p1, void* p2);
@property TypeInfo next();
void[] init(); // TODO: make this a property, but may need to be renamed to diambiguate with T.init...
@property uint flags();
@property TypeInfo next() nothrow pure;
void[] init() nothrow pure; // TODO: make this a property, but may need to be renamed to diambiguate with T.init...
@property uint flags() nothrow pure;
// 1: // has possible pointers into GC memory
OffsetTypeInfo[] offTi();
void destroy(void* p);
void postblit(void* p);
@property size_t talign();
@property size_t talign() nothrow pure;
version (X86_64) int argTypes(out TypeInfo arg1, out TypeInfo arg2);
}

Expand Down Expand Up @@ -128,8 +128,8 @@ class TypeInfo_Delegate : TypeInfo

class TypeInfo_Class : TypeInfo
{
@property TypeInfo_Class info() { return this; }
@property TypeInfo typeinfo() { return this; }
@property TypeInfo_Class info() nothrow pure { return this; }
@property TypeInfo typeinfo() nothrow pure { return this; }

byte[] init; // class static initializer
string name; // class name
Expand Down Expand Up @@ -212,16 +212,16 @@ class TypeInfo_Inout : TypeInfo_Const

abstract class MemberInfo
{
@property string name();
@property string name() nothrow pure;
}

class MemberInfo_field : MemberInfo
{
this(string name, TypeInfo ti, size_t offset);

@property override string name();
@property TypeInfo typeInfo();
@property size_t offset();
@property override string name() nothrow pure;
@property TypeInfo typeInfo() nothrow pure;
@property size_t offset() nothrow pure;
}

class MemberInfo_function : MemberInfo
Expand All @@ -235,10 +235,10 @@ class MemberInfo_function : MemberInfo

this(string name, TypeInfo ti, void* fp, uint flags);

@property override string name();
@property TypeInfo typeInfo();
void* fp();
@property uint flags();
@property override string name() nothrow pure;
@property TypeInfo typeInfo() nothrow pure;
@property void* fp() nothrow pure;
@property uint flags() nothrow pure;
}

struct ModuleInfo
Expand Down Expand Up @@ -273,21 +273,21 @@ struct ModuleInfo
Old o;
}

@property bool isNew();
@property uint index();
@property void index(uint i);
@property uint flags();
@property void flags(uint f);
@property void function() tlsctor();
@property void function() tlsdtor();
@property void* xgetMembers();
@property void function() ctor();
@property void function() dtor();
@property void function() ictor();
@property void function() unitTest();
@property ModuleInfo*[] importedModules();
@property TypeInfo_Class[] localClasses();
@property string name();
@property bool isNew() nothrow pure;
@property uint index() nothrow pure;
@property void index(uint i) nothrow pure;
@property uint flags() nothrow pure;
@property void flags(uint f) nothrow pure;
@property void function() tlsctor() nothrow pure;
@property void function() tlsdtor() nothrow pure;
@property void* xgetMembers() nothrow pure;
@property void function() ctor() nothrow pure;
@property void function() dtor() nothrow pure;
@property void function() ictor() nothrow pure;
@property void function() unitTest() nothrow pure;
@property ModuleInfo*[] importedModules() nothrow pure;
@property TypeInfo_Class[] localClasses() nothrow pure;
@property string name() nothrow pure;

static int opApply(scope int delegate(ref ModuleInfo*) dg);
}
Expand Down Expand Up @@ -346,10 +346,10 @@ extern (C)
void[] _aaKeys(void* p, size_t keysize);
void* _aaRehash(void** pp, TypeInfo keyti);

extern (D) typedef scope int delegate(void *) _dg_t;
extern (D) alias scope int delegate(void *) _dg_t;
int _aaApply(void* aa, size_t keysize, _dg_t dg);

extern (D) typedef scope int delegate(void *, void *) _dg2_t;
extern (D) alias scope int delegate(void *, void *) _dg2_t;
int _aaApply2(void* aa, size_t keysize, _dg2_t dg);

void* _d_assocarrayliteralT(TypeInfo_AssociativeArray ti, size_t length, ...);
Expand Down
4 changes: 3 additions & 1 deletion posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ MANIFEST= \
src/core/sys/posix/sys/time.d \
src/core/sys/posix/sys/types.d \
src/core/sys/posix/sys/uio.d \
src/core/sys/posix/sys/un.d \
src/core/sys/posix/sys/wait.d \
\
src/core/sys/windows/dbghelp.d \
Expand Down Expand Up @@ -473,6 +474,7 @@ IMPORTS=\
$(IMPDIR)/core/sys/posix/sys/time.di \
$(IMPDIR)/core/sys/posix/sys/types.di \
$(IMPDIR)/core/sys/posix/sys/uio.di \
$(IMPDIR)/core/sys/posix/sys/un.di \
$(IMPDIR)/core/sys/posix/sys/wait.di \
\
$(IMPDIR)/core/sys/windows/dbghelp.di \
Expand Down Expand Up @@ -518,7 +520,7 @@ $(OBJDIR)/errno_c.o : src/core/stdc/errno.c

$(OBJDIR)/threadasm.o : src/core/threadasm.S
@mkdir -p $(OBJDIR)
$(CC) -c $(CFLAGS) $< -o$@
$(CC) -Wa,-noexecstack -c $(CFLAGS) $< -o$@

################### Library generation #########################

Expand Down
68 changes: 53 additions & 15 deletions src/core/atomic.d
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ else version( AsmX86_32 )


HeadUnshared!(T) atomicLoad(msync ms = msync.seq, T)( ref const shared T val )
if(!__traits(isFloating, T))
{
static if( T.sizeof == byte.sizeof )
{
Expand Down Expand Up @@ -444,7 +445,6 @@ else version( AsmX86_32 )
}
}


void atomicStore(msync ms = msync.seq, T, V1)( ref shared T val, V1 newval )
if( __traits( compiles, mixin( "val = newval" ) ) )
{
Expand Down Expand Up @@ -749,7 +749,7 @@ else version( AsmX86_64 )


HeadUnshared!(T) atomicLoad(msync ms = msync.seq, T)( ref const shared T val )
{
if(!__traits(isFloating, T)) {
static if( T.sizeof == byte.sizeof )
{
//////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -975,6 +975,32 @@ else version( AsmX86_64 )
}
}

// This is an ABI adapter that works on all architectures. It type puns
// floats and doubles to ints and longs, atomically loads them, then puns
// them back. This is necessary so that they get returned in floating
// point instead of integer registers.
HeadUnshared!(T) atomicLoad(msync ms = msync.seq, T)( ref const shared T val )
if(__traits(isFloating, T))
{
static if(T.sizeof == int.sizeof)
{
static assert(is(T : float));
auto ptr = cast(int*) &val;
auto asInt = atomicLoad!(ms)(*ptr);
return *(cast(typeof(return)*) &asInt);
}
else static if(T.sizeof == long.sizeof)
{
static assert(is(T : double));
auto ptr = cast(long*) &val;
auto asLong = atomicLoad!(ms)(*ptr);
return *(cast(typeof(return)*) &asLong);
}
else
{
static assert(0, "Cannot atomically load 80-bit reals.");
}
}

////////////////////////////////////////////////////////////////////////////////
// Unit Tests
Expand All @@ -985,28 +1011,29 @@ version( unittest )
{
void testCAS(T)( T val = T.init + 1 )
{
T base;
shared(T) atom;

assert( base != val );
assert( atom == base );
assert( cas( &atom, base, val ) );
assert( atom == val );
assert( !cas( &atom, base, base ) );
assert( atom == val );
T base = cast(T) 0;
shared(T) atom = cast(T) 0;

assert( base != val, T.stringof );
assert( atom == base, T.stringof );

assert( cas( &atom, base, val ), T.stringof );
assert( atom == val, T.stringof );
assert( !cas( &atom, base, base ), T.stringof );
assert( atom == val, T.stringof );
}


void testLoadStore(msync ms = msync.seq, T)( T val = T.init + 1 )
{
T base;
shared(T) atom;
T base = cast(T) 0;
shared(T) atom = cast(T) 0;

assert( base != val );
assert( atom == base );
atomicStore!(ms)( atom, val );
base = atomicLoad!(ms)( atom );
assert( base == val );

assert( base == val, T.stringof );
assert( atom == val );
}

Expand Down Expand Up @@ -1034,6 +1061,9 @@ version( unittest )
testType!(uint)();

testType!(shared int*)();

testType!(float)(1.0f);
testType!(double)(1.0);

static if( has64BitCAS )
{
Expand All @@ -1048,5 +1078,13 @@ version( unittest )

atomicOp!"-="( i, cast(size_t) 1 );
assert( i == 0 );

float f = 0;
atomicOp!"+="( f, 1 );
assert( f == 1 );

double d = 0;
atomicOp!"+="( d, 1 );
assert( d == 1 );
}
}
12 changes: 7 additions & 5 deletions src/core/demangle.d
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ private struct Demangle
// faster than assembling the result piecemeal.


enum AddType { yes, no }
enum AddType { no, yes }


this( const(char)[] buf_, char[] dst_ = null )
{
this( buf_, AddType.no, dst_ );
this( buf_, AddType.yes, dst_ );
}


Expand All @@ -66,7 +66,7 @@ private struct Demangle
char[] dst = null;
size_t pos = 0;
size_t len = 0;
AddType addType = AddType.no;
AddType addType = AddType.yes;


static class ParseException : Exception
Expand Down Expand Up @@ -630,7 +630,7 @@ private struct Demangle
debug(trace) printf( "parseType+\n" );
debug(trace) scope(success) printf( "parseType-\n" );

enum IsDelegate { yes, no }
enum IsDelegate { no, yes }

auto beg = len;

Expand Down Expand Up @@ -930,6 +930,7 @@ private struct Demangle
case 'T': // TypeTypedef (T LName)
next();
parseQualifiedName();
pad( name );
return dst[beg .. len];
case 'D': // TypeDelegate (D TypeFunction)
next();
Expand All @@ -942,6 +943,7 @@ private struct Demangle
case 'v': // TypeVoid (v)
next();
put( "void" );
pad( name );
return dst[beg .. len];
case 'g': // TypeByte (g)
next();
Expand Down Expand Up @@ -1373,7 +1375,7 @@ private struct Demangle
debug(info) printf( "name (%.*s)\n", cast(int) name.length, name.ptr );
if( 'M' == tok() )
next(); // has 'this' pointer
if( addType )
if( AddType.yes == addType )
parseType( name );
if( pos >= buf.length )
return;
Expand Down
11 changes: 10 additions & 1 deletion src/core/memory.d
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,16 @@ struct GC
FINALIZE = 0b0000_0001, /// Finalize the data in this block on collect.
NO_SCAN = 0b0000_0010, /// Do not scan through this block on collect.
NO_MOVE = 0b0000_0100, /// Do not move this memory block on collect.
APPENDABLE = 0b0000_1000 /// This block contains the info to allow appending.
APPENDABLE = 0b0000_1000, /// This block contains the info to allow appending.

/**
This block is guaranteed to have a pointer to its base while it's
alive. Interior pointers can be safely ignored. This attribute
is useful for eliminating false pointers in very large data structures
and is only implemented for data structures at least a page in size.
*/
NO_INTERIOR = 0b0001_0000

}


Expand Down
8 changes: 4 additions & 4 deletions src/core/runtime.d
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ private
import core.demangle;
import core.stdc.stdlib : free;
import core.stdc.string : strlen, memchr;
extern (C) int backtrace(void**, size_t);
extern (C) int backtrace(void**, int);
extern (C) char** backtrace_symbols(void**, int);
extern (C) void backtrace_symbols_fd(void**,int,int);
extern (C) void backtrace_symbols_fd(void**, int, int);
import core.sys.posix.signal; // segv handler
}
else version( OSX )
{
import core.demangle;
import core.stdc.stdlib : free;
import core.stdc.string : strlen;
extern (C) int backtrace(void**, size_t);
extern (C) int backtrace(void**, int);
extern (C) char** backtrace_symbols(void**, int);
extern (C) void backtrace_symbols_fd(void**,int,int);
extern (C) void backtrace_symbols_fd(void**, int, int);
import core.sys.posix.signal; // segv handler
}
else version( Windows )
Expand Down
Loading

0 comments on commit 08687bd

Please sign in to comment.