Mercurial > projects > ldc
annotate tango/lib/compiler/llvmdc/memory.d @ 217:0806379a5eca trunk
[svn r233] Added: -oq command line option for writing fully qualified object names.
Added: started support for x86 80bit floating point.
Changed: aggregates passed by value now use the llvm 'byval' parameter attribute, also lays ground work for
using other attributes.
Changed: eliminated a lot more std::vectorS, these showed up pretty much at the top when profiling!
Changed: performed other misc. cleanups.
Changed: halt expression now call the new llvm trap intrinsic instead of an assert(0).
Changed: dstress suite now passes -O0 by default, this only eliminates unreferenced globals, which speeds up
linking quite a bit.
author | lindquist |
---|---|
date | Thu, 05 Jun 2008 06:38:36 +0200 |
parents | 1700239cab2e |
children | d9d5d59873d8 |
rev | line source |
---|---|
132 | 1 /** |
2 * This module exposes functionality for inspecting and manipulating memory. | |
3 * | |
4 * Copyright: Copyright (C) 2005-2006 Digital Mars, www.digitalmars.com. | |
5 * All rights reserved. | |
6 * License: | |
7 * This software is provided 'as-is', without any express or implied | |
8 * warranty. In no event will the authors be held liable for any damages | |
9 * arising from the use of this software. | |
10 * | |
11 * Permission is granted to anyone to use this software for any purpose, | |
12 * including commercial applications, and to alter it and redistribute it | |
13 * freely, in both source and binary form, subject to the following | |
14 * restrictions: | |
15 * | |
16 * o The origin of this software must not be misrepresented; you must not | |
17 * claim that you wrote the original software. If you use this software | |
18 * in a product, an acknowledgment in the product documentation would be | |
19 * appreciated but is not required. | |
20 * o Altered source versions must be plainly marked as such, and must not | |
21 * be misrepresented as being the original software. | |
22 * o This notice may not be removed or altered from any source | |
23 * distribution. | |
24 * Authors: Walter Bright, Sean Kelly | |
25 */ | |
26 module memory; | |
27 | |
28 | |
29 private | |
30 { | |
31 version( linux ) | |
32 { | |
33 //version = SimpleLibcStackEnd; | |
34 | |
35 version( SimpleLibcStackEnd ) | |
36 { | |
37 extern (C) extern void* __libc_stack_end; | |
38 } | |
39 else | |
40 { | |
41 import tango.stdc.posix.dlfcn; | |
42 } | |
43 } | |
44 version(LLVMDC) | |
45 { | |
46 pragma(LLVM_internal, "intrinsic", "llvm.frameaddress") | |
47 { | |
48 void* llvm_frameaddress(uint level=0); | |
49 } | |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
132
diff
changeset
|
50 extern(C) int printf(char*, ...); |
132 | 51 } |
52 } | |
53 | |
54 | |
55 /** | |
56 * | |
57 */ | |
58 extern (C) void* rt_stackBottom() | |
59 { | |
60 version( Win32 ) | |
61 { | |
62 asm | |
63 { | |
64 naked; | |
65 mov EAX,FS:4; | |
66 ret; | |
67 } | |
68 } | |
69 else version( linux ) | |
70 { | |
71 version( SimpleLibcStackEnd ) | |
72 { | |
73 return __libc_stack_end; | |
74 } | |
75 else | |
76 { | |
77 // See discussion: http://autopackage.org/forums/viewtopic.php?t=22 | |
78 static void** libc_stack_end; | |
79 | |
80 if( libc_stack_end == libc_stack_end.init ) | |
81 { | |
82 void* handle = dlopen( null, RTLD_NOW ); | |
83 libc_stack_end = cast(void**) dlsym( handle, "__libc_stack_end" ); | |
84 dlclose( handle ); | |
85 } | |
86 return *libc_stack_end; | |
87 } | |
88 } | |
89 else | |
90 { | |
91 static assert( false, "Operating system not supported." ); | |
92 } | |
93 } | |
94 | |
95 | |
96 /** | |
97 * | |
98 */ | |
99 extern (C) void* rt_stackTop() | |
100 { | |
101 version( D_InlineAsm_X86 ) | |
102 { | |
103 asm | |
104 { | |
105 naked; | |
106 mov EAX, ESP; | |
107 ret; | |
108 } | |
109 } | |
110 else version(LLVMDC) | |
111 { | |
112 return llvm_frameaddress(); | |
113 } | |
114 else | |
115 { | |
116 static assert( false, "Architecture not supported." ); | |
117 } | |
118 } | |
119 | |
120 | |
121 private | |
122 { | |
123 version( Win32 ) | |
124 { | |
125 extern (C) | |
126 { | |
127 extern int _xi_a; // &_xi_a just happens to be start of data segment | |
128 extern int _edata; // &_edata is start of BSS segment | |
129 extern int _end; // &_end is past end of BSS | |
130 } | |
131 } | |
132 else version( linux ) | |
133 { | |
134 extern (C) | |
135 { | |
136 extern int _data; | |
137 extern int __data_start; | |
138 extern int _end; | |
139 extern int _data_start__; | |
140 extern int _data_end__; | |
141 extern int _bss_start__; | |
142 extern int _bss_end__; | |
143 extern int __fini_array_end; | |
144 } | |
145 | |
146 alias __data_start Data_Start; | |
147 alias _end Data_End; | |
148 } | |
149 | |
150 alias void delegate( void*, void* ) scanFn; | |
151 } | |
152 | |
153 | |
154 /** | |
155 * | |
156 */ | |
157 extern (C) void rt_scanStaticData( scanFn scan ) | |
158 { | |
159 version( Win32 ) | |
160 { | |
161 scan( &_xi_a, &_end ); | |
162 } | |
163 else version( linux ) | |
164 { | |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
132
diff
changeset
|
165 //printf("scanning static data from %p to %p\n", &__data_start, &_end); |
132 | 166 scan( &__data_start, &_end ); |
167 } | |
168 else | |
169 { | |
170 static assert( false, "Operating system not supported." ); | |
171 } | |
172 } |