Changeset fe610ab
- Timestamp:
- Feb 17, 2022, 6:53:31 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- f69fac7
- Parents:
- 778315e (diff), 9ef9644 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 4 added
- 2 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified libcfa/src/Makefile.am ¶
r778315e rfe610ab 72 72 common.hfa \ 73 73 fstream.hfa \ 74 heap.hfa \75 74 iostream.hfa \ 76 75 iterator.hfa \ … … 102 101 startup.hfa \ 103 102 virtual.c \ 104 virtual.h 103 virtual.h \ 104 heap.cc \ 105 heap.h 105 106 106 107 # not all platforms support concurrency, add option do disable it … … 172 173 173 174 -include $(libdeps) 175 -include $(DEPDIR)/heap.Plo 174 176 175 177 thread_libdeps = $(join \ -
TabularUnified libcfa/src/concurrency/coroutine.cfa ¶
r778315e rfe610ab 85 85 // minimum feasible stack size in bytes 86 86 static const size_t MinStackSize = 1000; 87 extern size_t __page_size; // architecture pagesize HACK, should go in proper runtime singleton 88 extern int __map_prot; 87 88 extern "C" { 89 extern size_t __cfa_page_size; // architecture pagesize HACK, should go in proper runtime singleton 90 extern int __map_prot; 91 } 89 92 90 93 void __stack_prepare( __stack_info_t * this, size_t create_size ); … … 157 160 [void *, size_t] __stack_alloc( size_t storageSize ) { 158 161 const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment 159 assert(__ page_size != 0l);162 assert(__cfa_page_size != 0l); 160 163 size_t size = libCeiling( storageSize, 16 ) + stack_data_size; 161 size = ceiling(size, __ page_size);164 size = ceiling(size, __cfa_page_size); 162 165 163 166 // If we are running debug, we also need to allocate a guardpage to catch stack overflows. 164 167 void * storage; 165 168 #if CFA_COROUTINE_USE_MMAP 166 storage = mmap(0p, size + __ page_size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);169 storage = mmap(0p, size + __cfa_page_size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); 167 170 if(storage == ((void*)-1)) { 168 171 abort( "coroutine stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) ); 169 172 } 170 if ( mprotect( storage, __ page_size, PROT_NONE ) == -1 ) {173 if ( mprotect( storage, __cfa_page_size, PROT_NONE ) == -1 ) { 171 174 abort( "coroutine stack creation : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) ); 172 175 } // if 173 storage = (void *)(((intptr_t)storage) + __ page_size);176 storage = (void *)(((intptr_t)storage) + __cfa_page_size); 174 177 #else 175 178 __cfaabi_dbg_debug_do( 176 storage = memalign( __ page_size, size + __page_size );179 storage = memalign( __cfa_page_size, size + __cfa_page_size ); 177 180 ); 178 181 __cfaabi_dbg_no_debug_do( … … 181 184 182 185 __cfaabi_dbg_debug_do( 183 if ( mprotect( storage, __ page_size, PROT_NONE ) == -1 ) {186 if ( mprotect( storage, __cfa_page_size, PROT_NONE ) == -1 ) { 184 187 abort( "__stack_alloc : internal error, mprotect failure, error(%d) %s.", (int)errno, strerror( (int)errno ) ); 185 188 } 186 storage = (void *)(((intptr_t)storage) + __ page_size);189 storage = (void *)(((intptr_t)storage) + __cfa_page_size); 187 190 ); 188 191 #endif … … 198 201 #if CFA_COROUTINE_USE_MMAP 199 202 size_t size = ((intptr_t)this->storage->base) - ((intptr_t)this->storage->limit) + sizeof(__stack_t); 200 storage = (void *)(((intptr_t)storage) - __ page_size);201 if(munmap(storage, size + __ page_size) == -1) {203 storage = (void *)(((intptr_t)storage) - __cfa_page_size); 204 if(munmap(storage, size + __cfa_page_size) == -1) { 202 205 abort( "coroutine stack destruction : internal error, munmap failure, error(%d) %s.", errno, strerror( errno ) ); 203 206 } 204 207 #else 205 208 __cfaabi_dbg_debug_do( 206 storage = (char*)(storage) - __ page_size;207 if ( mprotect( storage, __ page_size, __map_prot ) == -1 ) {209 storage = (char*)(storage) - __cfa_page_size; 210 if ( mprotect( storage, __cfa_page_size, __map_prot ) == -1 ) { 208 211 abort( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) ); 209 212 } -
TabularUnified libcfa/src/concurrency/kernel/startup.cfa ¶
r778315e rfe610ab 122 122 extern "C" { 123 123 struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters; 124 } 125 126 extern size_t __page_size; 127 extern int __map_prot; 124 extern size_t __cfa_page_size; 125 extern int __map_prot; 126 } 128 127 129 128 //----------------------------------------------------------------------------- … … 574 573 } 575 574 576 extern size_t __page_size;577 575 void ^?{}(processor & this) with( this ){ 578 576 /* paranoid */ verify( !__atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) ); … … 740 738 void * stack; 741 739 #if CFA_PROCESSOR_USE_MMAP 742 stacksize = ceiling( stacksize, __ page_size ) + __page_size;740 stacksize = ceiling( stacksize, __cfa_page_size ) + __cfa_page_size; 743 741 stack = mmap(0p, stacksize, __map_prot, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); 744 742 if(stack == ((void*)-1)) { 745 743 abort( "pthread stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) ); 746 744 } 747 if ( mprotect( stack, __ page_size, PROT_NONE ) == -1 ) {745 if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) { 748 746 abort( "pthread stack creation : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) ); 749 747 } // if 750 748 #else 751 749 __cfaabi_dbg_debug_do( 752 stack = memalign( __ page_size, stacksize + __page_size );750 stack = memalign( __cfa_page_size, stacksize + __cfa_page_size ); 753 751 // pthread has no mechanism to create the guard page in user supplied stack. 754 if ( mprotect( stack, __ page_size, PROT_NONE ) == -1 ) {752 if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) { 755 753 abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) ); 756 754 } // if … … 779 777 check( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" ); 780 778 assert( stacksize >= PTHREAD_STACK_MIN ); 781 stacksize += __ page_size;779 stacksize += __cfa_page_size; 782 780 783 781 if(munmap(stack, stacksize) == -1) { … … 787 785 __cfaabi_dbg_debug_do( 788 786 // pthread has no mechanism to create the guard page in user supplied stack. 789 if ( mprotect( stack, __ page_size, __map_prot ) == -1 ) {787 if ( mprotect( stack, __cfa_page_size, __map_prot ) == -1 ) { 790 788 abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) ); 791 789 } // if -
TabularUnified libcfa/src/math.trait.hfa ¶
r778315e rfe610ab 16 16 #pragma once 17 17 18 trait Not( T) {19 void ?{}( T&, zero_t );20 int !?( T);18 trait Not( U ) { 19 void ?{}( U &, zero_t ); 20 int !?( U ); 21 21 }; // Not 22 22 … … 26 26 }; // Equality 27 27 28 trait Relational( T | Equality( T) ) {29 int ?<?( T, T);30 int ?<=?( T, T);31 int ?>?( T, T);32 int ?>=?( T, T);28 trait Relational( U | Equality( U ) ) { 29 int ?<?( U, U ); 30 int ?<=?( U, U ); 31 int ?>?( U, U ); 32 int ?>=?( U, U ); 33 33 }; // Relational 34 34 … … 39 39 }; // Signed 40 40 41 trait Additive( T | Signed( T) ) {42 T ?+?( T, T);43 T ?-?( T, T);44 T ?+=?( T &, T);45 T ?-=?( T &, T);41 trait Additive( U | Signed( U ) ) { 42 U ?+?( U, U ); 43 U ?-?( U, U ); 44 U ?+=?( U &, U ); 45 U ?-=?( U &, U ); 46 46 }; // Additive 47 47 … … 49 49 void ?{}( T &, one_t ); 50 50 // T ?++( T & ); 51 // T ++?( T & );51 // T ++?( T & ); 52 52 // T ?--( T & ); 53 53 // T --?( T & ); 54 54 }; // Incdec 55 55 56 trait Multiplicative( T | Incdec( T) ) {57 T ?*?( T, T);58 T ?/?( T, T);59 T ?%?( T, T);60 T ?/=?( T &, T);56 trait Multiplicative( U | Incdec( U ) ) { 57 U ?*?( U, U ); 58 U ?/?( U, U ); 59 U ?%?( U, U ); 60 U ?/=?( U &, U ); 61 61 }; // Multiplicative 62 62 -
TabularUnified libcfa/src/startup.cfa ¶
r778315e rfe610ab 27 27 void __cfaabi_appready_startup( void ) { 28 28 tzset(); // initialize time global variables 29 #ifdef __CFA_DEBUG__ 29 #ifdef __CFA_DEBUG__FIXME 30 30 extern void heapAppStart(); 31 31 heapAppStart(); 32 #endif // __CFA_DEBUG__ 32 #endif // __CFA_DEBUG__FIXME 33 33 } // __cfaabi_appready_startup 34 34 35 35 void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) )); 36 36 void __cfaabi_appready_shutdown( void ) { 37 #ifdef __CFA_DEBUG__ 37 #ifdef __CFA_DEBUG__FIXME 38 38 extern void heapAppStop(); 39 39 heapAppStop(); 40 #endif // __CFA_DEBUG__ 40 #endif // __CFA_DEBUG__FIXME 41 41 } // __cfaabi_appready_shutdown 42 42 -
TabularUnified libcfa/src/stdhdr/malloc.h ¶
r778315e rfe610ab 18 18 } // extern "C" 19 19 20 #include <heap.h fa>20 #include <heap.h> 21 21 22 22 // Local Variables: // -
TabularUnified libcfa/src/stdlib.hfa ¶
r778315e rfe610ab 21 21 22 22 #include <stdlib.h> // *alloc, strto*, ato* 23 #include <heap.h fa>23 #include <heap.h> 24 24 25 25 -
TabularUnified src/AST/Decl.cpp ¶
r778315e rfe610ab 39 39 if ( uniqueId ) return; // ensure only set once 40 40 uniqueId = ++lastUniqueId; 41 idMap[ uniqueId ] = this; 41 // The extra readonly pointer is causing some reference counting issues. 42 // idMap[ uniqueId ] = this; 42 43 } 43 44 44 45 readonly<Decl> Decl::fromId( UniqueId id ) { 46 // Right now this map is always empty, so don't use it. 47 assert( false ); 45 48 IdMapType::const_iterator i = idMap.find( id ); 46 49 if ( i != idMap.end() ) return i->second; -
TabularUnified src/SymTab/Validate.cc ¶
r778315e rfe610ab 194 194 }; 195 195 196 // These structs are the sub-sub-passes of ForallPointerDecay_old. 197 198 struct TraitExpander_old final { 199 void previsit( FunctionType * ); 200 void previsit( StructDecl * ); 201 void previsit( UnionDecl * ); 202 }; 203 204 struct AssertionFixer_old final { 205 void previsit( FunctionType * ); 206 void previsit( StructDecl * ); 207 void previsit( UnionDecl * ); 208 }; 209 210 struct CheckOperatorTypes_old final { 211 void previsit( ObjectDecl * ); 212 }; 213 214 struct FixUniqueIds_old final { 215 void previsit( DeclarationWithType * ); 216 }; 217 196 218 struct ReturnChecker : public WithGuards { 197 219 /// Checks that return statements return nothing if their return type is void … … 386 408 387 409 void validate_D( std::list< Declaration * > & translationUnit ) { 388 PassVisitor<ForallPointerDecay_old> fpd;389 410 { 390 411 Stats::Heap::newPass("validate-D"); … … 394 415 }); 395 416 Stats::Time::TimeBlock("Forall Pointer Decay", [&]() { 396 acceptAll( translationUnit, fpd); // must happen before autogenerateRoutines, after Concurrency::applyKeywords because uniqueIds must be set on declaration before resolution417 decayForallPointers( translationUnit ); // must happen before autogenerateRoutines, after Concurrency::applyKeywords because uniqueIds must be set on declaration before resolution 397 418 }); 398 419 Stats::Time::TimeBlock("Hoist Control Declarations", [&]() { … … 454 475 455 476 void decayForallPointers( std::list< Declaration * > & translationUnit ) { 456 PassVisitor<ForallPointerDecay_old> fpd; 457 acceptAll( translationUnit, fpd ); 477 PassVisitor<TraitExpander_old> te; 478 acceptAll( translationUnit, te ); 479 PassVisitor<AssertionFixer_old> af; 480 acceptAll( translationUnit, af ); 481 PassVisitor<CheckOperatorTypes_old> cot; 482 acceptAll( translationUnit, cot ); 483 PassVisitor<FixUniqueIds_old> fui; 484 acceptAll( translationUnit, fui ); 485 } 486 487 void decayForallPointersA( std::list< Declaration * > & translationUnit ) { 488 PassVisitor<TraitExpander_old> te; 489 acceptAll( translationUnit, te ); 490 } 491 void decayForallPointersB( std::list< Declaration * > & translationUnit ) { 492 PassVisitor<AssertionFixer_old> af; 493 acceptAll( translationUnit, af ); 494 } 495 void decayForallPointersC( std::list< Declaration * > & translationUnit ) { 496 PassVisitor<CheckOperatorTypes_old> cot; 497 acceptAll( translationUnit, cot ); 498 } 499 void decayForallPointersD( std::list< Declaration * > & translationUnit ) { 500 PassVisitor<FixUniqueIds_old> fui; 501 acceptAll( translationUnit, fui ); 458 502 } 459 503 … … 470 514 PassVisitor<EnumAndPointerDecay_old> epc; 471 515 PassVisitor<LinkReferenceToTypes_old> lrt( indexer ); 472 PassVisitor<ForallPointerDecay_old> fpd; 516 PassVisitor<TraitExpander_old> te; 517 PassVisitor<AssertionFixer_old> af; 518 PassVisitor<CheckOperatorTypes_old> cot; 519 PassVisitor<FixUniqueIds_old> fui; 473 520 type->accept( epc ); 474 521 type->accept( lrt ); 475 type->accept( fpd ); 522 type->accept( te ); 523 type->accept( af ); 524 type->accept( cot ); 525 type->accept( fui ); 476 526 } 477 527 … … 972 1022 } 973 1023 1024 /// Replace all traits in assertion lists with their assertions. 1025 void expandTraits( std::list< TypeDecl * > & forall ) { 1026 for ( TypeDecl * type : forall ) { 1027 std::list< DeclarationWithType * > asserts; 1028 asserts.splice( asserts.end(), type->assertions ); 1029 // expand trait instances into their members 1030 for ( DeclarationWithType * assertion : asserts ) { 1031 if ( TraitInstType * traitInst = dynamic_cast< TraitInstType * >( assertion->get_type() ) ) { 1032 // expand trait instance into all of its members 1033 expandAssertions( traitInst, back_inserter( type->assertions ) ); 1034 delete traitInst; 1035 } else { 1036 // pass other assertions through 1037 type->assertions.push_back( assertion ); 1038 } // if 1039 } // for 1040 } 1041 } 1042 1043 /// Fix each function in the assertion list and check for invalid void type. 1044 void fixAssertions( 1045 std::list< TypeDecl * > & forall, BaseSyntaxNode * node ) { 1046 for ( TypeDecl * type : forall ) { 1047 for ( DeclarationWithType *& assertion : type->assertions ) { 1048 bool isVoid = fixFunction( assertion ); 1049 if ( isVoid ) { 1050 SemanticError( node, "invalid type void in assertion of function " ); 1051 } // if 1052 } // for 1053 } 1054 } 1055 974 1056 void ForallPointerDecay_old::previsit( ObjectDecl * object ) { 975 1057 // ensure that operator names only apply to functions or function pointers … … 994 1076 void ForallPointerDecay_old::previsit( UnionDecl * aggrDecl ) { 995 1077 forallFixer( aggrDecl->parameters, aggrDecl ); 1078 } 1079 1080 void TraitExpander_old::previsit( FunctionType * ftype ) { 1081 expandTraits( ftype->forall ); 1082 } 1083 1084 void TraitExpander_old::previsit( StructDecl * aggrDecl ) { 1085 expandTraits( aggrDecl->parameters ); 1086 } 1087 1088 void TraitExpander_old::previsit( UnionDecl * aggrDecl ) { 1089 expandTraits( aggrDecl->parameters ); 1090 } 1091 1092 void AssertionFixer_old::previsit( FunctionType * ftype ) { 1093 fixAssertions( ftype->forall, ftype ); 1094 } 1095 1096 void AssertionFixer_old::previsit( StructDecl * aggrDecl ) { 1097 fixAssertions( aggrDecl->parameters, aggrDecl ); 1098 } 1099 1100 void AssertionFixer_old::previsit( UnionDecl * aggrDecl ) { 1101 fixAssertions( aggrDecl->parameters, aggrDecl ); 1102 } 1103 1104 void CheckOperatorTypes_old::previsit( ObjectDecl * object ) { 1105 // ensure that operator names only apply to functions or function pointers 1106 if ( CodeGen::isOperator( object->name ) && ! dynamic_cast< FunctionType * >( object->type->stripDeclarator() ) ) { 1107 SemanticError( object->location, toCString( "operator ", object->name.c_str(), " is not a function or function pointer." ) ); 1108 } 1109 } 1110 1111 void FixUniqueIds_old::previsit( DeclarationWithType * decl ) { 1112 decl->fixUniqueId(); 996 1113 } 997 1114 -
TabularUnified src/SymTab/Validate.h ¶
r778315e rfe610ab 43 43 void validate_F( std::list< Declaration * > &translationUnit ); 44 44 void decayForallPointers( std::list< Declaration * > & translationUnit ); 45 void decayForallPointersA( std::list< Declaration * > & translationUnit ); 46 void decayForallPointersB( std::list< Declaration * > & translationUnit ); 47 void decayForallPointersC( std::list< Declaration * > & translationUnit ); 48 void decayForallPointersD( std::list< Declaration * > & translationUnit ); 45 49 46 50 const ast::Type * validateType( -
TabularUnified src/Validate/module.mk ¶
r778315e rfe610ab 20 20 Validate/CompoundLiteral.cpp \ 21 21 Validate/CompoundLiteral.hpp \ 22 Validate/ForallPointerDecay.cpp \ 23 Validate/ForallPointerDecay.hpp \ 22 24 Validate/HandleAttributes.cc \ 23 25 Validate/HandleAttributes.h \ -
TabularUnified src/main.cc ¶
r778315e rfe610ab 32 32 33 33 #include "AST/Convert.hpp" 34 #include "AST/Print.hpp" 34 35 #include "CompilationState.h" 35 36 #include "../config.h" // for CFA_LIBDIR … … 76 77 #include "Validate/Autogen.hpp" // for autogenerateRoutines 77 78 #include "Validate/FindSpecialDecls.h" // for findGlobalDecls 79 #include "Validate/ForallPointerDecay.hpp" // for decayForallPointers 78 80 #include "Validate/CompoundLiteral.hpp" // for handleCompoundLiterals 79 81 #include "Validate/InitializerLength.hpp" // for setLengthFromInitializer … … 331 333 332 334 if( useNewAST ) { 333 PASS( "Apply Concurrent Keywords", Concurrency::applyKeywords( translationUnit ) ); 334 PASS( "Forall Pointer Decay", SymTab::decayForallPointers( translationUnit ) ); 335 PASS( "Implement Concurrent Keywords", Concurrency::applyKeywords( translationUnit ) ); 336 //PASS( "Forall Pointer Decay - A", SymTab::decayForallPointersA( translationUnit ) ); 337 //PASS( "Forall Pointer Decay - B", SymTab::decayForallPointersB( translationUnit ) ); 338 //PASS( "Forall Pointer Decay - C", SymTab::decayForallPointersC( translationUnit ) ); 339 //PASS( "Forall Pointer Decay - D", SymTab::decayForallPointersD( translationUnit ) ); 335 340 CodeTools::fillLocations( translationUnit ); 336 341 … … 342 347 343 348 forceFillCodeLocations( transUnit ); 349 350 // Must be after implement concurrent keywords; because uniqueIds 351 // must be set on declaration before resolution. 352 // Must happen before autogen routines are added. 353 PASS( "Forall Pointer Decay", Validate::decayForallPointers( transUnit ) ); 344 354 345 355 // Must happen before autogen routines are added. -
TabularUnified tests/meta/dumpable.cfa ¶
r778315e rfe610ab 72 72 } 73 73 74 if((buf.f_bsize * buf.f_bavail) < 536870912) { 75 serr | "Available diskspace is less than ~500Mb: " | (buf.f_bsize * buf.f_bavail); 74 uint64_t avail = buf.f_bavail; 75 avail *= buf.f_bsize; 76 if(avail < 536870912_l64u) { 77 serr | "Available diskspace is less than ~500Mb: " | avail; 76 78 } 77 79
Note: See TracChangeset
for help on using the changeset viewer.