Changes in / [8278abf:5b11c25]


Ignore:
Files:
1 added
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • Jenkins/FullBuild

    r8278abf r5b11c25  
    2525                                )
    2626                        }
     27
     28                        //Push latest changes to do-lang repo
     29                        push_build()
    2730                }
    28 
    29                 promote_email(true)
    3031        }
    3132
     
    4243
    4344                //Send email to notify the failure
    44                 promote_email(false)
     45                promote_failure_email()
    4546        }
    4647
     
    9192}
    9293
     94def push_build() {
     95        //Don't use the build_stage function which outputs the compiler
     96        stage('Push') {
     97
     98                status_prefix = 'Push'
     99
     100                def out_dir = pwd tmp: true
     101                sh "mkdir -p ${out_dir}"
     102
     103                //checkout the code to make sure this is a valid git repo
     104                checkout scm
     105
     106                collect_git_info()
     107
     108                //parse git logs to find what changed
     109                sh "git remote > ${out_dir}/GIT_REMOTE"
     110                git_remote = readFile("${out_dir}/GIT_REMOTE")
     111                remoteDoLangExists = git_remote.contains("DoLang")
     112
     113                if( !remoteDoLangExists ) {
     114                        sh 'git remote add DoLang git@gitlab.do-lang.org:internal/cfa-cc.git'
     115                }
     116
     117                //sh "GIT_SSH_COMMAND=\"ssh -v\" git push DoLang ${gitRefNewValue}:master"
     118                echo('BUILD NOT PUSH SINCE DO-LANG SERVER WAS DOWN')
     119        }
     120}
     121
    93122//Helper routine to collect information about the git history
    94123def collect_git_info() {
     
    112141
    113142//Email notification on a full build failure
    114 def promote_email(boolean success) {
     143def promote_failure_email() {
    115144        echo('notifying users')
    116 
    117         def result = success ? "PROMOTE - SUCCESS" : "PROMOTE - FAILURE"
    118145
    119146        //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
    120147        //Configurations for email format
    121         def email_subject = "[cforall git][${result}]"
    122         def email_body = """<p>This is an automated email from the Jenkins build machine. It was
    123 generated following the result of the C\u2200 nightly build.</p>
     148        def email_subject = "[cforall git][PROMOTE - FAILURE]"
     149        def email_body = """This is an automated email from the Jenkins build machine. It was
     150generated because of a git hooks/post-receive script following
     151a ref change was pushed to the repository containing
     152the project "UNNAMED PROJECT".
    124153
    125 <p>Check console output at ${env.BUILD_URL} to view the results.</p>
     154Check console output at ${env.BUILD_URL} to view the results.
    126155
    127 <p>- Status --------------------------------------------------------------</p>
     156- Status --------------------------------------------------------------
    128157
    129 <p>${result}</p>
    130 
    131 <p>- Performance ---------------------------------------------------------</p>
    132 
    133 <img src="https://cforall.uwaterloo.ca/jenkins/job/Cforall/job/master/plot/Compilation/getPlot?index=0" >
    134 
    135 <p>- Logs ----------------------------------------------------------------</p>
     158PROMOTE FAILURE
    136159"""
    137160
     
    139162
    140163        //send email notification
    141         emailext body: email_body, subject: email_subject, to: email_to, attachLog: !success
     164        emailext body: email_body, subject: email_subject, to: email_to, attachLog: true
    142165}
  • Jenkinsfile

    r8278abf r5b11c25  
    11#!groovy
    2 
    3 import groovy.transform.Field
    42
    53//===========================================================================================================
     
    2422                wrap([$class: 'TimestamperBuildWrapper']) {
    2523
     24                        notify_server(0)
     25
    2626                        Settings = prepare_build()
    2727
     
    3434                                checkout()
    3535
     36                                notify_server(0)
     37
    3638                                build()
    3739
     
    4850                        BuildDir  = pwd tmp: true
    4951                        SrcDir    = pwd tmp: false
     52
     53                        notify_server(45)
    5054                }
    5155        }
     
    6872        finally {
    6973                //Send email with final results if this is not a full build
    70                 email(log_needed)
     74                if( Settings && !Settings.Silent ) {
     75                        email(log_needed, Settings.IsSandbox)
     76                }
    7177
    7278                echo 'Build Completed'
     
    110116                        //Also specify the compiler by hand
    111117                        targets=""
    112                         if( Settings.RunAllTests || Settings.RunBenchmark ) {
     118                        if( Settings.RunAllTests ) {
    113119                                targets="--with-target-hosts='host:debug,host:nodebug'"
    114120                        } else {
     
    147153                dir (BuildDir) {
    148154                        //Append bench results
    149                         sh "make --no-print-directory -C benchmark jenkins"
     155                        sh "${SrcDir}/benchmark/jenkins.sh ${Settings.GitNewRef} ${Settings.Architecture} ${BuildDir}/bench.json"
    150156                }
    151157        }
     
    170176        build_stage('Publish') {
    171177
    172                 if( !Settings.RunBenchmark ) { echo 'No results to publish!!!' }
    173 
    174                 def groupCompile = new PlotGroup('Compilation', 'seconds', true)
    175                 def groupConcurrency = new PlotGroup('Concurrency', 'nanoseconds', false)
     178                if( !Settings.Publish ) return
    176179
    177180                //Then publish the results
    178                 do_plot(Settings.RunBenchmark && Settings.Publish, 'compile'  , groupCompile    , 'Compilation')
    179                 do_plot(Settings.RunBenchmark && Settings.Publish, 'ctxswitch', groupConcurrency, 'Context Switching')
    180                 do_plot(Settings.RunBenchmark && Settings.Publish, 'mutex'    , groupConcurrency, 'Mutual Exclusion')
    181                 do_plot(Settings.RunBenchmark && Settings.Publish, 'signal'   , groupConcurrency, 'Internal and External Scheduling')
     181                sh 'curl --silent --show-error -H \'Content-Type: application/json\' --data @${BuildDir}/bench.json https://cforall.uwaterloo.ca:8082/jenkins/publish > /dev/null || true'
    182182        }
    183183}
     
    196196
    197197        return """
    198 <pre>
    199198The branch ${env.BRANCH_NAME} has been updated.
    200199${gitUpdate}
    201 </pre>
    202 
    203 <p>Check console output at ${env.BUILD_URL} to view the results.</p>
    204 
    205 <p>- Status --------------------------------------------------------------</p>
    206 
    207 <p>BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}</p>
    208 
    209 <p>- Log -----------------------------------------------------------------</p>
    210 
    211 <pre>
     200
     201Check console output at ${env.BUILD_URL} to view the results.
     202
     203- Status --------------------------------------------------------------
     204
     205BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}
     206
     207- Log -----------------------------------------------------------------
    212208${gitLog}
    213 </pre>
    214 
    215 <p>-----------------------------------------------------------------------</p>
    216 <pre>
     209-----------------------------------------------------------------------
    217210Summary of changes:
    218211${gitDiff}
    219 </pre>
    220212"""
    221213}
    222214
    223215//Standard build email notification
    224 def email(boolean log) {
     216def email(boolean log, boolean bIsSandbox) {
    225217        //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
    226218        //Configurations for email format
     
    229221        def project_name = (env.JOB_NAME =~ /(.+)\/.+/)[0][1].toLowerCase()
    230222        def email_subject = "[${project_name} git][BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}] - branch ${env.BRANCH_NAME}"
    231         def email_body = """<p>This is an automated email from the Jenkins build machine. It was
     223        def email_body = """This is an automated email from the Jenkins build machine. It was
    232224generated because of a git hooks/post-receive script following
    233 a ref change which was pushed to the C\u2200 repository.</p>
     225a ref change which was pushed to the Cforall repository.
    234226""" + GitLogMessage()
    235227
    236         def email_to = !Settings.IsSandbox ? "cforall@lists.uwaterloo.ca" : "tdelisle@uwaterloo.ca"
    237 
    238         if( Settings && !Settings.Silent ) {
     228        def email_to = "cforall@lists.uwaterloo.ca"
     229
     230        if( Settings && !Settings.IsSandbox ) {
    239231                //send email notification
    240232                emailext body: email_body, subject: email_subject, to: email_to, attachLog: log
     
    319311                }
    320312
    321                 this.IsSandbox          = (branch == "jenkins-sandbox")
    322313                this.RunAllTests        = param.RunAllTests
    323314                this.RunBenchmark       = param.RunBenchmark
     
    325316                this.Publish            = param.Publish
    326317                this.Silent             = param.Silent
     318                this.IsSandbox          = (branch == "jenkins-sandbox")
    327319
    328320                def full = param.RunAllTests ? " (Full)" : ""
     
    341333                this.GitNewRef = ''
    342334                this.GitOldRef = ''
    343         }
    344 }
    345 
    346 class PlotGroup implements Serializable {
    347         public String name
    348         public String unit
    349         public boolean log
    350 
    351         PlotGroup(String name, String unit, boolean log) {
    352                 this.name = name
    353                 this.unit = unit
    354                 this.log = log
    355335        }
    356336}
     
    418398}
    419399
     400def notify_server(int wait) {
     401        sh """curl --silent --show-error --data "wait=${wait}" -X POST https://cforall.uwaterloo.ca:8082/jenkins/notify > /dev/null || true"""
     402        return
     403}
     404
    420405def make_doc() {
    421406        def err = null
     
    432417        }
    433418}
    434 
    435 def do_plot(boolean silent, String file, PlotGroup group, String title) {
    436 
    437         def series = silent ? [] : [[
    438                                 file: "${file}.csv",
    439                                 exclusionValues: '',
    440                                 displayTableFlag: false,
    441                                 inclusionFlag: 'OFF',
    442                                 url: ''
    443                         ]];
    444 
    445         echo "file is ${BuildDir}/benchmark/${file}.csv, group ${group}, title ${title}"
    446         dir("${BuildDir}/benchmark/") {
    447                 plot csvFileName: "cforall-${env.BRANCH_NAME}-${file}.csv",
    448                         csvSeries: series,
    449                         group: "${group.name}",
    450                         title: "${title}",
    451                         style: 'lineSimple',
    452                         exclZero: false,
    453                         keepRecords: false,
    454                         logarithmic: group.log,
    455                         numBuilds: '120',
    456                         useDescr: true,
    457                         yaxis: group.unit,
    458                         yaxisMaximum: '',
    459                         yaxisMinimum: ''
    460         }
    461 }
  • benchmark/Makefile.am

    r8278abf r5b11c25  
    6767
    6868.NOTPARALLEL:
    69 .PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv
    7069
    7170## =========================================================================================================
     
    9594## =========================================================================================================
    9695
    97 FIX_NEW_LINES = cat $@ | tr "\n" "\t" | sed -r 's/\t,/,/' | tr "\t" "\n" > $@
    98 
    9996jenkins$(EXEEXT):
     97        @echo "{"
     98        @echo -e '\t"githash": "'${githash}'",'
     99        @echo -e '\t"arch": "'   ${arch}   '",'
    100100@DOifskipcompile@
    101         @+make compile.csv
     101        @echo -e '\t"compile": {'
     102        @+make compile TIME_FORMAT='%e,' PRINT_FORMAT='\t\t\"%s\" :'
     103        @echo -e '\t\t"dummy" : {}'
     104        @echo -e '\t},'
    102105@DOendif@
    103         @+make ctxswitch.csv
    104         @+make mutex.csv
    105         @+make signal.csv
    106 @DOifskipcompile@
    107         @cat compile.csv
    108 @DOendif@
    109         @cat ctxswitch.csv
    110         @cat mutex.csv
    111         @cat signal.csv
    112 
    113 compile.csv:
    114         @echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
    115         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
    116         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
    117         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
    118         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
    119         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
    120         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
    121         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
    122         @+make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
    123         @$(srcdir)/fixcsv.sh $@
    124 
    125 ctxswitch.csv:
    126         @echo "coroutine,thread" > $@
    127         @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
    128         @+make ctxswitch-cfa_thread.runquiet >> $@
    129         @$(srcdir)/fixcsv.sh $@
    130 
    131 mutex.csv:
    132         @echo "1-monitor,2-monitor" > $@
    133         @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
    134         @+make mutex-cfa2.runquiet >> $@
    135         @$(srcdir)/fixcsv.sh $@
    136 
    137 signal.csv:
    138         @echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@
    139         @+make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@
    140         @+make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@
    141         @+make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@
    142         @+make waitfor-cfa2.runquiet >> $@
    143         @$(srcdir)/fixcsv.sh $@
     106        @echo -e '\t"ctxswitch": {'
     107        @echo -en '\t\t"coroutine":'
     108        @+make ctxswitch-cfa_coroutine.runquiet
     109        @echo -en '\t\t,"thread":'
     110        @+make ctxswitch-cfa_thread.runquiet
     111        @echo -e '\t},'
     112        @echo -e '\t"mutex": ['
     113        @echo -en '\t\t'
     114        @+make mutex-cfa1.runquiet
     115        @echo -en '\t\t,'
     116        @+make mutex-cfa2.runquiet
     117        @echo -e '\t],'
     118        @echo -e '\t"scheduling": ['
     119        @echo -en '\t\t'
     120        @+make signal-cfa1.runquiet
     121        @echo -en '\t\t,'
     122        @+make signal-cfa2.runquiet
     123        @echo -en '\t\t,'
     124        @+make waitfor-cfa1.runquiet
     125        @echo -en '\t\t,'
     126        @+make waitfor-cfa2.runquiet
     127        @echo -e '\n\t],'
     128        @echo -e '\t"epoch": ' $(shell date +%s)
     129        @echo "}"
    144130
    145131## =========================================================================================================
  • benchmark/Makefile.in

    r8278abf r5b11c25  
    401401PRINT_FORMAT = %20s: #Comments needed for spacing
    402402dummy_SOURCES = dummyC.c dummyCXX.cpp
    403 FIX_NEW_LINES = cat $@ | tr "\n" "\t" | sed -r 's/\t,/,/' | tr "\t" "\n" > $@
    404403CTXSWITCH_DEPEND = loop.run function.run fetch_add.run \
    405404        tls-fetch_add.run ctxswitch-pthread.run \
     
    732731
    733732.NOTPARALLEL:
    734 .PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv
    735733
    736734all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT)
     
    758756
    759757jenkins$(EXEEXT):
     758        @echo "{"
     759        @echo -e '\t"githash": "'${githash}'",'
     760        @echo -e '\t"arch": "'   ${arch}   '",'
    760761@DOifskipcompile@
    761         @+make compile.csv
     762        @echo -e '\t"compile": {'
     763        @+make compile TIME_FORMAT='%e,' PRINT_FORMAT='\t\t\"%s\" :'
     764        @echo -e '\t\t"dummy" : {}'
     765        @echo -e '\t},'
    762766@DOendif@
    763         @+make ctxswitch.csv
    764         @+make mutex.csv
    765         @+make signal.csv
    766 @DOifskipcompile@
    767         @cat compile.csv
    768 @DOendif@
    769         @cat ctxswitch.csv
    770         @cat mutex.csv
    771         @cat signal.csv
    772 
    773 compile.csv:
    774         @echo "array,attributes,empty,expression,io,monitor,operators,typeof" > $@
    775         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-array.make >> $@
    776         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-attributes.make >> $@
    777         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-empty.make >> $@
    778         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-expression.make >> $@
    779         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-io.make >> $@
    780         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-monitor.make >> $@
    781         @+make TIME_FORMAT='%e,' PRINT_FORMAT='' compile-operators.make >> $@
    782         @+make TIME_FORMAT='%e' PRINT_FORMAT='' compile-typeof.make >> $@
    783         @$(srcdir)/fixcsv.sh $@
    784 
    785 ctxswitch.csv:
    786         @echo "coroutine,thread" > $@
    787         @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
    788         @+make ctxswitch-cfa_thread.runquiet >> $@
    789         @$(srcdir)/fixcsv.sh $@
    790 
    791 mutex.csv:
    792         @echo "1-monitor,2-monitor" > $@
    793         @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
    794         @+make mutex-cfa2.runquiet >> $@
    795         @$(srcdir)/fixcsv.sh $@
    796 
    797 signal.csv:
    798         @echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@
    799         @+make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@
    800         @+make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@
    801         @+make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@
    802         @+make waitfor-cfa2.runquiet >> $@
    803         @$(srcdir)/fixcsv.sh $@
     767        @echo -e '\t"ctxswitch": {'
     768        @echo -en '\t\t"coroutine":'
     769        @+make ctxswitch-cfa_coroutine.runquiet
     770        @echo -en '\t\t,"thread":'
     771        @+make ctxswitch-cfa_thread.runquiet
     772        @echo -e '\t},'
     773        @echo -e '\t"mutex": ['
     774        @echo -en '\t\t'
     775        @+make mutex-cfa1.runquiet
     776        @echo -en '\t\t,'
     777        @+make mutex-cfa2.runquiet
     778        @echo -e '\t],'
     779        @echo -e '\t"scheduling": ['
     780        @echo -en '\t\t'
     781        @+make signal-cfa1.runquiet
     782        @echo -en '\t\t,'
     783        @+make signal-cfa2.runquiet
     784        @echo -en '\t\t,'
     785        @+make waitfor-cfa1.runquiet
     786        @echo -en '\t\t,'
     787        @+make waitfor-cfa2.runquiet
     788        @echo -e '\n\t],'
     789        @echo -e '\t"epoch": ' $(shell date +%s)
     790        @echo "}"
    804791
    805792loop$(EXEEXT):
  • libcfa/prelude/sync-builtins.cf

    r8278abf r5b11c25  
    323323_Bool __sync_bool_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
    324324#endif
    325 forall(dtype T) _Bool __sync_bool_compare_and_swap(T * volatile *, T *, T*, ...);
    326325
    327326char __sync_val_compare_and_swap(volatile char *, char, char,...);
     
    349348unsigned __int128 __sync_val_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
    350349#endif
    351 forall(dtype T) T * __sync_val_compare_and_swap(T * volatile *, T *, T*,...);
    352350
    353351char __sync_lock_test_and_set(volatile char *, char,...);
     
    436434#endif
    437435
    438 char __atomic_exchange_n(volatile char *, char, int);
     436char __atomic_exchange_n(volatile char *, volatile char *, int);
    439437char __atomic_exchange_1(volatile char *, char, int);
    440438void __atomic_exchange(volatile char *, volatile char *, volatile char *, int);
    441 signed char __atomic_exchange_n(volatile signed char *, signed char, int);
     439signed char __atomic_exchange_n(volatile signed char *, volatile signed char *, int);
    442440signed char __atomic_exchange_1(volatile signed char *, signed char, int);
    443441void __atomic_exchange(volatile signed char *, volatile signed char *, volatile signed char *, int);
    444 unsigned char __atomic_exchange_n(volatile unsigned char *, unsigned char, int);
     442unsigned char __atomic_exchange_n(volatile unsigned char *, volatile unsigned char *, int);
    445443unsigned char __atomic_exchange_1(volatile unsigned char *, unsigned char, int);
    446444void __atomic_exchange(volatile unsigned char *, volatile unsigned char *, volatile unsigned char *, int);
    447 signed short __atomic_exchange_n(volatile signed short *, signed short, int);
     445signed short __atomic_exchange_n(volatile signed short *, volatile signed short *, int);
    448446signed short __atomic_exchange_2(volatile signed short *, signed short, int);
    449447void __atomic_exchange(volatile signed short *, volatile signed short *, volatile signed short *, int);
    450 unsigned short __atomic_exchange_n(volatile unsigned short *, unsigned short, int);
     448unsigned short __atomic_exchange_n(volatile unsigned short *, volatile unsigned short *, int);
    451449unsigned short __atomic_exchange_2(volatile unsigned short *, unsigned short, int);
    452450void __atomic_exchange(volatile unsigned short *, volatile unsigned short *, volatile unsigned short *, int);
    453 signed int __atomic_exchange_n(volatile signed int *, signed int, int);
     451signed int __atomic_exchange_n(volatile signed int *, volatile signed int *, int);
    454452signed int __atomic_exchange_4(volatile signed int *, signed int, int);
    455453void __atomic_exchange(volatile signed int *, volatile signed int *, volatile signed int *, int);
    456 unsigned int __atomic_exchange_n(volatile unsigned int *, unsigned int, int);
     454unsigned int __atomic_exchange_n(volatile unsigned int *, volatile unsigned int *, int);
    457455unsigned int __atomic_exchange_4(volatile unsigned int *, unsigned int, int);
    458456void __atomic_exchange(volatile unsigned int *, volatile unsigned int *, volatile unsigned int *, int);
    459 signed long long int __atomic_exchange_n(volatile signed long long int *, signed long long int, int);
     457signed long long int __atomic_exchange_n(volatile signed long long int *, volatile signed long long int *, int);
    460458signed long long int __atomic_exchange_8(volatile signed long long int *, signed long long int, int);
    461459void __atomic_exchange(volatile signed long long int *, volatile signed long long int *, volatile signed long long int *, int);
    462 unsigned long long int __atomic_exchange_n(volatile unsigned long long int *, unsigned long long int, int);
     460unsigned long long int __atomic_exchange_n(volatile unsigned long long int *, volatile unsigned long long int *, int);
    463461unsigned long long int __atomic_exchange_8(volatile unsigned long long int *, unsigned long long int, int);
    464462void __atomic_exchange(volatile unsigned long long int *, volatile unsigned long long int *, volatile unsigned long long int *, int);
    465463#if defined(__SIZEOF_INT128__)
    466 signed __int128 __atomic_exchange_n(volatile signed __int128 *, signed __int128, int);
     464signed __int128 __atomic_exchange_n(volatile signed __int128 *, volatile signed __int128 *, int);
    467465signed __int128 __atomic_exchange_16(volatile signed __int128 *, signed __int128, int);
    468466void __atomic_exchange(volatile signed __int128 *, volatile signed __int128 *, volatile signed __int128 *, int);
    469 unsigned __int128 __atomic_exchange_n(volatile unsigned __int128 *, unsigned __int128, int);
     467unsigned __int128 __atomic_exchange_n(volatile unsigned __int128 *, volatile unsigned __int128 *, int);
    470468unsigned __int128 __atomic_exchange_16(volatile unsigned __int128 *, unsigned __int128, int);
    471469void __atomic_exchange(volatile unsigned __int128 *, volatile unsigned __int128 *, volatile unsigned __int128 *, int);
    472470#endif
    473 forall(dtype T) T * __atomic_exchange_n(T * volatile *, T *, int);
    474 forall(dtype T) void __atomic_exchange(T * volatile *, T * volatile *, T * volatile *, int);
    475471
    476472_Bool __atomic_load_n(const volatile _Bool *, int);
     
    511507void __atomic_load(const volatile unsigned __int128 *, volatile unsigned __int128 *, int);
    512508#endif
    513 forall(dtype T) T * __atomic_load_n(T * const volatile *, int);
    514 forall(dtype T) void __atomic_load(T * const volatile *, T **, int);
    515509
    516510_Bool __atomic_compare_exchange_n(volatile char *, char *, char, _Bool, int, int);
     
    549543_Bool __atomic_compare_exchange   (volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128 *, _Bool, int, int);
    550544#endif
    551 forall(dtype T) _Bool __atomic_compare_exchange_n (T * volatile *, T **, T*, _Bool, int, int);
    552 forall(dtype T) _Bool __atomic_compare_exchange   (T * volatile *, T **, T**, _Bool, int, int);
    553545
    554546void __atomic_store_n(volatile _Bool *, _Bool, int);
     
    589581void __atomic_store(volatile unsigned __int128 *, unsigned __int128 *, int);
    590582#endif
    591 forall(dtype T) void __atomic_store_n(T * volatile *, T *, int);
    592 forall(dtype T) void __atomic_store(T * volatile *, T **, int);
    593583
    594584char __atomic_add_fetch  (volatile char *, char, int);
  • src/ResolvExpr/ConversionCost.cc

    r8278abf r5b11c25  
    1010// Created On       : Sun May 17 07:06:19 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr 26 16:33:04 2019
    13 // Update Count     : 24
     12// Last Modified On : Thu Feb 14 17:04:31 2019
     13// Update Count     : 23
    1414//
    1515
     
    2828
    2929namespace ResolvExpr {
    30 #if 0
    3130        const Cost Cost::zero =      Cost{  0,  0,  0,  0,  0,  0,  0 };
    3231        const Cost Cost::infinity =  Cost{ -1, -1, -1, -1, -1,  1, -1 };
     
    3837        const Cost Cost::spec =      Cost{  0,  0,  0,  0,  0, -1,  0 };
    3938        const Cost Cost::reference = Cost{  0,  0,  0,  0,  0,  0,  1 };
    40 #endif
    4139
    4240#if 0
  • src/ResolvExpr/Cost.h

    r8278abf r5b11c25  
    77// Cost.h --
    88//
    9 // Author           : Peter Buhr and Aaron Moss
     9// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 09:39:50 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Apr 29 18:33:44 2019
    13 // Update Count     : 49
     12// Last Modified On : Thu Feb  7 20:54:29 2019
     13// Update Count     : 8
    1414//
    1515
     
    1717
    1818#include <iostream>
    19 #include <cassert>
    20 #include <climits>
    2119
    2220namespace ResolvExpr {
    23 #if 0
    24 
    25         //*************************** OLD ***************************
    26 
    2721        class Cost {
    2822          private:
    2923                Cost( int unsafeCost, int polyCost, int safeCost, int signCost,
    30                           int varCost, int specCost, int referenceCost );
     24                        int varCost, int specCost, int referenceCost );
    3125          public:
    3226                Cost & incUnsafe( int inc = 1 );
     
    7771
    7872        inline Cost::Cost( int unsafeCost, int polyCost, int safeCost, int signCost,
    79                                            int varCost, int specCost, int referenceCost )
     73                        int varCost, int specCost, int referenceCost )
    8074                : unsafeCost( unsafeCost ), polyCost( polyCost ), safeCost( safeCost ), signCost( signCost ),
    8175                  varCost( varCost ), specCost( specCost ), referenceCost( referenceCost ) {}
     
    127121                return Cost{
    128122                        unsafeCost + other.unsafeCost, polyCost + other.polyCost, safeCost + other.safeCost,
    129                                 signCost + other.signCost, varCost + other.varCost, specCost + other.specCost,
    130                                 referenceCost + other.referenceCost };
     123                        signCost + other.signCost, varCost + other.varCost, specCost + other.specCost,
     124                        referenceCost + other.referenceCost };
    131125        }
    132126
     
    217211                          << cost.referenceCost << " )";
    218212        }
    219 
    220 #else
    221 
    222         //*************************** NEW ***************************
    223 
    224         // To maximize performance and space, the 7 resolution costs are packed into a single 64-bit word. However, the
    225         // specialization cost is a negative value so a correction is needed is a few places.
    226 
    227         class Cost {
    228                 union {
    229                         struct {
    230                         #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
    231                                 // Little-endian => first value is low priority and last is high priority.
    232                                 unsigned char padding;                                  ///< unused
    233                                 unsigned char referenceCost;                    ///< reference conversions
    234                                 unsigned char specCost;                                 ///< Polymorphic type specializations (type assertions), negative cost
    235                                 unsigned char varCost;                                  ///< Count of polymorphic type variables
    236                                 unsigned char signCost;                                 ///< Count of safe sign conversions
    237                                 unsigned char safeCost;                                 ///< Safe (widening) conversions
    238                                 unsigned char polyCost;                                 ///< Count of parameters and return values bound to some poly type
    239                                 unsigned char unsafeCost;                               ///< Unsafe (narrowing) conversions
    240                         #else
    241                                 #error Cost BIG_ENDIAN unsupported
    242                         #endif
    243                         } v;
    244                         uint64_t all;
    245                 };
    246                 static const unsigned char correctb = 0xff;             // byte correction for negative spec cost
    247                 static const uint64_t correctw = 0x00'00'00'00'00'ff'00'00; //' word correction for negative spec cost
    248           public:
    249                 // Compiler adjusts constants for correct endian.
    250                 enum : uint64_t {
    251                         zero      = 0x00'00'00'00'00'ff'00'00,
    252                         infinity  = 0xff'ff'ff'ff'ff'00'ff'ff,
    253                         unsafe    = 0x01'00'00'00'00'ff'00'00,
    254                         poly      = 0x00'01'00'00'00'ff'00'00,
    255                         safe      = 0x00'00'01'00'00'ff'00'00,
    256                         sign      = 0x00'00'00'01'00'ff'00'00,
    257                         var       = 0x00'00'00'00'01'ff'00'00,
    258                         spec      = 0x00'00'00'00'00'fe'00'00,
    259                         reference = 0x00'00'00'00'00'ff'01'00,
    260                 }; //'
    261 
    262                 Cost( uint64_t all ) { Cost::all = all; }
    263                 Cost( int unsafeCost, int polyCost, int safeCost, int signCost, int varCost, int specCost, int referenceCost ) {
    264                         // Assume little-endian => first value is low priority and last is high priority.
    265                         v = {
    266                         #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
    267                                 (unsigned char)0,                                               // padding
    268                                 (unsigned char)referenceCost,                   // low priority
    269                                 (unsigned char)(specCost + correctb),   // correct for signedness
    270                                 (unsigned char)varCost,
    271                                 (unsigned char)signCost,
    272                                 (unsigned char)safeCost,
    273                                 (unsigned char)polyCost,
    274                                 (unsigned char)unsafeCost,                              // high priority
    275                         #else
    276                                 #error Cost BIG_ENDIAN unsupported
    277                         #endif
    278                         };
    279                 }
    280 
    281                 int get_unsafeCost() const { return v.unsafeCost; }
    282                 int get_polyCost() const { return v.polyCost; }
    283                 int get_safeCost() const { return v.safeCost; }
    284                 int get_signCost() const { return v.signCost; }
    285                 int get_varCost() const { return v.varCost; }
    286                 int get_specCost() const { return -(correctb - v.specCost); }
    287                 int get_referenceCost() const { return v.referenceCost; }
    288 
    289                 friend bool operator==( const Cost, const Cost );
    290                 friend bool operator!=( const Cost lhs, const Cost rhs );
    291                 // returns negative for *this < rhs, 0 for *this == rhs, positive for *this > rhs
    292                 int compare( const Cost rhs ) const {
    293                         if ( all == infinity ) return 1;
    294                         if ( rhs.all == infinity ) return -1;
    295                         return all > rhs.all ? 1 : all == rhs.all ? 0 : -1;
    296                 }
    297                 friend bool operator<( const Cost lhs, const Cost rhs );
    298 
    299                 friend Cost operator+( const Cost lhs, const Cost rhs );
    300  
    301                 Cost operator+=( const Cost rhs ) {
    302                         if ( all == infinity ) return *this;
    303                         if ( rhs.all == infinity ) {
    304                                 all = infinity;
    305                                 return *this;
    306                         }
    307                         all += rhs.all - correctw;                                      // correct for negative spec cost
    308                         return *this;
    309                 }
    310 
    311                 Cost incUnsafe( int inc = 1 ) {
    312                         if ( all != infinity ) { assert( v.unsafeCost + inc <= UCHAR_MAX ); v.unsafeCost += inc; }
    313                         return *this;
    314                 }
    315 
    316                 Cost incPoly( int inc = 1 ) {
    317                         if ( all != infinity ) { assert( v.polyCost + inc <= UCHAR_MAX ); v.polyCost += inc; }
    318                         return *this;
    319                 }
    320 
    321                 Cost incSafe( int inc = 1 ) {
    322                         if ( all != infinity ) { assert( v.safeCost + inc <= UCHAR_MAX ); v.safeCost += inc; }
    323                         return *this;
    324                 }
    325 
    326                 Cost incSign( int inc = 1 ) {
    327                         if ( all != infinity ) { assert( v.signCost + inc <= UCHAR_MAX ); v.signCost += inc; }
    328                         return *this;
    329                 }
    330 
    331                 Cost incVar( int inc = 1 ) {
    332                         if ( all != infinity ) { assert( v.varCost + inc <= UCHAR_MAX ); v.varCost += inc; }
    333                         return *this;
    334                 }
    335 
    336                 Cost decSpec( int dec = 1 ) {
    337                         if ( all != infinity ) { assert( v.specCost - dec >= 0 ); v.specCost -= dec; }
    338                         return *this;
    339                 }
    340 
    341                 Cost incReference( int inc = 1 ) {
    342                         if ( all != infinity ) { assert( v.referenceCost + inc <= UCHAR_MAX ); v.referenceCost += inc; }
    343                         return *this;
    344                 }
    345 
    346                 friend std::ostream & operator<<( std::ostream & os, const Cost cost );
    347         };
    348 
    349         inline bool operator==( const Cost lhs, const Cost rhs ) {
    350                 return lhs.all == rhs.all;
    351         }
    352 
    353         inline bool operator!=( const Cost lhs, const Cost rhs ) {
    354                 return !( lhs.all == rhs.all );
    355         }
    356 
    357         inline bool operator<( const Cost lhs, const Cost rhs ) {
    358                 if ( lhs.all == Cost::infinity ) return false;
    359                 if ( rhs.all == Cost::infinity ) return true;
    360                 return lhs.all < rhs.all;
    361         }
    362 
    363         inline Cost operator+( const Cost lhs, const Cost rhs ) {
    364                 if ( lhs.all == Cost::infinity || rhs.all == Cost::infinity ) return Cost{ Cost::infinity };
    365                 return Cost{ lhs.all + rhs.all - Cost::correctw }; // correct for negative spec cost
    366         }
    367 
    368         inline std::ostream & operator<<( std::ostream & os, const Cost cost ) {
    369                 return os << "( " << cost.get_unsafeCost() << ", " << cost.get_polyCost() << ", " << cost.get_safeCost()
    370                                   << ", " << cost.get_signCost() << ", " << cost.get_varCost() << ", " << cost.get_specCost()
    371                                   << ", " << cost.get_referenceCost() << " )";
    372         }
    373 #endif // 0
    374213} // namespace ResolvExpr
    375214
  • src/ResolvExpr/ResolveAssertions.cc

    r8278abf r5b11c25  
    3535#include "SynTree/Expression.h"     // for InferredParams
    3636#include "TypeEnvironment.h"        // for TypeEnvironment, etc.
    37 #include "typeops.h"                // for adjustExprType, specCost
     37#include "typeops.h"                // for adjustExprType
    3838#include "Unify.h"                  // for unify
    3939
     
    5858        using CandidateList = std::vector<AssnCandidate>;
    5959
     60        /// Unique identifier for a yet-to-be-resolved assertion
     61        struct AssnId {
     62                DeclarationWithType* decl;  ///< Declaration of assertion
     63                AssertionSetValue info;     ///< Information about assertion
     64
     65                AssnId(DeclarationWithType* decl, const AssertionSetValue& info) : decl(decl), info(info) {}
     66        };
     67
     68        /// Cached assertion items
     69        struct AssnCacheItem {
     70                CandidateList matches;         ///< Possible matches for this assertion
     71                std::vector<AssnId> deferIds;  ///< Deferred assertions which resolve to this item
     72
     73                AssnCacheItem( CandidateList&& m ) : matches(std::move(m)), deferIds() {}
     74        };
     75
     76        /// Cache of resolved assertions
     77        using AssnCache = std::unordered_map<std::string, AssnCacheItem>;
     78
    6079        /// Reference to single deferred item
    6180        struct DeferRef {
    62                 const DeclarationWithType* decl;
    63                 const AssertionSetValue& info;
     81                const AssnCacheItem& item;
    6482                const AssnCandidate& match;
    6583        };
     
    6886        /// Acts like indexed list of DeferRef
    6987        struct DeferItem {
    70                 const DeclarationWithType* decl;
    71                 const AssertionSetValue& info;
    72                 CandidateList matches;
    73 
    74                 DeferItem( DeclarationWithType* decl, const AssertionSetValue& info, CandidateList&& matches )
    75                 : decl(decl), info(info), matches(std::move(matches)) {}
    76 
    77                 bool empty() const { return matches.empty(); }
    78 
    79                 CandidateList::size_type size() const { return matches.size(); }
    80 
    81                 DeferRef operator[] ( unsigned i ) const { return { decl, info, matches[i] }; }
     88                const AssnCache* cache;     ///< Cache storing assertion item
     89                std::string key;            ///< Key into cache
     90               
     91                DeferItem( const AssnCache& cache, const std::string& key ) : cache(&cache), key(key) {}
     92
     93                bool empty() const { return cache->at(key).matches.empty(); }
     94
     95                CandidateList::size_type size() const { return cache->at(key).matches.size(); }
     96
     97                DeferRef operator[] ( unsigned i ) const {
     98                        const AssnCacheItem& item = cache->at(key);
     99                        return { item, item.matches[i] };
     100                }
     101
     102                const DeclarationWithType* get_decl() const { return cache->at(key).deferIds[0].decl; }
     103
     104                // sortable by key
     105                // TODO look into optimizing combination process with other sort orders (e.g. by number
     106                // of matches in candidate)
     107                bool operator< ( const DeferItem& o ) const { return key < o.key; }
     108                bool operator== ( const DeferItem& o ) const { return key == o.key; }
    82109        };
    83110
     
    154181                                for ( const auto& assn : x.assns ) {
    155182                                        k += computeConversionCost(
    156                                                 assn.match.adjType, assn.decl->get_type(), indexer, x.env );
    157                                        
    158                                         // mark vars+specialization cost on function-type assertions
    159                                         PointerType* ptr = dynamic_cast< PointerType* >( assn.decl->get_type() );
    160                                         if ( ! ptr ) continue;
    161                                         FunctionType* func = dynamic_cast< FunctionType* >( ptr->base );
    162                                         if ( ! func ) continue;
    163                                        
    164                                         for ( DeclarationWithType* formal : func->parameters ) {
    165                                                 k.decSpec( specCost( formal->get_type() ) );
    166                                         }
    167                                         k.incVar( func->forall.size() );
    168                                         for ( TypeDecl* td : func->forall ) {
    169                                                 k.decSpec( td->assertions.size() );
    170                                         }
     183                                                assn.match.adjType, assn.item.deferIds[0].decl->get_type(), indexer,
     184                                                x.env );
    171185                                }
    172186                                it = cache.emplace_hint( it, &x, k );
     
    239253
    240254        /// Resolve a single assertion, in context
    241         bool resolveAssertion( AssertionItem& assn, ResnState& resn ) {
     255        bool resolveAssertion( AssertionItem& assn, ResnState& resn, AssnCache& cache ) {
    242256                // skip unused assertions
    243257                if ( ! assn.info.isUsed ) return true;
    244258
    245                 // lookup candidates for this assertion
    246                 std::list< SymTab::Indexer::IdData > candidates;
    247                 resn.indexer.lookupId( assn.decl->name, candidates );
    248 
    249                 // find the candidates that unify with the desired type
    250                 CandidateList matches;
    251                 for ( const auto& cdata : candidates ) {
    252                         DeclarationWithType* candidate = cdata.id;
    253 
    254                         // build independent unification context for candidate
    255                         AssertionSet have, newNeed;
    256                         TypeEnvironment newEnv{ resn.alt.env };
    257                         OpenVarSet newOpenVars{ resn.alt.openVars };
    258                         Type* adjType = candidate->get_type()->clone();
    259                         adjustExprType( adjType, newEnv, resn.indexer );
    260                         renameTyVars( adjType );
    261 
    262                         // keep unifying candidates
    263                         if ( unify( assn.decl->get_type(), adjType, newEnv, newNeed, have, newOpenVars,
    264                                         resn.indexer ) ) {
    265                                 // set up binding slot for recursive assertions
    266                                 UniqueId crntResnSlot = 0;
    267                                 if ( ! newNeed.empty() ) {
    268                                         crntResnSlot = ++globalResnSlot;
    269                                         for ( auto& a : newNeed ) {
    270                                                 a.second.resnSlot = crntResnSlot;
     259                // check cache for this assertion
     260                std::string assnKey = SymTab::Mangler::mangleAssnKey( assn.decl, resn.alt.env );
     261                auto it = cache.find( assnKey );
     262
     263                // attempt to resolve assertion if this is the first time seen
     264                if ( it == cache.end() ) {
     265                        // lookup candidates for this assertion
     266                        std::list< SymTab::Indexer::IdData > candidates;
     267                        resn.indexer.lookupId( assn.decl->name, candidates );
     268
     269                        // find the candidates that unify with the desired type
     270                        CandidateList matches;
     271                        for ( const auto& cdata : candidates ) {
     272                                DeclarationWithType* candidate = cdata.id;
     273
     274                                // build independent unification context for candidate
     275                                AssertionSet have, newNeed;
     276                                TypeEnvironment newEnv{ resn.alt.env };
     277                                OpenVarSet newOpenVars{ resn.alt.openVars };
     278                                Type* adjType = candidate->get_type()->clone();
     279                                adjustExprType( adjType, newEnv, resn.indexer );
     280                                renameTyVars( adjType );
     281
     282                                // keep unifying candidates
     283                                if ( unify( assn.decl->get_type(), adjType, newEnv, newNeed, have, newOpenVars,
     284                                                resn.indexer ) ) {
     285                                        // set up binding slot for recursive assertions
     286                                        UniqueId crntResnSlot = 0;
     287                                        if ( ! newNeed.empty() ) {
     288                                                crntResnSlot = ++globalResnSlot;
     289                                                for ( auto& a : newNeed ) {
     290                                                        a.second.resnSlot = crntResnSlot;
     291                                                }
    271292                                        }
    272                                 }
    273 
    274                                 matches.emplace_back( cdata, adjType, std::move(newEnv), std::move(have),
    275                                         std::move(newNeed), std::move(newOpenVars), crntResnSlot );
    276                         } else {
    277                                 delete adjType;
     293
     294                                        matches.emplace_back( cdata, adjType, std::move(newEnv), std::move(have),
     295                                                std::move(newNeed), std::move(newOpenVars), crntResnSlot );
     296                                } else {
     297                                        delete adjType;
     298                                }
    278299                        }
    279                 }
     300
     301                        it = cache.emplace_hint( it, assnKey, AssnCacheItem{ std::move(matches) } );
     302                }
     303
     304                CandidateList& matches = it->second.matches;
    280305
    281306                // break if no suitable assertion
     
    284309                // defer if too many suitable assertions
    285310                if ( matches.size() > 1 ) {
    286                         resn.deferred.emplace_back( assn.decl, assn.info, std::move(matches) );
     311                        it->second.deferIds.emplace_back( assn.decl, assn.info );
     312                        resn.deferred.emplace_back( cache, assnKey );
    287313                        return true;
    288314                }
     
    292318                addToIndexer( match.have, resn.indexer );
    293319                resn.newNeed.insert( match.need.begin(), match.need.end() );
    294                 resn.alt.env = std::move(match.env);
    295                 resn.alt.openVars = std::move(match.openVars);
     320                resn.alt.env = match.env;
     321                resn.alt.openVars = match.openVars;
    296322
    297323                bindAssertion( assn.decl, assn.info, resn.alt, match, resn.inferred );
     
    354380                ResnList resns{ ResnState{ alt, root_indexer } };
    355381                ResnList new_resns{};
     382                AssnCache assnCache;
    356383
    357384                // resolve assertions in breadth-first-order up to a limited number of levels deep
     
    362389                                for ( auto& assn : resn.need ) {
    363390                                        // fail early if any assertion is not resolvable
    364                                         if ( ! resolveAssertion( assn, resn ) ) {
     391                                        if ( ! resolveAssertion( assn, resn, assnCache ) ) {
    365392                                                Indenter tabs{ Indenter::tabsize, 3 };
    366393                                                std::ostringstream ss;
     
    383410                                        }
    384411                                } else {
     412                                        // only resolve each deferred assertion once
     413                                        std::sort( resn.deferred.begin(), resn.deferred.end() );
     414                                        auto last = std::unique( resn.deferred.begin(), resn.deferred.end() );
     415                                        resn.deferred.erase( last, resn.deferred.end() );
    385416                                        // resolve deferred assertions by mutual compatibility
    386417                                        std::vector<CandidateEnvMerger::OutType> compatible = filterCombos(
     
    396427                                                ++tabs;
    397428                                                for ( const auto& d : resn.deferred ) {
    398                                                         d.decl->print( ss, tabs );
     429                                                        d.get_decl()->print( ss, tabs );
    399430                                                }
    400431
     
    427458                                                        new_resn.newNeed.insert( match.need.begin(), match.need.end() );
    428459
    429                                                         bindAssertion( r.decl, r.info, new_resn.alt, match, new_resn.inferred );
     460                                                        // for each deferred assertion with the same form
     461                                                        for ( AssnId id : r.item.deferIds ) {
     462                                                                bindAssertion(
     463                                                                        id.decl, id.info, new_resn.alt, match, new_resn.inferred );
     464                                                        }
    430465                                                }
    431466
  • src/SymTab/Mangler.cc

    r8278abf r5b11c25  
    3838                        struct Mangler : public WithShortCircuiting, public WithVisitorRef<Mangler>, public WithGuards {
    3939                                Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams );
     40                                Mangler( const ResolvExpr::TypeEnvironment& env );
    4041                                Mangler( const Mangler & ) = delete;
    4142
     
    6667                          private:
    6768                                std::ostringstream mangleName;  ///< Mangled name being constructed
    68                                 typedef std::map< std::string, std::pair< int, int > > VarMapType;
     69                                typedef std::map< std::string, std::pair< std::string, int > > VarMapType;
    6970                                VarMapType varNums;             ///< Map of type variables to indices
    7071                                int nextVarNum;                 ///< Next type variable index
     72                                const ResolvExpr::TypeEnvironment* env;  ///< optional environment for substitutions
    7173                                bool isTopLevel;                ///< Is the Mangler at the top level
    7274                                bool mangleOverridable;         ///< Specially mangle overridable built-in methods
     
    7880                          public:
    7981                                Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams,
    80                                         int nextVarNum, const VarMapType& varNums );
     82                                        int nextVarNum, const ResolvExpr::TypeEnvironment* env,
     83                                        const VarMapType& varNums );
    8184
    8285                          private:
     
    106109                }
    107110
     111                std::string mangleAssnKey( DeclarationWithType* decl,
     112                                const ResolvExpr::TypeEnvironment& env ) {
     113                        PassVisitor<Mangler> mangler( env );
     114                        maybeAccept( decl, mangler );
     115                        return mangler.pass.get_mangleName();
     116                }
     117
    108118                namespace {
    109119                        Mangler::Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams )
    110                                 : nextVarNum( 0 ), isTopLevel( true ),
     120                                : nextVarNum( 0 ), env(nullptr), isTopLevel( true ),
    111121                                mangleOverridable( mangleOverridable ), typeMode( typeMode ),
    112122                                mangleGenericParams( mangleGenericParams ) {}
    113123                       
     124                        Mangler::Mangler( const ResolvExpr::TypeEnvironment& env )
     125                                : nextVarNum( 0 ), env( &env ), isTopLevel( true ), mangleOverridable( false ),
     126                                typeMode( false ), mangleGenericParams( true ) {}
     127                       
    114128                        Mangler::Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams,
    115                                 int nextVarNum, const VarMapType& varNums )
    116                                 : varNums( varNums ), nextVarNum( nextVarNum ), isTopLevel( false ),
     129                                int nextVarNum, const ResolvExpr::TypeEnvironment* env,
     130                                const VarMapType& varNums )
     131                                : varNums( varNums ), nextVarNum( nextVarNum ), env( env ), isTopLevel( false ),
    117132                                mangleOverridable( mangleOverridable ), typeMode( typeMode ),
    118133                                mangleGenericParams( mangleGenericParams ) {}
     
    343358                                                        assert( false );
    344359                                                } // switch
    345                                                 varNums[ (*i)->name ] = std::make_pair( nextVarNum, (int)(*i)->get_kind() );
     360                                                std::string varName;
     361                                                // replace type with substitution name if environment is available and bound
     362                                                if ( env ) {
     363                                                        const ResolvExpr::EqvClass* varClass = env->lookup( (*i)->name );
     364                                                        if ( varClass && varClass->type ) {
     365                                                                PassVisitor<Mangler> sub_mangler(
     366                                                                        mangleOverridable, typeMode, mangleGenericParams, nextVarNum,
     367                                                                        env, varNums );
     368                                                                varClass->type->accept( sub_mangler );
     369                                                                varName = std::string{"%"} + sub_mangler.pass.get_mangleName();
     370                                                        }
     371                                                }
     372                                                // otherwise just give type numeric name
     373                                                if ( varName.empty() ) {
     374                                                        varName = std::to_string( nextVarNum++ );
     375                                                }
     376                                                varNums[ (*i)->name ] = std::make_pair( varName, (int)(*i)->get_kind() );
    346377                                                for ( std::list< DeclarationWithType* >::iterator assert = (*i)->assertions.begin(); assert != (*i)->assertions.end(); ++assert ) {
    347378                                                        PassVisitor<Mangler> sub_mangler(
    348                                                                 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, varNums );
     379                                                                mangleOverridable, typeMode, mangleGenericParams, nextVarNum, env,
     380                                                                varNums );
    349381                                                        (*assert)->accept( sub_mangler );
    350382                                                        assertionNames.push_back( sub_mangler.pass.get_mangleName() );
  • src/SymTab/Mangler.h

    r8278abf r5b11c25  
    4444                /// Mangle ignoring generic type parameters
    4545                std::string mangleConcrete( Type* ty );
     46                /// Mangle for assertion key
     47                std::string mangleAssnKey( DeclarationWithType* decl,
     48                        const ResolvExpr::TypeEnvironment& env );
    4649
    4750                namespace Encoding {
  • tests/builtins/sync.cfa

    r8278abf r5b11c25  
    1111        volatile __int128 * vp16 = 0; __int128 * rp16 = 0; __int128 v16 = 0;
    1212        #endif
    13         struct type * volatile * vpp = 0; struct type ** rpp = 0; struct type * vp = 0;
    1413
    1514        { char ret; ret = __sync_fetch_and_add(vp1, v1); }
     
    181180        { _Bool ret; ret = __sync_bool_compare_and_swap_16(vp16, v16,v16); }
    182181        #endif
    183         { _Bool ret; ret = __sync_bool_compare_and_swap(vpp, vp, vp); }
    184182
    185183        { char ret; ret = __sync_val_compare_and_swap(vp1, v1, v1); }
     
    195193        { __int128 ret; ret = __sync_val_compare_and_swap_16(vp16, v16,v16); }
    196194        #endif
    197         { struct type * ret; ret = __sync_val_compare_and_swap(vpp, vp, vp); }
    198 
    199195
    200196        { char ret; ret = __sync_lock_test_and_set(vp1, v1); }
     
    234230        { __atomic_clear(vp1, v1); }
    235231
    236         { char ret; ret = __atomic_exchange_n(vp1, v1, __ATOMIC_SEQ_CST); }
     232        { char ret; ret = __atomic_exchange_n(vp1, &v1, __ATOMIC_SEQ_CST); }
    237233        { char ret; ret = __atomic_exchange_1(vp1, v1, __ATOMIC_SEQ_CST); }
    238234        { char ret; __atomic_exchange(vp1, &v1, &ret, __ATOMIC_SEQ_CST); }
    239         { short ret; ret = __atomic_exchange_n(vp2, v2, __ATOMIC_SEQ_CST); }
     235        { short ret; ret = __atomic_exchange_n(vp2, &v2, __ATOMIC_SEQ_CST); }
    240236        { short ret; ret = __atomic_exchange_2(vp2, v2, __ATOMIC_SEQ_CST); }
    241237        { short ret; __atomic_exchange(vp2, &v2, &ret, __ATOMIC_SEQ_CST); }
    242         { int ret; ret = __atomic_exchange_n(vp4, v4, __ATOMIC_SEQ_CST); }
     238        { int ret; ret = __atomic_exchange_n(vp4, &v4, __ATOMIC_SEQ_CST); }
    243239        { int ret; ret = __atomic_exchange_4(vp4, v4, __ATOMIC_SEQ_CST); }
    244240        { int ret; __atomic_exchange(vp4, &v4, &ret, __ATOMIC_SEQ_CST); }
    245         { long long int ret; ret = __atomic_exchange_n(vp8, v8, __ATOMIC_SEQ_CST); }
     241        { long long int ret; ret = __atomic_exchange_n(vp8, &v8, __ATOMIC_SEQ_CST); }
    246242        { long long int ret; ret = __atomic_exchange_8(vp8, v8, __ATOMIC_SEQ_CST); }
    247243        { long long int ret; __atomic_exchange(vp8, &v8, &ret, __ATOMIC_SEQ_CST); }
    248244        #if defined(__SIZEOF_INT128__)
    249         { __int128 ret; ret = __atomic_exchange_n(vp16, v16, __ATOMIC_SEQ_CST); }
     245        { __int128 ret; ret = __atomic_exchange_n(vp16, &v16, __ATOMIC_SEQ_CST); }
    250246        { __int128 ret; ret = __atomic_exchange_16(vp16, v16, __ATOMIC_SEQ_CST); }
    251247        { __int128 ret; __atomic_exchange(vp16, &v16, &ret, __ATOMIC_SEQ_CST); }
    252248        #endif
    253         { struct type * ret; ret = __atomic_exchange_n(vpp, vp, __ATOMIC_SEQ_CST); }
    254         { struct type * ret; __atomic_exchange(vpp, &vp, &ret, __ATOMIC_SEQ_CST); }
    255249
    256250        { char ret; ret = __atomic_load_n(vp1, __ATOMIC_SEQ_CST); }
     
    271265        { __int128 ret; __atomic_load(vp16, &ret, __ATOMIC_SEQ_CST); }
    272266        #endif
    273         { struct type * ret; ret = __atomic_load_n(vpp, __ATOMIC_SEQ_CST); }
    274         { struct type * ret; __atomic_load(vpp, &ret, __ATOMIC_SEQ_CST); }
    275267
    276268        { _Bool ret; ret = __atomic_compare_exchange_n(vp1, rp1, v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     
    291283        { _Bool ret; ret = __atomic_compare_exchange(vp16, rp16, &v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    292284        #endif
    293         { _Bool ret; ret = __atomic_compare_exchange_n(vpp, rpp, vp, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    294         { _Bool ret; ret = __atomic_compare_exchange(vpp, rpp, &vp, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    295285
    296286        { __atomic_store_n(vp1, v1, __ATOMIC_SEQ_CST); }
     
    311301        { __atomic_store(vp16, &v16, __ATOMIC_SEQ_CST); }
    312302        #endif
    313         { __atomic_store_n(vpp, vp, __ATOMIC_SEQ_CST); }
    314         { __atomic_store(vpp, &vp, __ATOMIC_SEQ_CST); }
    315303
    316304        { char ret; ret = __atomic_add_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
  • tools/PrettyGitLogs.sh

    r8278abf r5b11c25  
    2727git rev-list --format=short ${GitOldRef}...${GitNewRef} >  ${GIT_LOG}
    2828
    29 git diff --stat --color ${GitNewRef} ${GitOldRef} | sed -e 's/\[32m/<span style\=\"color\: \#00AA00\;\">/g' -e 's/\[31m/<span style\=\"color\: \#AA0000\;\">/g' -e 's/\[m/<\/span>/g' >  ${GIT_DIFF}
     29git diff --stat ${GitNewRef} ${GitOldRef} >  ${GIT_DIFF}
Note: See TracChangeset for help on using the changeset viewer.