Changes in / [2b18848:1b5c3d60]
- Files:
-
- 7 edited
-
libcfa/src/concurrency/kernel/fwd.hfa (modified) (1 diff)
-
libcfa/src/concurrency/preemption.cfa (modified) (8 diffs)
-
libcfa/src/stdlib.hfa (modified) (1 diff)
-
src/AST/Pass.impl.hpp (modified) (1 diff)
-
src/AST/Pass.proto.hpp (modified) (1 diff)
-
src/ResolvExpr/Resolver.cc (modified) (2 diffs)
-
src/ResolvExpr/SatisfyAssertions.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/fwd.hfa
r2b18848 r1b5c3d60 65 65 66 66 extern uintptr_t __cfatls_get( unsigned long int member ); 67 #define publicTLS_get( member ) ((typeof(__cfaabi_tls.member))__cfatls_get( __builtin_offsetof(KernelThreadData, member) )) 67 // #define publicTLS_get( member ) ((typeof(__cfaabi_tls.member))__cfatls_get( __builtin_offsetof(KernelThreadData, member) )) 68 #define publicTLS_get( member ) (__cfaabi_tls.member) 69 // extern forall(otype T) T __cfatls_get( T * member, T value ); 70 // #define publicTLS_set( member, value ) __cfatls_set( (typeof(member)*)__builtin_offsetof(KernelThreadData, member), value ); 68 71 69 72 static inline uint64_t __tls_rand() { -
libcfa/src/concurrency/preemption.cfa
r2b18848 r1b5c3d60 231 231 } 232 232 233 struct asm_region {234 void * before;235 void * after;236 };237 238 static inline bool __cfaasm_in( void * ip, struct asm_region & region ) {239 return ip >= region.before && ip <= region.after;240 }241 242 243 233 //---------- 244 234 // Get data from the TLS block 245 // struct asm_region __cfaasm_get;246 235 uintptr_t __cfatls_get( unsigned long int offset ) __attribute__((__noinline__)); //no inline to avoid problems 247 236 uintptr_t __cfatls_get( unsigned long int offset ) { 248 // __cfaasm_get.before = ({ void * value; asm("movq $__cfaasm_get_before, %[v]\n\t" : [v]"=r"(value) ); value; });249 // __cfaasm_get.after = ({ void * value; asm("movq $__cfaasm_get_after , %[v]\n\t" : [v]"=r"(value) ); value; });250 237 // create a assembler label before 251 238 // marked as clobber all to avoid movement … … 266 253 // create a assembler label before 267 254 // marked as clobber all to avoid movement 268 asm volatile("__cfaasm_d sable_before:":::"memory");255 asm volatile("__cfaasm_disable_before:":::"memory"); 269 256 270 257 with( __cfaabi_tls.preemption_state ) { … … 288 275 // create a assembler label after 289 276 // marked as clobber all to avoid movement 290 asm volatile("__cfaasm_d sable_after:":::"memory");277 asm volatile("__cfaasm_disable_after:":::"memory"); 291 278 } 292 279 … … 296 283 // create a assembler label before 297 284 // marked as clobber all to avoid movement 298 asm volatile("__cfaasm_en ble_before:":::"memory");285 asm volatile("__cfaasm_enable_before:":::"memory"); 299 286 300 287 processor * proc = __cfaabi_tls.this_processor; // Cache the processor now since interrupts can start happening after the atomic store … … 331 318 // create a assembler label after 332 319 // marked as clobber all to avoid movement 333 asm volatile("__cfaasm_en ble_after:":::"memory");320 asm volatile("__cfaasm_enable_after:":::"memory"); 334 321 } 335 322 … … 399 386 } 400 387 401 //-----------------------------------------------------------------------------402 // Some assembly required403 #if defined( __i386 )404 #ifdef __PIC__405 #define RELOC_PRELUDE( label ) \406 "calll .Lcfaasm_prelude_" #label "$pb\n\t" \407 ".Lcfaasm_prelude_" #label "$pb:\n\t" \408 "popl %%eax\n\t" \409 ".Lcfaasm_prelude_" #label "_end:\n\t" \410 "addl $_GLOBAL_OFFSET_TABLE_+(.Lcfaasm_prelude_" #label "_end-.Lcfaasm_prelude_" #label "$pb), %%eax\n\t"411 #define RELOC_PREFIX ""412 #define RELOC_SUFFIX "@GOT(%%eax)"413 #else414 #define RELOC_PREFIX "$"415 #define RELOC_SUFFIX ""416 #endif417 #define __cfaasm_label( label ) static struct asm_region label = \418 ({ \419 struct asm_region region; \420 asm( \421 RELOC_PRELUDE( label ) \422 "movl " RELOC_PREFIX "__cfaasm_" #label "_before" RELOC_SUFFIX ", %[vb]\n\t" \423 "movl " RELOC_PREFIX "__cfaasm_" #label "_after" RELOC_SUFFIX ", %[va]\n\t" \424 : [vb]"=r"(region.before), [va]"=r"(region.after) \425 ); \426 region; \427 });428 #elif defined( __x86_64 )429 #ifdef __PIC__430 #define RELOC_PREFIX ""431 #define RELOC_SUFFIX "@GOTPCREL(%%rip)"432 #else433 #define RELOC_PREFIX "$"434 #define RELOC_SUFFIX ""435 #endif436 #define __cfaasm_label( label ) static struct asm_region label = \437 ({ \438 struct asm_region region; \439 asm( \440 "movq " RELOC_PREFIX "__cfaasm_" #label "_before" RELOC_SUFFIX ", %[vb]\n\t" \441 "movq " RELOC_PREFIX "__cfaasm_" #label "_after" RELOC_SUFFIX ", %[va]\n\t" \442 : [vb]"=r"(region.before), [va]"=r"(region.after) \443 ); \444 region; \445 });446 #elif defined( __aarch64__ )447 #ifdef __PIC__448 #define RELOC_TAG "@PLT"449 #else450 #define RELOC_TAG ""451 #endif452 #define __cfaasm_label( label ) \453 ({ \454 struct asm_region region; \455 asm( \456 "mov %[vb], __cfaasm_" #label "_before@GOTPCREL(%%rip)" "\n\t" \457 "mov %[va], __cfaasm_" #label "_after@GOTPCREL(%%rip)" "\n\t" \458 : [vb]"=r"(region.before), [va]"=r"(region.after) \459 ); \460 region; \461 });462 #else463 #error unknown hardware architecture464 #endif465 466 388 // KERNEL ONLY 467 389 // Check if a __cfactx_switch signal handler shoud defer 468 390 // If true : preemption is safe 469 391 // If false : preemption is unsafe and marked as pending 470 static inline bool preemption_ready( void * ip ) { 471 // Get all the region for which it is not safe to preempt 472 __cfaasm_label( get ); 473 __cfaasm_label( check ); 474 __cfaasm_label( dsable ); 475 __cfaasm_label( enble ); 476 __cfaasm_label( nopoll ); 477 392 static inline bool preemption_ready() { 478 393 // Check if preemption is safe 479 bool ready = true; 480 if( __cfaasm_in( ip, get ) ) { ready = false; goto EXIT; }; 481 if( __cfaasm_in( ip, check ) ) { ready = false; goto EXIT; }; 482 if( __cfaasm_in( ip, dsable ) ) { ready = false; goto EXIT; }; 483 if( __cfaasm_in( ip, enble ) ) { ready = false; goto EXIT; }; 484 if( __cfaasm_in( ip, nopoll ) ) { ready = false; goto EXIT; }; 485 if( !__cfaabi_tls.preemption_state.enabled) { ready = false; goto EXIT; }; 486 if( __cfaabi_tls.preemption_state.in_progress ) { ready = false; goto EXIT; }; 487 488 EXIT: 394 bool ready = __cfaabi_tls.preemption_state.enabled && ! __cfaabi_tls.preemption_state.in_progress; 395 489 396 // Adjust the pending flag accordingly 490 397 __cfaabi_tls.this_processor->pending_preemption = !ready; … … 561 468 // Kernel Signal Handlers 562 469 //============================================================================================= 470 struct asm_region { 471 void * before; 472 void * after; 473 }; 474 475 //----------------------------------------------------------------------------- 476 // Some assembly required 477 #if defined( __i386 ) 478 #define __cfaasm_label( label ) \ 479 ({ \ 480 struct asm_region region; \ 481 asm( \ 482 "movl $__cfaasm_" #label "_before, %[vb]\n\t" \ 483 "movl $__cfaasm_" #label "_after , %[va]\n\t" \ 484 : [vb]"=r"(region.before), [vb]"=r"(region.before) \ 485 ); \ 486 region; \ 487 }); 488 #elif defined( __x86_64 ) 489 #ifdef __PIC__ 490 #define PLT "@PLT" 491 #else 492 #define PLT "" 493 #endif 494 #define __cfaasm_label( label ) \ 495 ({ \ 496 struct asm_region region; \ 497 asm( \ 498 "movq $__cfaasm_" #label "_before" PLT ", %[vb]\n\t" \ 499 "movq $__cfaasm_" #label "_after" PLT ", %[va]\n\t" \ 500 : [vb]"=r"(region.before), [va]"=r"(region.after) \ 501 ); \ 502 region; \ 503 }); 504 #elif defined( __aarch64__ ) 505 #error __cfaasm_label undefined for arm 506 #else 507 #error unknown hardware architecture 508 #endif 509 563 510 __cfaabi_dbg_debug_do( static thread_local void * last_interrupt = 0; ) 564 511 … … 583 530 584 531 // Check if it is safe to preempt here 585 if( !preemption_ready( ip ) ) { return; } 532 if( !preemption_ready() ) { return; } 533 534 struct asm_region region; 535 region = __cfaasm_label( get ); if( ip >= region.before && ip <= region.after ) return; 536 region = __cfaasm_label( check ); if( ip >= region.before && ip <= region.after ) return; 537 region = __cfaasm_label( disable ); if( ip >= region.before && ip <= region.after ) return; 538 region = __cfaasm_label( enable ); if( ip >= region.before && ip <= region.after ) return; 539 region = __cfaasm_label( nopoll ); if( ip >= region.before && ip <= region.after ) return; 586 540 587 541 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p @ %p).\n", __cfaabi_tls.this_processor, __cfaabi_tls.this_thread, (void *)(cxt->uc_mcontext.CFA_REG_IP) ); -
libcfa/src/stdlib.hfa
r2b18848 r1b5c3d60 129 129 forall( dtype T | sized(T) ) { 130 130 union U_fill { char c; T * a; T t; }; 131 struct S_fill { char tag; U_fill(T) fill; };131 struct S_fill { char tag; char c; size_t size; T * at; char t[50]; }; 132 132 struct S_realloc { inline T *; }; 133 133 } -
src/AST/Pass.impl.hpp
r2b18848 r1b5c3d60 423 423 } 424 424 catch( SemanticErrorException &e ) { 425 if (__pass::on _error (visitor.core, *i, 0))425 if (__pass::onError (visitor.core, *i, 0)) 426 426 errors.append( e ); 427 427 } -
src/AST/Pass.proto.hpp
r2b18848 r1b5c3d60 270 270 271 271 template< typename core_t > 272 static bool on _error (core_t &, ptr<Decl> &, long) { return true; }273 274 template< typename core_t > 275 static auto on _error (core_t & core, ptr<Decl> & decl, int) -> decltype(core.on_error(decl)) {276 return core.on _error(decl);272 static bool onError (core_t &, ptr<Decl> &, long) { return true; } 273 274 template< typename core_t > 275 static auto onError (core_t & core, ptr<Decl> & decl, int) -> decltype(core.onError(decl)) { 276 return core.onError(decl); 277 277 } 278 278 -
src/ResolvExpr/Resolver.cc
r2b18848 r1b5c3d60 1289 1289 void beginScope() { managedTypes.beginScope(); } 1290 1290 void endScope() { managedTypes.endScope(); } 1291 bool on _error(ast::ptr<ast::Decl> & decl);1291 bool onError(ast::ptr<ast::Decl> & decl); 1292 1292 }; 1293 1293 // size_t Resolver_new::traceId = Stats::Heap::new_stacktrace_id("Resolver"); … … 2068 2068 2069 2069 // suppress error on autogen functions and mark invalid autogen as deleted. 2070 bool Resolver_new::on _error(ast::ptr<ast::Decl> & decl) {2070 bool Resolver_new::onError(ast::ptr<ast::Decl> & decl) { 2071 2071 if (auto functionDecl = decl.as<ast::FunctionDecl>()) { 2072 2072 // xxx - can intrinsic gen ever fail? -
src/ResolvExpr/SatisfyAssertions.cpp
r2b18848 r1b5c3d60 247 247 auto it = inferred.find( slot ); 248 248 if ( it == inferred.end() ) { 249 //std::cerr << "missing assertion " << slot << std::endl;249 std::cerr << "missing assertion " << slot << std::endl; 250 250 missingSlots.push_back(slot); 251 251 continue;
Note:
See TracChangeset
for help on using the changeset viewer.