Mercurial > projects > ldc
comparison runtime/ldc.diff @ 755:61c7a96f28c3
Merge in most of x86-64 tango patch.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 08 Nov 2008 11:34:35 +0100 |
parents | f34b552619fd |
children | 0375841e3175 |
comparison
equal
deleted
inserted
replaced
754:f34b552619fd | 755:61c7a96f28c3 |
---|---|
94 sem_t suspendCount; | 94 sem_t suspendCount; |
95 + sem_t* suspendCountPtr; | 95 + sem_t* suspendCountPtr; |
96 | 96 |
97 | 97 |
98 extern (C) void thread_suspendHandler( int sig ) | 98 extern (C) void thread_suspendHandler( int sig ) |
99 @@ -256,8 +257,29 @@ | 99 @@ -256,8 +257,50 @@ |
100 } | 100 } |
101 body | 101 body |
102 { | 102 { |
103 - version( D_InlineAsm_X86 ) | 103 - version( D_InlineAsm_X86 ) |
104 + version( LDC) | 104 + version( LDC) |
115 + mov ebp[EBP], EBP ; | 115 + mov ebp[EBP], EBP ; |
116 + mov esi[EBP], ESI ; | 116 + mov esi[EBP], ESI ; |
117 + mov edi[EBP], EDI ; | 117 + mov edi[EBP], EDI ; |
118 + } | 118 + } |
119 + } | 119 + } |
120 + else version (X86_64) | |
121 + { | |
122 + ulong rax,rbx,rcx,rdx,rbp,rsi,rdi,rsp,r10,r11,r12,r13,r14,r15; | |
123 + asm | |
124 + { | |
125 + movq rax[RBP], RAX ; | |
126 + movq rbx[RBP], RBX ; | |
127 + movq rcx[RBP], RCX ; | |
128 + movq rdx[RBP], RDX ; | |
129 + movq rbp[RBP], RBP ; | |
130 + movq rsi[RBP], RSI ; | |
131 + movq rdi[RBP], RDI ; | |
132 + movq rsp[RBP], RSP ; | |
133 + movq r10[RBP], R10 ; | |
134 + movq r11[RBP], R11 ; | |
135 + movq r12[RBP], R12 ; | |
136 + movq r13[RBP], R13 ; | |
137 + movq r14[RBP], R14 ; | |
138 + movq r15[RBP], R15 ; | |
139 + } | |
140 + } | |
120 + else | 141 + else |
121 + { | 142 + { |
122 + static assert( false, "Architecture not supported." ); | 143 + static assert( false, "Architecture not supported." ); |
123 + } | 144 + } |
124 + } | 145 + } |
125 + else version( D_InlineAsm_X86 ) | 146 + else version( D_InlineAsm_X86 ) |
126 + { | 147 + { |
127 asm | 148 asm |
128 { | 149 { |
129 pushad; | 150 pushad; |
130 @@ -298,7 +320,7 @@ | 151 @@ -298,7 +341,7 @@ |
131 status = sigdelset( &sigres, SIGUSR2 ); | 152 status = sigdelset( &sigres, SIGUSR2 ); |
132 assert( status == 0 ); | 153 assert( status == 0 ); |
133 | 154 |
134 - status = sem_post( &suspendCount ); | 155 - status = sem_post( &suspendCount ); |
135 + status = sem_post( suspendCountPtr ); | 156 + status = sem_post( suspendCountPtr ); |
136 assert( status == 0 ); | 157 assert( status == 0 ); |
137 | 158 |
138 sigsuspend( &sigres ); | 159 sigsuspend( &sigres ); |
139 @@ -309,8 +331,12 @@ | 160 @@ -309,8 +352,12 @@ |
140 } | 161 } |
141 } | 162 } |
142 | 163 |
143 - version( D_InlineAsm_X86 ) | 164 - version( D_InlineAsm_X86 ) |
144 + version( LDC) | 165 + version( LDC) |
148 + else version( D_InlineAsm_X86 ) | 169 + else version( D_InlineAsm_X86 ) |
149 + { | 170 + { |
150 asm | 171 asm |
151 { | 172 { |
152 popad; | 173 popad; |
153 @@ -1584,8 +1610,14 @@ | 174 @@ -1584,8 +1631,14 @@ |
154 status = sigaction( SIGUSR2, &sigusr2, null ); | 175 status = sigaction( SIGUSR2, &sigusr2, null ); |
155 assert( status == 0 ); | 176 assert( status == 0 ); |
156 | 177 |
157 - status = sem_init( &suspendCount, 0, 0 ); | 178 - status = sem_init( &suspendCount, 0, 0 ); |
158 - assert( status == 0 ); | 179 - assert( status == 0 ); |
165 + assert(status==0); | 186 + assert(status==0); |
166 + } | 187 + } |
167 | 188 |
168 status = pthread_key_create( &Thread.sm_this, null ); | 189 status = pthread_key_create( &Thread.sm_this, null ); |
169 assert( status == 0 ); | 190 assert( status == 0 ); |
170 @@ -1793,7 +1825,7 @@ | 191 @@ -1793,7 +1846,7 @@ |
171 // to simply loop on sem_wait at the end, but I'm not | 192 // to simply loop on sem_wait at the end, but I'm not |
172 // convinced that this would be much faster than the | 193 // convinced that this would be much faster than the |
173 // current approach. | 194 // current approach. |
174 - sem_wait( &suspendCount ); | 195 - sem_wait( &suspendCount ); |
175 + sem_wait( suspendCountPtr ); | 196 + sem_wait( suspendCountPtr ); |
176 } | 197 } |
177 else if( !t.m_lock ) | 198 else if( !t.m_lock ) |
178 { | 199 { |
179 @@ -2298,6 +2330,13 @@ | 200 @@ -2298,7 +2351,20 @@ |
180 version = AsmPPC_Posix; | 201 version = AsmPPC_Posix; |
181 } | 202 } |
182 | 203 |
183 + version( LLVM_InlineAsm_X86 ) | 204 + version( LLVM_InlineAsm_X86 ) |
184 + { | 205 + { |
185 + version( Win32 ) | 206 + version( Win32 ) |
186 + version = LLVM_AsmX86_Win32; | 207 + version = LLVM_AsmX86_Win32; |
187 + else version( Posix ) | 208 + else version( Posix ) |
188 + version = LLVM_AsmX86_Posix; | 209 + version = LLVM_AsmX86_Posix; |
189 + } | 210 + } |
190 | 211 + else version( LLVM_InlineAsm_X86_64 ) |
212 + { | |
213 + version( Posix ) | |
214 + version = LLVM_AsmX86_64_Posix; | |
215 + } | |
216 | |
217 + | |
191 version( Posix ) | 218 version( Posix ) |
192 { | 219 { |
193 @@ -2308,6 +2347,8 @@ | 220 import tango.stdc.posix.unistd; // for sysconf |
221 @@ -2308,6 +2374,10 @@ | |
194 version( AsmX86_Win32 ) {} else | 222 version( AsmX86_Win32 ) {} else |
195 version( AsmX86_Posix ) {} else | 223 version( AsmX86_Posix ) {} else |
196 version( AsmPPC_Posix ) {} else | 224 version( AsmPPC_Posix ) {} else |
197 + version( LLVM_AsmX86_Win32 ) {} else | 225 + version( LLVM_AsmX86_Win32 ) {} else |
198 + version( LLVM_AsmX86_Posix ) {} else | 226 + version( LLVM_AsmX86_Posix ) {} else |
227 +//TODO: Enable when x86-64 Posix supports fibers | |
228 +// version( LLVM_AsmX86_64_Posix ) {} else | |
199 { | 229 { |
200 // NOTE: The ucontext implementation requires architecture specific | 230 // NOTE: The ucontext implementation requires architecture specific |
201 // data definitions to operate so testing for it must be done | 231 // data definitions to operate so testing for it must be done |
202 @@ -2318,10 +2359,10 @@ | 232 @@ -2318,10 +2388,10 @@ |
203 import tango.stdc.posix.ucontext; | 233 import tango.stdc.posix.ucontext; |
204 } | 234 } |
205 } | 235 } |
206 - | 236 - |
207 - const size_t PAGESIZE; | 237 - const size_t PAGESIZE; |
210 +// this can't be private since it's used as default argument to a public function | 240 +// this can't be private since it's used as default argument to a public function |
211 +const size_t PAGESIZE; | 241 +const size_t PAGESIZE; |
212 | 242 |
213 static this() | 243 static this() |
214 { | 244 { |
215 @@ -2348,7 +2389,7 @@ | 245 @@ -2348,7 +2418,7 @@ |
216 } | 246 } |
217 } | 247 } |
218 | 248 |
219 - | 249 - |
220 +extern(C) int printf(char*, ...); | 250 +extern(C) int printf(char*, ...); |
221 //////////////////////////////////////////////////////////////////////////////// | 251 //////////////////////////////////////////////////////////////////////////////// |
222 // Fiber Entry Point and Context Switch | 252 // Fiber Entry Point and Context Switch |
223 //////////////////////////////////////////////////////////////////////////////// | 253 //////////////////////////////////////////////////////////////////////////////// |
224 @@ -2462,6 +2503,22 @@ | 254 @@ -2462,6 +2532,28 @@ |
225 ret; | 255 ret; |
226 } | 256 } |
227 } | 257 } |
228 + else version( LLVM_AsmX86_Posix ) | 258 + else version( LLVM_AsmX86_Posix ) |
229 + { | 259 + { |
239 + mov [EAX], ESP; | 269 + mov [EAX], ESP; |
240 + // load newp to begin context switch | 270 + // load newp to begin context switch |
241 + mov ESP, newp; | 271 + mov ESP, newp; |
242 + } | 272 + } |
243 + } | 273 + } |
274 +/+ | |
275 + version( LLVM_AsmX86_64_Posix ) | |
276 + { | |
277 + //TODO: Fiber implementation here | |
278 + } | |
279 ++/ | |
244 else static if( is( ucontext_t ) ) | 280 else static if( is( ucontext_t ) ) |
245 { | 281 { |
246 Fiber cfib = Fiber.getThis(); | 282 Fiber cfib = Fiber.getThis(); |
247 @@ -3127,6 +3184,16 @@ | 283 @@ -2980,16 +3072,25 @@ |
284 m_size = sz; | |
285 } | |
286 else | |
287 - { static if( is( typeof( mmap ) ) ) | |
288 + { | |
289 + static if( is( typeof( mmap ) ) ) | |
290 { | |
291 - m_pmem = mmap( null, | |
292 + //TODO: This seems a bit dubious. | |
293 + version (X86_64) | |
294 + { | |
295 + m_pmem = malloc( sz ); | |
296 + } | |
297 + else | |
298 + { | |
299 + m_pmem = mmap( null, | |
300 sz, | |
301 PROT_READ | PROT_WRITE, | |
302 MAP_PRIVATE | MAP_ANON, | |
303 -1, | |
304 0 ); | |
305 - if( m_pmem == MAP_FAILED ) | |
306 - m_pmem = null; | |
307 + if( m_pmem == MAP_FAILED ) | |
308 + m_pmem = null; | |
309 + } | |
310 } | |
311 else static if( is( typeof( valloc ) ) ) | |
312 { | |
313 @@ -3127,6 +3228,22 @@ | |
248 push( 0x00000000 ); // ESI | 314 push( 0x00000000 ); // ESI |
249 push( 0x00000000 ); // EDI | 315 push( 0x00000000 ); // EDI |
250 } | 316 } |
251 + else version( LLVM_AsmX86_Posix ) | 317 + else version( LLVM_AsmX86_Posix ) |
252 + { | 318 + { |
256 + push( 0x00000000 ); // EBP | 322 + push( 0x00000000 ); // EBP |
257 + push( 0x00000000 ); // EBX | 323 + push( 0x00000000 ); // EBX |
258 + push( 0x00000000 ); // ESI | 324 + push( 0x00000000 ); // ESI |
259 + push( 0x00000000 ); // EDI | 325 + push( 0x00000000 ); // EDI |
260 + } | 326 + } |
327 +//TODO: Implement x86-64 fibers | |
328 +/+ | |
329 + else version( LLVM_AsmX86_Posix ) | |
330 + { | |
331 + } | |
332 ++/ | |
261 else version( AsmPPC_Posix ) | 333 else version( AsmPPC_Posix ) |
262 { | 334 { |
263 version( StackGrowsDown ) | 335 version( StackGrowsDown ) |
264 Index: lib/gc/basic/gcx.d | 336 Index: lib/gc/basic/gcx.d |
265 =================================================================== | 337 =================================================================== |
291 - } | 363 - } |
292 - | 364 - |
293 extern (C) void* rt_stackBottom(); | 365 extern (C) void* rt_stackBottom(); |
294 extern (C) void* rt_stackTop(); | 366 extern (C) void* rt_stackTop(); |
295 | 367 |
296 @@ -2178,6 +2178,28 @@ | 368 @@ -2178,6 +2178,49 @@ |
297 __builtin_unwind_init(); | 369 __builtin_unwind_init(); |
298 sp = & sp; | 370 sp = & sp; |
299 } | 371 } |
300 + else version(LDC) | 372 + else version(LDC) |
301 + { | 373 + { |
312 + mov esi[EBP], ESI ; | 384 + mov esi[EBP], ESI ; |
313 + mov edi[EBP], EDI ; | 385 + mov edi[EBP], EDI ; |
314 + mov sp[EBP],ESP ; | 386 + mov sp[EBP],ESP ; |
315 + } | 387 + } |
316 + } | 388 + } |
389 + else version (X86_64) | |
390 + { | |
391 + ulong rax,rbx,rcx,rdx,rbp,rsi,rdi,rsp,r10,r11,r12,r13,r14,r15; | |
392 + asm | |
393 + { | |
394 + movq rax[RBP], RAX ; | |
395 + movq rbx[RBP], RBX ; | |
396 + movq rcx[RBP], RCX ; | |
397 + movq rdx[RBP], RDX ; | |
398 + movq rbp[RBP], RBP ; | |
399 + movq rsi[RBP], RSI ; | |
400 + movq rdi[RBP], RDI ; | |
401 + movq rsp[RBP], RSP ; | |
402 + movq r10[RBP], R10 ; | |
403 + movq r11[RBP], R11 ; | |
404 + movq r12[RBP], R12 ; | |
405 + movq r13[RBP], R13 ; | |
406 + movq r14[RBP], R14 ; | |
407 + movq r15[RBP], R15 ; | |
408 + } | |
409 + } | |
317 + else | 410 + else |
318 + { | 411 + { |
319 + static assert( false, "Architecture not supported." ); | 412 + static assert( false, "Architecture not supported." ); |
320 + } | 413 + } |
321 + } | 414 + } |
322 else | 415 else |
323 { | 416 { |
324 asm | 417 asm |
325 @@ -2191,6 +2213,10 @@ | 418 @@ -2191,6 +2234,10 @@ |
326 { | 419 { |
327 // nothing to do | 420 // nothing to do |
328 } | 421 } |
329 + else version(LDC) | 422 + else version(LDC) |
330 + { | 423 + { |