 |
|
Revision 3145, 3.1 kB
(checked in by sean, 7 months ago)
|
* Moved exception trace generation from tango.core.Exception into the runtime. This involved adding a TraceInfo? interface to the global Exception class, and moving the machinery to generate a trace into genobj.d.
* The new hook to attach a trace hander is as follows:
extern (C) void rt_setTraceHandler( void function( void* ptr = null ) h );
This feature is exposed in tango.core.Runtime as the new 'traceHandler' property.
* The change to tracing inspired me to similarly rewire the collection handler code to move that hook into the runtime as well. This was done to improve efficiency for collections, as each collected object can now simply test a pointer to see if a handler is set rather than calling into user-space to perform the same check. The new hook for this mechanism is:
extern (C) void rt_setCollectHandler( void function(Object) h );
And the feature is also exposed in the Runtime object as the new collectHandler property. I thought about the name 'collectHandler' being in Runtime rather than GC, but I think the accompanying explanation for the function justifies the decision.
|
- Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 |
module object; |
|---|
| 2 |
|
|---|
| 3 |
alias typeof(int.sizeof) size_t; |
|---|
| 4 |
alias typeof(cast(void*)0 - cast(void*)0) ptrdiff_t; |
|---|
| 5 |
|
|---|
| 6 |
alias size_t hash_t; |
|---|
| 7 |
|
|---|
| 8 |
class Object |
|---|
| 9 |
{ |
|---|
| 10 |
char[] toString(); |
|---|
| 11 |
hash_t toHash(); |
|---|
| 12 |
int opCmp(Object o); |
|---|
| 13 |
int opEquals(Object o); |
|---|
| 14 |
|
|---|
| 15 |
interface Monitor |
|---|
| 16 |
{ |
|---|
| 17 |
void lock(); |
|---|
| 18 |
void unlock(); |
|---|
| 19 |
} |
|---|
| 20 |
} |
|---|
| 21 |
|
|---|
| 22 |
struct Interface |
|---|
| 23 |
{ |
|---|
| 24 |
ClassInfo classinfo; |
|---|
| 25 |
void*[] vtbl; |
|---|
| 26 |
ptrdiff_t offset; // offset to Interface 'this' from Object 'this' |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
class ClassInfo : Object |
|---|
| 30 |
{ |
|---|
| 31 |
byte[] init; // class static initializer |
|---|
| 32 |
char[] name; // class name |
|---|
| 33 |
void*[] vtbl; // virtual function pointer table |
|---|
| 34 |
Interface[] interfaces; |
|---|
| 35 |
ClassInfo base; |
|---|
| 36 |
void* destructor; |
|---|
| 37 |
void(*classInvariant)(Object); |
|---|
| 38 |
uint flags; |
|---|
| 39 |
// 1: // IUnknown |
|---|
| 40 |
// 2: // has no possible pointers into GC memory |
|---|
| 41 |
// 4: // has offTi[] member |
|---|
| 42 |
// 8: // has constructors |
|---|
| 43 |
void* deallocator; |
|---|
| 44 |
OffsetTypeInfo[] offTi; |
|---|
| 45 |
void* defaultConstructor; |
|---|
| 46 |
|
|---|
| 47 |
static ClassInfo find(char[] classname); |
|---|
| 48 |
Object create(); |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
struct OffsetTypeInfo |
|---|
| 52 |
{ |
|---|
| 53 |
size_t offset; |
|---|
| 54 |
TypeInfo ti; |
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
class TypeInfo |
|---|
| 58 |
{ |
|---|
| 59 |
hash_t getHash(void *p); |
|---|
| 60 |
int equals(void *p1, void *p2); |
|---|
| 61 |
int compare(void *p1, void *p2); |
|---|
| 62 |
size_t tsize(); |
|---|
| 63 |
void swap(void *p1, void *p2); |
|---|
| 64 |
TypeInfo next(); |
|---|
| 65 |
void[] init(); |
|---|
| 66 |
uint flags(); |
|---|
| 67 |
// 1: // has possible pointers into GC memory |
|---|
| 68 |
OffsetTypeInfo[] offTi(); |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
class TypeInfo_Typedef : TypeInfo |
|---|
| 72 |
{ |
|---|
| 73 |
TypeInfo base; |
|---|
| 74 |
char[] name; |
|---|
| 75 |
void[] m_init; |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
class TypeInfo_Enum : TypeInfo_Typedef |
|---|
| 79 |
{ |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
class TypeInfo_Pointer : TypeInfo |
|---|
| 83 |
{ |
|---|
| 84 |
TypeInfo m_next; |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
class TypeInfo_Array : TypeInfo |
|---|
| 88 |
{ |
|---|
| 89 |
TypeInfo value; |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
class TypeInfo_StaticArray : TypeInfo |
|---|
| 93 |
{ |
|---|
| 94 |
TypeInfo value; |
|---|
| 95 |
size_t len; |
|---|
| 96 |
} |
|---|
| 97 |
|
|---|
| 98 |
class TypeInfo_AssociativeArray : TypeInfo |
|---|
| 99 |
{ |
|---|
| 100 |
TypeInfo value; |
|---|
| 101 |
TypeInfo key; |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
class TypeInfo_Function : TypeInfo |
|---|
| 105 |
{ |
|---|
| 106 |
TypeInfo next; |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
class TypeInfo_Delegate : TypeInfo |
|---|
| 110 |
{ |
|---|
| 111 |
TypeInfo next; |
|---|
| 112 |
} |
|---|
| 113 |
|
|---|
| 114 |
class TypeInfo_Class : TypeInfo |
|---|
| 115 |
{ |
|---|
| 116 |
ClassInfo info; |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
class TypeInfo_Interface : TypeInfo |
|---|
| 120 |
{ |
|---|
| 121 |
ClassInfo info; |
|---|
| 122 |
} |
|---|
| 123 |
|
|---|
| 124 |
class TypeInfo_Struct : TypeInfo |
|---|
| 125 |
{ |
|---|
| 126 |
char[] name; |
|---|
| 127 |
void[] m_init; |
|---|
| 128 |
|
|---|
| 129 |
uint function(void*) xtoHash; |
|---|
| 130 |
int function(void*,void*) xopEquals; |
|---|
| 131 |
int function(void*,void*) xopCmp; |
|---|
| 132 |
char[] function(void*) xtoString; |
|---|
| 133 |
|
|---|
| 134 |
uint m_flags; |
|---|
| 135 |
} |
|---|
| 136 |
|
|---|
| 137 |
class TypeInfo_Tuple : TypeInfo |
|---|
| 138 |
{ |
|---|
| 139 |
TypeInfo[] elements; |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
class ModuleInfo |
|---|
| 143 |
{ |
|---|
| 144 |
char[] name; |
|---|
| 145 |
ModuleInfo[] importedModules; |
|---|
| 146 |
ClassInfo[] localClasses; |
|---|
| 147 |
uint flags; |
|---|
| 148 |
|
|---|
| 149 |
void function() ctor; |
|---|
| 150 |
void function() dtor; |
|---|
| 151 |
void function() unitTest; |
|---|
| 152 |
|
|---|
| 153 |
static int opApply( int delegate( inout ModuleInfo ) ); |
|---|
| 154 |
} |
|---|
| 155 |
|
|---|
| 156 |
class Exception : Object |
|---|
| 157 |
{ |
|---|
| 158 |
interface TraceInfo |
|---|
| 159 |
{ |
|---|
| 160 |
int opApply( int delegate( inout char[] ) ); |
|---|
| 161 |
char[] toString(); |
|---|
| 162 |
} |
|---|
| 163 |
|
|---|
| 164 |
char[] msg; |
|---|
| 165 |
char[] file; |
|---|
| 166 |
size_t line; |
|---|
| 167 |
TraceInfo info; |
|---|
| 168 |
Exception next; |
|---|
| 169 |
|
|---|
| 170 |
this(char[] msg, Exception next = null); |
|---|
| 171 |
this(char[] msg, char[] file, size_t line, Exception next = null); |
|---|
| 172 |
char[] toString(); |
|---|
| 173 |
} |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic