root/trunk/docsrc/abi.dd

Revision 2139, 23.3 kB (checked in by walter, 1 year ago)

bugzilla 690 ABI not fully documented

  • Property svn:eol-style set to native
Line 
1 Ddoc
2
3 $(SPEC_S D Application Binary Interface,
4
5     $(P A D implementation that conforms to the D ABI (Application Binary
6     Interface)
7     will be able to generate libraries, DLL's, etc., that can interoperate
8     with
9     D binaries built by other implementations.
10     )
11
12 $(SECTION3 C ABI,
13
14     $(P The C ABI referred to in this specification means the C Application
15     Binary Interface of the target system.
16     C and D code should be freely linkable together, in particular, D
17     code shall have access to the entire C ABI runtime library.
18     )
19 )
20
21 $(SECTION3 Endianness,
22
23     $(P The $(LINK2 http://en.wikipedia.org/wiki/Endianness, endianness)
24     (byte order) of the layout of the data
25     will conform to the endianness of the target machine.
26     The Intel x86 CPUs are $(I little endian) meaning that
27     the value 0x0A0B0C0D is stored in memory as:
28     $(CODE 0D 0C 0B 0A).
29     )
30 )
31
32 $(SECTION3 Basic Types,
33
34     $(DL
35     $(DT bool)
36     $(DD 8 bit byte with the values 0 for false and 1 for true)
37     $(DT byte)
38     $(DD 8 bit signed value)
39     $(DT ubyte)
40     $(DD 8 bit unsigned value)
41     $(DT short)
42     $(DD 16 bit signed value)
43     $(DT ushort)
44     $(DD 16 bit unsigned value)
45     $(DT int)
46     $(DD 32 bit signed value)
47     $(DT uint)
48     $(DD 32 bit unsigned value)
49     $(DT long)
50     $(DD 64 bit signed value)
51     $(DT ulong)
52     $(DD 64 bit unsigned value)
53     $(DT cent)
54     $(DD 128 bit signed value)
55     $(DT ucent)
56     $(DD 128 bit unsigned value)
57     $(DT float)
58     $(DD 32 bit IEEE 754 floating point value)
59     $(DT double)
60     $(DD 64 bit IEEE 754 floating point value)
61     $(DT real)
62     $(DD implementation defined floating point value, for x86 it is
63      80 bit IEEE 754 extended real)
64     )
65 )
66
67 $(SECTION3 Delegates,
68
69     $(P Delegates are $(I fat pointers) with two parts:)
70
71     $(TABLE2 Delegate Layout,
72     $(TR $(TH offset) $(TH property) $(TH contents))
73     $(TR $(TD 0) $(TD $(CODE .ptr)) $(TD context pointer))
74     $(TR $(TD $(I ptrsize)) $(TD $(CODE .funcptr)) $(TD pointer to function))
75     )
76
77     $(P The $(I context pointer) can be a class $(I this)
78     reference, a struct $(I this) pointer, a pointer to
79     a closure (nested functions) or a pointer to an enclosing
80     function's stack frame (nested functions).
81     )
82 )
83
84 $(SECTION3 Structs,
85
86     $(P Conforms to the target's C ABI struct layout.)
87 )
88
89 $(SECTION3 Classes,
90
91     $(P An object consists of:)
92
93 $(TABLE2 Class Object Layout,
94 $(TR $(TH size) $(TH property) $(TH contents))
95 $(TR $(TD $(I ptrsize)) $(TD $(CODE .__vptr)) $(TD pointer to vtable))
96 $(TR $(TD $(I ptrsize)) $(TD $(CODE .__monitor)) $(TD monitor))
97 $(TR $(TD ...) $(TD ...) $(TD super's non-static fields and super's interface vptrs, from least to most derived))
98 $(TR $(TD ...) $(TD named fields) $(TD non-static fields))
99 $(TR $(TD $(I ptrsize)...) $(TD  ) $(TD vptr's for any interfaces implemented by this class in left to right, most to least derived, order))
100 )
101
102     $(P The vtable consists of:)
103
104 $(TABLE2 Virtual Function Pointer Table Layout,
105 $(TR $(TH size)     $(TH contents))
106 $(TR $(TD $(I ptrsize)) $(TD pointer to instance of $(V1 ClassInfo)$(V2 TypeInfo)))
107 $(TR $(TD $(I ptrsize)...) $(TD pointers to virtual member functions))
108 )
109
110     $(P Casting a class object to an interface consists of adding the offset of
111     the interface's corresponding vptr to the address of the base of the object.
112     Casting an interface ptr back to the class type it came from involves getting
113     the correct offset to subtract from it from the object.Interface entry at vtbl[0].
114     Adjustor thunks are created and pointers to them stored in the method entries in the vtbl[]
115     in order to set the this pointer to the start of the object instance corresponding
116     to the implementing method.
117     )
118
119     $(P An adjustor thunk looks like:)
120
121 $(CCODE
122     ADD EAX,offset
123     JMP method
124 )
125
126     $(P The leftmost side of the inheritance graph of the interfaces all share
127     their vptrs, this is the single inheritance model.
128     Every time the inheritance graph forks (for multiple inheritance) a new vptr is created
129     and stored in the class' instance.
130     Every time a virtual method is overridden, a new vtbl[] must be created with
131     the updated method pointers in it.
132     )
133
134     $(P The class definition:)
135
136 ---------
137 class XXXX
138 {
139     ....
140 };
141 ---------
142
143     $(P Generates the following:)
144
145     $(UL
146     $(LI An instance of Class called ClassXXXX.)
147
148     $(LI A type called StaticClassXXXX which defines all the static members.)
149
150     $(LI An instance of StaticClassXXXX called StaticXXXX for the static members.)
151     )
152 )
153
154 $(SECTION3 Interfaces,
155
156     $(P An interface is a pointer to a pointer to a vtbl[].
157     The vtbl[0] entry is a pointer to the corresponding
158     instance of the object.Interface class.
159     The rest of the vtbl[1..$] entries are pointers to the
160     virtual functions implemented by that interface, in the
161     order that they were declared.
162     )
163
164     $(P A COM interface differs from a regular interface in that
165     there is no object.Interface entry in vtbl[0]; the entries
166     vtbl[0..$] are all the virtual function pointers, in the order
167     that they were declared.
168     This matches the COM object layout used by Windows.
169     )
170     $(V2
171     $(P A C++ interface differs from a regular interface in that
172     it matches the layout of a C++ class using single inheritance
173     on the target machine.
174     )
175     )
176 )
177
178 $(SECTION3 Arrays,
179
180     $(P A dynamic array consists of:)
181
182 $(TABLE2 Dynamic Array Layout,
183 $(TR $(TH offset) $(TH property) $(TH contents))
184 $(TR $(TD  0) $(TD $(CODE .length)) $(TD  array dimension))
185 $(TR $(TD  $(I size_t)) $(TD $(CODE .ptr)) $(TD  pointer to array data))
186 )
187
188     $(P A dynamic array is declared as:)
189
190 ---------
191 type[] array;
192 ---------
193
194     $(P whereas a static array is declared as:)
195
196 ---------
197 type[dimension] array;
198 ---------
199
200     $(P Thus, a static array always has the dimension statically available as part of the type, and
201     so it is implemented like in C. Static array's and Dynamic arrays can be easily converted back
202     and forth to each other.
203     )
204 )
205
206 $(SECTION3 Associative Arrays,
207
208     $(P Associative arrays consist of a pointer to an opaque, implementation
209     defined type.
210     $(V1 The current implementation is contained in and defined by
211      $(PHOBOSSRC internal/aaA.d).)
212     $(V2 The current implementation is contained in and defined by
213      $(DRUNTIMESRC rt/aaA.d).)
214     )
215 )
216
217 $(SECTION3 Reference Types,
218
219     $(P D has reference types, but they are implicit. For example, classes are always
220     referred to by reference; this means that class instances can never reside on the stack
221     or be passed as function parameters.
222     )
223
224     $(P When passing a static array to a function, the result, although declared as a static array, will
225     actually be a reference to a static array. For example:
226     )
227
228 ---------
229 int[3] abc;
230 ---------
231
232     $(P Passing abc to functions results in these implicit conversions:)
233
234 ---------
235 void func(int[3] array); // actually <reference to><array[3] of><int>
236 void func(int* p);       // abc is converted to a pointer
237              // to the first element
238 void func(int[] array);  // abc is converted to a dynamic array
239 ---------
240 )
241
242
243 $(SECTION3 Name Mangling,
244
245     $(P D accomplishes typesafe linking by $(I mangling) a D identifier
246     to include scope and type information.
247     )
248
249 $(GRAMMAR
250 $(I MangledName):
251     $(B _D) $(I QualifiedName) $(I Type)
252     $(B _D) $(I QualifiedName) $(B M) $(I Type)
253
254 $(I QualifiedName):
255     $(I SymbolName)
256     $(I SymbolName) $(I QualifiedName)
257
258 $(I SymbolName):
259     $(I LName)
260     $(I TemplateInstanceName)
261 )
262
263     $(P The $(B M) means that the symbol is a function that requires
264     a $(TT this) pointer.)
265
266     $(P Template Instance Names have the types and values of its parameters
267     encoded into it:
268     )
269
270 $(GRAMMAR
271 $(I TemplateInstanceName):
272     $(Number) $(B __T) $(I LName) $(I TemplateArgs) $(B Z)
273
274 $(I TemplateArgs):
275     $(I TemplateArg)
276     $(I TemplateArg) $(I TemplateArgs)
277
278 $(I TemplateArg):
279     $(B T) $(I Type)
280     $(B V) $(I Type) $(I Value)
281     $(B S) $(I LName)
282
283 $(I Value):
284     $(B n)
285     $(I Number)
286     $(B i) $(I Number)
287     $(B N) $(I Number)
288     $(B e) $(I HexFloat)
289     $(B c) $(I HexFloat) $(B c) $(I HexFloat)
290     $(B A) $(I Number) $(I Value)...
291
292 $(I HexFloat):
293     $(B NAN)
294     $(B INF)
295     $(B NINF)
296     $(B N) $(I HexDigits) $(B P) $(I Exponent)
297     $(I HexDigits) $(B P) $(I Exponent)
298
299 $(I Exponent):
300     $(B N) $(I Number)
301     $(I Number)
302
303 $(I HexDigits):
304     $(I HexDigit)
305     $(I HexDigit) $(I HexDigits)
306
307 $(I HexDigit):
308     $(I Digit)
309     $(B A)
310     $(B B)
311     $(B C)
312     $(B D)
313     $(B E)
314     $(B F)
315 )
316
317 $(DL
318     $(DT $(I n))
319     $(DD is for $(B null) arguments.)
320
321     $(DT $(I Number))
322     $(DD is for positive numeric literals (including
323     character literals).)
324
325     $(DT $(B N) $(I Number))
326     $(DD is for negative numeric literals.)
327
328     $(DT $(B e) $(I HexFloat))
329     $(DD is for real and imaginary floating point literals.)
330
331     $(DT $(B c) $(I HexFloat) $(B c) $(I HexFloat))
332     $(DD is for complex floating point literals.)
333
334     $(DT $(I Width) $(I Number) $(B _) $(I HexDigits))
335     $(DD $(I Width) is whether the characters
336     are 1 byte ($(B a)), 2 bytes ($(B w)) or 4 bytes ($(B d)) in size.
337     $(I Number) is the number of characters in the string.
338     The $(I HexDigits) are the hex data for the string.
339     )
340
341     $(DT $(B A) $(I Number) $(I Value)...)
342     $(DD An array literal. $(I Value) is repeated $(I Number) times.
343     )
344 )
345
346 $(GRAMMAR
347 $(I Name):
348     $(I Namestart)
349     $(I Namestart) $(I Namechars)
350
351 $(I Namestart):
352     $(B _)
353     $(I Alpha)
354
355 $(I Namechar):
356     $(I Namestart)
357     $(I Digit)
358
359 $(I Namechars):
360     $(I Namechar)
361     $(I Namechar) $(I Namechars)
362 )
363
364     $(P A $(I Name) is a standard D identifier.)
365
366 $(GRAMMAR
367 $(I LName):
368     $(I Number) $(I Name)
369
370 $(I Number):
371     $(I Digit)
372     $(I Digit) $(I Number)
373
374 $(I Digit):
375     $(B 0)
376     $(B 1)
377     $(B 2)
378     $(B 3)
379     $(B 4)
380     $(B 5)
381     $(B 6)
382     $(B 7)
383     $(B 8)
384     $(B 9)
385 )
386
387     $(P An $(I LName) is a name preceded by a $(I Number) giving
388     the number of characters in the $(I Name).
389     )
390 )
391
392 $(SECTION3 Type Mangling,
393
394     $(P Types are mangled using a simple linear scheme:)
395
396 $(GRAMMAR
397 $(I Type):
398     $(I Shared)
399     $(I Const)
400     $(I Immutable)
401     $(I Wild)
402     $(I TypeArray)
403 $(V2      $(I TypeNewArray)
404 )    $(I TypeStaticArray)
405     $(I TypeAssocArray)
406     $(I TypePointer)
407     $(I TypeFunction)
408     $(I TypeIdent)
409     $(I TypeClass)
410     $(I TypeStruct)
411     $(I TypeEnum)
412     $(I TypeTypedef)
413     $(I TypeDelegate)
414     $(I TypeNone)
415     $(I TypeVoid)
416     $(I TypeByte)
417     $(I TypeUbyte)
418     $(I TypeShort)
419     $(I TypeUshort)
420     $(I TypeInt)
421     $(I TypeUint)
422     $(I TypeLong)
423     $(I TypeUlong)
424     $(I TypeFloat)
425     $(I TypeDouble)
426     $(I TypeReal)
427     $(I TypeIfloat)
428     $(I TypeIdouble)
429     $(I TypeIreal)
430     $(I TypeCfloat)
431     $(I TypeCdouble)
432     $(I TypeCreal)
433     $(I TypeBool)
434     $(I TypeChar)
435     $(I TypeWchar)
436     $(I TypeDchar)
437     $(I TypeTuple)
438
439 $(I Shared):
440     $(B O) $(I Type)
441
442 $(I Const):
443     $(B x) $(I Type)
444
445 $(I Immutable):
446     $(B y) $(I Type)
447
448 $(I Wild):
449     $(B Ng) $(I Type)
450
451 $(I TypeArray):
452     $(B A) $(I Type)
453
454 $(V2 $(I TypeNewArray):
455     $(B Ne) $(I Type)
456 )
457 $(I TypeStaticArray):
458     $(B G) $(I Number) $(I Type)
459
460 $(I TypeAssocArray):
461     $(B H) $(I Type) $(I Type)
462
463 $(I TypePointer):
464     $(B P) $(I Type)
465
466 $(I TypeFunction):
467     $(I CallConvention) $(V2 $(I FuncAttrs) )$(I Arguments) $(I ArgClose) $(I Type)
468
469 $(I CallConvention):
470     $(B F)       $(GREEN // D)
471     $(B U)       $(GREEN // C)
472     $(B W)       $(GREEN // Windows)
473     $(B V)       $(GREEN // Pascal)
474     $(B R)       $(GREEN // C++)
475
476 $(V2 $(I FuncAttrs):
477     $(I FuncAttr)
478     $(I FuncAttr) $(I FuncAttrs)
479
480 $(I FuncAttr):
481     $(I empty)
482     $(I FuncAttrPure)
483     $(I FuncAttrNothrow)
484     $(I FuncAttrProperty)
485     $(I FuncAttrRef)
486     $(I FuncAttrTrusted)
487     $(I FuncAttrSafe)
488
489 $(I FuncAttrPure):
490     $(B Na)
491
492 $(I FuncAttrNothrow):
493     $(B Nb)
494
495 $(I FuncAttrRef):
496     $(B Nc)
497
498 $(I FuncAttrProperty):
499     $(B Nd)
500
501 $(I FuncAttrTrusted):
502     $(B Ne)
503
504 $(I FuncAttrSafe):
505     $(B Nf)
506 )
507
508 $(I Arguments):
509     $(I Argument)
510     $(I Argument) $(I Arguments)
511
512 $(I Argument:)
513 $(V2
514     $(I Argument2)
515     $(B M) $(I Argument2)     $(GREEN // scope)
516
517 $(I Argument2:)
518 )    $(I Type)
519     $(B J) $(I Type)     $(GREEN // out)
520     $(B K) $(I Type)     $(GREEN // ref)
521     $(B L) $(I Type)     $(GREEN // lazy)
522
523 $(I ArgClose)
524     $(B X)     $(GREEN // variadic T t,...$(RPAREN) style)
525     $(B Y)     $(GREEN // variadic T t...$(RPAREN) style)
526     $(B Z)     $(GREEN // not variadic)
527
528 $(I TypeIdent):
529     $(B I) $(I LName)
530
531 $(I TypeClass):
532     $(B C) $(I LName)
533
534 $(I TypeStruct):
535     $(B S) $(I LName)
536
537 $(I TypeEnum):
538     $(B E) $(I LName)
539
540 $(I TypeTypedef):
541     $(B T) $(I LName)
542
543 $(I TypeDelegate):
544     $(B D) $(I TypeFunction)
545
546 $(I TypeNone):
547     $(B n)
548
549 $(I TypeVoid):
550     $(B v)
551
552 $(I TypeByte):
553     $(B g)
554
555 $(I TypeUbyte):
556     $(B h)
557
558 $(I TypeShort):
559     $(B s)
560
561 $(I TypeUshort):
562     $(B t)
563
564 $(I TypeInt):
565     $(B i)
566
567 $(I TypeUint):
568     $(B k)
569
570 $(I TypeLong):
571     $(B l)
572
573 $(I TypeUlong):
574     $(B m)
575
576 $(I TypeFloat):
577     $(B f)
578
579 $(I TypeDouble):
580     $(B d)
581
582 $(I TypeReal):
583     $(B e)
584
585 $(I TypeIfloat):
586     $(B o)
587
588 $(I TypeIdouble):
589     $(B p)
590
591 $(I TypeIreal):
592     $(B j)
593
594 $(I TypeCfloat):
595     $(B q)
596
597 $(I TypeCdouble):
598     $(B r)
599
600 $(I TypeCreal):
601     $(B c)
602
603 $(I TypeBool):
604     $(B b)
605
606 $(I TypeChar):
607     $(B a)
608
609 $(I TypeWchar):
610     $(B u)
611
612 $(I TypeDchar):
613     $(B w)
614
615 $(I TypeTuple):
616     $(B B) $(I Number) $(I Arguments)
617 )
618 )
619
620 $(SECTION3 Function Calling Conventions,
621
622     $(P The extern (C) calling convention matches the C calling convention
623     used by the supported C compiler on the host system.
624     The extern (D) calling convention for x86 is described here.)
625
626 $(SECTION4 Register Conventions,
627
628     $(UL
629
630     $(LI EAX, ECX, EDX are scratch registers and can be destroyed
631     by a function.)
632
633     $(LI EBX, ESI, EDI, EBP must be preserved across function calls.)
634
635     $(LI EFLAGS is assumed destroyed across function calls, except
636     for the direction flag which must be forward.)
637
638     $(LI The FPU stack must be empty when calling a function.)
639
640     $(LI The FPU control word must be preserved across function calls.)
641
642     $(LI Floating point return values are returned on the FPU stack.
643     These must be cleaned off by the caller, even if they are not used.)
644
645     )
646 )
647
648 $(SECTION4 Return Value,
649
650     $(UL
651
652     $(LI The types bool, byte, ubyte, short, ushort, int, uint,
653     pointer, Object, and interfaces
654     are returned in EAX.)
655
656     $(LI long and ulong
657     are returned in EDX,EAX, where EDX gets the most significant
658     half.)
659
660     $(LI float, double, real, ifloat, idouble, ireal are returned
661     in ST0.)
662
663     $(LI cfloat, cdouble, creal are returned in ST1,ST0 where ST1
664     is the real part and ST0 is the imaginary part.)
665
666     $(LI Dynamic arrays are returned with the pointer in EDX
667     and the length in EAX.)
668
669     $(LI Associative arrays are returned in EAX with garbage
670     returned in EDX. The EDX value will probably be removed in
671     the future; it's there for backwards compatibility with
672     an earlier implementation of AA's.)
673
674     $(V2 $(LI References are returned as pointers in EAX.))
675
676     $(LI Delegates are returned with the pointer to the function
677     in EDX and the context pointer in EAX.)
678
679     $(LI 1, 2 and 4 byte structs are returned in EAX.)
680
681     $(LI 8 byte structs are returned in EDX,EAX, where
682     EDX gets the most significant half.)
683
684     $(LI For other struct sizes,
685     the return value is stored through a hidden pointer passed as
686     an argument to the function.)
687
688     $(LI Constructors return the this pointer in EAX.)
689
690     )
691 )
692
693 $(SECTION4 Parameters,
694
695     $(P The parameters to the non-variadic function:)
696
697 ---
698     foo(a1, a2, ..., an);
699 ---
700
701     $(P are passed as follows:)
702
703     $(TABLE
704     $(TR $(TD a1))
705     $(TR $(TD a2))
706     $(TR $(TD ...))
707     $(TR $(TD an))
708     $(TR $(TD hidden))
709     $(TR $(TD this))
710     )
711
712     $(P where $(I hidden) is present if needed to return a struct
713     value, and $(I this) is present if needed as the this pointer
714     for a member function or the context pointer for a nested
715     function.)
716
717     $(P The last parameter is passed in EAX rather than being pushed
718     on the stack if the following conditions are met:)
719
720     $(UL
721     $(LI It fits in EAX.)
722     $(LI It is not a 3 byte struct.)
723     $(LI It is not a floating point type.)
724     )
725
726     $(P Parameters are always pushed as multiples of 4 bytes,
727     rounding upwards,
728     so the stack is always aligned on 4 byte boundaries.
729     They are pushed most significant first.
730     $(B out) and $(B ref) are passed as pointers.
731     Static arrays are passed as pointers to their first element.
732     On Windows, a real is pushed as a 10 byte quantity,
733     a creal is pushed as a 20 byte quantity.
734     On Linux, a real is pushed as a 12 byte quantity,
735     a creal is pushed as two 12 byte quantities.
736     The extra two bytes of pad occupy the $(SINGLEQUOTE most significant) position.
737     )
738
739     $(P The callee cleans the stack.)
740
741     $(P The parameters to the variadic function:)
742
743 ---
744     void foo(int p1, int p2, int[] p3...)
745     foo(a1, a2, ..., an);
746 ---
747
748     $(P are passed as follows:)
749
750     $(TABLE
751     $(TR $(TD p1))
752     $(TR $(TD p2))
753     $(TR $(TD a3))
754     $(TR $(TD hidden))
755     $(TR $(TD this))
756     )
757
758     $(P The variadic part is converted to a dynamic array and the
759     rest is the same as for non-variadic functions.)
760
761     $(P The parameters to the variadic function:)
762
763 ---
764     void foo(int p1, int p2, ...)
765     foo(a1, a2, a3, ..., an);
766 ---
767
768     $(P are passed as follows:)
769
770     $(TABLE
771     $(TR $(TD an))
772     $(TR $(TD ...))
773     $(TR $(TD a3))
774     $(TR $(TD a2))
775     $(TR $(TD a1))
776     $(TR $(TD _arguments))
777     $(TR $(TD hidden))
778     $(TR $(TD this))
779     )
780
781     $(P The caller is expected to clean the stack.
782     $(B _argptr) is not
783     passed, it is computed by the callee.)
784 )
785
786 $(SECTION4 Function Attributes,
787     $(DL
788     $(DT $(B Na)
789     $(DD pure)
790     )
791     $(DT $(B Nb)
792     $(DD nothrow)
793     )
794     )
795 )
796
797 )
798
799 $(SECTION3 Exception Handling,
800
801     $(SECTION4 Windows,
802
803     $(P Conforms to the Microsoft Windows Structured Exception Handling
804     conventions.
805     )
806     )
807
808     $(SECTION4 Linux and OSX,
809
810     $(P Uses static address range/handler tables.
811     It is not compatible with the ELF exception handling tables.
812     The stack is walked assuming it uses the EBP stack frame
813     convention. The EBP convention must be used for every
814     function that has an associated EH table.
815     )
816
817     $(P For each function that has exception handlers,
818     an EH table entry is generated.
819     )
820
821     $(TABLE1
822     <caption>EH Table Entry</caption>
823     $(TR $(TH field) $(TH description))
824     $(TR $(TD void*) $(TD pointer to start of function))
825     $(TR $(TD DHandlerTable*) $(TD pointer to corresponding EH data))
826     $(TR $(TD uint) $(TD size in bytes of the function))
827     )
828     $(BR)
829
830     $(P The EH table entries are placed into the following special
831     segments, which are concatenated by the linker.
832     )
833
834     $(TABLE1
835     <caption>EH Table Segment</caption>
836     $(TR $(TH Operating System) $(TH Segment Name))
837     $(TR $(TD Windows) $(TD FI))
838     $(TR $(TD Linux) $(TD .deh_eh))
839     $(TR $(TD OSX) $(TD __deh_eh, __DATA))
840     )
841     $(BR)
842
843     $(P The rest of the EH data can be placed anywhere,
844     it is immutable.)
845
846     $(TABLE1
847     <caption>DHandlerTable</caption>
848     $(TR $(TH field) $(TH description))
849     $(TR $(TD void*) $(TD pointer to start of function))
850     $(TR $(TD uint) $(TD offset of ESP from EBP))
851     $(TR $(TD uint) $(TD offset from start of function to return code))
852     $(TR $(TD uint) $(TD number of entries in DHandlerInfo[]))
853     $(TR $(TD DHandlerInfo[]) $(TD array of handler information))
854     )
855     $(BR)
856
857     $(TABLE1
858     <caption>DHandlerInfo</caption>
859     $(TR $(TH field) $(TH description))
860     $(TR $(TD uint) $(TD offset from function address to start of guarded section))
861     $(TR $(TD uint) $(TD offset of end of guarded section))
862     $(TR $(TD int) $(TD previous table index))
863     $(TR $(TD uint) $(TD if != 0 offset to DCatchInfo data from start of table))
864     $(TR $(TD void*) $(TD if not null, pointer to finally code to execute))
865     )
866     $(BR)
867
868     $(TABLE1
869     <caption>DCatchInfo</caption>
870     $(TR $(TH field) $(TH description))
871     $(TR $(TD uint) $(TD number of entries in DCatchBlock[]))
872     $(TR $(TD DCatchBlock[]) $(TD array of catch information))
873     )
874     $(BR)
875
876     $(TABLE1
877     <caption>DCatchBlock</caption>
878     $(TR $(TH field) $(TH description))
879     $(TR $(TD ClassInfo) $(TD catch type))
880     $(TR $(TD uint) $(TD offset from EBP to catch variable))
881     $(TR $(TD void*) $(TD catch handler code))
882     )
883     )
884 )
885
886 $(SECTION3 Garbage Collection,
887
888     $(P The interface to this is found in $(TT phobos/internal/gc).)
889 )
890
891 $(SECTION3 Runtime Helper Functions,
892
893     $(P These are found in $(TT phobos/internal).)
894 )
895
896 $(SECTION3 Module Initialization and Termination,
897
898     $(P All the static constructors for a module are aggregated into a
899     single function, and a pointer to that function is inserted
900     into the ctor member of the ModuleInfo instance for that
901     module.
902     )
903
904     $(P All the static denstructors for a module are aggregated into a
905     single function, and a pointer to that function is inserted
906     into the dtor member of the ModuleInfo instance for that
907     module.
908     )
909 )
910
911 $(SECTION3 Unit Testing,
912
913     $(P All the unit tests for a module are aggregated into a
914     single function, and a pointer to that function is inserted
915     into the unitTest member of the ModuleInfo instance for that
916     module.
917     )
918 )
919
920 $(SECTION2 Symbolic Debugging,
921
922     $(P D has types that are not represented in existing C or C++ debuggers.
923     These are dynamic arrays, associative arrays, and delegates.
924     Representing these types as structs causes problems because function
925     calling conventions for structs are often different than that for
926     these types, which causes C/C++ debuggers to misrepresent things.
927     For these debuggers, they are represented as a C type which
928     does match the calling conventions for the type.
929     The $(B dmd) compiler will generate only C symbolic type info with the
930     $(B -gc) compiler switch.
931     )
932
933     $(TABLE2 Types for C Debuggers,
934     $(TR
935     $(TH D type)
936     $(TH C representation)
937     )
938     $(TR
939     $(TD dynamic array)
940     $(TD unsigned long long)
941     )
942     $(TR
943     $(TD associative array)
944     $(TD void*)
945     )
946     $(TR
947     $(TD delegate)
948     $(TD long long)
949     )
950     $(TR
951     $(TD dchar)
952     $(TD unsigned long)
953     )
954     )
955
956     $(P For debuggers that can be modified to accept new types, the
957     following extensions help them fully support the types.
958     )
959
960 $(SECTION3 <a name="codeview">Codeview Debugger Extensions</a>,
961
962     $(P The D $(B dchar) type is represented by the special
963     primitive type 0x78.)
964
965     $(P D makes use of the Codeview OEM generic type record
966     indicated by $(B LF_OEM) (0x0015). The format is:)
967
968     $(TABLE2 Codeview OEM Extensions for D,
969     $(TR
970     $(TD field size)
971     $(TD 2)
972     $(TD 2)
973     $(TD 2)
974     $(TD 2)
975     $(TD 2)
976     $(TD 2)
977     )
978     $(TR
979     $(TH D Type)
980     $(TH Leaf Index)
981     $(TH OEM Identifier)
982     $(TH recOEM)
983     $(TH num indices)
984     $(TH type index)
985     $(TH type index)
986     )
987     $(TR
988     $(TD dynamic array)
989     $(TD LF_OEM)
990     $(TD $(I OEM))
991     $(TD 1)
992     $(TD 2)
993     $(TD @$(I index))
994     $(TD @$(I element))
995     )
996     $(TR
997     $(TD associative array)
998     $(TD LF_OEM)
999     $(TD $(I OEM))
1000     $(TD 2)
1001     $(TD 2)
1002     $(TD @$(I key))
1003     $(TD @$(I element))
1004     )
1005     $(TR
1006     $(TD delegate)
1007     $(TD LF_OEM)
1008     $(TD $(I OEM))
1009     $(TD 3)
1010     $(TD 2)
1011     $(TD @$(I this))
1012     $(TD @$(I function))
1013     )
1014     )
1015
1016     $(BR) $(BR)
1017
1018     $(TABLE
1019     $(TR
1020     $(TD $(I OEM))
1021     $(TD 0x42)
1022     )
1023     $(TR
1024     $(TD $(I index))
1025     $(TD type index of array index)
1026     )
1027     $(TR
1028     $(TD $(I key))
1029     $(TD type index of key)
1030     )
1031     $(TR
1032     $(TD $(I element))
1033     $(TD type index of array element)
1034     )
1035     $(TR
1036     $(TD $(I this))
1037     $(TD type index of context pointer)
1038     )
1039     $(TR
1040     $(TD $(I function))
1041     $(TD type index of function)
1042     )
1043     )
1044
1045     $(P These extensions can be pretty-printed
1046     by $(LINK2 http://www.digitalmars.com/ctg/obj2asm.html, obj2asm).
1047
1048     $(P The $(LINK2 http://ddbg.mainia.de/releases.html, Ddbg) debugger
1049     supports them.)
1050     )
1051 )
1052
1053 $(SECTION3 <a name="dwarf">Dwarf Debugger Extensions</a>,
1054     $(P The following leaf types are added:)
1055
1056     $(TABLE2 Dwarf Extensions for D,
1057     $(TR
1058     $(TH D type)
1059     $(TH Identifier)
1060     $(TH Value)
1061     $(TH Format)
1062     )
1063     $(TR
1064     $(TD dynamic array)
1065     $(TD DW_TAG_darray_type)
1066     $(TD 0x41)
1067     $(TD DW_AT_type is element type)
1068     )
1069     $(TR
1070     $(TD associative array)
1071     $(TD DW_TAG_aarray_type)
1072     $(TD 0x42)
1073     $(TD DW_AT_type, is element type, DW_AT_containing_type key type)
1074     )
1075     $(TR
1076     $(TD delegate)
1077     $(TD DW_TAG_delegate_type)
1078     $(TD 0x43)
1079     $(TD DW_AT_type, is function type, DW_AT_containing_type is $(SINGLEQUOTE this) type)
1080     )
1081     )
1082
1083     $(P These extensions can be pretty-printed
1084     by $(LINK2 http://www.digitalmars.com/ctg/dumpobj.html, dumpobj).
1085
1086     $(P The $(LINK2 http://www.zerobugs.org, ZeroBUGS)
1087     debugger supports them.)
1088     )
1089 )
1090
1091
1092 )
1093
1094 )
1095
1096 Macros:
1097     TITLE=Application Binary Interface
1098     WIKI=ABI
Note: See TracBrowser for help on using the browser.