Ticket #2038: 64Bit.12.patch
File 64Bit.12.patch, 127.4 kB (added by Marenz, 13 years ago) |
---|
added argTypes where it was missing, only for dmd so far |
-
build/script/unittest.sh
old new 9 9 EXE=runUnittests_$DC 10 10 DL="-L-ldl" 11 11 UNAME=`uname` 12 OPTIONS="-debug -debug=UnitTest "12 OPTIONS="-debug -debug=UnitTest -debug=PRINTF" 13 13 14 14 error () { 15 15 echo "Example : DC=dmd PLATFORM=linux ARCH=32 build/script/unittest.sh" … … 33 33 OPTIONS="-oq -d-debug -d-debug=UnitTest" 34 34 fi 35 35 36 build/bin/$PLATFORM$ARCH/bob -v -r=$DC -c=$DC -p=$PLATFORM -l=libtango-$DC-tst -o="-g -unittest $OPTIONS" . 36 echo build/bin/${PLATFORM}32/bob -r=$DC -v -c=$DC -p=$PLATFORM -l=libtango-$DC-tst -o=\"-m$ARCH -gc -unittest $OPTIONS\" . 37 build/bin/${PLATFORM}32/bob -r=$DC -v -c=$DC -p=$PLATFORM -l=libtango-$DC-tst -o="-m$ARCH -gc -unittest $OPTIONS" . 37 38 39 40 echo "Compiled" 41 38 42 if ! which $DC >& /dev/null 39 43 then 40 44 echo "$DC not found on your \$PATH!" … … 99 103 DL="" 100 104 fi 101 105 102 echo "$DC $EXE.d $DFILES -g $OPTIONS-unittest -L-L. -L-ltango-$DC-tst $DL -L-lz -L-lbz2"103 $DC $EXE.d $DFILES -g $OPTIONS -unittest -L-L. -L-ltango-$DC-tst $DL -L-lz -L-lbz2&& rm $EXE.d && rm libtango-$DC-tst.a106 echo "$DC $EXE.d $DFILES -gc $OPTIONS -m$ARCH -unittest -L-L. -L-ltango-$DC-tst $DL -L-lz -L-lbz2" 107 $DC $EXE.d $DFILES -gc $OPTIONS -m$ARCH -unittest -L-L. -L-ltango-$DC-tst $DL -L-lz -L-lbz2 #&& rm $EXE.d && rm libtango-$DC-tst.a 104 108 105 109 ./runUnittests_$DC 106 110 -
build/src/bob.d
old new 38 38 new FreeBSD (args); 39 39 new Solaris (args); 40 40 new Windows (args); 41 stdout.formatln ("{} files", FileFilter.builder(args.os, args.compiler)());41 Stdout.formatln ("{} files", FileFilter.builder(args.os, args.compiler)()); 42 42 } 43 43 } 44 44 … … 170 170 171 171 if (args.core) { 172 172 foreach (file; scan(".c")) { 173 auto obj = compile (file, gcc 32);173 auto obj = compile (file, gcc); 174 174 addToLib(obj); 175 175 } 176 176 177 177 foreach (file; scan(".S")) { 178 auto obj = compile (file, gcc 32);178 auto obj = compile (file, gcc); 179 179 addToLib(obj); 180 180 } 181 181 } … … 780 780 if (args.verbose) 781 781 { 782 782 foreach (str; cmd) 783 stdout (str)(' ');784 stdout.newline;783 Stdout (str)(' '); 784 Stdout.newline; 785 785 } 786 786 787 787 if (! args.inhibit) … … 794 794 proc.copyEnv (true); 795 795 796 796 proc.execute(); 797 stdout.stream.copy (proc.stderr);798 stdout.stream.copy (proc.stdout);797 Stdout.stream.copy (proc.stderr); 798 Stdout.stream.copy (proc.stdout); 799 799 auto result = proc.wait; 800 800 if (result.reason != Process.Result.Exit) 801 801 throw new Exception (result.toString); -
object.di
old new 119 119 equals_t equals(void *p1, void *p2); 120 120 /// compares the types of this TypeInfo stored at p1 and p2 121 121 int compare(void *p1, void *p2); 122 /// Return alignment of type 123 size_t talign() { return tsize(); } 122 124 /// returns the size of a type with the current TypeInfo 123 125 size_t tsize(); 124 126 /// swaps the two types stored at p1 and p2 … … 131 133 PointerMap pointermap(); 132 134 /// offsets of the various elements 133 135 OffsetTypeInfo[] offTi(); 136 137 /** Return internal info on arguments fitting into 8byte. 138 * See X86-64 ABI 3.2.3 139 */ 140 version (X86_64) int argTypes(out TypeInfo arg1, out TypeInfo arg2); 134 141 } 135 142 136 143 class TypeInfo_Typedef : TypeInfo -
tango/text/convert/Layout.d
old new 66 66 alias void* Arg; 67 67 alias va_list ArgList; 68 68 } 69 else version(DigitalMars) 70 { 71 private import tango.core.Vararg; 72 alias void* Arg; 73 alias va_list ArgList; 74 } 69 75 else 70 76 { 71 77 alias void* Arg; -
tango/text/Text.d
old new 213 213 214 214 private import tango.stdc.string : memmove; 215 215 216 version(DigitalMars) 217 { 218 private import tango.core.Vararg; 219 } 216 220 217 221 /******************************************************************************* 218 222 -
tango/io/Console.d
old new 638 638 Cerr = new Console.Output (conduit, conduit.redirected); 639 639 } 640 640 641 642 641 /****************************************************************************** 643 642 644 643 Flush outputs before we exit. -
tango/io/stream/Snoop.d
old new 17 17 18 18 private import tango.text.convert.Format; 19 19 20 version(DigitalMars) 21 { 22 private import tango.core.Vararg; 23 } 24 20 25 private alias void delegate(char[]) Snoop; 21 26 22 27 /******************************************************************************* -
tango/io/stream/Format.d
old new 16 16 17 17 private import tango.text.convert.Layout; 18 18 19 version(DigitalMars) 20 { 21 private import tango.core.Vararg; 22 } 23 19 24 /******************************************************************************* 20 25 21 26 A bridge between a Layout instance and a stream. This is used for -
tango/core/rt/gc/basic/gcx.d
old new 64 64 private import gcc.builtins; // for __builtin_unwind_init 65 65 } 66 66 67 extern (C) uint sleep(uint seconds); 67 68 68 69 struct BlkInfo 69 70 { … … 1666 1667 */ 1667 1668 void addRange(void *pbot, void *ptop) 1668 1669 { 1669 debug(PRINTF) printf("Thread %x ", pthread_self());1670 debug(PRINTF) debug(THREADINVARIANT) printf("Thread %x ", pthread_self()); 1670 1671 debug(PRINTF) printf("%x.Gcx::addRange(%x, %x), nranges = %d\n", this, pbot, ptop, nranges); 1671 1672 if (nranges == rangedim) 1672 1673 { … … 1694 1695 */ 1695 1696 void removeRange(void *pbot) 1696 1697 { 1697 debug(PRINTF) printf("Thread %x ", pthread_self());1698 debug(PRINTF) debug(THREADINVARIANT) printf("Thread %x ", pthread_self()); 1698 1699 debug(PRINTF) printf("%x.Gcx.removeRange(%x), nranges = %d\n", this, pbot, nranges); 1699 1700 for (size_t i = nranges; i--;) 1700 1701 { … … 2098 2099 size_t newnpools; 2099 2100 size_t i; 2100 2101 2101 //debug(PRINTF) printf("************Gcx::newPool(npages = %d)****************\n", npages);2102 2102 2103 debug(PRINTF) printf("************Gcx::newPool(npages = %x)****************\n", npages); 2104 if ( npages > 0xc5e00010 ) 2105 sleep ( 5); 2106 2103 2107 // Round up to COMMITSIZE pages 2104 2108 npages = (npages + (COMMITSIZE/PAGESIZE) - 1) & ~(COMMITSIZE/PAGESIZE - 1); 2105 2109 … … 2344 2348 } 2345 2349 else 2346 2350 { 2351 version (D_InlineAsm_X86) 2352 { 2347 2353 asm 2348 2354 { 2349 2355 pushad ; 2350 2356 mov sp[EBP],ESP ; 2351 2357 } 2352 2358 } 2359 else version (D_InlineAsm_X86_64) 2360 { 2361 asm 2362 { 2363 push RAX ; 2364 push RBX ; 2365 push RCX ; 2366 push RDX ; 2367 push RSI ; 2368 push RDI ; 2369 push RBP ; 2370 push R8 ; 2371 push R9 ; 2372 push R10 ; 2373 push R11 ; 2374 push R12 ; 2375 push R13 ; 2376 push R14 ; 2377 push R15 ; 2378 push EAX ; // 16 byte align the stack 2379 } 2380 } 2381 else 2382 { 2383 static assert( false, "Architecture not supported." ); 2384 } 2385 } 2353 2386 result = fullcollect(sp); 2354 2387 version (GNU) 2355 2388 { … … 2359 2392 { 2360 2393 // nothing to do 2361 2394 } 2362 else 2395 else version (D_InlineAsm_X86) 2363 2396 { 2364 2397 asm 2365 2398 { 2366 2399 popad ; 2367 2400 } 2368 2401 } 2402 else version (D_InlineAsm_X86_64) 2403 { 2404 asm 2405 { 2406 pop EAX ; // 16 byte align the stack 2407 pop R15 ; 2408 pop R14 ; 2409 pop R13 ; 2410 pop R12 ; 2411 pop R11 ; 2412 pop R10 ; 2413 pop R9 ; 2414 pop R8 ; 2415 pop RBP ; 2416 pop RDI ; 2417 pop RSI ; 2418 pop RDX ; 2419 pop RCX ; 2420 pop RBX ; 2421 pop RAX ; 2422 } 2423 } 2424 else 2425 { 2426 static assert( false, "Architecture not supported." ); 2427 } 2369 2428 return result; 2370 2429 } 2371 2430 … … 2471 2530 } 2472 2531 *b = 0; 2473 2532 2474 auto o = pool.baseAddr + (b - bbase) * 32* 16;2533 auto o = pool.baseAddr + (b - bbase) * (typeof(bitm).sizeof*8) * 16; 2475 2534 if (!(bitm & 0xFFFF)) 2476 2535 { 2477 2536 bitm >>= 16; … … 2519 2578 for (n = 0; n < npools; n++) 2520 2579 { size_t pn; 2521 2580 size_t ncommitted; 2522 uint* bbase;2523 2581 2524 2582 pool = pooltable[n]; 2525 bbase = pool.mark.base();2583 auto bbase = pool.mark.base(); 2526 2584 ncommitted = pool.ncommitted; 2527 2585 for (pn = 0; pn < ncommitted; pn++, bbase += PAGESIZE / (32 * 16)) 2528 2586 { … … 2571 2629 sentinel_Invariant(sentinel_add(p)); 2572 2630 2573 2631 pool.freebits.set(biti); 2632 2574 2633 if (pool.finals.nbits && pool.finals.testClear(biti)) 2575 2634 rt_finalize(cast(List *)sentinel_add(p), false/*noStack > 0*/); 2576 2635 clrBits(pool, biti, BlkAttr.ALL_BITS); … … 2909 2968 //debug(PRINTF) printf("Pool::Pool(%u)\n", npages); 2910 2969 poolsize = npages * PAGESIZE; 2911 2970 assert(poolsize >= POOLSIZE); 2971 2972 debug(PRINTF) printf("alloc of pool: %p bytes\n", poolsize); 2973 2912 2974 baseAddr = cast(byte *)os_mem_map(poolsize); 2913 2975 2914 2976 // Some of the code depends on page alignment of memory pools -
tango/core/rt/gc/basic/gcalloc.d
old new 115 115 } 116 116 else static if (is(typeof(mmap))) // else version (GC_Use_Alloc_MMap) 117 117 { 118 debug(PRINTF) import tango.stdc.stdio: printf; 119 120 118 121 void *os_mem_map(size_t nbytes) 119 122 { void *p; 120 123 124 debug(PRINTF) printf("mmap alloc of %p bytes\n", nbytes); 121 125 p = mmap(null, nbytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); 122 126 return (p == MAP_FAILED) ? null : p; 123 127 } -
tango/core/rt/gc/basic/gcbits.d
old new 50 50 51 51 struct GCBits 52 52 { 53 const int BITS_PER_WORD = 32; 54 const int BITS_SHIFT = 5; 55 const int BITS_MASK = 31; 53 alias size_t wordtype; 56 54 57 uint* data = null; 55 const BITS_PER_WORD = (wordtype.sizeof * 8); 56 const BITS_SHIFT = (wordtype.sizeof == 8 ? 6 : 5); 57 const BITS_MASK = (BITS_PER_WORD - 1); 58 const BITS_1 = cast(wordtype)1; 59 60 wordtype* data = null; 58 61 size_t nwords = 0; // allocated words in data[] excluding sentinals 59 62 size_t nbits = 0; // number of bits in data[] excluding sentinals 60 63 … … 79 82 { 80 83 this.nbits = nbits; 81 84 nwords = (nbits + (BITS_PER_WORD - 1)) >> BITS_SHIFT; 82 data = cast( uint*)calloc(nwords + 2, uint.sizeof);85 data = cast(wordtype*)calloc(nwords + 2, wordtype.sizeof); 83 86 if (!data) 84 87 onOutOfMemoryError(); 85 88 } 86 89 87 uinttest(size_t i)90 wordtype test(size_t i) 88 91 in 89 92 { 90 93 assert(i < nbits); … … 92 95 body 93 96 { 94 97 //return (cast(bit *)(data + 1))[i]; 95 return data[1 + (i >> BITS_SHIFT)] & ( 1 << (i & BITS_MASK));98 return data[1 + (i >> BITS_SHIFT)] & (BITS_1 << (i & BITS_MASK)); 96 99 } 97 100 98 101 void set(size_t i) … … 103 106 body 104 107 { 105 108 //(cast(bit *)(data + 1))[i] = 1; 106 data[1 + (i >> BITS_SHIFT)] |= ( 1 << (i & BITS_MASK));109 data[1 + (i >> BITS_SHIFT)] |= (BITS_1 << (i & BITS_MASK)); 107 110 } 108 111 109 112 void clear(size_t i) … … 114 117 body 115 118 { 116 119 //(cast(bit *)(data + 1))[i] = 0; 117 data[1 + (i >> BITS_SHIFT)] &= ~( 1 << (i & BITS_MASK));120 data[1 + (i >> BITS_SHIFT)] &= ~(BITS_1 << (i & BITS_MASK)); 118 121 } 119 122 120 uinttestClear(size_t i)123 wordtype testClear(size_t i) 121 124 { 122 125 version (bitops) 123 126 { … … 136 139 } 137 140 } 138 141 else 139 { uintresult;142 { wordtype result; 140 143 141 144 //result = (cast(bit *)(data + 1))[i]; 142 145 //(cast(bit *)(data + 1))[i] = 0; 143 146 144 uint* p = &data[1 + (i >> BITS_SHIFT)];145 uint mask = (1 << (i & BITS_MASK));147 wordtype* p = &data[1 + (i >> BITS_SHIFT)]; 148 wordtype mask = (BITS_1 << (i & BITS_MASK)); 146 149 result = *p & mask; 147 150 *p &= ~mask; 148 151 return result; … … 188 191 for (;d1!=dEnd;++d1) 189 192 *d1=0u; 190 193 } else { 191 memset(data + 1, 0, nwords * uint.sizeof);194 memset(data + 1, 0, nwords * wordtype.sizeof); 192 195 } 193 196 } 194 197 … … 200 203 body 201 204 { 202 205 version(MEMCPY_NON_SIG_SAFE) { 203 uint* d1=data+1,d2=f.data+1,dEnd=d1+nwords;206 wordtype * d1=data+1,d2=f.data+1,dEnd=d1+nwords; 204 207 for (;d1!=dEnd;++d1,++d2) 205 208 *d1=*d2; 206 209 } else { 207 memcpy(data + 1, f.data + 1, nwords * uint.sizeof);210 memcpy(data + 1, f.data + 1, nwords * wordtype.sizeof); 208 211 } 209 212 } 210 213 211 uint* base()214 wordtype* base() 212 215 in 213 216 { 214 217 assert(data); -
tango/core/rt/compiler/ldc/object_.d
old new 412 412 /// Compares two instances for <, ==, or >. 413 413 int compare(in void* p1, in void* p2) { return 0; } //throw new Exception("non comparable",__FILE__,__LINE__); 414 414 415 /// Return alignment of type 416 size_t talign() { return tsize(); } 417 415 418 /// Returns size of the type. 416 419 size_t tsize() { return 0; } 417 420 -
tango/core/rt/compiler/ldc/typeinfo/ti_void.d
old new 22 22 return *cast(byte *)p1 - *cast(byte *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return void.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return void.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_wchar.d
old new 21 21 return *cast(wchar *)p1 - *cast(wchar *)p2; 22 22 } 23 23 24 override size_t talign() 25 { 26 return wchar.alignof; 27 } 28 24 29 override size_t tsize() 25 30 { 26 31 return wchar.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_ptr.d
old new 25 25 return 0; 26 26 } 27 27 28 override size_t talign() 29 { 30 return (void*).alignof; 31 } 32 28 33 override size_t tsize() 29 34 { 30 35 return (void*).sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_Afloat.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (float[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (float[]).sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_double.d
old new 43 43 return _compare(*cast(double *)p1, *cast(double *)p2); 44 44 } 45 45 46 override size_t talign() 47 { 48 return double.alignof; 49 } 50 46 51 override size_t tsize() 47 52 { 48 53 return double.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_delegate.d
old new 18 18 return *cast(dg *)p1 == *cast(dg *)p2; 19 19 } 20 20 21 override size_t talign() 22 { 23 return dg.alignof; 24 } 25 21 26 override size_t tsize() 22 27 { 23 28 return dg.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_Adouble.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (double[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (double[]).sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_char.d
old new 20 20 return *cast(char *)p1 - *cast(char *)p2; 21 21 } 22 22 23 override size_t talign() 24 { 25 return char.alignof; 26 } 27 23 28 override size_t tsize() 24 29 { 25 30 return char.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_Acdouble.d
old new 75 75 return 0; 76 76 } 77 77 78 override size_t talign() 79 { 80 return (cdouble[]).alignof; 81 } 82 78 83 override size_t tsize() 79 84 { 80 85 return (cdouble[]).sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_uint.d
old new 26 26 return 0; 27 27 } 28 28 29 override size_t talign() 30 { 31 return uint.alignof; 32 } 33 29 34 override size_t tsize() 30 35 { 31 36 return uint.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_AC.d
old new 82 82 return 0; 83 83 } 84 84 85 override size_t talign() 86 { 87 return (Object[]).alignof; 88 } 89 85 90 override size_t tsize() 86 91 { 87 92 return (Object[]).sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_ulong.d
old new 31 31 return 0; 32 32 } 33 33 34 override size_t talign() 35 { 36 return ulong.alignof; 37 } 38 34 39 override size_t tsize() 35 40 { 36 41 return ulong.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_creal.d
old new 44 44 return _compare(*cast(creal *)p1, *cast(creal *)p2); 45 45 } 46 46 47 override size_t talign() 48 { 49 return creal.alignof; 50 } 51 47 52 override size_t tsize() 48 53 { 49 54 return creal.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_ubyte.d
old new 22 22 return *cast(ubyte *)p1 - *cast(ubyte *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return ubyte.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return ubyte.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_Aint.d
old new 47 47 return 0; 48 48 } 49 49 50 override size_t talign() 51 { 52 return (int[]).alignof; 53 } 54 50 55 override size_t tsize() 51 56 { 52 57 return (int[]).sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_long.d
old new 31 31 return 0; 32 32 } 33 33 34 override size_t talign() 35 { 36 return long.alignof; 37 } 38 34 39 override size_t tsize() 35 40 { 36 41 return long.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_short.d
old new 22 22 return *cast(short *)p1 - *cast(short *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return short.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return short.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_Along.d
old new 48 48 return 0; 49 49 } 50 50 51 override size_t talign() 52 { 53 return (long[]).alignof; 54 } 55 51 56 override size_t tsize() 52 57 { 53 58 return (long[]).sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_byte.d
old new 22 22 return *cast(byte *)p1 - *cast(byte *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return byte.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return byte.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_float.d
old new 42 42 return _compare(*cast(float *)p1, *cast(float *)p2); 43 43 } 44 44 45 override size_t talign() 46 { 47 return float.alignof; 48 } 49 45 50 override size_t tsize() 46 51 { 47 52 return float.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_cfloat.d
old new 44 44 return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2); 45 45 } 46 46 47 override size_t talign() 48 { 49 return cfloat.alignof; 50 } 51 47 52 override size_t tsize() 48 53 { 49 54 return cfloat.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_Acfloat.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (cfloat[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (cfloat[]).sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_cdouble.d
old new 44 44 return _compare(*cast(cdouble *)p1, *cast(cdouble *)p2); 45 45 } 46 46 47 override size_t talign() 48 { 49 return cdouble.alignof; 50 } 51 47 52 override size_t tsize() 48 53 { 49 54 return cdouble.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_dchar.d
old new 22 22 return *cast(dchar *)p1 - *cast(dchar *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return dchar.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return dchar.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_C.d
old new 62 62 return c; 63 63 } 64 64 65 override size_t talign() 66 { 67 return Object.alignof; 68 } 69 65 70 override size_t tsize() 66 71 { 67 72 return Object.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_real.d
old new 43 43 return _compare(*cast(real *)p1, *cast(real *)p2); 44 44 } 45 45 46 override size_t talign() 47 { 48 return real.alignof; 49 } 50 46 51 override size_t tsize() 47 52 { 48 53 return real.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_ushort.d
old new 22 22 return *cast(ushort *)p1 - *cast(ushort *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return ushort.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return ushort.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_Areal.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (real[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (real[]).sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_Acreal.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (creal[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (creal[]).sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_Ag.d
old new 48 48 return 0; 49 49 } 50 50 51 override size_t talign() 52 { 53 return (byte[]).alignof; 54 } 55 51 56 override size_t tsize() 52 57 { 53 58 return (byte[]).sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_int.d
old new 26 26 return 0; 27 27 } 28 28 29 override size_t talign() 30 { 31 return int.alignof; 32 } 33 29 34 override size_t tsize() 30 35 { 31 36 return int.sizeof; -
tango/core/rt/compiler/ldc/typeinfo/ti_Ashort.d
old new 47 47 return 0; 48 48 } 49 49 50 override size_t talign() 51 { 52 return (short[]).alignof; 53 } 54 50 55 override size_t tsize() 51 56 { 52 57 return (short[]).sizeof; -
tango/core/rt/compiler/dmd/rt/lifetime.d
old new 33 33 import tango.stdc.string : memcpy, memset, memcmp; 34 34 import tango.stdc.stdarg; 35 35 debug(PRINTF) import tango.stdc.stdio : printf; 36 37 alias void[] array_t; 36 38 } 37 39 38 40 … … 192 194 * ti is the type of the resulting array, or pointer to element. 193 195 * (For when the array is initialized to 0) 194 196 */ 195 extern (C) ulong_d_newarrayT(TypeInfo ti, size_t length)197 extern(C) array_t _d_newarrayT(TypeInfo ti, size_t length) 196 198 { 197 199 void* p; 198 ulongresult;200 array_t result; 199 201 auto size = ti.next.tsize(); // array element size 200 202 201 203 debug(PRINTF) printf("_d_newarrayT(length = x%x, size = %d)\n", length, size); 202 204 if (length == 0 || size == 0) 203 result = 0;205 result = array_t.init; 204 206 else 205 207 { 206 208 version (D_InlineAsm_X86) … … 213 215 jc Loverflow ; 214 216 } 215 217 } 218 else version (D_InlineAsm_X86_64) 219 asm 220 { 221 mov RAX,size ; 222 mul RAX,length ; 223 mov size,RAX ; 224 jc Loverflow ; 225 } 216 226 else 217 227 size *= length; 228 218 229 PointerMap pm; 219 version (D_HavePointerMap) { 220 pm = ti.next.pointermap(); 221 } 230 version (D_HavePointerMap) pm = ti.next.pointermap(); 231 222 232 p = gc_malloc(size + 1, !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN : 0, pm); 223 233 debug(PRINTF) printf(" p = %p\n", p); 224 234 memset(p, 0, size); 225 result = cast( ulong)length + (cast(ulong)cast(uint)p << 32);235 result = cast(array_t)p[0..length]; 226 236 } 227 237 return result; 228 238 … … 233 243 /** 234 244 * For when the array has a non-zero initializer. 235 245 */ 236 extern (C) ulong_d_newarrayiT(TypeInfo ti, size_t length)246 extern(C) array_t _d_newarrayiT(TypeInfo ti, size_t length) 237 247 { 238 ulongresult;248 array_t result; 239 249 auto size = ti.next.tsize(); // array element size 240 250 241 251 debug(PRINTF) printf("_d_newarrayiT(length = %d, size = %d)\n", length, size); 242 252 243 253 if (length == 0 || size == 0) 244 result = 0;254 result = array_t.init; 245 255 else 246 256 { 247 257 auto initializer = ti.next.init(); … … 257 267 jc Loverflow ; 258 268 } 259 269 } 270 else version (D_InlineAsm_X86_64) 271 asm 272 { 273 mov RAX,size ; 274 mul RAX,length ; 275 mov size,RAX ; 276 jc Loverflow ; 277 } 260 278 else 261 279 size *= length; 280 262 281 PointerMap pm; 263 282 version (D_HavePointerMap) { 264 283 pm = ti.next.pointermap(); … … 284 303 } 285 304 } 286 305 va_end(q); 287 result = cast( ulong)length + (cast(ulong)cast(uint)p << 32);306 result = cast(array_t)p[0..length]; 288 307 } 289 308 return result; 290 309 … … 295 314 /** 296 315 * 297 316 */ 298 extern (C) ulong_d_newarraymT(TypeInfo ti, int ndims, ...)317 extern(C) array_t _d_newarraymT(TypeInfo ti, int ndims, ...) 299 318 { 300 ulongresult;319 array_t result; 301 320 302 321 debug(PRINTF) printf("_d_newarraymT(ndims = %d)\n", ndims); 303 322 if (ndims == 0) 304 result = 0;323 result = array_t.init; 305 324 else 306 { va_list q;307 va_ start!(int)(q, ndims);325 { 326 va_list q; 308 327 309 void[] foo(TypeInfo ti, size_t* pdim, int ndims) 328 version(X86) 329 va_start(q, ndims); 330 else version(X86_64) 331 va_start(q, __va_argsave); 332 else 333 static assert(false, "platform not supported"); 334 335 void[] foo(TypeInfo ti, va_list ap, int ndims) 310 336 { 311 size_t dim = *pdim; 337 size_t dim; 338 va_arg(ap, dim); 312 339 void[] p; 313 340 314 341 debug(PRINTF) printf("foo(ti = %p, ti.next = %p, dim = %d, ndims = %d\n", ti, ti.next, dim, ndims); … … 320 347 else 321 348 { 322 349 p = gc_malloc(dim * (void[]).sizeof + 1)[0 .. dim]; 323 for (int i = 0; i < dim; i++) 350 351 version (X86) 324 352 { 325 (cast(void[]*)p.ptr)[i] = foo(ti.next, pdim + 1, ndims - 1); 353 va_list ap2; 354 va_copy(ap2, ap); 326 355 } 356 357 for (size_t i = 0; i < dim; i++) 358 { 359 version (X86_64) 360 { 361 __va_list argsave = *cast(__va_list*)ap; 362 va_list ap2 = &argsave; 327 363 } 364 (cast(void[]*)p.ptr)[i] = foo(ti.next, ap2, ndims - 1); 365 } 366 } 328 367 return p; 329 368 } 330 369 331 size_t* pdim = cast(size_t *)q; 332 result = cast(ulong)foo(ti, pdim, ndims); 370 result = cast(typeof(result))foo(ti, q, ndims); 333 371 debug(PRINTF) printf("result = %llx\n", result); 334 372 335 373 version (none) … … 348 386 /** 349 387 * 350 388 */ 351 extern (C) ulong _d_newarraymiT(TypeInfo ti, int ndims, ...)389 extern(C) array_t _d_newarraymiT(TypeInfo ti, size_t ndims, ...) 352 390 { 353 ulongresult;391 array_t result; 354 392 355 393 debug(PRINTF) printf("_d_newarraymiT(ndims = %d)\n", ndims); 356 394 if (ndims == 0) 357 result = 0;395 result = array_t.init; 358 396 else 359 397 { 360 398 va_list q; 361 va_start!(int)(q, ndims);362 399 363 void[] foo(TypeInfo ti, size_t* pdim, int ndims) 400 version(X86) 401 va_start(q, ndims); 402 else version(X86_64) 403 va_start(q, __va_argsave); 404 else 405 static assert(false, "platform not supported"); 406 407 void[] foo(TypeInfo ti, va_list ap, size_t ndims) 364 408 { 365 size_t dim = *pdim; 409 size_t dim; 410 va_arg(ap, dim); 366 411 void[] p; 367 412 368 413 if (ndims == 1) … … 373 418 else 374 419 { 375 420 p = gc_malloc(dim * (void[]).sizeof + 1)[0 .. dim]; 376 for (int i = 0; i < dim; i++) 421 422 version (X86) 377 423 { 378 (cast(void[]*)p.ptr)[i] = foo(ti.next, pdim + 1, ndims - 1); 424 va_list ap2; 425 va_copy(ap2, ap); 379 426 } 427 428 for (size_t i = 0; i < dim; i++) 429 { 430 version (X86_64) 431 { 432 __va_list argsave = *cast(__va_list*)ap; 433 va_list ap2 = &argsave; 380 434 } 435 (cast(void[]*)p.ptr)[i] = foo(ti.next, ap2, ndims - 1); 436 } 437 } 438 381 439 return p; 382 440 } 383 441 384 size_t* pdim = cast(size_t *)q; 385 result = cast(ulong)foo(ti, pdim, ndims); 442 result = cast(typeof(result))foo(ti, q, ndims); 386 443 debug(PRINTF) printf("result = %llx\n", result); 387 444 388 445 version (none) … … 457 514 { 458 515 Interface *pi = **cast(Interface ***)p; 459 516 Object o = cast(Object)(p - pi.offset); 517 debug(PRINTF) printf("finalizing..."); 460 518 rt_finalize(cast(void*)o); 461 519 } 462 520 } … … 467 525 */ 468 526 extern (C) void _d_callfinalizer(void* p) 469 527 { 528 debug(PRINTF) printf("dcall finalizing..."); 470 529 rt_finalize( p ); 471 530 } 472 531 … … 490 549 if (p) // not necessary if called from gc 491 550 { 492 551 if (det) 552 { 553 debug(PRINTF) printf("\t det=true, calling dispose\n"); 493 554 (cast(Object)p).dispose(); 555 } 556 debug(PRINTF) printf("\tcasting to class info\n"); 494 557 495 558 ClassInfo** pc = cast(ClassInfo**)p; 496 559 560 debug(PRINTF) printf("\tdereferencing pc: %lu\n", *pc); 561 497 562 if (*pc) 498 563 { 499 564 ClassInfo c = **pc; 500 565 501 566 try 502 567 { 568 debug(PRINTF) printf("\tdoing tests.. collecthandler is %lu\n", cast(void*)collectHandler); 503 569 if (det || collectHandler is null || collectHandler(cast(Object)p)) 504 570 { 505 571 do … … 509 575 void delegate() dg; 510 576 dg.ptr = p; 511 577 dg.funcptr = cast(void function()) c.destructor; 578 debug(PRINTF) printf("\tcalling dtor of %s\n", c.name.ptr); 512 579 dg(); // call destructor 580 debug(PRINTF) printf("\tdtor done.\n"); 513 581 } 514 582 c = c.base; 515 583 } while (c); … … 519 587 } 520 588 catch (Exception e) 521 589 { 590 debug(PRINTF) printf("\tException while finalizing\n"); 522 591 onFinalizeError(**pc, e); 523 592 } 524 593 finally … … 527 596 } 528 597 } 529 598 } 599 debug(PRINTF) printf("\tLeaving.\n"); 530 600 } 531 601 532 602 … … 753 823 onOutOfMemoryError(); 754 824 } 755 825 826 /************************************** 827 * Extend an array by n elements. 828 * Caller must initialize that element. 829 */ 830 version(X86_64) extern (C) byte[] _d_arrayappendcTX(TypeInfo ti, inout byte[] x, size_t n) 831 { 832 auto sizeelem = ti.next.tsize(); // array element size 833 auto info = gc_query(x.ptr); 834 auto length = x.length; 835 auto newlength = length + n; 836 auto newsize = newlength * sizeelem; 756 837 838 assert(info.size == 0 || length * sizeelem <= info.size); 839 840 //printf("_d_arrayappendcTX(sizeelem = %d, ptr = %p, length = %d, cap = %d)\n", sizeelem, x.ptr, x.length, cap); 841 842 if (newsize >= info.size) 843 { byte* newdata; 844 845 if (info.size >= PAGESIZE) 846 { // Try to extend in-place 847 auto u = gc_extend(x.ptr, (newsize + 1) - info.size, (newsize + 1) - info.size); 848 if (u) 849 { 850 goto L1; 851 } 852 } 853 854 PointerMap pm; 855 version (D_HavePointerMap) { 856 pm = ti.next.pointermap(); 857 } 858 859 uint attr = !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN : 0; 860 newdata = cast(byte *) gc_malloc(newCapacity(newlength, sizeelem) + 1, attr, pm); 861 862 memcpy(newdata, x.ptr, length * sizeelem); 863 864 (cast(void **)(&x))[1] = newdata; 865 } 866 867 L1: 868 *cast(size_t *)&x = newlength; 869 assert((cast(size_t)x.ptr & 15) == 0); 870 assert(gc_query(x.ptr).size > x.length * sizeelem); 871 return x; 872 } 873 874 757 875 /** 758 876 * Append y[] to array x[]. 759 877 * size is size of each array element. … … 1113 1231 byte[] b; 1114 1232 auto size = ti.next.tsize(); // array element size 1115 1233 1116 p = cast(byte[]*)(&n + 1); 1117 1118 for (i = 0; i < n; i++) 1234 version (X86) 1119 1235 { 1236 auto p = cast(byte[]*)(&n + 1); 1237 for (uint i = 0; i < n; i++) 1238 { 1120 1239 b = *p++; 1121 1240 length += b.length; 1122 1241 } 1242 } 1243 else version (X86_64) 1244 { 1245 __va_list argsave = __va_argsave.va; 1246 va_list ap; 1247 va_start(ap, __va_argsave); 1248 for (i = 0; i < n; i++) 1249 { 1250 b.length = 0; 1251 va_arg(ap, b); 1252 length += b.length; 1253 } 1254 va_end(ap); 1255 } 1256 1123 1257 if (!length) 1124 1258 return null; 1125 1259 … … 1128 1262 pm = ti.next.pointermap(); 1129 1263 } 1130 1264 a = gc_malloc(length * size, !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN : 0, pm); 1265 1266 version (X86) 1267 { 1131 1268 p = cast(byte[]*)(&n + 1); 1132 1133 uint j = 0; 1269 size_t j = 0; 1134 1270 for (i = 0; i < n; i++) 1135 1271 { 1136 1272 b = *p++; 1137 1273 if (b.length) 1138 1274 { 1275 memcpy(a + j, b.ptr, b.length * sizee); 1276 j += b.length * size; 1277 } 1278 } 1279 } 1280 else version (X86_64) 1281 { 1282 va_list ap2 = &argsave; 1283 size_t j = 0; 1284 for (i = 0; i < n; i++) 1285 { 1286 b.length = 0; 1287 va_arg(ap2, b); 1288 if (b.length) 1289 { 1139 1290 memcpy(a + j, b.ptr, b.length * size); 1140 1291 j += b.length * size; 1141 1292 } 1142 1293 } 1294 va_end(ap2); 1295 } 1143 1296 1144 1297 byte[] result; 1145 1298 *cast(size_t *)&result = length; // jam length … … 1147 1300 return result; 1148 1301 } 1149 1302 1303 extern (C) void* _d_arrayliteralTX(TypeInfo ti, size_t length) 1304 { 1305 auto sizeelem = ti.next.tsize(); // array element size 1306 void* result; 1150 1307 1308 //printf("_d_arrayliteralTX(sizeelem = %d, length = %d)\n", sizeelem, length); 1309 if (length == 0 || sizeelem == 0) 1310 result = null; 1311 else 1312 { 1313 PointerMap pm; 1314 version (D_HavePointerMap) { 1315 pm = ti.next.pointermap(); 1316 } 1317 result = gc_malloc(length * sizeelem, !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN : 0, pm); 1318 } 1319 return result; 1320 } 1321 1151 1322 /** 1152 1323 * 1153 1324 */ 1154 extern (C) void* _d_arrayliteralT(TypeInfo ti, size_t length, ...)1325 version (X86) extern (C) void* _d_arrayliteralT(TypeInfo ti, size_t length, ...) 1155 1326 { 1156 1327 auto sizeelem = ti.next.tsize(); // array element size 1157 1328 void* result; … … 1167 1338 } 1168 1339 result = gc_malloc(length * sizeelem, !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN : 0, pm); 1169 1340 1341 version(X86) 1342 { 1170 1343 va_list q; 1171 1344 va_start!(size_t)(q, length); 1172 1345 … … 1187 1360 1188 1361 va_end(q); 1189 1362 } 1363 else version(X86_64) 1364 { 1365 va_list q; 1366 va_start(q, __va_argsave); 1367 for (size_t i = 0; i < length; i++) 1368 { 1369 va_arg(q, ti.next, result + i * sizeelem); 1370 } 1371 va_end(q); 1372 } 1373 } 1190 1374 return result; 1191 1375 } 1192 1376 … … 1204 1388 /** 1205 1389 * 1206 1390 */ 1207 extern (C) long_adDupT(TypeInfo ti, Array2 a)1391 extern (C) array_t _adDupT(TypeInfo ti, Array2 a) 1208 1392 out (result) 1209 1393 { 1210 1394 auto sizeelem = ti.next.tsize(); // array element size … … 1226 1410 r.length = a.length; 1227 1411 memcpy(r.ptr, a.ptr, size); 1228 1412 } 1229 return *cast( long*)(&r);1413 return *cast(array_t*)(&r); 1230 1414 } 1231 1415 1232 1416 -
tango/core/rt/compiler/dmd/rt/trace.d
old new 787 787 * dw length 788 788 * ascii string 789 789 */ 790 791 version (OSX) { // 16 byte align stack 792 asm { 793 naked ; 790 version (OSX) 791 { // 16 byte align stack 792 version (D_InlineAsm_X86) 793 asm 794 { naked ; 794 795 pushad ; 795 796 mov ECX,8*4[ESP] ; 796 797 xor EAX,EAX ; … … 814 815 popad ; 815 816 ret ; 816 817 } 817 } else { 818 asm { 819 naked ; 818 else version (D_InlineAsm_X86_64) 819 static assert(0); 820 else 821 static assert(0); 822 } 823 else 824 { 825 version (D_InlineAsm_X86) 826 asm 827 { naked ; 820 828 pushad ; 821 829 mov ECX,8*4[ESP] ; 822 830 xor EAX,EAX ; … … 839 847 popad ; 840 848 ret ; 841 849 } 850 else version (D_InlineAsm_X86_64) 851 asm 852 { naked ; 853 push RAX ; 854 push RCX ; 855 push RDX ; 856 push RSI ; 857 push RDI ; 858 push R8 ; 859 push R9 ; 860 push R10 ; 861 push R11 ; 862 mov RCX,9*8[RSP] ; 863 xor RAX,RAX ; 864 mov AL,[RCX] ; 865 cmp AL,0xFF ; 866 jne L1 ; 867 cmp byte ptr 1[RCX],0 ; 868 jne L1 ; 869 mov AX,2[RCX] ; 870 add 9*8[RSP],3 ; 871 add RCX,3 ; 872 L1: inc RAX ; 873 inc RCX ; 874 add 9*8[RSP],RAX ; 875 dec RAX ; 876 push RCX ; 877 push RAX ; 878 call trace_pro ; 879 add RSP,16 ; 880 pop R11 ; 881 pop R10 ; 882 pop R8 ; 883 pop R9 ; 884 pop RDI ; 885 pop RSI ; 886 pop RDX ; 887 pop RCX ; 888 pop RAX ; 889 ret ; 842 890 } 891 else 892 static assert(0); 843 893 } 894 } 844 895 845 896 ///////////////////////////////////////////// 846 897 // Function called by trace code in function epilog. … … 906 957 } 907 958 } 908 959 } 960 else version (D_InlineAsm_X86_64) 961 { 962 extern (D) 963 { 964 void QueryPerformanceCounter(timer_t* ctr) 965 { 966 asm 967 { 968 naked ; 969 rdtsc ; 970 mov [RDI],EAX ; 971 mov 4[RDI],EDX ; 972 ret ; 973 } 974 } 975 976 void QueryPerformanceFrequency(timer_t* freq) 977 { 978 *freq = 3579545; 979 } 980 } 981 } 909 982 else 910 983 { 911 984 static assert(0); -
tango/core/rt/compiler/dmd/rt/memory.d
old new 109 109 ret; 110 110 } 111 111 } 112 else version( D_InlineAsm_X86_64 ) 113 { 114 asm 115 { 116 naked; 117 mov RAX, RSP; 118 ret; 119 } 120 } 112 121 else 113 122 { 114 123 static assert( false, "Architecture not supported." ); -
tango/core/rt/compiler/dmd/rt/dmain2.d
old new 112 112 if (result) 113 113 return result; 114 114 115 printf("Running critical init.\n"); 115 116 _d_criticalInit(); 116 117 117 118 try 118 119 { 120 printf("Running gc_init.\n"); 119 121 gc_init(); 120 122 version (Win32) 121 123 _minit(); 124 printf("Running module ctors.\n"); 122 125 _moduleCtor(); 123 126 return result = true; 124 127 } … … 138 141 { 139 142 console("error while executing module initializers\n"); 140 143 } 144 printf("Running critical term.\n"); 141 145 _d_criticalTerm(); 142 146 return result = false; 143 147 } … … 305 309 { 306 310 try 307 311 { 312 printf("Running dg.\n"); 308 313 dg(); 309 314 } 310 315 catch (Exception e) 311 316 { 317 printf("Exception happened.\n"); 312 318 e.writeOut(delegate void(char[]s){ console(s); }); 313 319 result = EXIT_FAILURE; 314 320 } 315 321 catch (Object o) 316 322 { 323 printf("Object happened.\n"); 317 324 //fprintf(stderr, "%.*s\n", o.toString()); 318 325 console (o.toString)("\n"); 319 326 result = EXIT_FAILURE; … … 341 348 342 349 void runAll() 343 350 { 351 printf("Running init.\n"); 344 352 rt_init(); 353 printf("Running runModuleUnitTests.\n"); 345 354 if (runModuleUnitTests()) 355 { 356 printf("Running main.\n"); 346 357 tryExec(&runMain); 358 } 359 360 printf("Running Term.\n"); 347 361 rt_term(); 348 362 } 349 363 -
tango/core/rt/compiler/dmd/rt/cover.d
old new 34 34 struct BitArray 35 35 { 36 36 size_t len; 37 uint*ptr;37 size_t* ptr; 38 38 39 39 bool opIndex( size_t i ) 40 40 in -
tango/core/rt/compiler/dmd/rt/aaA.d
old new 69 69 * Although DMD will return types of Array in registers, 70 70 * gcc will not, so we instead use a 'long'. 71 71 */ 72 alias longArrayRet_t;72 alias void[] ArrayRet_t; 73 73 74 74 struct Array 75 75 { … … 110 110 111 111 size_t aligntsize(size_t tsize) 112 112 { 113 // Is pointer alignment on the x64 4 bytes or 8? 113 version (X86_64) 114 // Size of key needed to align value on 16 bytes 115 return (tsize + 15) & ~(15); 116 else 114 117 return (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1); 115 118 } 116 119 … … 238 241 */ 239 242 240 243 void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, ...) 244 { 245 return _aaGetX(aa, keyti, valuesize, cast(void *)(&valuesize + 1)); 246 } 247 248 void* _aaGetX(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) 241 249 in 242 250 { 243 251 assert(aa); … … 251 259 } 252 260 body 253 261 { 254 auto pkey = cast(void *)(&valuesize + 1);255 262 size_t i; 256 263 aaA *e; 257 264 auto keysize = aligntsize(keyti.tsize()); 258 265 259 266 if (!aa.a) 260 267 aa.a = new BB(); 268 261 269 aa.a.keyti = keyti; 262 270 263 271 if (!aa.a.b.length) … … 269 277 } 270 278 271 279 auto key_hash = keyti.getHash(pkey); 280 272 281 //printf("hash = %d\n", key_hash); 282 273 283 i = key_hash % aa.a.b.length; 274 284 auto pe = &aa.a.b[i]; 285 275 286 while ((e = *pe) !is null) 276 287 { 277 288 if (key_hash == e.hash) … … 312 323 313 324 void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, ...) 314 325 { 326 return _aaGetRvalueX(aa, keyti, valuesize, cast(void *)(&valuesize + 1)); 327 } 328 329 void* _aaGetRvalueX(AA aa, TypeInfo keyti, size_t valuesize, void* pkey) 330 { 315 331 //printf("_aaGetRvalue(valuesize = %u)\n", valuesize); 316 332 if (!aa.a) 317 333 return null; 318 334 319 auto pkey = cast(void *)(&valuesize + 1);320 335 auto keysize = aligntsize(keyti.tsize()); 321 336 auto len = aa.a.b.length; 322 337 … … 351 366 */ 352 367 353 368 void* _aaIn(AA aa, TypeInfo keyti, ...) 369 { 370 return _aaInX(aa, keyti, cast(void *)(&keyti + 1)); 371 } 372 373 void* _aaInX(AA aa, TypeInfo keyti, void* pkey) 354 374 in 355 375 { 356 376 } … … 362 382 { 363 383 if (aa.a) 364 384 { 365 auto pkey = cast(void *)(&keyti + 1);366 367 385 //printf("_aaIn(), .length = %d, .ptr = %x\n", aa.a.length, cast(uint)aa.a.ptr); 368 386 auto len = aa.a.b.length; 369 387 … … 399 417 400 418 void _aaDel(AA aa, TypeInfo keyti, ...) 401 419 { 402 auto pkey = cast(void *)(&keyti + 1); 420 return _aaDelX(aa, keyti, cast(void *)(&keyti + 1)); 421 } 422 423 void _aaDelX(AA aa, TypeInfo keyti, void* pkey) 424 { 403 425 aaA *e; 404 426 405 427 if (aa.a && aa.a.b.length) … … 673 695 674 696 auto len = _aaLen(aa); 675 697 if (!len) 676 return 0;698 return null; 677 699 res = (cast(byte*) gc_malloc(len * keysize, 678 700 !(aa.a.keyti.flags() & 1) ? BlkAttr.NO_SCAN : 0))[0 .. len * keysize]; 679 701 resi = 0; … … 801 823 return result; 802 824 } 803 825 826 extern (C) BB* _d_assocarrayliteralTX(TypeInfo_AssociativeArray ti, void[] keys, void[] values) 827 { 828 auto valueti = ti.next; 829 auto valuesize = valueti.tsize(); // value size 830 auto keyti = ti.key; 831 auto keysize = keyti.tsize(); // key size 832 auto length = keys.length; 833 BB* result; 804 834 835 //printf("_d_assocarrayliteralT(keysize = %d, valuesize = %d, length = %d)\n", keysize, valuesize, length); 836 //printf("tivalue = %.*s\n", ti.next.classinfo.name); 837 assert(length == values.length); 838 if (length == 0 || valuesize == 0 || keysize == 0) 839 { 840 ; 841 } 842 else 843 { 844 result = new BB(); 845 846 size_t i; 847 for (i = 0; i < prime_list.length - 1; i++) 848 { 849 if (length <= prime_list[i]) 850 break; 851 } 852 auto len = prime_list[i]; 853 result.b = new aaA*[len]; 854 855 size_t keytsize = aligntsize(keysize); 856 857 for (size_t j = 0; j < length; j++) 858 { auto pkey = keys.ptr + j * keysize; 859 auto pvalue = values.ptr + j * valuesize; 860 aaA* e; 861 862 auto key_hash = keyti.getHash(pkey); 863 //printf("hash = %d\n", key_hash); 864 i = key_hash % len; 865 auto pe = &result.b[i]; 866 while (1) 867 { 868 e = *pe; 869 if (!e) 870 { 871 // Not found, create new elem 872 //printf("create new one\n"); 873 e = cast(aaA *) cast(void*) new void[aaA.sizeof + keytsize + valuesize]; 874 memcpy(e + 1, pkey, keysize); 875 e.hash = key_hash; 876 *pe = e; 877 result.nodes++; 878 break; 879 } 880 if (key_hash == e.hash) 881 { 882 auto c = keyti.compare(pkey, e + 1); 883 if (c == 0) 884 break; 885 pe = (c < 0) ? &e.left : &e.right; 886 } 887 else 888 pe = (key_hash < e.hash) ? &e.left : &e.right; 889 } 890 memcpy(cast(void *)(e + 1) + keytsize, pvalue, valuesize); 891 } 892 } 893 return result; 894 } 895 805 896 /*********************************** 806 897 * Construct an associative array of type ti from 807 898 * length pairs of key/value pairs. 808 899 */ 809 900 810 extern (C) 811 BB* _d_assocarrayliteralT(TypeInfo_AssociativeArray ti, size_t length, ...) 901 extern (C) BB* _d_assocarrayliteralT(TypeInfo_AssociativeArray ti, size_t length, ...) 812 902 { 813 903 auto valuesize = ti.next.tsize(); // value size 814 904 auto keyti = ti.key; … … 824 914 else 825 915 { 826 916 va_list q; 827 v a_start!(size_t)(q, length);917 version(X86_64) va_start(q, __va_argsave); else va_start!(size_t)(q, length); 828 918 829 919 result = new BB(); 830 920 result.keyti = keyti; -
tango/core/rt/compiler/dmd/rt/cast_.d
old new 82 82 83 83 Object _d_dynamic_cast(Object o, ClassInfo c) 84 84 { ClassInfo oc; 85 size_t offset = 0;85 uint offset = 0; 86 86 87 87 //printf("_d_dynamic_cast(o = %p, c = '%.*s')\n", o, c.name); 88 88 … … 101 101 return o; 102 102 } 103 103 104 int _d_isbaseof2(ClassInfo oc, ClassInfo c, ref size_t offset)104 int _d_isbaseof2(ClassInfo oc, ClassInfo c, ref uint offset) 105 105 { int i; 106 106 107 107 if (oc is c) -
tango/core/rt/compiler/dmd/rt/memset.d
old new 41 41 return pstart; 42 42 } 43 43 44 44 45 int *_memset32(int *p, int value, size_t count) 45 46 { 46 version ( X86)47 version (D_InlineAsm_X86) 47 48 { 48 49 asm 49 50 { … … 118 119 } 119 120 return pstart; 120 121 } 122 123 float *_memsetFloat(float *p, float value, size_t count) 124 { 125 float *pstart = p; 126 float *ptop; 127 128 for (ptop = &p[count]; p < ptop; p++) 129 *p = value; 130 return pstart; 131 } 132 133 double *_memsetDouble(double *p, double value, size_t count) 134 { 135 double *pstart = p; 136 double *ptop; 137 138 for (ptop = &p[count]; p < ptop; p++) 139 *p = value; 140 return pstart; 141 } -
tango/core/rt/compiler/dmd/rt/alloca.d
old new 27 27 * EAX allocated data, null if stack overflows 28 28 */ 29 29 30 30 31 extern (C) void* __alloca(int nbytes) 31 32 { 33 version (D_InlineAsm_X86) 34 { 32 35 asm 33 36 { 34 37 naked ; … … 37 40 push EBX ; 38 41 push EDI ; 39 42 push ESI ; 43 } 44 45 version (OSX) 46 { 47 asm 48 { 49 add EAX,15 ; 50 and EAX,0xFFFFFFF0 ; // round up to 16 byte boundary 51 } 52 } 53 else 54 { 55 asm 56 { 40 57 add EAX,3 ; 41 58 and EAX,0xFFFFFFFC ; // round up to dword 59 } 60 } 61 62 asm 63 { 42 64 jnz Abegin ; 43 65 mov EAX,4 ; // allow zero bytes allocation, 0 rounded to dword is 4.. 44 66 Abegin: … … 108 130 ret ; 109 131 } 110 132 } 133 else version (D_InlineAsm_X86_64) 134 { 135 asm 136 { 137 naked ; 138 mov RDX,RCX ; 139 mov RAX,RDI ; // get nbytes 140 add RAX,15 ; 141 and AL,0xF0 ; // round up to 16 byte boundary 142 test RAX,RAX ; 143 jnz Abegin ; 144 mov RAX,16 ; // allow zero bytes allocation 145 Abegin: 146 mov RSI,RAX ; // RSI = nbytes 147 neg RAX ; 148 add RAX,RSP ; // RAX is now what the new RSP will be. 149 jae Aoverflow ; 150 } 151 version (Win64) 152 { 153 asm 154 { 155 // We need to be careful about the guard page 156 // Thus, for every 4k page, touch it to cause the OS to load it in. 157 mov RCX,RAX ; // RCX is new location for stack 158 mov RBX,RSI ; // RBX is size to "grow" stack 159 L1: 160 test [RCX+RBX],RBX ; // bring in page 161 sub RBX,0x1000 ; // next 4K page down 162 jae L1 ; // if more pages 163 test [RCX],RBX ; // bring in last page 164 } 165 } 166 version (Unix) 167 { 168 asm 169 { 170 cmp RAX,_pastdata ; 171 jbe Aoverflow ; // Unlikely - ~2 Gbytes under UNIX 172 } 173 } 174 asm 175 { 176 // Copy down to [RSP] the temps on the stack. 177 // The number of temps is (RBP - RSP - locals). 178 mov RCX,RBP ; 179 sub RCX,RSP ; 180 sub RCX,[RDX] ; // RCX = number of temps (bytes) to move. 181 add [RDX],RSI ; // adjust locals by nbytes for next call to alloca() 182 mov RSP,RAX ; // Set up new stack pointer. 183 add RAX,RCX ; // Return value = RSP + temps. 184 mov RDI,RSP ; // Destination of copy of temps. 185 add RSI,RSP ; // Source of copy. 186 shr RCX,3 ; // RCX to count of qwords in temps 187 rep ; 188 movsq ; 189 jmp done ; 190 191 Aoverflow: 192 // Overflowed the stack. Return null 193 xor RAX,RAX ; 194 195 done: 196 ret ; 197 } 198 } 199 else 200 static assert(0); 201 } -
tango/core/rt/compiler/dmd/object_.d
old new 331 331 { 332 332 foreach (m; ModuleInfo) 333 333 { 334 if (!m) 335 continue; 336 334 337 //writefln("module %s, %d", m.name, m.localClasses.length); 335 338 foreach (c; m.localClasses) 336 339 { … … 416 419 417 420 /// Compares two instances for <, ==, or >. 418 421 int compare(in void* p1, in void* p2) { return 0; } // throw new Exception("non comparable",__FILE__,__LINE__); 419 422 /// Return alignment of type 423 size_t talign() { return tsize(); } 420 424 /// Returns size of the type. 421 425 size_t tsize() { return 0; } 422 426 … … 473 477 474 478 /// Get type information on the contents of the type; null if not available 475 479 OffsetTypeInfo[] offTi() { return null; } 480 481 482 /** Return internal info on arguments fitting into 8byte. 483 * See X86-64 ABI 3.2.3 484 */ 485 version (X86_64) int argTypes(out TypeInfo arg1, out TypeInfo arg2) 486 { 487 arg1 = this; 488 return 0; 476 489 } 490 } 477 491 478 492 class TypeInfo_Typedef : TypeInfo 479 493 { … … 499 513 override PointerMap pointermap() { return base.pointermap(); } 500 514 override void[] init() { return m_init.length ? m_init : base.init(); } 501 515 516 size_t talign() { return base.talign(); } 517 518 version (X86_64) int argTypes(out TypeInfo arg1, out TypeInfo arg2) 519 { 520 return base.argTypes(arg1, arg2); 521 } 522 502 523 TypeInfo base; 503 524 char[] name; 504 525 void[] m_init; … … 636 657 637 658 override uint flags() { return 1; } 638 659 660 size_t talign() 661 { 662 return (void[]).alignof; 663 } 664 665 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 666 { //arg1 = typeid(size_t); 667 //arg2 = typeid(void*); 668 return 0; 669 } 670 639 671 override PointerMap pointermap() 640 672 { 641 673 //return static mask for arrays … … 750 782 751 783 TypeInfo value; 752 784 size_t len; 785 786 size_t talign() 787 { 788 return value.talign(); 753 789 } 754 790 791 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 792 { 793 arg1 = typeid(void*); 794 return 0; 795 } 796 797 } 798 755 799 class TypeInfo_AssociativeArray : TypeInfo 756 800 { 757 801 override char[] toString() … … 818 862 819 863 TypeInfo value; 820 864 TypeInfo key; 865 866 size_t talign() 867 { 868 return (char[int]).alignof; 821 869 } 822 870 871 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 872 { 873 arg1 = typeid(void*); 874 return 0; 875 } 876 } 877 823 878 class TypeInfo_Function : TypeInfo 824 879 { 825 880 override char[] toString() … … 902 957 } 903 958 904 959 TypeInfo next; 960 961 size_t talign() 962 { 963 alias int delegate() dg; 964 return dg.alignof; 905 965 } 906 966 967 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 968 { //arg1 = typeid(void*); 969 //arg2 = typeid(void*); 970 return 0; 971 } 972 973 } 974 907 975 class TypeInfo_Class : TypeInfo 908 976 { 909 977 override char[] toString() { return info.name; } … … 1114 1182 1115 1183 override uint flags() { return m_flags; } 1116 1184 1185 size_t talign() { return m_align; } 1186 1187 1117 1188 char[] name; 1118 1189 void[] m_init; // initializer; init.ptr == null if 0 initialize 1119 1190 … … 1124 1195 char[] function() xtoString; 1125 1196 1126 1197 uint m_flags; 1198 uint m_align; 1127 1199 1128 1200 version (D_HavePointerMap) { 1129 1201 PointerMap m_pointermap; 1130 1202 1131 1203 override PointerMap pointermap() { return m_pointermap; } 1132 1204 } 1205 1206 version (X86_64) 1207 { 1208 int argTypes(out TypeInfo arg1, out TypeInfo arg2) 1209 { 1210 arg1 = m_arg1; 1211 arg2 = m_arg2; 1212 return 0; 1133 1213 } 1214 TypeInfo m_arg1; 1215 TypeInfo m_arg2; 1216 } 1217 } 1134 1218 1135 1219 class TypeInfo_Tuple : TypeInfo 1136 1220 { … … 1197 1281 { 1198 1282 assert(0); 1199 1283 } 1284 1285 version (X86_64) int argTypes(out TypeInfo arg1, out TypeInfo arg2) 1286 { 1287 assert(0); 1200 1288 } 1289 } 1201 1290 1202 1291 1203 1292 //////////////////////////////////////////////////////////////////////////////// … … 1476 1565 { _moduleinfo_array[len] = mr.mod; 1477 1566 len++; 1478 1567 } 1568 1569 debug(PRINTF) foreach (m; _moduleinfo_array) 1570 { 1571 //printf("\t%p\n", m); 1572 printf("\t%.*s\n", m.name.length,m.name.ptr); 1479 1573 } 1480 1574 1575 } 1576 1481 1577 version( freebsd ) 1482 1578 { 1483 1579 int len = 0; … … 1552 1648 debug(PRINTF) printf("\tmodule[%d] = '%p'\n", i, m); 1553 1649 if (!m) 1554 1650 continue; 1555 debug(PRINTF) printf("\tmodule[%d] = '%.*s'\n", i, m.name);1651 debug(PRINTF) printf("\tmodule[%d].name = '%s'\n", i, m.name); 1556 1652 if (m.flags & MIctordone) 1557 1653 continue; 1558 1654 debug(PRINTF) printf("\tmodule[%d] = '%.*s', m = x%x\n", i, m.name, m); -
tango/core/rt/compiler/dmd/std/intrinsic.d
old new 25 25 * The bit number of the first bit set. 26 26 * The return value is undefined if v is zero. 27 27 */ 28 int bsf( uint v );28 int bsf( size_t v ); 29 29 30 30 31 31 /** … … 133 133 array = [0]:x2, [1]:x100 134 134 </pre> 135 135 */ 136 136 137 int bts( size_t* p, size_t bitnum ); 137 138 138 139 139 /** 140 140 * Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes 141 141 * byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3 -
tango/core/rt/compiler/dmd/typeinfo/ti_void.d
old new 22 22 return *cast(byte *)p1 - *cast(byte *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return void.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return void.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_wchar.d
old new 21 21 return *cast(wchar *)p1 - *cast(wchar *)p2; 22 22 } 23 23 24 override size_t talign() 25 { 26 return wchar.alignof; 27 } 28 24 29 override size_t tsize() 25 30 { 26 31 return wchar.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_ptr.d
old new 25 25 return 0; 26 26 } 27 27 28 override size_t talign() 29 { 30 return (void*).alignof; 31 } 32 28 33 override size_t tsize() 29 34 { 30 35 return (void*).sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_Afloat.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (float[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (float[]).sizeof; … … 90 95 { 91 96 return typeid(float); 92 97 } 98 99 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 100 { 101 return 0; 93 102 } 103 } 94 104 95 105 // ifloat[] 96 106 -
tango/core/rt/compiler/dmd/typeinfo/ti_double.d
old new 43 43 return _compare(*cast(double *)p1, *cast(double *)p2); 44 44 } 45 45 46 override size_t talign() 47 { 48 return double.alignof; 49 } 50 46 51 override size_t tsize() 47 52 { 48 53 return double.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_delegate.d
old new 18 18 return *cast(dg *)p1 == *cast(dg *)p2; 19 19 } 20 20 21 override size_t talign() 22 { 23 return dg.alignof; 24 } 25 21 26 override size_t tsize() 22 27 { 23 28 return dg.sizeof; … … 36 41 { 37 42 return 1; 38 43 } 44 45 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 46 { 47 arg1 = typeid(void*); 48 arg2 = typeid(void*); 49 return 0; 39 50 } 51 } -
tango/core/rt/compiler/dmd/typeinfo/ti_Adouble.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (double[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (double[]).sizeof; … … 90 95 { 91 96 return typeid(double); 92 97 } 98 99 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 100 { 101 return 0; 93 102 } 103 } 94 104 95 105 // idouble[] 96 106 -
tango/core/rt/compiler/dmd/typeinfo/ti_char.d
old new 20 20 return *cast(char *)p1 - *cast(char *)p2; 21 21 } 22 22 23 override size_t talign() 24 { 25 return char.alignof; 26 } 27 23 28 override size_t tsize() 24 29 { 25 30 return char.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_Acdouble.d
old new 75 75 return 0; 76 76 } 77 77 78 override size_t talign() 79 { 80 return (cdouble[]).alignof; 81 } 82 78 83 override size_t tsize() 79 84 { 80 85 return (cdouble[]).sizeof; … … 89 94 { 90 95 return typeid(cdouble); 91 96 } 97 98 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 99 { 100 return 0; 92 101 } 102 } -
tango/core/rt/compiler/dmd/typeinfo/ti_uint.d
old new 26 26 return 0; 27 27 } 28 28 29 override size_t talign() 30 { 31 return uint.alignof; 32 } 33 29 34 override size_t tsize() 30 35 { 31 36 return uint.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_AC.d
old new 82 82 return 0; 83 83 } 84 84 85 override size_t talign() 86 { 87 return (Object[]).alignof; 88 } 89 85 90 override size_t tsize() 86 91 { 87 92 return (Object[]).sizeof; … … 96 101 { 97 102 return typeid(Object); 98 103 } 104 105 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 106 { 107 return 0; 99 108 } 109 } -
tango/core/rt/compiler/dmd/typeinfo/ti_ulong.d
old new 31 31 return 0; 32 32 } 33 33 34 override size_t talign() 35 { 36 return ulong.alignof; 37 } 38 34 39 override size_t tsize() 35 40 { 36 41 return ulong.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_creal.d
old new 44 44 return _compare(*cast(creal *)p1, *cast(creal *)p2); 45 45 } 46 46 47 override size_t talign() 48 { 49 return creal.alignof; 50 } 51 47 52 override size_t tsize() 48 53 { 49 54 return creal.sizeof; … … 63 68 64 69 return (cast(creal *)&r)[0 .. 1]; 65 70 } 71 72 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 73 { 74 arg1 = typeid(real); 75 arg2 = typeid(real); 76 return 0; 66 77 } 78 } -
tango/core/rt/compiler/dmd/typeinfo/ti_ubyte.d
old new 22 22 return *cast(ubyte *)p1 - *cast(ubyte *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return ubyte.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return ubyte.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_Aint.d
old new 47 47 return 0; 48 48 } 49 49 50 override size_t talign() 51 { 52 return (int[]).alignof; 53 } 54 50 55 override size_t tsize() 51 56 { 52 57 return (int[]).sizeof; … … 61 66 { 62 67 return typeid(int); 63 68 } 69 70 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 71 { 72 return 0; 64 73 } 74 } 65 75 66 76 unittest 67 77 { -
tango/core/rt/compiler/dmd/typeinfo/ti_long.d
old new 31 31 return 0; 32 32 } 33 33 34 override size_t talign() 35 { 36 return long.alignof; 37 } 38 34 39 override size_t tsize() 35 40 { 36 41 return long.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_short.d
old new 22 22 return *cast(short *)p1 - *cast(short *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return short.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return short.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_Along.d
old new 48 48 return 0; 49 49 } 50 50 51 override size_t talign() 52 { 53 return (long[]).alignof; 54 } 55 51 56 override size_t tsize() 52 57 { 53 58 return (long[]).sizeof; … … 62 67 { 63 68 return typeid(long); 64 69 } 70 71 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 72 { 73 return 0; 65 74 } 75 } 66 76 67 77 68 78 // ulong[] -
tango/core/rt/compiler/dmd/typeinfo/ti_byte.d
old new 22 22 return *cast(byte *)p1 - *cast(byte *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return byte.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return byte.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_float.d
old new 42 42 return _compare(*cast(float *)p1, *cast(float *)p2); 43 43 } 44 44 45 override size_t talign() 46 { 47 return float.alignof; 48 } 49 45 50 override size_t tsize() 46 51 { 47 52 return float.sizeof; … … 61 66 62 67 return (cast(float *)&r)[0 .. 1]; 63 68 } 69 70 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 71 { 72 return 0; 64 73 } 74 } -
tango/core/rt/compiler/dmd/typeinfo/ti_cfloat.d
old new 44 44 return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2); 45 45 } 46 46 47 override size_t talign() 48 { 49 return cfloat.alignof; 50 } 51 47 52 override size_t tsize() 48 53 { 49 54 return cfloat.sizeof; … … 63 68 64 69 return (cast(cfloat *)&r)[0 .. 1]; 65 70 } 71 72 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 73 { 74 arg1 = typeid(double); 75 return 0; 66 76 } 77 } -
tango/core/rt/compiler/dmd/typeinfo/ti_Acfloat.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (cfloat[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (cfloat[]).sizeof; … … 90 95 { 91 96 return typeid(cfloat); 92 97 } 98 99 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 100 { 101 return 0; 93 102 } 103 } -
tango/core/rt/compiler/dmd/typeinfo/ti_cdouble.d
old new 44 44 return _compare(*cast(cdouble *)p1, *cast(cdouble *)p2); 45 45 } 46 46 47 override size_t talign() 48 { 49 return cdouble.alignof; 50 } 51 47 52 override size_t tsize() 48 53 { 49 54 return cdouble.sizeof; … … 63 68 64 69 return (cast(cdouble *)&r)[0 .. 1]; 65 70 } 71 72 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 73 { 74 return 0; 66 75 } 76 } -
tango/core/rt/compiler/dmd/typeinfo/ti_dchar.d
old new 22 22 return *cast(dchar *)p1 - *cast(dchar *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return dchar.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return dchar.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_C.d
old new 62 62 return c; 63 63 } 64 64 65 override size_t talign() 66 { 67 return Object.alignof; 68 } 69 65 70 override size_t tsize() 66 71 { 67 72 return Object.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_real.d
old new 43 43 return _compare(*cast(real *)p1, *cast(real *)p2); 44 44 } 45 45 46 override size_t talign() 47 { 48 return real.alignof; 49 } 50 46 51 override size_t tsize() 47 52 { 48 53 return real.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_ushort.d
old new 22 22 return *cast(ushort *)p1 - *cast(ushort *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return ushort.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return ushort.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_Areal.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (real[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (real[]).sizeof; … … 90 95 { 91 96 return typeid(real); 92 97 } 98 99 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 100 { 101 return 0; 93 102 } 103 } 94 104 95 105 // ireal[] 96 106 -
tango/core/rt/compiler/dmd/typeinfo/ti_Acreal.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (creal[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (creal[]).sizeof; … … 90 95 { 91 96 return typeid(creal); 92 97 } 98 99 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 100 { 101 return 0; 93 102 } 103 } -
tango/core/rt/compiler/dmd/typeinfo/ti_Ag.d
old new 48 48 return 0; 49 49 } 50 50 51 override size_t talign() 52 { 53 return (byte[]).alignof; 54 } 55 51 56 override size_t tsize() 52 57 { 53 58 return (byte[]).sizeof; … … 117 122 118 123 override hash_t getHash(in void* p){ 119 124 char[] s = *cast(char[]*)p; 125 120 126 version (OldHash) 121 127 { 122 128 hash_t hash = 0; … … 133 139 { 134 140 return typeid(char); 135 141 } 142 143 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 144 { 145 return 0; 136 146 } 147 } -
tango/core/rt/compiler/dmd/typeinfo/ti_int.d
old new 26 26 return 0; 27 27 } 28 28 29 override size_t talign() 30 { 31 return int.alignof; 32 } 33 29 34 override size_t tsize() 30 35 { 31 36 return int.sizeof; -
tango/core/rt/compiler/dmd/typeinfo/ti_Ashort.d
old new 47 47 return 0; 48 48 } 49 49 50 override size_t talign() 51 { 52 return (short[]).alignof; 53 } 54 50 55 override size_t tsize() 51 56 { 52 57 return (short[]).sizeof; … … 61 66 { 62 67 return typeid(short); 63 68 } 69 70 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 71 { 72 arg1 = typeid(size_t); 73 arg2 = typeid(void*); 74 return 0; 64 75 } 76 } 65 77 66 78 67 79 // ushort[] -
tango/core/rt/compiler/dmd/posix/deh.d
old new 64 64 void *fptr; // pointer to start of function 65 65 uint espoffset; // offset of ESP from EBP 66 66 uint retoffset; // offset from start of function to return code 67 uint nhandlers; // dimension of handler_info[]67 size_t nhandlers; // dimension of handler_info[] 68 68 DHandlerInfo handler_info[1]; 69 69 } 70 70 71 71 struct DCatchBlock 72 72 { 73 73 ClassInfo type; // catch type 74 uint bpoffset; // EBP offset of catch var74 size_t bpoffset; // EBP offset of catch var 75 75 void *code; // catch handler code 76 76 } 77 77 78 78 // Create one of these for each try-catch 79 79 struct DCatchInfo 80 80 { 81 uint ncatches; // number of catch blocks81 size_t ncatches; // number of catch blocks 82 82 DCatchBlock catch_block[1]; // data for each catch block 83 83 } 84 84 … … 164 164 * caller's EBP 165 165 */ 166 166 167 uint __eh_find_caller(uint regbp, uint *pretaddr)167 size_t __eh_find_caller(size_t regbp, size_t *pretaddr) 168 168 { 169 uint bp = *cast(uint *)regbp;169 size_t bp = *cast(size_t *)regbp; 170 170 171 171 if (bp) // if not end of call chain 172 172 { … … 176 176 // stack should grow to smaller values 177 177 terminate(); 178 178 179 *pretaddr = *cast( uint *)(regbp + int.sizeof);179 *pretaddr = *cast(size_t *)(regbp + size_t.sizeof); 180 180 } 181 181 return bp; 182 182 } … … 195 195 * Throw a D object. 196 196 */ 197 197 198 extern(C) void _d_throwc(Object *h){ 199 uint regebp; 198 extern(C) void _d_throwc(Object *h) 199 { 200 size_t regebp; 200 201 201 202 debug(deh) 202 203 { … … 204 205 printf("\tvptr = %p\n", *cast(void **)h); 205 206 } 206 207 208 version (D_InlineAsm_X86) 207 209 asm 208 210 { 209 211 mov regebp,EBP ; 210 212 } 213 else version (D_InlineAsm_X86_64) 214 asm 215 { 216 mov regebp,RBP ; 217 } 218 else 219 static assert(0); 211 220 212 221 //static uint abc; 213 222 //if (++abc == 2) *(char *)0=0; … … 218 227 DHandlerTable *handler_table; 219 228 FuncTable *pfunc; 220 229 DHandlerInfo *phi; 221 uint retaddr;222 uint funcoffset;230 size_t retaddr; 231 size_t funcoffset; 223 232 uint spoff; 224 233 uint retoffset; 225 234 int index; 226 int dim;235 size_t dim; 227 236 int ndx; 228 237 int prev_ndx; 229 238 … … 244 253 debug(deh) printf("no handler table\n"); 245 254 continue; 246 255 } 247 funcoffset = cast( uint)handler_table.fptr;256 funcoffset = cast(size_t)handler_table.fptr; 248 257 spoff = handler_table.espoffset; 249 258 retoffset = handler_table.retoffset; 250 259 … … 261 270 debug(deh) 262 271 { 263 272 printf("handler_info[]:\n"); 264 for ( int i = 0; i < dim; i++)273 for (size_t i = 0; i < dim; i++) 265 274 { 266 275 phi = handler_table.handler_info.ptr + i; 267 276 printf("\t[%d]: offset = x%04x, endoffset = x%04x, prev_index = %d, cioffset = x%04x, finally_code = %x\n", … … 270 279 } 271 280 272 281 index = -1; 273 for ( int i = 0; i < dim; i++)282 for (size_t i = 0; i < dim; i++) 274 283 { 275 284 phi = handler_table.handler_info.ptr + i; 276 285 277 286 debug(deh) printf("i = %d, phi.offset = %04x\n", i, funcoffset + phi.offset); 278 if ( cast(uint)retaddr > funcoffset + phi.offset &&279 cast(uint)retaddr <= funcoffset + phi.endoffset)287 if (retaddr > funcoffset + phi.offset && 288 retaddr <= funcoffset + phi.endoffset) 280 289 index = i; 281 290 } 282 291 debug(deh) printf("index = %d\n", index); … … 287 296 { 288 297 phi = handler_table.handler_info.ptr + ndx; 289 298 prev_ndx = phi.prev_index; 299 290 300 if (phi.cioffset) 291 301 { 292 302 // this is a catch handler (no finally) 293 303 DCatchInfo *pci; 294 int ncatches;295 int i;304 size_t ncatches; 305 size_t i; 296 306 297 307 pci = cast(DCatchInfo *)(cast(char *)handler_table + phi.cioffset); 298 308 ncatches = pci.ncatches; 309 299 310 for (i = 0; i < ncatches; i++) 300 311 { 301 312 DCatchBlock *pcb; … … 311 322 312 323 // Jump to catch block. Does not return. 313 324 { 314 uint catch_esp;325 size_t catch_esp; 315 326 fp_t catch_addr; 316 327 317 328 catch_addr = cast(fp_t)(pcb.code); 318 329 catch_esp = regebp - handler_table.espoffset - fp_t.sizeof; 330 331 version (D_InlineAsm_X86) 319 332 asm 320 333 { 321 334 mov EAX,catch_esp ; … … 325 338 mov ESP,EAX ; // reset stack 326 339 ret ; // jump to catch block 327 340 } 341 else version (D_InlineAsm_X86_64) 342 asm 343 { 344 mov RAX,catch_esp ; 345 mov RCX,catch_esp ; 346 mov RCX,catch_addr ; 347 mov [RAX],RCX ; 348 mov RBP,regebp ; 349 mov RSP,RAX ; // reset stack 350 ret ; // jump to catch block 328 351 } 352 else 353 static assert(0); 354 329 355 } 330 356 } 331 357 } 358 } 332 359 else if (phi.finally_code) 333 360 { // Call finally block 334 361 // Note that it is unnecessary to adjust the ESP, as the finally block … … 338 365 339 366 version (OSX) 340 367 { 341 asm { 368 version (D_InlineAsm_X86) 369 asm 370 { 342 371 sub ESP,4 ; 343 372 push EBX ; 344 373 mov EBX,blockaddr ; … … 349 378 pop EBX ; 350 379 add ESP,4 ; 351 380 } 352 } else { 353 asm { 381 else version (D_InlineAsm_X86_64) 382 asm 383 { 384 sub RSP,8 ; 385 push RBX ; 386 mov RBX,blockaddr ; 387 push RBP ; 388 mov RBP,regebp ; 389 call RBX ; 390 pop RBP ; 391 pop RBX ; 392 add RSP,8 ; 393 } 394 else 395 static assert(0); 396 } 397 else 398 { 399 version (D_InlineAsm_X86) 400 asm 401 { 354 402 push EBX ; 355 403 mov EBX,blockaddr ; 356 404 push EBP ; … … 359 407 pop EBP ; 360 408 pop EBX ; 361 409 } 410 else version (D_InlineAsm_X86_64) 411 asm 412 { 413 sub RSP,8 ; 414 push RBX ; 415 mov RBX,blockaddr ; 416 push RBP ; 417 mov RBP,regebp ; 418 call RBX ; 419 pop RBP ; 420 pop RBX ; 421 add RSP,8 ; 362 422 } 423 else 424 static assert(0); 363 425 } 364 426 } 365 427 } 366 428 } 429 } -
tango/core/rt/compiler/gdc/object_.d
old new 413 413 /// Compares two instances for <, ==, or >. 414 414 int compare(in void* p1, in void* p2) { return 0; } // throw new Exception("non comparable",__FILE__,__LINE__); 415 415 416 /// Return alignment of type 417 size_t talign() { return tsize(); } 418 416 419 /// Returns size of the type. 417 420 size_t tsize() { return 0; } 418 421 -
tango/core/rt/compiler/gdc/typeinfo/ti_void.d
old new 22 22 return *cast(byte *)p1 - *cast(byte *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return void.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return void.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_wchar.d
old new 21 21 return *cast(wchar *)p1 - *cast(wchar *)p2; 22 22 } 23 23 24 override size_t talign() 25 { 26 return wchar.alignof; 27 } 28 24 29 override size_t tsize() 25 30 { 26 31 return wchar.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_ptr.d
old new 25 25 return 0; 26 26 } 27 27 28 override size_t talign() 29 { 30 return (void*).alignof; 31 } 32 28 33 override size_t tsize() 29 34 { 30 35 return (void*).sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_Afloat.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (float[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (float[]).sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_double.d
old new 43 43 return _compare(*cast(double *)p1, *cast(double *)p2); 44 44 } 45 45 46 override size_t talign() 47 { 48 return double.alignof; 49 } 50 46 51 override size_t tsize() 47 52 { 48 53 return double.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_delegate.d
old new 18 18 return *cast(dg *)p1 == *cast(dg *)p2; 19 19 } 20 20 21 override size_t talign() 22 { 23 return dg.alignof; 24 } 25 21 26 override size_t tsize() 22 27 { 23 28 return dg.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_Adouble.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (double[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (double[]).sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_char.d
old new 20 20 return *cast(char *)p1 - *cast(char *)p2; 21 21 } 22 22 23 override size_t talign() 24 { 25 return char.alignof; 26 } 27 23 28 override size_t tsize() 24 29 { 25 30 return char.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_Acdouble.d
old new 75 75 return 0; 76 76 } 77 77 78 override size_t talign() 79 { 80 return (cdouble[]).alignof; 81 } 82 78 83 override size_t tsize() 79 84 { 80 85 return (cdouble[]).sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_uint.d
old new 26 26 return 0; 27 27 } 28 28 29 override size_t talign() 30 { 31 return uint.alignof; 32 } 33 29 34 override size_t tsize() 30 35 { 31 36 return uint.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_AC.d
old new 82 82 return 0; 83 83 } 84 84 85 override size_t talign() 86 { 87 return (Object[]).alignof; 88 } 89 85 90 override size_t tsize() 86 91 { 87 92 return (Object[]).sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_ulong.d
old new 31 31 return 0; 32 32 } 33 33 34 override size_t talign() 35 { 36 return ulong.alignof; 37 } 38 34 39 override size_t tsize() 35 40 { 36 41 return ulong.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_creal.d
old new 44 44 return _compare(*cast(creal *)p1, *cast(creal *)p2); 45 45 } 46 46 47 override size_t talign() 48 { 49 return creal.alignof; 50 } 51 47 52 override size_t tsize() 48 53 { 49 54 return creal.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_ubyte.d
old new 22 22 return *cast(ubyte *)p1 - *cast(ubyte *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return ubyte.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return ubyte.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_Aint.d
old new 47 47 return 0; 48 48 } 49 49 50 override size_t talign() 51 { 52 return (int[]).alignof; 53 } 54 50 55 override size_t tsize() 51 56 { 52 57 return (int[]).sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_long.d
old new 31 31 return 0; 32 32 } 33 33 34 override size_t talign() 35 { 36 return long.alignof; 37 } 38 34 39 override size_t tsize() 35 40 { 36 41 return long.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_short.d
old new 22 22 return *cast(short *)p1 - *cast(short *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return short.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return short.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_Along.d
old new 48 48 return 0; 49 49 } 50 50 51 override size_t talign() 52 { 53 return (long[]).alignof; 54 } 55 51 56 override size_t tsize() 52 57 { 53 58 return (long[]).sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_byte.d
old new 22 22 return *cast(byte *)p1 - *cast(byte *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return byte.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return byte.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_float.d
old new 42 42 return _compare(*cast(float *)p1, *cast(float *)p2); 43 43 } 44 44 45 override size_t talign() 46 { 47 return float.alignof; 48 } 49 45 50 override size_t tsize() 46 51 { 47 52 return float.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_cfloat.d
old new 44 44 return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2); 45 45 } 46 46 47 override size_t talign() 48 { 49 return cfloat.alignof; 50 } 51 47 52 override size_t tsize() 48 53 { 49 54 return cfloat.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_Acfloat.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (cfloat[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (cfloat[]).sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_cdouble.d
old new 44 44 return _compare(*cast(cdouble *)p1, *cast(cdouble *)p2); 45 45 } 46 46 47 override size_t talign() 48 { 49 return cdouble.alignof; 50 } 51 47 52 override size_t tsize() 48 53 { 49 54 return cdouble.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_dchar.d
old new 22 22 return *cast(dchar *)p1 - *cast(dchar *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return dchar.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return dchar.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_C.d
old new 62 62 return c; 63 63 } 64 64 65 override size_t talign() 66 { 67 return Object.alignof; 68 } 69 65 70 override size_t tsize() 66 71 { 67 72 return Object.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_real.d
old new 43 43 return _compare(*cast(real *)p1, *cast(real *)p2); 44 44 } 45 45 46 override size_t talign() 47 { 48 return real.alignof; 49 } 50 46 51 override size_t tsize() 47 52 { 48 53 return real.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_ushort.d
old new 22 22 return *cast(ushort *)p1 - *cast(ushort *)p2; 23 23 } 24 24 25 override size_t talign() 26 { 27 return ushort.alignof; 28 } 29 25 30 override size_t tsize() 26 31 { 27 32 return ushort.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_Areal.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (real[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (real[]).sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_Acreal.d
old new 76 76 return 0; 77 77 } 78 78 79 override size_t talign() 80 { 81 return (creal[]).alignof; 82 } 83 79 84 override size_t tsize() 80 85 { 81 86 return (creal[]).sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_Ag.d
old new 48 48 return 0; 49 49 } 50 50 51 override size_t talign() 52 { 53 return (byte[]).alignof; 54 } 55 51 56 override size_t tsize() 52 57 { 53 58 return (byte[]).sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_int.d
old new 26 26 return 0; 27 27 } 28 28 29 override size_t talign() 30 { 31 return int.alignof; 32 } 33 29 34 override size_t tsize() 30 35 { 31 36 return int.sizeof; -
tango/core/rt/compiler/gdc/typeinfo/ti_Ashort.d
old new 47 47 return 0; 48 48 } 49 49 50 override size_t talign() 51 { 52 return (short[]).alignof; 53 } 54 50 55 override size_t tsize() 51 56 { 52 57 return (short[]).sizeof; -
tango/core/Variant.d
old new 8 8 module tango.core.Variant; 9 9 10 10 private import tango.core.Memory : GC; 11 private import tango.core.Vararg : va_list;11 private import tango.core.Vararg; 12 12 private import tango.core.Traits; 13 13 private import tango.core.Tuple; 14 14 … … 37 37 version=EnableVararg; 38 38 } 39 39 } 40 version( X86_64 ) 41 { 42 version( Windows ) 43 { 44 version=EnableVararg; 40 45 } 46 else version( Posix ) 47 { 48 version=EnableVararg; 49 } 50 } 51 } 41 52 else version( LDC ) 42 53 { 43 54 version( X86 ) -
tango/core/Thread.d
old new 348 348 { 349 349 __builtin_unwind_init(); 350 350 } 351 else version ( D_InlineAsm_X86_64 ) 352 { 353 asm 354 { 355 // Not sure what goes here, pushad is invalid in 64 bit code 356 push RAX ; 357 push RBX ; 358 push RCX ; 359 push RDX ; 360 push RSI ; 361 push RDI ; 362 push RBP ; 363 push R8 ; 364 push R9 ; 365 push R10 ; 366 push R11 ; 367 push R12 ; 368 push R13 ; 369 push R14 ; 370 push R15 ; 371 push EAX ; // 16 byte align the stack 372 } 373 } 351 374 else 352 375 { 353 376 static assert( false, "Architecture not supported." ); … … 411 434 { 412 435 // registers will be popped automatically 413 436 } 437 else version ( D_InlineAsm_X86_64 ) 438 { 439 asm 440 { 441 // Not sure what goes here, popad is invalid in 64 bit code 442 pop EAX ; // 16 byte align the stack 443 pop R15 ; 444 pop R14 ; 445 pop R13 ; 446 pop R12 ; 447 pop R11 ; 448 pop R10 ; 449 pop R9 ; 450 pop R8 ; 451 pop RBP ; 452 pop RDI ; 453 pop RSI ; 454 pop RDX ; 455 pop RCX ; 456 pop RBX ; 457 pop RAX ; 458 } 459 } 414 460 else 415 461 { 416 462 static assert( false, "Architecture not supported." ); … … 2670 2716 } 2671 2717 else version( AsmX86_64_Posix ) 2672 2718 { 2673 asm2719 version( DigitalMars ) asm 2674 2720 { 2675 2721 naked; 2676 2722 2677 2723 // save current stack state 2724 push RBP; 2725 mov RBP, RSP; 2726 push RBX; 2727 push R12; 2728 push R13; 2729 push R14; 2730 push R15; 2731 sub RSP, 4; 2732 stmxcsr [RSP]; 2733 sub RSP, 4; 2734 //version(SynchroFloatExcept){ 2735 fstcw [RSP]; 2736 fwait; 2737 //} else { 2738 // fnstcw [RSP]; 2739 // fnclex; 2740 //} 2741 2742 // store oldp again with more accurate address 2743 mov [RDI], RSP; 2744 // load newp to begin context switch 2745 mov RSP, RSI; 2746 2747 // load saved state from new stack 2748 fldcw [RSP]; 2749 add RSP, 4; 2750 ldmxcsr [RSP]; 2751 add RSP, 4; 2752 pop R15; 2753 pop R14; 2754 pop R13; 2755 pop R12; 2756 2757 pop RBX; 2758 pop RBP; 2759 2760 // 'return' to complete switch 2761 ret; 2762 2763 } 2764 else asm 2765 { 2766 naked; 2767 2768 // save current stack state 2678 2769 pushq RBP; 2679 2770 mov RBP, RSP; 2680 2771 pushq RBX; -
tango/core/vendor/std/intrinsic.di
old new 25 25 * The bit number of the first bit set. 26 26 * The return value is undefined if v is zero. 27 27 */ 28 int bsf( uint v );28 int bsf( size_t v ); 29 29 30 30 31 31 /** -
tango/core/Vararg.d
old new 21 21 } 22 22 else 23 23 { 24 /** 25 * The base vararg list type. 26 */ 24 version (X86) 25 { 27 26 alias void* va_list; 28 27 29 30 /** 31 * This function initializes the supplied argument pointer for subsequent 32 * use by va_arg and va_end. 33 * 34 * Params: 35 * ap = The argument pointer to initialize. 36 * paramn = The identifier of the rightmost parameter in the function 37 * parameter list. 38 */ 39 void va_start(T) ( out va_list ap, ref T parmn ) 28 template va_arg(T) 40 29 { 41 ap = cast(va_list) ( cast(void*) &parmn + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) ); 42 } 43 44 /** 45 * This function returns the next argument in the sequence referenced by 46 * the supplied argument pointer. The argument pointer will be adjusted 47 * to point to the next arggument in the sequence. 48 * 49 * Params: 50 * ap = The argument pointer. 51 * 52 * Returns: 53 * The next argument in the sequence. The result is undefined if ap 54 * does not point to a valid argument. 55 */ 56 T va_arg(T) ( ref va_list ap ) 30 T va_arg(ref va_list _argptr) 57 31 { 58 T arg = *cast(T*) ap;59 ap = cast(va_list) ( cast(void*) ap + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ));32 T arg = *cast(T*)_argptr; 33 _argptr = _argptr + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1)); 60 34 return arg; 61 35 } 62 63 /**64 * This function cleans up any resources allocated by va_start. It is65 * currently a no-op and exists mostly for syntax compatibility with66 * the variadric argument functions for C.67 *68 * Params:69 * ap = The argument pointer.70 */71 void va_end( va_list ap )72 {73 74 36 } 75 76 77 /** 78 * This function copied the argument pointer src to dst. 79 * 80 * Params: 81 * src = The source pointer. 82 * dst = The destination pointer. 83 */ 84 void va_copy( out va_list dst, va_list src ) 37 } 38 else 85 39 { 86 dst = src;40 public import tango.stdc.stdarg; 87 41 } 88 42 } -
tango/core/sync/Atomic.d
old new 245 245 return oldval; 246 246 } 247 247 } else version(D_InlineAsm_X86) { 248 T atomicSwap( T )( inoutT val, T newval )248 T atomicSwap( T )( ref T val, T newval ) 249 249 in { 250 250 // NOTE: 32 bit x86 systems support 8 byte CAS, which only requires 251 251 // 4 byte alignment, so use size_t as the align type here. … … 289 289 } 290 290 } 291 291 } else version (D_InlineAsm_X86_64){ 292 T atomicSwap( T )( inoutT val, T newval )292 T atomicSwap( T )( ref T val, T newval ) 293 293 in { 294 294 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); 295 295 } body { … … 332 332 } 333 333 } 334 334 } else { 335 T atomicSwap( T )( inoutT val, T newval )335 T atomicSwap( T )( ref T val, T newval ) 336 336 in { 337 337 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); 338 338 } body { -
tango/stdc/stdarg.d
old new 8 8 */ 9 9 module tango.stdc.stdarg; 10 10 11 12 11 version( GNU ) 13 12 { 14 13 public import std.c.stdarg; … … 19 18 } 20 19 else 21 20 { 21 version (X86) 22 { 23 /********************* 24 * The argument pointer type. 25 */ 22 26 alias void* va_list; 23 27 24 template va_start( T ) 28 /********** 29 * Initialize ap. 30 * For 32 bit code, parmn should be the last named parameter. 31 * For 64 bit code, parmn should be __va_argsave. 32 */ 33 void va_start(T)(out va_list ap, ref T parmn) 25 34 { 26 void va_start( out va_list ap, ref T parmn )27 {28 35 ap = cast(va_list) ( cast(void*) &parmn + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) ); 29 36 } 30 }31 37 32 template va_arg( T ) 38 /************ 39 * Retrieve and return the next value that is type T. 40 * Should use the other va_arg instead, as this won't work for 64 bit code. 41 */ 42 T va_arg(T)(ref va_list ap) 33 43 { 34 T va_arg( ref va_list ap )35 {36 44 T arg = *cast(T*) ap; 37 45 ap = cast(va_list) ( cast(void*) ap + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) ); 38 46 return arg; 39 47 } 48 49 /************ 50 * Retrieve and return the next value that is type T. 51 * This is the preferred version. 52 */ 53 void va_arg(T)(ref va_list ap, ref T parmn) 54 { 55 parmn = *cast(T*)ap; 56 ap = cast(va_list)(cast(void*)ap + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1))); 40 57 } 41 58 59 /************* 60 * Retrieve and store through parmn the next value that is of TypeInfo ti. 61 * Used when the static type is not known. 62 */ 63 void va_arg()(ref va_list ap, TypeInfo ti, void* parmn) 64 { 65 // Wait until everyone updates to get TypeInfo.talign() 66 //auto talign = ti.talign(); 67 //auto p = cast(void*)(cast(size_t)ap + talign - 1) & ~(talign - 1); 68 auto p = ap; 69 auto tsize = ti.tsize(); 70 ap = cast(void*)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1))); 71 parmn[0..tsize] = p[0..tsize]; 72 } 73 74 /*********************** 75 * End use of ap. 76 */ 42 77 void va_end( va_list ap ) 43 78 { 79 } 44 80 81 void va_copy(out va_list dest, va_list src) 82 { 83 dest = src; 45 84 } 85 } 86 else version (X86_64) 87 { 88 // Layout of this struct must match __gnuc_va_list for C ABI compatibility 89 struct __va_list 90 { 91 uint offset_regs = 6 * 8; // no regs 92 uint offset_fpregs = 6 * 8 + 8 * 16; // no fp regs 93 void* stack_args; 94 void* reg_args; 95 } 46 96 97 struct __va_argsave_t 98 { 99 size_t[6] regs; // RDI,RSI,RDX,RCX,R8,R9 100 real[8] fpregs; // XMM0..XMM7 101 __va_list va; 102 } 103 104 /* 105 * Making it an array of 1 causes va_list to be passed as a pointer in 106 * function argument lists 107 */ 108 alias void* va_list; 109 110 void va_start(T)(out va_list ap, ref T parmn) 111 { 112 ap = &parmn.va; 113 } 114 115 T va_arg(T)(va_list ap) 116 { T a; 117 va_arg(ap, a); 118 return a; 119 } 120 121 void va_arg(T)(va_list apx, ref T parmn) 122 { 123 __va_list* ap = cast(__va_list*)apx; 124 static if (is(T U == __argTypes)) 125 { 126 static if (U.length == 0 || T.sizeof > 16 || U[0].sizeof > 8) 127 { // Always passed in memory 128 // The arg may have more strict alignment than the stack 129 auto p = (cast(size_t)ap.stack_args + T.alignof - 1) & ~(T.alignof - 1); 130 ap.stack_args = cast(void*)(p + ((T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1))); 131 parmn = *cast(T*)p; 132 } 133 else static if (U.length == 1) 134 { // Arg is passed in one register 135 alias U[0] T1; 136 static if (is(T1 == double) || is(T1 == float)) 137 { // Passed in XMM register 138 if (ap.offset_fpregs < (6 * 8 + 16 * 8)) 139 { 140 parmn = *cast(T*)(ap.reg_args + ap.offset_fpregs); 141 ap.offset_fpregs += 16; 142 } 143 else 144 { 145 parmn = *cast(T*)ap.stack_args; 146 ap.stack_args += (T1.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1); 147 } 148 } 149 else 150 { // Passed in regular register 151 if (ap.offset_regs < 6 * 8 && T.sizeof <= 8) 152 { 153 parmn = *cast(T*)(ap.reg_args + ap.offset_regs); 154 ap.offset_regs += 8; 155 } 156 else 157 { 158 auto p = (cast(size_t)ap.stack_args + T.alignof - 1) & ~(T.alignof - 1); 159 ap.stack_args = cast(void*)(p + ((T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1))); 160 parmn = *cast(T*)p; 161 } 162 } 163 } 164 else static if (U.length == 2) 165 { // Arg is passed in two registers 166 alias U[0] T1; 167 alias U[1] T2; 168 169 static if (is(T1 == double) || is(T1 == float)) 170 { 171 if (ap.offset_fpregs < (6 * 8 + 16 * 8)) 172 { 173 *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_fpregs); 174 ap.offset_fpregs += 16; 175 } 176 else 177 { 178 *cast(T1*)&parmn = *cast(T1*)ap.stack_args; 179 ap.stack_args += (T1.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1); 180 } 181 } 182 else 183 { 184 if (ap.offset_regs < 6 * 8 && T1.sizeof <= 8) 185 { 186 *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_regs); 187 ap.offset_regs += 8; 188 } 189 else 190 { 191 *cast(T1*)&parmn = *cast(T1*)ap.stack_args; 192 ap.stack_args += 8; 193 } 194 } 195 196 auto p = cast(void*)&parmn + 8; 197 static if (is(T2 == double) || is(T2 == float)) 198 { 199 if (ap.offset_fpregs < (6 * 8 + 16 * 8)) 200 { 201 *cast(T2*)p = *cast(T2*)(ap.reg_args + ap.offset_fpregs); 202 ap.offset_fpregs += 16; 203 } 204 else 205 { 206 *cast(T2*)p = *cast(T2*)ap.stack_args; 207 ap.stack_args += (T2.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1); 208 } 209 } 210 else 211 { 212 void* a = void; 213 if (ap.offset_regs < 6 * 8 && T2.sizeof <= 8) 214 { 215 a = ap.reg_args + ap.offset_regs; 216 ap.offset_regs += 8; 217 } 218 else 219 { 220 a = ap.stack_args; 221 ap.stack_args += 8; 222 } 223 // Be careful not to go past the size of the actual argument 224 const sz2 = T.sizeof - 8; 225 p[0..sz2] = a[0..sz2]; 226 } 227 } 228 else 229 { 230 static assert(0); 231 } 232 } 233 else 234 { 235 static assert(0, "not a valid argument type for va_arg"); 236 } 237 } 238 239 void va_arg()(va_list apx, TypeInfo ti, void* parmn) 240 { 241 __va_list* ap = cast(__va_list*)apx; 242 TypeInfo arg1, arg2; 243 if (!ti.argTypes(arg1, arg2)) 244 { 245 if (arg1 && arg1.tsize() <= 8) 246 { // Arg is passed in one register 247 auto tsize = arg1.tsize(); 248 void* p; 249 auto s = arg1.toString(); 250 if (s == "double" || s == "float") 251 { // Passed in XMM register 252 if (ap.offset_fpregs < (6 * 8 + 16 * 8)) 253 { 254 p = ap.reg_args + ap.offset_fpregs; 255 ap.offset_fpregs += 16; 256 } 257 else 258 { 259 p = ap.stack_args; 260 ap.stack_args += (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1); 261 } 262 } 263 else 264 { // Passed in regular register 265 if (ap.offset_regs < 6 * 8) 266 { 267 p = ap.reg_args + ap.offset_regs; 268 ap.offset_regs += 8; 269 } 270 else 271 { 272 p = ap.stack_args; 273 ap.stack_args += 8; 274 } 275 } 276 parmn[0..tsize] = p[0..tsize]; 277 278 if (arg2) 279 { 280 parmn += 8; 281 tsize = arg2.tsize(); 282 s = arg2.toString(); 283 if (s == "double" || s == "float") 284 { // Passed in XMM register 285 if (ap.offset_fpregs < (6 * 8 + 16 * 8)) 286 { 287 p = ap.reg_args + ap.offset_fpregs; 288 ap.offset_fpregs += 16; 289 } 290 else 291 { 292 p = ap.stack_args; 293 ap.stack_args += (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1); 294 } 295 } 296 else 297 { // Passed in regular register 298 if (ap.offset_regs < 6 * 8) 299 { 300 p = ap.reg_args + ap.offset_regs; 301 ap.offset_regs += 8; 302 } 303 else 304 { 305 p = ap.stack_args; 306 ap.stack_args += 8; 307 } 308 } 309 tsize = ti.tsize() - 8; 310 parmn[0..tsize] = p[0..tsize]; 311 } 312 } 313 else 314 { // Always passed in memory 315 // The arg may have more strict alignment than the stack 316 auto talign = ti.talign(); 317 auto tsize = ti.tsize(); 318 auto p = cast(void*)((cast(size_t)ap.stack_args + talign - 1) & ~(talign - 1)); 319 ap.stack_args = cast(void*)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1))); 320 parmn[0..tsize] = p[0..tsize]; 321 } 322 } 323 else 324 { 325 assert(0, "not a valid argument type for va_arg"); 326 } 327 } 328 329 void va_end(va_list ap) 330 { 331 } 332 47 333 void va_copy( out va_list dest, va_list src ) 48 334 { 49 335 dest = src; 50 336 } 51 337 } 338 else 339 { 340 static assert(0); 341 } 342 } -
tango/util/log/Log.d
old new 103 103 alias void* Arg; 104 104 alias va_list ArgList; 105 105 } 106 version (DigitalMars) 107 { 108 private import tango.core.Vararg; 109 alias void* Arg; 110 alias va_list ArgList; 111 } 106 112 else 107 113 { 108 114 alias void* Arg;