Changes in / [fe610ab:778315e]


Ignore:
Files:
2 added
4 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.am

    rfe610ab r778315e  
    7272        common.hfa \
    7373        fstream.hfa \
     74        heap.hfa \
    7475        iostream.hfa \
    7576        iterator.hfa \
     
    101102        startup.hfa \
    102103        virtual.c \
    103         virtual.h \
    104         heap.cc \
    105         heap.h
     104        virtual.h
    106105
    107106# not all platforms support concurrency, add option do disable it
     
    173172
    174173-include $(libdeps)
    175 -include $(DEPDIR)/heap.Plo
    176174
    177175thread_libdeps = $(join \
  • libcfa/src/concurrency/coroutine.cfa

    rfe610ab r778315e  
    8585// minimum feasible stack size in bytes
    8686static const size_t MinStackSize = 1000;
    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 }
     87extern size_t __page_size;                              // architecture pagesize HACK, should go in proper runtime singleton
     88extern int __map_prot;
    9289
    9390void __stack_prepare( __stack_info_t * this, size_t create_size );
     
    160157[void *, size_t] __stack_alloc( size_t storageSize ) {
    161158        const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
    162         assert(__cfa_page_size != 0l);
     159        assert(__page_size != 0l);
    163160        size_t size = libCeiling( storageSize, 16 ) + stack_data_size;
    164         size = ceiling(size, __cfa_page_size);
     161        size = ceiling(size, __page_size);
    165162
    166163        // If we are running debug, we also need to allocate a guardpage to catch stack overflows.
    167164        void * storage;
    168165        #if CFA_COROUTINE_USE_MMAP
    169                 storage = mmap(0p, size + __cfa_page_size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
     166                storage = mmap(0p, size + __page_size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
    170167                if(storage == ((void*)-1)) {
    171168                        abort( "coroutine stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) );
    172169                }
    173                 if ( mprotect( storage, __cfa_page_size, PROT_NONE ) == -1 ) {
     170                if ( mprotect( storage, __page_size, PROT_NONE ) == -1 ) {
    174171                        abort( "coroutine stack creation : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    175172                } // if
    176                 storage = (void *)(((intptr_t)storage) + __cfa_page_size);
     173                storage = (void *)(((intptr_t)storage) + __page_size);
    177174        #else
    178175                __cfaabi_dbg_debug_do(
    179                         storage = memalign( __cfa_page_size, size + __cfa_page_size );
     176                        storage = memalign( __page_size, size + __page_size );
    180177                );
    181178                __cfaabi_dbg_no_debug_do(
     
    184181
    185182                __cfaabi_dbg_debug_do(
    186                         if ( mprotect( storage, __cfa_page_size, PROT_NONE ) == -1 ) {
     183                        if ( mprotect( storage, __page_size, PROT_NONE ) == -1 ) {
    187184                                abort( "__stack_alloc : internal error, mprotect failure, error(%d) %s.", (int)errno, strerror( (int)errno ) );
    188185                        }
    189                         storage = (void *)(((intptr_t)storage) + __cfa_page_size);
     186                        storage = (void *)(((intptr_t)storage) + __page_size);
    190187                );
    191188        #endif
     
    201198        #if CFA_COROUTINE_USE_MMAP
    202199                size_t size = ((intptr_t)this->storage->base) - ((intptr_t)this->storage->limit) + sizeof(__stack_t);
    203                 storage = (void *)(((intptr_t)storage) - __cfa_page_size);
    204                 if(munmap(storage, size + __cfa_page_size) == -1) {
     200                storage = (void *)(((intptr_t)storage) - __page_size);
     201                if(munmap(storage, size + __page_size) == -1) {
    205202                        abort( "coroutine stack destruction : internal error, munmap failure, error(%d) %s.", errno, strerror( errno ) );
    206203                }
    207204        #else
    208205                __cfaabi_dbg_debug_do(
    209                         storage = (char*)(storage) - __cfa_page_size;
    210                         if ( mprotect( storage, __cfa_page_size, __map_prot ) == -1 ) {
     206                        storage = (char*)(storage) - __page_size;
     207                        if ( mprotect( storage, __page_size, __map_prot ) == -1 ) {
    211208                                abort( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) );
    212209                        }
  • libcfa/src/concurrency/kernel/startup.cfa

    rfe610ab r778315e  
    122122extern "C" {
    123123        struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
    124         extern size_t __cfa_page_size;
    125         extern int __map_prot;
    126 }
     124}
     125
     126extern size_t __page_size;
     127extern int __map_prot;
    127128
    128129//-----------------------------------------------------------------------------
     
    573574}
    574575
     576extern size_t __page_size;
    575577void ^?{}(processor & this) with( this ){
    576578        /* paranoid */ verify( !__atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) );
     
    738740        void * stack;
    739741        #if CFA_PROCESSOR_USE_MMAP
    740                 stacksize = ceiling( stacksize, __cfa_page_size ) + __cfa_page_size;
     742                stacksize = ceiling( stacksize, __page_size ) + __page_size;
    741743                stack = mmap(0p, stacksize, __map_prot, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
    742744                if(stack == ((void*)-1)) {
    743745                        abort( "pthread stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) );
    744746                }
    745                 if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) {
     747                if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
    746748                        abort( "pthread stack creation : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    747749                } // if
    748750        #else
    749751                __cfaabi_dbg_debug_do(
    750                         stack = memalign( __cfa_page_size, stacksize + __cfa_page_size );
     752                        stack = memalign( __page_size, stacksize + __page_size );
    751753                        // pthread has no mechanism to create the guard page in user supplied stack.
    752                         if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) {
     754                        if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
    753755                                abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    754756                        } // if
     
    777779                check( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );
    778780                assert( stacksize >= PTHREAD_STACK_MIN );
    779                 stacksize += __cfa_page_size;
     781                stacksize += __page_size;
    780782
    781783                if(munmap(stack, stacksize) == -1) {
     
    785787                __cfaabi_dbg_debug_do(
    786788                        // pthread has no mechanism to create the guard page in user supplied stack.
    787                         if ( mprotect( stack, __cfa_page_size, __map_prot ) == -1 ) {
     789                        if ( mprotect( stack, __page_size, __map_prot ) == -1 ) {
    788790                                abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    789791                        } // if
  • libcfa/src/math.trait.hfa

    rfe610ab r778315e  
    1616#pragma once
    1717
    18 trait Not( U ) {
    19         void ?{}( U &, zero_t );
    20         int !?( U );
     18trait Not( T ) {
     19        void ?{}( T &, zero_t );
     20        int !?( T );
    2121}; // Not
    2222
     
    2626}; // Equality
    2727
    28 trait Relational( U | Equality( U ) ) {
    29         int ?<?( U, U );
    30         int ?<=?( U, U );
    31         int ?>?( U, U );
    32         int ?>=?( U, U );
     28trait Relational( T | Equality( T ) ) {
     29        int ?<?( T, T );
     30        int ?<=?( T, T );
     31        int ?>?( T, T );
     32        int ?>=?( T, T );
    3333}; // Relational
    3434
     
    3939}; // Signed
    4040
    41 trait Additive( U | Signed( U ) ) {
    42         U ?+?( U, U );
    43         U ?-?( U, U );
    44         U ?+=?( U &, U );
    45         U ?-=?( U &, U );
     41trait Additive( T | Signed( T ) ) {
     42        T ?+?( T, T );
     43        T ?-?( T, T );
     44        T ?+=?( T &, T );
     45        T ?-=?( T &, T );
    4646}; // Additive
    4747
     
    4949        void ?{}( T &, one_t );
    5050        // T ?++( T & );
    51         // T ++?( T & );
     51        // T ++?( T &);
    5252        // T ?--( T & );
    5353        // T --?( T & );
    5454}; // Incdec
    5555
    56 trait Multiplicative( U | Incdec( U ) ) {
    57         U ?*?( U, U );
    58         U ?/?( U, U );
    59         U ?%?( U, U );
    60         U ?/=?( U &, U );
     56trait Multiplicative( T | Incdec( T ) ) {
     57        T ?*?( T, T );
     58        T ?/?( T, T );
     59        T ?%?( T, T );
     60        T ?/=?( T &, T );
    6161}; // Multiplicative
    6262
  • libcfa/src/startup.cfa

    rfe610ab r778315e  
    2727        void __cfaabi_appready_startup( void ) {
    2828                tzset();                                                                                // initialize time global variables
    29                 #ifdef __CFA_DEBUG__FIXME
     29                #ifdef __CFA_DEBUG__
    3030                extern void heapAppStart();
    3131                heapAppStart();
    32                 #endif // __CFA_DEBUG__FIXME
     32                #endif // __CFA_DEBUG__
    3333        } // __cfaabi_appready_startup
    3434
    3535        void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) ));
    3636        void __cfaabi_appready_shutdown( void ) {
    37                 #ifdef __CFA_DEBUG__FIXME
     37                #ifdef __CFA_DEBUG__
    3838                extern void heapAppStop();
    3939                heapAppStop();
    40                 #endif // __CFA_DEBUG__FIXME
     40                #endif // __CFA_DEBUG__
    4141        } // __cfaabi_appready_shutdown
    4242
  • libcfa/src/stdhdr/malloc.h

    rfe610ab r778315e  
    1818} // extern "C"
    1919
    20 #include <heap.h>
     20#include <heap.hfa>
    2121
    2222// Local Variables: //
  • libcfa/src/stdlib.hfa

    rfe610ab r778315e  
    2121
    2222#include <stdlib.h>                                                                             // *alloc, strto*, ato*
    23 #include <heap.h>
     23#include <heap.hfa>
    2424
    2525
  • src/AST/Decl.cpp

    rfe610ab r778315e  
    3939        if ( uniqueId ) return;  // ensure only set once
    4040        uniqueId = ++lastUniqueId;
    41         // The extra readonly pointer is causing some reference counting issues.
    42         // idMap[ uniqueId ] = this;
     41        idMap[ uniqueId ] = this;
    4342}
    4443
    4544readonly<Decl> Decl::fromId( UniqueId id ) {
    46         // Right now this map is always empty, so don't use it.
    47         assert( false );
    4845        IdMapType::const_iterator i = idMap.find( id );
    4946        if ( i != idMap.end() ) return i->second;
  • src/SymTab/Validate.cc

    rfe610ab r778315e  
    194194        };
    195195
    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 
    218196        struct ReturnChecker : public WithGuards {
    219197                /// Checks that return statements return nothing if their return type is void
     
    408386
    409387        void validate_D( std::list< Declaration * > & translationUnit ) {
     388                PassVisitor<ForallPointerDecay_old> fpd;
    410389                {
    411390                        Stats::Heap::newPass("validate-D");
     
    415394                        });
    416395                        Stats::Time::TimeBlock("Forall Pointer Decay", [&]() {
    417                                 decayForallPointers( translationUnit ); // must happen before autogenerateRoutines, after Concurrency::applyKeywords because uniqueIds must be set on declaration before resolution
     396                                acceptAll( translationUnit, fpd ); // must happen before autogenerateRoutines, after Concurrency::applyKeywords because uniqueIds must be set on declaration before resolution
    418397                        });
    419398                        Stats::Time::TimeBlock("Hoist Control Declarations", [&]() {
     
    475454
    476455        void decayForallPointers( std::list< Declaration * > & translationUnit ) {
    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 );
     456                PassVisitor<ForallPointerDecay_old> fpd;
     457                acceptAll( translationUnit, fpd );
    502458        }
    503459
     
    514470                PassVisitor<EnumAndPointerDecay_old> epc;
    515471                PassVisitor<LinkReferenceToTypes_old> lrt( indexer );
    516                 PassVisitor<TraitExpander_old> te;
    517                 PassVisitor<AssertionFixer_old> af;
    518                 PassVisitor<CheckOperatorTypes_old> cot;
    519                 PassVisitor<FixUniqueIds_old> fui;
     472                PassVisitor<ForallPointerDecay_old> fpd;
    520473                type->accept( epc );
    521474                type->accept( lrt );
    522                 type->accept( te );
    523                 type->accept( af );
    524                 type->accept( cot );
    525                 type->accept( fui );
     475                type->accept( fpd );
    526476        }
    527477
     
    1022972        }
    1023973
    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 
    1056974        void ForallPointerDecay_old::previsit( ObjectDecl * object ) {
    1057975                // ensure that operator names only apply to functions or function pointers
     
    1076994        void ForallPointerDecay_old::previsit( UnionDecl * aggrDecl ) {
    1077995                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();
    1113996        }
    1114997
  • src/SymTab/Validate.h

    rfe610ab r778315e  
    4343        void validate_F( std::list< Declaration * > &translationUnit );
    4444        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 );
    4945
    5046        const ast::Type * validateType(
  • src/Validate/module.mk

    rfe610ab r778315e  
    2020        Validate/CompoundLiteral.cpp \
    2121        Validate/CompoundLiteral.hpp \
    22         Validate/ForallPointerDecay.cpp \
    23         Validate/ForallPointerDecay.hpp \
    2422        Validate/HandleAttributes.cc \
    2523        Validate/HandleAttributes.h \
  • src/main.cc

    rfe610ab r778315e  
    3232
    3333#include "AST/Convert.hpp"
    34 #include "AST/Print.hpp"
    3534#include "CompilationState.h"
    3635#include "../config.h"                      // for CFA_LIBDIR
     
    7776#include "Validate/Autogen.hpp"             // for autogenerateRoutines
    7877#include "Validate/FindSpecialDecls.h"      // for findGlobalDecls
    79 #include "Validate/ForallPointerDecay.hpp"  // for decayForallPointers
    8078#include "Validate/CompoundLiteral.hpp"     // for handleCompoundLiterals
    8179#include "Validate/InitializerLength.hpp"   // for setLengthFromInitializer
     
    333331
    334332                if( useNewAST ) {
    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 ) );
     333                        PASS( "Apply Concurrent Keywords", Concurrency::applyKeywords( translationUnit ) );
     334                        PASS( "Forall Pointer Decay", SymTab::decayForallPointers( translationUnit ) );
    340335                        CodeTools::fillLocations( translationUnit );
    341336
     
    347342
    348343                        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 ) );
    354344
    355345                        // Must happen before autogen routines are added.
  • tests/meta/dumpable.cfa

    rfe610ab r778315e  
    7272        }
    7373
    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;
     74        if((buf.f_bsize * buf.f_bavail) < 536870912) {
     75                serr | "Available diskspace is less than ~500Mb: " | (buf.f_bsize * buf.f_bavail);
    7876        }
    7977
Note: See TracChangeset for help on using the changeset viewer.