Changeset 57
- Timestamp:
- 12/07/08 01:33:12 (4 years ago)
- Files:
-
- trunk/src/common/core/thread.d (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/common/core/thread.d
r43 r57 93 93 extern (C) uintptr_t _beginthreadex(void*, uint, btex_fptr, void*, uint, uint*); 94 94 95 /* The memory between the addresses of _tlsstart and _tlsend 96 * lies all the implicit thread local storage variables for this 97 * thread for this module. 98 * Both are declared in \dm\src\win32\tlsseg.asm 99 */ 100 extern (C) 101 { 102 extern __thread int _tlsstart; 103 extern __thread int _tlsend; 104 } 95 105 96 106 // … … 109 119 Thread.setThis( obj ); 110 120 121 /* Save the bounds of the TLS data block 122 */ 123 void* pstart = cast(void*)&_tlsstart; 124 void* pend = cast(void*)&_tlsend; 125 obj.m_tls = pstart[0 .. pend - pstart]; 126 111 127 // NOTE: No GC allocations may occur until the stack pointers have 112 128 // been set and Thread.getThis returns a valid reference to … … 164 180 import gcc.builtins; 165 181 } 182 183 /* The memory between the addresses of _tlsstart and _tlsend 184 * lies all the implicit thread local storage variables for this 185 * thread for this module. 186 * These two are magically allocated by the compiler so that 187 * they will bracket the .tdata and .tbss segments. 188 * See elfobj.c in the dmd compiler source for details. 189 */ 190 extern (C) 191 { 192 __thread int _tlsstart; 193 __thread int _tlsend; 194 } 166 195 167 196 … … 240 269 Thread.add( &obj.m_main ); 241 270 Thread.setThis( obj ); 271 272 /* Save the bounds of the TLS data block 273 */ 274 void* pstart = cast(void*)&_tlsstart; 275 void* pend = cast(void*)&_tlsend; 276 obj.m_tls = pstart[0 .. pend - pstart]; 277 242 278 243 279 // NOTE: No GC allocations may occur until the stack pointers have … … 1121 1157 m_call = Call.NO; 1122 1158 m_curr = &m_main; 1159 1160 void* pstart = cast(void*)&_tlsstart; 1161 void* pend = cast(void*)&_tlsend; 1162 m_tls = pstart[0 .. pend - pstart]; 1123 1163 } 1124 1164 … … 1281 1321 Context* m_curr; 1282 1322 bool m_lock; 1323 void[] m_tls; // spans implicit thread local storage 1283 1324 1284 1325 version( Windows ) … … 1968 2009 } 1969 2010 } 1970 version( Windows ) 1971 { 1972 for( Thread t = Thread.sm_tbeg; t; t = t.next ) 1973 { 2011 2012 for( Thread t = Thread.sm_tbeg; t; t = t.next ) 2013 { 2014 /* Scan thread local storage. 2015 * The BUG here is that the tls for other modules 2016 * is not scanned. 2017 */ 2018 scan( t.m_tls.ptr, t.m_tls.ptr + t.m_tls.length ); 2019 2020 version (Windows) 1974 2021 scan( &t.m_reg[0], &t.m_reg[0] + t.m_reg.length ); 1975 }1976 2022 } 1977 2023 }
