Changeset ec28948


Ignore:
Timestamp:
Apr 30, 2019, 2:53:47 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
02af79b0, 8278abf
Parents:
1bc5975 (diff), 98d4df9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
2 added
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • Jenkins/FullBuild

    r1bc5975 rec28948  
    2525                                )
    2626                        }
     27                }
    2728
    28                         //Push latest changes to do-lang repo
    29                         push_build()
    30                 }
     29                promote_email(true)
    3130        }
    3231
     
    4342
    4443                //Send email to notify the failure
    45                 promote_failure_email()
     44                promote_email(false)
    4645        }
    4746
     
    9291}
    9392
    94 def 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 
    12293//Helper routine to collect information about the git history
    12394def collect_git_info() {
     
    141112
    142113//Email notification on a full build failure
    143 def promote_failure_email() {
     114def promote_email(boolean success) {
    144115        echo('notifying users')
     116
     117        def result = success ? "PROMOTE - SUCCESS" : "PROMOTE - FAILURE"
    145118
    146119        //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
    147120        //Configurations for email format
    148         def email_subject = "[cforall git][PROMOTE - FAILURE]"
    149         def email_body = """This is an automated email from the Jenkins build machine. It was
    150 generated because of a git hooks/post-receive script following
    151 a ref change was pushed to the repository containing
    152 the project "UNNAMED PROJECT".
     121        def email_subject = "[cforall git][${result}]"
     122        def email_body = """<p>This is an automated email from the Jenkins build machine. It was
     123generated following the result of the C\u2200 nightly build.</p>
    153124
    154 Check console output at ${env.BUILD_URL} to view the results.
     125<p>Check console output at ${env.BUILD_URL} to view the results.</p>
    155126
    156 - Status --------------------------------------------------------------
     127<p>- Status --------------------------------------------------------------</p>
    157128
    158 PROMOTE FAILURE
     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>
    159136"""
    160137
     
    162139
    163140        //send email notification
    164         emailext body: email_body, subject: email_subject, to: email_to, attachLog: true
     141        emailext body: email_body, subject: email_subject, to: email_to, attachLog: !success
    165142}
  • Jenkinsfile

    r1bc5975 rec28948  
    11#!groovy
     2
     3import groovy.transform.Field
    24
    35//===========================================================================================================
     
    2224                wrap([$class: 'TimestamperBuildWrapper']) {
    2325
    24                         notify_server(0)
    25 
    2626                        Settings = prepare_build()
    2727
     
    3434                                checkout()
    3535
    36                                 notify_server(0)
    37 
    3836                                build()
    3937
     
    5048                        BuildDir  = pwd tmp: true
    5149                        SrcDir    = pwd tmp: false
    52 
    53                         notify_server(45)
    5450                }
    5551        }
     
    7268        finally {
    7369                //Send email with final results if this is not a full build
    74                 if( Settings && !Settings.Silent ) {
    75                         email(log_needed, Settings.IsSandbox)
    76                 }
     70                email(log_needed)
    7771
    7872                echo 'Build Completed'
     
    116110                        //Also specify the compiler by hand
    117111                        targets=""
    118                         if( Settings.RunAllTests ) {
     112                        if( Settings.RunAllTests || Settings.RunBenchmark ) {
    119113                                targets="--with-target-hosts='host:debug,host:nodebug'"
    120114                        } else {
     
    153147                dir (BuildDir) {
    154148                        //Append bench results
    155                         sh "${SrcDir}/benchmark/jenkins.sh ${Settings.GitNewRef} ${Settings.Architecture} ${BuildDir}/bench.json"
     149                        sh "make --no-print-directory -C benchmark jenkins"
    156150                }
    157151        }
     
    176170        build_stage('Publish') {
    177171
    178                 if( !Settings.Publish ) return
     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)
    179176
    180177                //Then publish the results
    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'
     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')
    182182        }
    183183}
     
    196196
    197197        return """
     198<pre>
    198199The branch ${env.BRANCH_NAME} has been updated.
    199200${gitUpdate}
    200 
    201 Check console output at ${env.BUILD_URL} to view the results.
    202 
    203 - Status --------------------------------------------------------------
    204 
    205 BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}
    206 
    207 - Log -----------------------------------------------------------------
     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>
    208212${gitLog}
    209 -----------------------------------------------------------------------
     213</pre>
     214
     215<p>-----------------------------------------------------------------------</p>
     216<pre>
    210217Summary of changes:
    211218${gitDiff}
     219</pre>
    212220"""
    213221}
    214222
    215223//Standard build email notification
    216 def email(boolean log, boolean bIsSandbox) {
     224def email(boolean log) {
    217225        //Since tokenizer doesn't work, figure stuff out from the environnement variables and command line
    218226        //Configurations for email format
     
    221229        def project_name = (env.JOB_NAME =~ /(.+)\/.+/)[0][1].toLowerCase()
    222230        def email_subject = "[${project_name} git][BUILD# ${env.BUILD_NUMBER} - ${currentBuild.result}] - branch ${env.BRANCH_NAME}"
    223         def email_body = """This is an automated email from the Jenkins build machine. It was
     231        def email_body = """<p>This is an automated email from the Jenkins build machine. It was
    224232generated because of a git hooks/post-receive script following
    225 a ref change which was pushed to the Cforall repository.
     233a ref change which was pushed to the C\u2200 repository.</p>
    226234""" + GitLogMessage()
    227235
    228         def email_to = "cforall@lists.uwaterloo.ca"
    229 
    230         if( Settings && !Settings.IsSandbox ) {
     236        def email_to = !Settings.IsSandbox ? "cforall@lists.uwaterloo.ca" : "tdelisle@uwaterloo.ca"
     237
     238        if( Settings && !Settings.Silent ) {
    231239                //send email notification
    232240                emailext body: email_body, subject: email_subject, to: email_to, attachLog: log
     
    311319                }
    312320
     321                this.IsSandbox          = (branch == "jenkins-sandbox")
    313322                this.RunAllTests        = param.RunAllTests
    314323                this.RunBenchmark       = param.RunBenchmark
     
    316325                this.Publish            = param.Publish
    317326                this.Silent             = param.Silent
    318                 this.IsSandbox          = (branch == "jenkins-sandbox")
    319327
    320328                def full = param.RunAllTests ? " (Full)" : ""
     
    333341                this.GitNewRef = ''
    334342                this.GitOldRef = ''
     343        }
     344}
     345
     346class 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
    335355        }
    336356}
     
    398418}
    399419
    400 def 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 
    405420def make_doc() {
    406421        def err = null
     
    417432        }
    418433}
     434
     435def 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

    r1bc5975 rec28948  
    6767
    6868.NOTPARALLEL:
     69.PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv
    6970
    7071## =========================================================================================================
     
    9495## =========================================================================================================
    9596
     97FIX_NEW_LINES = cat $@ | tr "\n" "\t" | sed -r 's/\t,/,/' | tr "\t" "\n" > $@
     98
    9699jenkins$(EXEEXT):
    97         @echo "{"
    98         @echo -e '\t"githash": "'${githash}'",'
    99         @echo -e '\t"arch": "'   ${arch}   '",'
    100100@DOifskipcompile@
    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},'
     101        @+make compile.csv
    105102@DOendif@
    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 "}"
     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
     113compile.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
     125ctxswitch.csv:
     126        @echo "coroutine,thread" > $@
     127        @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     128        @+make ctxswitch-cfa_thread.runquiet >> $@
     129        @$(srcdir)/fixcsv.sh $@
     130
     131mutex.csv:
     132        @echo "1-monitor,2-monitor" > $@
     133        @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
     134        @+make mutex-cfa2.runquiet >> $@
     135        @$(srcdir)/fixcsv.sh $@
     136
     137signal.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 $@
    130144
    131145## =========================================================================================================
  • benchmark/Makefile.in

    r1bc5975 rec28948  
    401401PRINT_FORMAT = %20s: #Comments needed for spacing
    402402dummy_SOURCES = dummyC.c dummyCXX.cpp
     403FIX_NEW_LINES = cat $@ | tr "\n" "\t" | sed -r 's/\t,/,/' | tr "\t" "\n" > $@
    403404CTXSWITCH_DEPEND = loop.run function.run fetch_add.run \
    404405        tls-fetch_add.run ctxswitch-pthread.run \
     
    731732
    732733.NOTPARALLEL:
     734.PHONY: compile.csv ctxswitch.csv mutex.csv signal.csv
    733735
    734736all : ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT)
     
    756758
    757759jenkins$(EXEEXT):
    758         @echo "{"
    759         @echo -e '\t"githash": "'${githash}'",'
    760         @echo -e '\t"arch": "'   ${arch}   '",'
    761760@DOifskipcompile@
    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},'
     761        @+make compile.csv
    766762@DOendif@
    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 "}"
     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
     773compile.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
     785ctxswitch.csv:
     786        @echo "coroutine,thread" > $@
     787        @+make ctxswitch-cfa_coroutine.runquiet >> $@ && echo -n ',' >> $@
     788        @+make ctxswitch-cfa_thread.runquiet >> $@
     789        @$(srcdir)/fixcsv.sh $@
     790
     791mutex.csv:
     792        @echo "1-monitor,2-monitor" > $@
     793        @+make mutex-cfa1.runquiet >> $@ && echo -n ',' >> $@
     794        @+make mutex-cfa2.runquiet >> $@
     795        @$(srcdir)/fixcsv.sh $@
     796
     797signal.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 $@
    791804
    792805loop$(EXEEXT):
  • libcfa/prelude/sync-builtins.cf

    r1bc5975 rec28948  
    323323_Bool __sync_bool_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
    324324#endif
     325forall(dtype T) _Bool __sync_bool_compare_and_swap(T * volatile *, T *, T*, ...);
    325326
    326327char __sync_val_compare_and_swap(volatile char *, char, char,...);
     
    348349unsigned __int128 __sync_val_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
    349350#endif
     351forall(dtype T) T * __sync_val_compare_and_swap(T * volatile *, T *, T*,...);
    350352
    351353char __sync_lock_test_and_set(volatile char *, char,...);
     
    434436#endif
    435437
    436 char __atomic_exchange_n(volatile char *, volatile char *, int);
     438char __atomic_exchange_n(volatile char *, char, int);
    437439char __atomic_exchange_1(volatile char *, char, int);
    438440void __atomic_exchange(volatile char *, volatile char *, volatile char *, int);
    439 signed char __atomic_exchange_n(volatile signed char *, volatile signed char *, int);
     441signed char __atomic_exchange_n(volatile signed char *, signed char, int);
    440442signed char __atomic_exchange_1(volatile signed char *, signed char, int);
    441443void __atomic_exchange(volatile signed char *, volatile signed char *, volatile signed char *, int);
    442 unsigned char __atomic_exchange_n(volatile unsigned char *, volatile unsigned char *, int);
     444unsigned char __atomic_exchange_n(volatile unsigned char *, unsigned char, int);
    443445unsigned char __atomic_exchange_1(volatile unsigned char *, unsigned char, int);
    444446void __atomic_exchange(volatile unsigned char *, volatile unsigned char *, volatile unsigned char *, int);
    445 signed short __atomic_exchange_n(volatile signed short *, volatile signed short *, int);
     447signed short __atomic_exchange_n(volatile signed short *, signed short, int);
    446448signed short __atomic_exchange_2(volatile signed short *, signed short, int);
    447449void __atomic_exchange(volatile signed short *, volatile signed short *, volatile signed short *, int);
    448 unsigned short __atomic_exchange_n(volatile unsigned short *, volatile unsigned short *, int);
     450unsigned short __atomic_exchange_n(volatile unsigned short *, unsigned short, int);
    449451unsigned short __atomic_exchange_2(volatile unsigned short *, unsigned short, int);
    450452void __atomic_exchange(volatile unsigned short *, volatile unsigned short *, volatile unsigned short *, int);
    451 signed int __atomic_exchange_n(volatile signed int *, volatile signed int *, int);
     453signed int __atomic_exchange_n(volatile signed int *, signed int, int);
    452454signed int __atomic_exchange_4(volatile signed int *, signed int, int);
    453455void __atomic_exchange(volatile signed int *, volatile signed int *, volatile signed int *, int);
    454 unsigned int __atomic_exchange_n(volatile unsigned int *, volatile unsigned int *, int);
     456unsigned int __atomic_exchange_n(volatile unsigned int *, unsigned int, int);
    455457unsigned int __atomic_exchange_4(volatile unsigned int *, unsigned int, int);
    456458void __atomic_exchange(volatile unsigned int *, volatile unsigned int *, volatile unsigned int *, int);
    457 signed long long int __atomic_exchange_n(volatile signed long long int *, volatile signed long long int *, int);
     459signed long long int __atomic_exchange_n(volatile signed long long int *, signed long long int, int);
    458460signed long long int __atomic_exchange_8(volatile signed long long int *, signed long long int, int);
    459461void __atomic_exchange(volatile signed long long int *, volatile signed long long int *, volatile signed long long int *, int);
    460 unsigned long long int __atomic_exchange_n(volatile unsigned long long int *, volatile unsigned long long int *, int);
     462unsigned long long int __atomic_exchange_n(volatile unsigned long long int *, unsigned long long int, int);
    461463unsigned long long int __atomic_exchange_8(volatile unsigned long long int *, unsigned long long int, int);
    462464void __atomic_exchange(volatile unsigned long long int *, volatile unsigned long long int *, volatile unsigned long long int *, int);
    463465#if defined(__SIZEOF_INT128__)
    464 signed __int128 __atomic_exchange_n(volatile signed __int128 *, volatile signed __int128 *, int);
     466signed __int128 __atomic_exchange_n(volatile signed __int128 *, signed __int128, int);
    465467signed __int128 __atomic_exchange_16(volatile signed __int128 *, signed __int128, int);
    466468void __atomic_exchange(volatile signed __int128 *, volatile signed __int128 *, volatile signed __int128 *, int);
    467 unsigned __int128 __atomic_exchange_n(volatile unsigned __int128 *, volatile unsigned __int128 *, int);
     469unsigned __int128 __atomic_exchange_n(volatile unsigned __int128 *, unsigned __int128, int);
    468470unsigned __int128 __atomic_exchange_16(volatile unsigned __int128 *, unsigned __int128, int);
    469471void __atomic_exchange(volatile unsigned __int128 *, volatile unsigned __int128 *, volatile unsigned __int128 *, int);
    470472#endif
     473forall(dtype T) T * __atomic_exchange_n(T * volatile *, T *, int);
     474forall(dtype T) void __atomic_exchange(T * volatile *, T * volatile *, T * volatile *, int);
    471475
    472476_Bool __atomic_load_n(const volatile _Bool *, int);
     
    507511void __atomic_load(const volatile unsigned __int128 *, volatile unsigned __int128 *, int);
    508512#endif
     513forall(dtype T) T * __atomic_load_n(T * const volatile *, int);
     514forall(dtype T) void __atomic_load(T * const volatile *, T **, int);
    509515
    510516_Bool __atomic_compare_exchange_n(volatile char *, char *, char, _Bool, int, int);
     
    543549_Bool __atomic_compare_exchange   (volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128 *, _Bool, int, int);
    544550#endif
     551forall(dtype T) _Bool __atomic_compare_exchange_n (T * volatile *, T **, T*, _Bool, int, int);
     552forall(dtype T) _Bool __atomic_compare_exchange   (T * volatile *, T **, T**, _Bool, int, int);
    545553
    546554void __atomic_store_n(volatile _Bool *, _Bool, int);
     
    581589void __atomic_store(volatile unsigned __int128 *, unsigned __int128 *, int);
    582590#endif
     591forall(dtype T) void __atomic_store_n(T * volatile *, T *, int);
     592forall(dtype T) void __atomic_store(T * volatile *, T **, int);
    583593
    584594char __atomic_add_fetch  (volatile char *, char, int);
  • src/ResolvExpr/ConversionCost.cc

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

    r1bc5975 rec28948  
    77// Cost.h --
    88//
    9 // Author           : Richard C. Bilson
     9// Author           : Peter Buhr and Aaron Moss
    1010// Created On       : Sun May 17 09:39:50 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  7 20:54:29 2019
    13 // Update Count     : 8
     12// Last Modified On : Mon Apr 29 18:33:44 2019
     13// Update Count     : 49
    1414//
    1515
     
    1717
    1818#include <iostream>
     19#include <cassert>
     20#include <climits>
    1921
    2022namespace ResolvExpr {
     23#if 0
     24
     25        //*************************** OLD ***************************
     26
    2127        class Cost {
    2228          private:
    2329                Cost( int unsafeCost, int polyCost, int safeCost, int signCost,
    24                         int varCost, int specCost, int referenceCost );
     30                          int varCost, int specCost, int referenceCost );
    2531          public:
    2632                Cost & incUnsafe( int inc = 1 );
     
    7177
    7278        inline Cost::Cost( int unsafeCost, int polyCost, int safeCost, int signCost,
    73                         int varCost, int specCost, int referenceCost )
     79                                           int varCost, int specCost, int referenceCost )
    7480                : unsafeCost( unsafeCost ), polyCost( polyCost ), safeCost( safeCost ), signCost( signCost ),
    7581                  varCost( varCost ), specCost( specCost ), referenceCost( referenceCost ) {}
     
    121127                return Cost{
    122128                        unsafeCost + other.unsafeCost, polyCost + other.polyCost, safeCost + other.safeCost,
    123                         signCost + other.signCost, varCost + other.varCost, specCost + other.specCost,
    124                         referenceCost + other.referenceCost };
     129                                signCost + other.signCost, varCost + other.varCost, specCost + other.specCost,
     130                                referenceCost + other.referenceCost };
    125131        }
    126132
     
    211217                          << cost.referenceCost << " )";
    212218        }
     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
    213374} // namespace ResolvExpr
    214375
  • src/ResolvExpr/ResolveAssertions.cc

    r1bc5975 rec28948  
    3535#include "SynTree/Expression.h"     // for InferredParams
    3636#include "TypeEnvironment.h"        // for TypeEnvironment, etc.
    37 #include "typeops.h"                // for adjustExprType
     37#include "typeops.h"                // for adjustExprType, specCost
    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 
    7960        /// Reference to single deferred item
    8061        struct DeferRef {
    81                 const AssnCacheItem& item;
     62                const DeclarationWithType* decl;
     63                const AssertionSetValue& info;
    8264                const AssnCandidate& match;
    8365        };
     
    8668        /// Acts like indexed list of DeferRef
    8769        struct DeferItem {
    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; }
     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] }; }
    10982        };
    11083
     
    181154                                for ( const auto& assn : x.assns ) {
    182155                                        k += computeConversionCost(
    183                                                 assn.match.adjType, assn.item.deferIds[0].decl->get_type(), indexer,
    184                                                 x.env );
     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                                        }
    185171                                }
    186172                                it = cache.emplace_hint( it, &x, k );
     
    253239
    254240        /// Resolve a single assertion, in context
    255         bool resolveAssertion( AssertionItem& assn, ResnState& resn, AssnCache& cache ) {
     241        bool resolveAssertion( AssertionItem& assn, ResnState& resn ) {
    256242                // skip unused assertions
    257243                if ( ! assn.info.isUsed ) return true;
    258244
    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                                                 }
    292                                         }
    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                                 }
     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;
     271                                        }
     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;
    299278                        }
    300 
    301                         it = cache.emplace_hint( it, assnKey, AssnCacheItem{ std::move(matches) } );
    302                 }
    303 
    304                 CandidateList& matches = it->second.matches;
     279                }
    305280
    306281                // break if no suitable assertion
     
    309284                // defer if too many suitable assertions
    310285                if ( matches.size() > 1 ) {
    311                         it->second.deferIds.emplace_back( assn.decl, assn.info );
    312                         resn.deferred.emplace_back( cache, assnKey );
     286                        resn.deferred.emplace_back( assn.decl, assn.info, std::move(matches) );
    313287                        return true;
    314288                }
     
    318292                addToIndexer( match.have, resn.indexer );
    319293                resn.newNeed.insert( match.need.begin(), match.need.end() );
    320                 resn.alt.env = match.env;
    321                 resn.alt.openVars = match.openVars;
     294                resn.alt.env = std::move(match.env);
     295                resn.alt.openVars = std::move(match.openVars);
    322296
    323297                bindAssertion( assn.decl, assn.info, resn.alt, match, resn.inferred );
     
    380354                ResnList resns{ ResnState{ alt, root_indexer } };
    381355                ResnList new_resns{};
    382                 AssnCache assnCache;
    383356
    384357                // resolve assertions in breadth-first-order up to a limited number of levels deep
     
    389362                                for ( auto& assn : resn.need ) {
    390363                                        // fail early if any assertion is not resolvable
    391                                         if ( ! resolveAssertion( assn, resn, assnCache ) ) {
     364                                        if ( ! resolveAssertion( assn, resn ) ) {
    392365                                                Indenter tabs{ Indenter::tabsize, 3 };
    393366                                                std::ostringstream ss;
     
    410383                                        }
    411384                                } 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() );
    416385                                        // resolve deferred assertions by mutual compatibility
    417386                                        std::vector<CandidateEnvMerger::OutType> compatible = filterCombos(
     
    427396                                                ++tabs;
    428397                                                for ( const auto& d : resn.deferred ) {
    429                                                         d.get_decl()->print( ss, tabs );
     398                                                        d.decl->print( ss, tabs );
    430399                                                }
    431400
     
    458427                                                        new_resn.newNeed.insert( match.need.begin(), match.need.end() );
    459428
    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                                                         }
     429                                                        bindAssertion( r.decl, r.info, new_resn.alt, match, new_resn.inferred );
    465430                                                }
    466431
  • src/SymTab/Mangler.cc

    r1bc5975 rec28948  
    3838                        struct Mangler : public WithShortCircuiting, public WithVisitorRef<Mangler>, public WithGuards {
    3939                                Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams );
    40                                 Mangler( const ResolvExpr::TypeEnvironment& env );
    4140                                Mangler( const Mangler & ) = delete;
    4241
     
    6766                          private:
    6867                                std::ostringstream mangleName;  ///< Mangled name being constructed
    69                                 typedef std::map< std::string, std::pair< std::string, int > > VarMapType;
     68                                typedef std::map< std::string, std::pair< int, int > > VarMapType;
    7069                                VarMapType varNums;             ///< Map of type variables to indices
    7170                                int nextVarNum;                 ///< Next type variable index
    72                                 const ResolvExpr::TypeEnvironment* env;  ///< optional environment for substitutions
    7371                                bool isTopLevel;                ///< Is the Mangler at the top level
    7472                                bool mangleOverridable;         ///< Specially mangle overridable built-in methods
     
    8078                          public:
    8179                                Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams,
    82                                         int nextVarNum, const ResolvExpr::TypeEnvironment* env,
    83                                         const VarMapType& varNums );
     80                                        int nextVarNum, const VarMapType& varNums );
    8481
    8582                          private:
     
    109106                }
    110107
    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 
    118108                namespace {
    119109                        Mangler::Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams )
    120                                 : nextVarNum( 0 ), env(nullptr), isTopLevel( true ),
     110                                : nextVarNum( 0 ), isTopLevel( true ),
    121111                                mangleOverridable( mangleOverridable ), typeMode( typeMode ),
    122112                                mangleGenericParams( mangleGenericParams ) {}
    123113                       
    124                         Mangler::Mangler( const ResolvExpr::TypeEnvironment& env )
    125                                 : nextVarNum( 0 ), env( &env ), isTopLevel( true ), mangleOverridable( false ),
    126                                 typeMode( false ), mangleGenericParams( true ) {}
    127                        
    128114                        Mangler::Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams,
    129                                 int nextVarNum, const ResolvExpr::TypeEnvironment* env,
    130                                 const VarMapType& varNums )
    131                                 : varNums( varNums ), nextVarNum( nextVarNum ), env( env ), isTopLevel( false ),
     115                                int nextVarNum, const VarMapType& varNums )
     116                                : varNums( varNums ), nextVarNum( nextVarNum ), isTopLevel( false ),
    132117                                mangleOverridable( mangleOverridable ), typeMode( typeMode ),
    133118                                mangleGenericParams( mangleGenericParams ) {}
     
    358343                                                        assert( false );
    359344                                                } // switch
    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() );
     345                                                varNums[ (*i)->name ] = std::make_pair( nextVarNum, (int)(*i)->get_kind() );
    377346                                                for ( std::list< DeclarationWithType* >::iterator assert = (*i)->assertions.begin(); assert != (*i)->assertions.end(); ++assert ) {
    378347                                                        PassVisitor<Mangler> sub_mangler(
    379                                                                 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, env,
    380                                                                 varNums );
     348                                                                mangleOverridable, typeMode, mangleGenericParams, nextVarNum, varNums );
    381349                                                        (*assert)->accept( sub_mangler );
    382350                                                        assertionNames.push_back( sub_mangler.pass.get_mangleName() );
  • src/SymTab/Mangler.h

    r1bc5975 rec28948  
    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 );
    4946
    5047                namespace Encoding {
  • tests/builtins/sync.cfa

    r1bc5975 rec28948  
    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;
    1314
    1415        { char ret; ret = __sync_fetch_and_add(vp1, v1); }
     
    180181        { _Bool ret; ret = __sync_bool_compare_and_swap_16(vp16, v16,v16); }
    181182        #endif
     183        { _Bool ret; ret = __sync_bool_compare_and_swap(vpp, vp, vp); }
    182184
    183185        { char ret; ret = __sync_val_compare_and_swap(vp1, v1, v1); }
     
    193195        { __int128 ret; ret = __sync_val_compare_and_swap_16(vp16, v16,v16); }
    194196        #endif
     197        { struct type * ret; ret = __sync_val_compare_and_swap(vpp, vp, vp); }
     198
    195199
    196200        { char ret; ret = __sync_lock_test_and_set(vp1, v1); }
     
    230234        { __atomic_clear(vp1, v1); }
    231235
    232         { char ret; ret = __atomic_exchange_n(vp1, &v1, __ATOMIC_SEQ_CST); }
     236        { char ret; ret = __atomic_exchange_n(vp1, v1, __ATOMIC_SEQ_CST); }
    233237        { char ret; ret = __atomic_exchange_1(vp1, v1, __ATOMIC_SEQ_CST); }
    234238        { char ret; __atomic_exchange(vp1, &v1, &ret, __ATOMIC_SEQ_CST); }
    235         { short ret; ret = __atomic_exchange_n(vp2, &v2, __ATOMIC_SEQ_CST); }
     239        { short ret; ret = __atomic_exchange_n(vp2, v2, __ATOMIC_SEQ_CST); }
    236240        { short ret; ret = __atomic_exchange_2(vp2, v2, __ATOMIC_SEQ_CST); }
    237241        { short ret; __atomic_exchange(vp2, &v2, &ret, __ATOMIC_SEQ_CST); }
    238         { int ret; ret = __atomic_exchange_n(vp4, &v4, __ATOMIC_SEQ_CST); }
     242        { int ret; ret = __atomic_exchange_n(vp4, v4, __ATOMIC_SEQ_CST); }
    239243        { int ret; ret = __atomic_exchange_4(vp4, v4, __ATOMIC_SEQ_CST); }
    240244        { int ret; __atomic_exchange(vp4, &v4, &ret, __ATOMIC_SEQ_CST); }
    241         { long long int ret; ret = __atomic_exchange_n(vp8, &v8, __ATOMIC_SEQ_CST); }
     245        { long long int ret; ret = __atomic_exchange_n(vp8, v8, __ATOMIC_SEQ_CST); }
    242246        { long long int ret; ret = __atomic_exchange_8(vp8, v8, __ATOMIC_SEQ_CST); }
    243247        { long long int ret; __atomic_exchange(vp8, &v8, &ret, __ATOMIC_SEQ_CST); }
    244248        #if defined(__SIZEOF_INT128__)
    245         { __int128 ret; ret = __atomic_exchange_n(vp16, &v16, __ATOMIC_SEQ_CST); }
     249        { __int128 ret; ret = __atomic_exchange_n(vp16, v16, __ATOMIC_SEQ_CST); }
    246250        { __int128 ret; ret = __atomic_exchange_16(vp16, v16, __ATOMIC_SEQ_CST); }
    247251        { __int128 ret; __atomic_exchange(vp16, &v16, &ret, __ATOMIC_SEQ_CST); }
    248252        #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); }
    249255
    250256        { char ret; ret = __atomic_load_n(vp1, __ATOMIC_SEQ_CST); }
     
    265271        { __int128 ret; __atomic_load(vp16, &ret, __ATOMIC_SEQ_CST); }
    266272        #endif
     273        { struct type * ret; ret = __atomic_load_n(vpp, __ATOMIC_SEQ_CST); }
     274        { struct type * ret; __atomic_load(vpp, &ret, __ATOMIC_SEQ_CST); }
    267275
    268276        { _Bool ret; ret = __atomic_compare_exchange_n(vp1, rp1, v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     
    283291        { _Bool ret; ret = __atomic_compare_exchange(vp16, rp16, &v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    284292        #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); }
    285295
    286296        { __atomic_store_n(vp1, v1, __ATOMIC_SEQ_CST); }
     
    301311        { __atomic_store(vp16, &v16, __ATOMIC_SEQ_CST); }
    302312        #endif
     313        { __atomic_store_n(vpp, vp, __ATOMIC_SEQ_CST); }
     314        { __atomic_store(vpp, &vp, __ATOMIC_SEQ_CST); }
    303315
    304316        { char ret; ret = __atomic_add_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
  • tools/PrettyGitLogs.sh

    r1bc5975 rec28948  
    2727git rev-list --format=short ${GitOldRef}...${GitNewRef} >  ${GIT_LOG}
    2828
    29 git diff --stat ${GitNewRef} ${GitOldRef} >  ${GIT_DIFF}
     29git 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}
Note: See TracChangeset for help on using the changeset viewer.