Changes in / [ae151cf:f704974]


Ignore:
Files:
5 added
7 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • Jenkins/FullBuild

    rae151cf rf704974  
    1818
    1919                                parallel (
    20                                         gcc_08_x86_new: { trigger_build( 'gcc-10',  'x86', false ) },
    21                                         gcc_07_x86_new: { trigger_build( 'gcc-9',   'x86', false ) },
    22                                         gcc_10_x64_new: { trigger_build( 'gcc-10',  'x64', false ) },
    23                                         gcc_09_x64_new: { trigger_build( 'gcc-9',   'x64', false ) },
    24                                         gcc_08_x64_new: { trigger_build( 'gcc-8',   'x64', false ) },
    25                                         gcc_07_x64_new: { trigger_build( 'gcc-7',   'x64', false ) },
    26                                         gcc_06_x64_new: { trigger_build( 'gcc-6',   'x64', false ) },
    27                                         clang_x64_new:  { trigger_build( 'clang',   'x64', true ) },
     20                                        gcc_08_x86_new: { trigger_build( 'gcc-10',  'x86' ) },
     21                                        gcc_07_x86_new: { trigger_build( 'gcc-9',   'x86' ) },
     22                                        gcc_10_x64_new: { trigger_build( 'gcc-10',  'x64' ) },
     23                                        gcc_09_x64_new: { trigger_build( 'gcc-9',   'x64' ) },
     24                                        gcc_08_x64_new: { trigger_build( 'gcc-8',   'x64' ) },
     25                                        gcc_07_x64_new: { trigger_build( 'gcc-7',   'x64' ) },
     26                                        gcc_06_x64_new: { trigger_build( 'gcc-6',   'x64' ) },
     27                                        clang_x64_new:  { trigger_build( 'clang',   'x64' ) },
    2828                                )
    2929                        }
     
    6767//===========================================================================================================
    6868
    69 def trigger_build(String cc, String arch, boolean doc) {
     69def trigger_build(String cc, String arch) {
    7070        // Randomly delay the builds by a random amount to avoid hitting the SC server to hard
    7171        sleep(time: 5 * Math.random(), unit:"MINUTES")
     
    9292                        [$class: 'BooleanParameterValue',               \
    9393                          name: 'BuildDocumentation',           \
    94                           value: doc],                                  \
     94                          value: true],                                         \
    9595                        [$class: 'BooleanParameterValue',               \
    9696                          name: 'Publish',                              \
  • libcfa/src/assert.cfa

    rae151cf rf704974  
    2525
    2626        #define CFA_ASSERT_FMT "Cforall Assertion error \"%s\" from program \"%s\" in \"%s\" at line %d in file \"%s\""
    27         #define CFA_WARNING_FMT "Cforall Assertion warning \"%s\" from program \"%s\" in \"%s\" at line %d in file \"%s\""
    2827
    2928        // called by macro assert in assert.h
     
    4948                abort();
    5049        }
    51 
    52         // called by macro warnf
    53         // would be cool to remove libcfa_public but it's needed for libcfathread
    54         void __assert_warn_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) libcfa_public {
    55                 __cfaabi_bits_acquire();
    56                 __cfaabi_bits_print_nolock( STDERR_FILENO, CFA_WARNING_FMT ": ", assertion, __progname, function, line, file );
    57 
    58                 va_list args;
    59                 va_start( args, fmt );
    60                 __cfaabi_bits_print_vararg( STDERR_FILENO, fmt, args );
    61                 va_end( args );
    62 
    63                 __cfaabi_bits_print_nolock( STDERR_FILENO, "\n" );
    64                 __cfaabi_bits_release();
    65         }
    6650}
    6751
  • libcfa/src/concurrency/alarm.cfa

    rae151cf rf704974  
    5555        this.period  = period;
    5656        this.thrd = thrd;
    57         this.deadline = __kernel_get_time() + alarm;
     57        this.timeval = __kernel_get_time() + alarm;
    5858        set = false;
    5959        type = User;
     
    6464        this.period  = period;
    6565        this.proc = proc;
    66         this.deadline = __kernel_get_time() + alarm;
     66        this.timeval = __kernel_get_time() + alarm;
    6767        set = false;
    6868        type = Kernel;
     
    7272        this.initial = alarm;
    7373        this.period  = period;
    74         this.deadline = __kernel_get_time() + alarm;
     74        this.timeval = __kernel_get_time() + alarm;
    7575        set = false;
    7676        type = Callback;
     
    8585void insert( alarm_list_t * this, alarm_node_t * n ) {
    8686        alarm_node_t * it = & (*this)`first;
    87         while( it && (n->deadline > it->deadline) ) {
     87        while( it && (n->timeval > it->timeval) ) {
    8888                it = & (*it)`next;
    8989        }
     
    116116
    117117                Time curr = __kernel_get_time();
    118                 __cfadbg_print_safe( preemption, " KERNEL: alarm inserting %p (%lu -> %lu).\n", this, curr.tn, this->deadline.tn );
     118                __cfadbg_print_safe( preemption, " KERNEL: alarm inserting %p (%lu -> %lu).\n", this, curr.tn, this->timeval.tn );
    119119                insert( &alarms, this );
    120                 __kernel_set_timer( this->deadline - curr);
     120                __kernel_set_timer( this->timeval - curr);
    121121                this->set = true;
    122122        }
  • libcfa/src/concurrency/alarm.hfa

    rae151cf rf704974  
    5757        };
    5858
    59         Time deadline;          // actual time at which the alarm goes off
     59        Time timeval;           // actual time at which the alarm goes off
    6060        enum alarm_type type;   // true if this is not a user defined alarm
    6161        bool set                :1;     // whether or not the alarm has be registered
  • libcfa/src/concurrency/io.cfa

    rae151cf rf704974  
    201201                __atomic_unlock(&ctx->cq.lock);
    202202
    203                 touch_tsc( cltr->sched.io.tscs, ctx->cq.id, ts_prev, ts_next, false );
     203                touch_tsc( cltr->sched.io.tscs, ctx->cq.id, ts_prev, ts_next );
    204204
    205205                return true;
    206206        }
    207207
    208         bool __cfa_io_drain( struct processor * proc ) {
     208        bool __cfa_io_drain( processor * proc ) {
    209209                bool local = false;
    210210                bool remote = false;
     
    243243                                /* paranoid */ verify( io.tscs[target].t.tv != ULLONG_MAX );
    244244                                HELP: if(target < ctxs_count) {
    245                                         const unsigned long long cutoff = calc_cutoff(ctsc, ctx->cq.id, ctxs_count, io.data, io.tscs, __shard_factor.io, false);
    246                                         const unsigned long long age = moving_average(ctsc, io.tscs[target].t.tv, io.tscs[target].t.ma, false);
     245                                        const unsigned long long cutoff = calc_cutoff(ctsc, ctx->cq.id, ctxs_count, io.data, io.tscs, __shard_factor.io);
     246                                        const unsigned long long age = moving_average(ctsc, io.tscs[target].t.tv, io.tscs[target].t.ma);
    247247                                        __cfadbg_print_safe(io, "Kernel I/O: Help attempt on %u from %u, age %'llu vs cutoff %'llu, %s\n", target, ctx->cq.id, age, cutoff, age > cutoff ? "yes" : "no");
    248248                                        if(age <= cutoff) break HELP;
     
    273273        }
    274274
    275         bool __cfa_io_flush( struct processor * proc ) {
     275        bool __cfa_io_flush( processor * proc ) {
    276276                /* paranoid */ verify( ! __preemption_enabled() );
    277277                /* paranoid */ verify( proc );
     
    353353
    354354                disable_interrupts();
    355                 struct processor * proc = __cfaabi_tls.this_processor;
     355                processor * proc = __cfaabi_tls.this_processor;
    356356                io_context$ * ctx = proc->io.ctx;
    357357                /* paranoid */ verify( __cfaabi_tls.this_processor );
     
    433433                disable_interrupts();
    434434                __STATS__( true, if(!lazy) io.submit.eagr += 1; )
    435                 struct processor * proc = __cfaabi_tls.this_processor;
     435                processor * proc = __cfaabi_tls.this_processor;
    436436                io_context$ * ctx = proc->io.ctx;
    437437                /* paranoid */ verify( __cfaabi_tls.this_processor );
     
    641641
    642642        #if defined(CFA_WITH_IO_URING_IDLE)
    643                 bool __kernel_read(struct processor * proc, io_future_t & future, iovec & iov, int fd) {
     643                bool __kernel_read(processor * proc, io_future_t & future, iovec & iov, int fd) {
    644644                        io_context$ * ctx = proc->io.ctx;
    645645                        /* paranoid */ verify( ! __preemption_enabled() );
     
    692692                }
    693693
    694                 void __cfa_io_idle( struct processor * proc ) {
     694                void __cfa_io_idle( processor * proc ) {
    695695                        iovec iov;
    696696                        __atomic_acquire( &proc->io.ctx->cq.lock );
  • libcfa/src/concurrency/io/types.hfa

    rae151cf rf704974  
    127127        struct __attribute__((aligned(64))) io_context$ {
    128128                io_arbiter$ * arbiter;
    129                 struct processor * proc;
     129                processor * proc;
    130130
    131131                __outstanding_io_queue ext_sq;
  • libcfa/src/concurrency/kernel/cluster.cfa

    rae151cf rf704974  
    254254}
    255255
    256 static void assign_list(unsigned & valrq, unsigned & valio, dlist(struct processor) & list, unsigned count) {
    257         struct processor * it = &list`first;
     256static void assign_list(unsigned & valrq, unsigned & valio, dlist(processor) & list, unsigned count) {
     257        processor * it = &list`first;
    258258        for(unsigned i = 0; i < count; i++) {
    259259                /* paranoid */ verifyf( it, "Unexpected null iterator, at index %u of %u\n", i, count);
     
    278278
    279279#if defined(CFA_HAVE_LINUX_IO_URING_H)
    280         static void assign_io(io_context$ ** data, size_t count, dlist(struct processor) & list) {
    281                 struct processor * it = &list`first;
     280        static void assign_io(io_context$ ** data, size_t count, dlist(processor) & list) {
     281                processor * it = &list`first;
    282282                while(it) {
    283283                        /* paranoid */ verifyf( it, "Unexpected null iterator\n");
  • libcfa/src/concurrency/kernel/cluster.hfa

    rae151cf rf704974  
    2121#include <limits.h>
    2222
    23 #include "clock.hfa"
    24 
    2523//-----------------------------------------------------------------------
    2624// Calc moving average based on existing average, before and current time.
    27 static inline unsigned long long moving_average(unsigned long long currtsc, unsigned long long instsc, unsigned long long old_avg, bool strict) {
    28         (void)strict; // disable the warning around the fact this is unused in release.
    29         /* paranoid */ warnf( !strict || old_avg < 33_000_000_000, "Suspiciously large previous average: %'llu (%llx), %'ldms \n", old_avg, old_avg, program()`ms );
     25static inline unsigned long long moving_average(unsigned long long currtsc, unsigned long long instsc, unsigned long long old_avg) {
     26        /* paranoid */ verifyf( old_avg < 15000000000000, "Suspiciously large previous average: %'llu (%llx)\n", old_avg, old_avg );
    3027
    3128        const unsigned long long new_val = currtsc > instsc ? currtsc - instsc : 0;
     
    3431        const unsigned long long old_weight = total_weight - new_weight;
    3532        const unsigned long long ret = ((new_weight * new_val) + (old_weight * old_avg)) / total_weight;
    36 
    37         /* paranoid */ warnf( !strict || ret < 33_000_000_000, "Suspiciously large new average after %'ldms cputime: %'llu (%llx) from %'llu-%'llu (%'llu, %'llu) and %'llu\n", program()`ms, ret, ret, currtsc, instsc, new_val, new_val / 1000000, old_avg );
    3833        return ret;
    3934}
    4035
    41 static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next, bool strict) {
     36static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next) {
    4237        if (ts_next == ULLONG_MAX) return;
    4338        unsigned long long now = rdtscl();
    4439        unsigned long long pma = __atomic_load_n(&tscs[ idx ].t.ma, __ATOMIC_RELAXED);
    4540        __atomic_store_n(&tscs[ idx ].t.tv, ts_next, __ATOMIC_RELAXED);
    46         __atomic_store_n(&tscs[ idx ].t.ma, moving_average(now, ts_prev, pma, strict), __ATOMIC_RELAXED);
     41        __atomic_store_n(&tscs[ idx ].t.ma, moving_average(now, ts_prev, pma), __ATOMIC_RELAXED);
    4742}
    4843
     
    5651        Data_t * data,
    5752        __timestamp_t * tscs,
    58         const unsigned shard_factor,
    59         bool strict
     53        const unsigned shard_factor
    6054) {
    6155        unsigned start = procid;
     
    6559                if(ptsc != ULLONG_MAX) {
    6660                        /* paranoid */ verify( start + i < count );
    67                         unsigned long long tsc = moving_average(ctsc, ptsc, tscs[start + i].t.ma, strict);
     61                        unsigned long long tsc = moving_average(ctsc, ptsc, tscs[start + i].t.ma);
    6862                        if(tsc > max) max = tsc;
    6963                }
  • libcfa/src/concurrency/preemption.cfa

    rae151cf rf704974  
    104104static inline alarm_node_t * get_expired( alarm_list_t * alarms, Time currtime ) {
    105105        if( ! & (*alarms)`first ) return 0p;                                            // If no alarms return null
    106         if( (*alarms)`first.deadline >= currtime ) return 0p;   // If alarms head not expired return null
     106        if( (*alarms)`first.timeval >= currtime ) return 0p;    // If alarms head not expired return null
    107107        return pop(alarms);                                                                     // Otherwise just pop head
    108108}
     
    140140                if( period > 0 ) {
    141141                        __cfadbg_print_buffer_local( preemption, " KERNEL: alarm period is %lu.\n", period`ns );
    142                         node->deadline = currtime + period;  // Alarm is periodic, add currtime to it (used cached current time)
     142                        node->timeval = currtime + period;  // Alarm is periodic, add currtime to it (used cached current time)
    143143                        insert( alarms, node );             // Reinsert the node for the next time it triggers
    144144                }
     
    147147        // If there are still alarms pending, reset the timer
    148148        if( & (*alarms)`first ) {
    149                 Duration delta = (*alarms)`first.deadline - currtime;
     149                Duration delta = (*alarms)`first.timeval - currtime;
    150150                __kernel_set_timer( delta );
    151151        }
  • libcfa/src/concurrency/ready_queue.cfa

    rae151cf rf704974  
    6262//-----------------------------------------------------------------------
    6363__attribute__((hot)) void push(struct cluster * cltr, struct thread$ * thrd, unpark_hint hint) with (cltr->sched) {
    64         struct processor * const proc = kernelTLS().this_processor;
     64        processor * const proc = kernelTLS().this_processor;
    6565        const bool external = (!proc) || (cltr != proc->cltr);
    6666        const bool remote   = hint == UNPARK_REMOTE;
     
    116116        /* paranoid */ verify( kernelTLS().this_processor->rdq.id < lanes_count );
    117117
    118         struct processor * const proc = kernelTLS().this_processor;
     118        processor * const proc = kernelTLS().this_processor;
    119119        unsigned this = proc->rdq.id;
    120120        /* paranoid */ verify( this < lanes_count );
     
    139139                /* paranoid */ verify( readyQ.tscs[target].t.tv != ULLONG_MAX );
    140140                if(target < lanes_count) {
    141                         const unsigned long long cutoff = calc_cutoff(ctsc, proc->rdq.id, lanes_count, cltr->sched.readyQ.data, cltr->sched.readyQ.tscs, __shard_factor.readyq, true);
    142                         const unsigned long long age = moving_average(ctsc, readyQ.tscs[target].t.tv, readyQ.tscs[target].t.ma, false);
     141                        const unsigned long long cutoff = calc_cutoff(ctsc, proc->rdq.id, lanes_count, cltr->sched.readyQ.data, cltr->sched.readyQ.tscs, __shard_factor.readyq);
     142                        const unsigned long long age = moving_average(ctsc, readyQ.tscs[target].t.tv, readyQ.tscs[target].t.ma);
    143143                        __cfadbg_print_safe(ready_queue, "Kernel : Help attempt on %u from %u, age %'llu vs cutoff %'llu, %s\n", target, this, age, cutoff, age > cutoff ? "yes" : "no");
    144144                        if(age > cutoff) {
     
    214214        __STATS( stats.success++; )
    215215
    216         touch_tsc(readyQ.tscs, w, ts_prev, ts_next, true);
     216        touch_tsc(readyQ.tscs, w, ts_prev, ts_next);
    217217
    218218        thrd->preferred = w / __shard_factor.readyq;
  • libcfa/src/stdhdr/assert.h

    rae151cf rf704974  
    2727        #define assertf( expr, fmt, ... ) ((expr) ? ((void)0) : __assert_fail_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ ))
    2828
    29         void __assert_warn_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) __attribute__((format( printf, 5, 6) ));
    3029        void __assert_fail_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) __attribute__((noreturn, format( printf, 5, 6) ));
    3130#endif
    3231
    3332#if !defined(NDEBUG) && (defined(__CFA_DEBUG__) || defined(__CFA_VERIFY__))
    34         #define __CFA_WITH_VERIFY__
    3533        #define verify(x) assert(x)
    3634        #define verifyf(x, ...) assertf(x, __VA_ARGS__)
    3735        #define verifyfail(...)
    38         #define warnf( expr, fmt, ... ) ({ static bool check_once##__LINE__ = false; if( false == check_once##__LINE__ && false == (expr)) { check_once##__LINE__ = true; __assert_warn_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ ); } })
     36        #define __CFA_WITH_VERIFY__
    3937#else
    4038        #define verify(x)
    4139        #define verifyf(x, ...)
    4240        #define verifyfail(...)
    43         #define warnf( expr, fmt, ... )
    4441#endif
    4542
  • src/Tuples/TupleExpansionNew.cpp

    rae151cf rf704974  
    1010// Created On       : Mon Aug 23 15:36:09 2021
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Sep 26 10:25:00 2022
    13 // Update Count     : 5
     12// Last Modified On : Tue Sep 20 16:17:00 2022
     13// Update Count     : 4
    1414//
    1515
     
    3030struct UniqueExprExpander final : public ast::WithDeclsToAdd<> {
    3131        const ast::Expr * postvisit( const ast::UniqueExpr * unqExpr );
    32         // Not a vector, because they may not be adding in increasing order.
    33         std::map< int, ast::ptr<ast::Expr> > decls;
    34 };
    35 
    36 /// Replaces Tuple Assign & Index Expressions, and Tuple Types.
    37 struct TupleMainExpander final :
    38                 public ast::WithCodeLocation,
    39                 public ast::WithDeclsToAdd<>,
    40                 public ast::WithGuards,
    41                 public ast::WithVisitorRef<TupleMainExpander> {
    42         ast::Expr const * postvisit( ast::TupleAssignExpr const * expr );
    43 
    44         void previsit( ast::CompoundStmt const * );
    45         ast::Expr const * postvisit( ast::Expr const * expr );
    46         ast::Type const * postvisit( ast::TupleType const * type );
    47 
    48         ast::Expr const * postvisit( ast::TupleIndexExpr const * expr );
    49 private:
    50         ScopedMap< int, ast::StructDecl const * > typeMap;
    51 };
    52 
    53 struct TupleExprExpander final {
    54         ast::Expr const * postvisit( ast::TupleExpr const * expr );
     32        std::map< int, ast::ptr<ast::Expr> > decls; // not vector, because order added may not be increasing order
    5533};
    5634
     
    122100}
    123101
    124 // Handles expansion of tuple assignment.
    125 ast::Expr const * TupleMainExpander::postvisit(
    126                 ast::TupleAssignExpr const * expr ) {
    127         // Just move the env on the new top level expression.
    128         return ast::mutate_field( expr->stmtExpr.get(),
    129                 &ast::TupleAssignExpr::env, expr->env.get() );
    130 }
    131 
    132 // Context information for tuple type expansion.
    133 void TupleMainExpander::previsit( ast::CompoundStmt const * ) {
    134         GuardScope( typeMap );
    135 }
    136 
    137 // Make sure types in a TypeSubstitution are expanded.
    138 ast::Expr const * TupleMainExpander::postvisit( ast::Expr const * expr ) {
    139         if ( nullptr == expr->env ) {
    140                 return expr;
    141         }
    142         return ast::mutate_field( expr, &ast::Expr::env,
    143                 expr->env->accept( *visitor ) );
    144 }
    145 
    146 // Create a generic tuple structure of a given size.
    147 ast::StructDecl * createTupleStruct(
    148                 unsigned int tupleSize, CodeLocation const & location ) {
    149         ast::StructDecl * decl = new ast::StructDecl( location,
    150                 toString( "_tuple", tupleSize, "_" )
    151         );
    152         decl->body = true;
    153 
    154         for ( size_t i = 0 ; i < tupleSize ; ++i ) {
    155                 ast::TypeDecl * typeParam = new ast::TypeDecl( location,
    156                         toString( "tuple_param_", tupleSize, "_", i ),
    157                         ast::Storage::Classes(),
    158                         nullptr,
    159                         ast::TypeDecl::Dtype,
    160                         true
     102/// Replaces Tuple Assign & Index Expressions, and Tuple Types.
     103struct TupleMainExpander final :
     104                public ast::WithCodeLocation,
     105                public ast::WithDeclsToAdd<>,
     106                public ast::WithGuards,
     107                public ast::WithVisitorRef<TupleMainExpander> {
     108        ast::Expr const * postvisit( ast::TupleAssignExpr const * expr ) {
     109                // Just move the env on the new top level expression.
     110                return ast::mutate_field( expr->stmtExpr.get(),
     111                        &ast::TupleAssignExpr::env, expr->env.get() );
     112        }
     113
     114        void previsit( ast::CompoundStmt const * ) {
     115                GuardScope( typeMap );
     116        }
     117
     118        ast::Expr const * postvisit( ast::Expr const * expr ) {
     119                if ( nullptr == expr->env ) {
     120                        return expr;
     121                }
     122                // TypeSubstitutions are never visited in the new Pass template,
     123                // so it is done manually here, where all types have to be replaced.
     124                return ast::mutate_field( expr, &ast::Expr::env,
     125                        expr->env->accept( *visitor ) );
     126        }
     127
     128        ast::Type const * postvisit( ast::TupleType const * type ) {
     129                assert( location );
     130                unsigned tupleSize = type->size();
     131                if ( !typeMap.count( tupleSize ) ) {
     132                        ast::StructDecl * decl = new ast::StructDecl( *location,
     133                                toString( "_tuple", tupleSize, "_" )
    161134                        );
    162                 ast::ObjectDecl * member = new ast::ObjectDecl( location,
    163                         toString( "field_", i ),
    164                         new ast::TypeInstType( typeParam )
    165                         );
    166                 decl->params.push_back( typeParam );
    167                 decl->members.push_back( member );
    168         }
    169 
    170         // Empty structures are not standard C. Add a dummy field to
    171         // empty tuples to silence warnings when a compound literal
    172         // `_tuple0_` is created.
    173         if ( tupleSize == 0 ) {
    174                 decl->members.push_back(
    175                         new ast::ObjectDecl( location,
    176                                 "dummy",
    177                                 new ast::BasicType( ast::BasicType::SignedInt ),
    178                                 nullptr,
    179                                 ast::Storage::Classes(),
    180                                 // Does this have to be a C linkage?
    181                                 ast::Linkage::C
    182                         )
    183                 );
    184         }
    185         return decl;
    186 }
    187 
    188 ast::Type const * TupleMainExpander::postvisit( ast::TupleType const * type ) {
    189         assert( location );
    190         unsigned tupleSize = type->size();
    191         if ( !typeMap.count( tupleSize ) ) {
    192                 ast::StructDecl * decl = createTupleStruct( tupleSize, *location );
    193                 typeMap[tupleSize] = decl;
    194                 declsToAddBefore.push_back( decl );
    195         }
    196 
    197         ast::StructDecl const * decl = typeMap[ tupleSize ];
    198         ast::StructInstType * newType =
    199                 new ast::StructInstType( decl, type->qualifiers );
    200         for ( auto pair : group_iterate( type->types, decl->params ) ) {
    201                 ast::Type const * t = std::get<0>( pair );
    202                 newType->params.push_back(
    203                         new ast::TypeExpr( *location, ast::deepCopy( t ) ) );
    204         }
    205         return newType;
    206 }
    207 
    208 // Expand a tuple index into a field access in the underlying structure.
    209 ast::Expr const * TupleMainExpander::postvisit(
    210                 ast::TupleIndexExpr const * expr ) {
    211         CodeLocation const & location = expr->location;
    212         ast::Expr const * tuple = expr->tuple.get();
    213         assert( tuple );
    214         unsigned int index = expr->index;
    215         ast::TypeSubstitution const * env = expr->env.get();
    216 
    217         if ( auto tupleExpr = dynamic_cast<ast::TupleExpr const *>( tuple ) ) {
    218                 // Optimization: If it is a definitely pure tuple expr,
    219                 // then it can reduce to the only relevant component.
    220                 if ( !maybeImpureIgnoreUnique( tupleExpr ) ) {
    221                         assert( index < tupleExpr->exprs.size() );
    222                         ast::ptr<ast::Expr> const & expr =
    223                                 *std::next( tupleExpr->exprs.begin(), index );
    224                         ast::Expr * ret = ast::mutate( expr.get() );
    225                         ret->env = env;
    226                         return ret;
    227                 }
    228         }
    229 
    230         auto type = tuple->result.strict_as<ast::StructInstType>();
    231         ast::StructDecl const * structDecl = type->base;
    232         assert( index < structDecl->members.size() );
    233         ast::ptr<ast::Decl> const & member =
    234                 *std::next( structDecl->members.begin(), index );
    235         ast::MemberExpr * memberExpr = new ast::MemberExpr( location,
    236                 member.strict_as<ast::DeclWithType>(), tuple );
    237         memberExpr->env = env;
    238         return memberExpr;
    239 }
     135                        decl->body = true;
     136
     137                        for ( size_t i = 0 ; i < tupleSize ; ++i ) {
     138                                ast::TypeDecl * typeParam = new ast::TypeDecl( *location,
     139                                        toString( "tuple_param_", tupleSize, "_", i ),
     140                                        ast::Storage::Classes(),
     141                                        nullptr,
     142                                        ast::TypeDecl::Dtype,
     143                                        true
     144                                        );
     145                                ast::ObjectDecl * member = new ast::ObjectDecl( *location,
     146                                        toString( "field_", i ),
     147                                        new ast::TypeInstType( typeParam )
     148                                        );
     149                                decl->params.push_back( typeParam );
     150                                decl->members.push_back( member );
     151                        }
     152
     153                        // Empty structures are not standard C. Add a dummy field to
     154                        // empty tuples to silence warnings when a compound literal
     155                        // `_tuple0_` is created.
     156                        if ( tupleSize == 0 ) {
     157                                decl->members.push_back(
     158                                        new ast::ObjectDecl( *location,
     159                                                "dummy",
     160                                                new ast::BasicType( ast::BasicType::SignedInt ),
     161                                                nullptr,
     162                                                ast::Storage::Classes(),
     163                                                // Does this have to be a C linkage?
     164                                                ast::Linkage::C
     165                                        )
     166                                );
     167                        }
     168                        typeMap[tupleSize] = decl;
     169                        declsToAddBefore.push_back( decl );
     170                }
     171
     172                ast::StructDecl const * decl = typeMap[ tupleSize ];
     173                ast::StructInstType * newType =
     174                        new ast::StructInstType( decl, type->qualifiers );
     175                for ( auto pair : group_iterate( type->types, decl->params ) ) {
     176                        ast::Type const * t = std::get<0>( pair );
     177                        newType->params.push_back(
     178                                new ast::TypeExpr( *location, ast::deepCopy( t ) ) );
     179                }
     180                return newType;
     181        }
     182
     183        ast::Expr const * postvisit( ast::TupleIndexExpr const * expr ) {
     184                CodeLocation const & location = expr->location;
     185                ast::Expr const * tuple = expr->tuple.get();
     186                assert( tuple );
     187                unsigned int index = expr->index;
     188                ast::TypeSubstitution const * env = expr->env.get();
     189
     190                if ( auto tupleExpr = dynamic_cast<ast::TupleExpr const *>( tuple ) ) {
     191                        // Optimization: If it is a definitely pure tuple expr,
     192                        // then it can reduce to the only relevant component.
     193                        if ( !maybeImpureIgnoreUnique( tupleExpr ) ) {
     194                                assert( index < tupleExpr->exprs.size() );
     195                                ast::ptr<ast::Expr> const & expr =
     196                                        *std::next( tupleExpr->exprs.begin(), index );
     197                                ast::Expr * ret = ast::mutate( expr.get() );
     198                                ret->env = env;
     199                                return ret;
     200                        }
     201                }
     202
     203                auto type = tuple->result.strict_as<ast::StructInstType>();
     204                ast::StructDecl const * structDecl = type->base;
     205                assert( index < structDecl->members.size() );
     206                ast::ptr<ast::Decl> const & member =
     207                        *std::next( structDecl->members.begin(), index );
     208                ast::MemberExpr * memberExpr = new ast::MemberExpr( location,
     209                        member.strict_as<ast::DeclWithType>(), tuple );
     210                memberExpr->env = env;
     211                return memberExpr;
     212        }
     213private:
     214        ScopedMap< int, ast::StructDecl const * > typeMap;
     215};
    240216
    241217ast::Expr const * replaceTupleExpr(
     
    273249}
    274250
    275 ast::Expr const * TupleExprExpander::postvisit( ast::TupleExpr const * expr ) {
    276         return replaceTupleExpr( expr->location,
    277                 expr->result, expr->exprs, expr->env );
    278 }
     251struct TupleExprExpander final {
     252        ast::Expr const * postvisit( ast::TupleExpr const * expr ) {
     253                return replaceTupleExpr( expr->location,
     254                        expr->result, expr->exprs, expr->env );
     255        }
     256};
    279257
    280258} // namespace
  • tests/pybin/tools.py

    rae151cf rf704974  
    2323
    2424# helper functions to run terminal commands
    25 def sh(*cmd, timeout = False, output_file = None, input_file = None, input_text = None, error = subprocess.STDOUT, ignore_dry_run = False, pass_fds = [], nice = False):
     25def sh(*cmd, timeout = False, output_file = None, input_file = None, input_text = None, error = subprocess.STDOUT, ignore_dry_run = False, pass_fds = []):
    2626        try:
    2727                cmd = list(cmd)
     
    5858                        error = openfd(error, 'w', onexit, False)
    5959
    60                         # prepare the parameters to the call
    61                         popen_kwargs = {
    62                                 'stdout' : output_file,
    63                                 'stderr' : error,
    64                                 'pass_fds': pass_fds,
    65                         }
    66 
    67                         # depending on how we are passing inputs we need to set a different argument to popen
    68                         if input_text:
    69                                 popen_kwargs['input'] = bytes(input_text, encoding='utf-8')
    70                         else:
    71                                 popen_kwargs['stdin'] = input_file
    72 
    73                         # we might want to nice this so it's not to obnixious to users
    74                         if nice:
    75                                 popen_kwargs['preexec_fn'] = lambda: os.nice(5)
    76 
    7760                        # run the desired command
    7861                        # use with statement to make sure proc is cleaned
    7962                        # don't use subprocess.run because we want to send SIGABRT on exit
    80                         with subprocess.Popen( cmd, **popen_kwargs ) as proc:
     63                        with subprocess.Popen(
     64                                cmd,
     65                                **({'input' : bytes(input_text, encoding='utf-8')} if input_text else {'stdin' : input_file}),
     66                                stdout  = output_file,
     67                                stderr  = error,
     68                                pass_fds = pass_fds
     69                        ) as proc:
     70
    8171                                try:
    8272                                        out, errout = proc.communicate(
  • tests/test.py

    rae151cf rf704974  
    2323
    2424        def match_test(path):
    25                 match = re.search("^%s\/([\w\/\-_]*).expect\/([\w\-_\+]+)(\.[\w\-_]+)?\.txt$" % settings.SRCDIR, path)
     25                match = re.search("^%s\/([\w\/\-_]*).expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt$" % settings.SRCDIR, path)
    2626                if match :
    2727                        test = Test()
     
    190190                                if settings.dry_run or is_exe(exe_file):
    191191                                        # run test
    192                                         retcode, _, _ = sh(exe_file, output_file=out_file, input_file=in_file, timeout=True, nice=True)
     192                                        retcode, _, _ = sh(exe_file, output_file=out_file, input_file=in_file, timeout=True)
    193193                                else :
    194194                                        # simply cat the result into the output
  • tools/gdb/utils-gdb.py

    rae151cf rf704974  
    159159
    160160                # if we already saw the root, then go forward
    161                 my_next = self.curr['_X4linkS5dlink_S9processor__1']['_X4nextPY13__tE_generic__1']
     161                my_next = self.curr['_X4link']['_X4nextPY13__tE_generic__1']
    162162                self.curr = my_next.cast(cfa_t.processor_ptr)
    163163
     
    355355                ))
    356356                tls = tls_for_proc( processor )
    357                 thrd = thread_for_proc( processor )
     357                thrd = tls['_X11this_threadVPS7thread$_1']
    358358                if thrd != 0x0:
    359359                        tname = '{} {}'.format(thrd['self_cor']['name'].string(), str(thrd))
Note: See TracChangeset for help on using the changeset viewer.