Changeset 13755 in project


Ignore:
Timestamp:
03/14/09 17:33:44 (11 years ago)
Author:
felix winkelmann
Message:

added initial scrutinizer code

Location:
chicken/branches/scrutiny
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • chicken/branches/scrutiny/batch-driver.scm

    r12937 r13755  
    6464  default-declarations units-used-by-default words-per-flonum default-debugging-declarations
    6565  default-profiling-declarations default-optimization-passes
    66   file-requirements import-libraries inline-globally
     66  file-requirements import-libraries inline-globally scrutinize
    6767  foreign-string-result-reserve parameter-limit eq-inline-operator optimizable-rest-argument-operators
    6868  membership-test-operators membership-unfold-limit valid-compiler-options valid-compiler-options-with-argument
     
    7070  generate-code make-variable-list make-argument-list generate-foreign-stubs foreign-type-declaration
    7171  do-lambda-lifting compiler-warning emit-global-inline-file load-inline-file
    72   foreign-argument-conversion foreign-result-conversion)
     72  foreign-argument-conversion foreign-result-conversion
     73  load-identifier-database load-type-database)
    7374
    7475
     
    8283(define user-preprocessor-pass (make-parameter #f))
    8384(define user-pass (make-parameter #f))
    84 (define user-pass-2 (make-parameter #f))
    8585(define user-post-analysis-pass (make-parameter #f))
    8686
     
    133133        [start-time #f]
    134134        (upap #f)
     135        (do-scrutinize #f)
    135136        [ssize (or (memq 'nursery options) (memq 'stack-size options))] )
    136137
     
    229230           (collect-options 'emit-import-library)))
    230231    (when (memq 'lambda-lift options) (set! do-lambda-lifting #t))
     232    (when (memq 'scrutinize options) (set! do-scrutinize #t))
    231233    (when (memq 't debugging-chicken) (##sys#start-timer))
    232234    (when (memq 'b debugging-chicken) (set! time-breakdown #t))
     
    366368
    367369    ;;*** hardcoded "modules.db" is bad (also used in chicken-install.scm)
    368     (and-let* ((rp (repository-path))
    369                (dbfile (file-exists? (make-pathname rp "modules.db"))))
    370       (dribble "loading database ~a ..." dbfile)
    371       (for-each
    372        (lambda (e)
    373          (##sys#put!
    374           (car e) '##core#db
    375           (append (or (##sys#get (car e) '##core#db) '()) (list (cdr e))) ))
    376        (read-file dbfile)))
     370    (load-identifier-database "modules.db")
    377371
    378372    (cond ((memq 'version options)
     
    504498                  (concatenate (map cdr req)))))
    505499
    506              (let* ([node0 (make-node
    507                             'lambda '(())
    508                             (list (build-node-graph
    509                                    (canonicalize-begin-body exps) ) ) ) ]
    510                     [proc (user-pass-2)] )
    511                (when proc
    512                  (dribble "Secondary user pass...")
     500             (let ((node0 (make-node
     501                           'lambda '(())
     502                           (list (build-node-graph
     503                                  (canonicalize-begin-body exps) ) ) ) )
     504                   (db #f))
     505
     506               (when do-scrutinize
     507                 ;;;*** hardcoded database file name
     508                 (load-type-database "types.db")
    513509                 (begin-time)
    514510                 (set! first-analysis #f)
    515                  (let ([db (analyze 'user node0)])
    516                    (print-db "analysis (u)" '|0| db 0)
    517                    (end-time "pre-analysis (u)")
    518                    (begin-time)
    519                    (proc node0)
    520                    (end-time "secondary user pass")
    521                    (print-node "secondary user pass" '|U| node0) )
     511                 (set! db (analyze 'scrutiny node0))
     512                 (print-db "analysis" '|0| db 0)
     513                 (end-time "pre-analysis")
     514                 (begin-time)
     515                 (scrutinize node0 db)
     516                 (end-time "scrutiny")
    522517                 (set! first-analysis #t) )
    523518
    524519               (when do-lambda-lifting
    525520                 (begin-time)
    526                  (set! first-analysis #f)
    527                  (let ([db (analyze 'lift node0)])
     521                 (unless do-scrutinize  ; no need to do analysis if already done above
     522                   (set! first-analysis #f)
     523                   (set! db (analyze 'lift node0))
    528524                   (print-db "analysis" '|0| db 0)
    529                    (end-time "pre-analysis")
    530                    (begin-time)
    531                    (perform-lambda-lifting! node0 db)
    532                    (end-time "lambda lifting")
    533                    (print-node "lambda lifted" '|L| node0) )
     525                   (end-time "pre-analysis"))
     526                 (begin-time)
     527                 (perform-lambda-lifting! node0 db)
     528                 (end-time "lambda lifting")
     529                 (print-node "lambda lifted" '|L| node0)
    534530                 (set! first-analysis #t) )
    535531
  • chicken/branches/scrutiny/c-platform.scm

    r13150 r13755  
    123123    disable-stack-overflow-checks disable-c-syntax-checks unsafe-libraries raw
    124124    emit-external-prototypes-first release local inline-global
    125     analyze-only dynamic) )
     125    analyze-only dynamic scrutinize) )
    126126
    127127(define valid-compiler-options-with-argument
  • chicken/branches/scrutiny/csc.scm

    r13239 r13755  
    127127    -check-syntax -case-insensitive -benchmark-mode -shared -compile-syntax -no-lambda-info
    128128    -lambda-lift -dynamic -disable-stack-overflow-checks -local
    129     -emit-external-prototypes-first -inline -extension -release
     129    -emit-external-prototypes-first -inline -extension -release -scrutinize
    130130    -analyze-only -keep-shadowed-macros -inline-global) -ignore-repository)
    131131
     
    140140  '((-h "-help")
    141141    (-s "-shared")
     142    (-S "-scrutinize")
    142143    (|-E| "-extension")
    143144    (|-P| "-check-syntax")
     
    318319    -accumulate-profile         executable emits profiling information in append mode
    319320    -profile-name FILENAME      name of the generated profile information file
     321    -S  -scrutinize             perform local flow analysis
    320322
    321323  Optimization options:
  • chicken/branches/scrutiny/distribution/manifest

    r13152 r13755  
    6464lolevel.c
    6565optimizer.c
     66scrutinizer.c
    6667regex.c
    6768posixunix.c
     
    175176lolevel.scm
    176177optimizer.scm
     178scrutinizer.scm
    177179regex.scm
    178180irregex.scm
  • chicken/branches/scrutiny/manual/Using the compiler

    r12896 r13755  
    170170; -require-extension NAME : Loads the extension {{NAME}} before the compilation process commences. This is identical to adding {{(require-extension NAME)}} at the start of the compiled program. If {{-uses NAME}} is also given on the command line, then any occurrences of {{-require-extension NAME}} are replaced with {{(declare (uses NAME))}}. Multiple names may be given and should be separated by {{,}}.
    171171
     172; -scrutinize : Enable simple flow-analysis to catch common type errors and argument/result mismatches
     173
    172174; -static-extension NAME : similar to {{-require-extension NAME}}, but links extension statically (also applies for an explicit {{(require-extension NAME)}}).
    173175
     
    360362or compiled code specified using the {{-extend}} option are loaded
    361363and evaluated.  The parameters {{user-options-pass, user-read-pass,
    362 user-preprocessor-pass, user-pass, user-pass-2}} and {{user-post-analysis-pass}} can be set
     364user-preprocessor-pass, user-pass}} and {{user-post-analysis-pass}} can be set
    363365to procedures that are called to perform certain compilation passes
    364366instead of the usual processing (for more information about parameters
     
    372374
    373375; [parameter] user-pass : Holds a procedure of one argument. This procedure is applied to each toplevel expression '''after''' macro-expansion.  The result of the procedure is then compiled in place of the original expression.
    374 
    375 ; [parameter] user-pass-2 : Holds a procedure of three arguments, which is called with the canonicalized node-graph as its sole argument. The result is ignored, so this pass has to mutate the node-structure to cause any effect.
    376376
    377377; [parameter] user-post-analysis-pass : Holds a procedure that will be called after every performed program analysis pass. The procedure (when defined) will be called with seven arguments: a symbol indicating the analysis pass, the program database, the current node graph, a getter and a setter-procedure which can be used to access and manipulate the program database, which holds various information about the compiled program, a pass iteration count, and an analysis continuation flag. The getter procedure should be called with two arguments: a symbol representing the binding for which information should be retrieved, and a symbol that specifies the database-entry. The current value of the database entry will be returned or {{#f}}, if no such entry is available. The setter procedure is called with three arguments: the symbol and key and the new value. The pass iteration count currently is meaningful only for the 'opt pass. The analysis continuation flag will be {{#f}} for the last 'opt pass. For information about the contents of the program database contact the author.
  • chicken/branches/scrutiny/support.scm

    r13300 r13755  
    6969  constant-declarations process-lambda-documentation big-fixnum? sort-symbols llist-length
    7070  export-dump-hook intrinsic? node->sexpr emit-global-inline-file inline-max-size
    71   make-random-name foreign-type-convert-result foreign-type-convert-argument)
     71  make-random-name foreign-type-convert-result foreign-type-convert-argument
     72  load-identifier-database)
    7273
    7374
     
    12731274    -accumulate-profile         executable emits profiling information in append mode
    12741275    -no-lambda-info             omit additional procedure-information
     1276    -scrutinize                 perform local flow analysis
    12751277
    12761278  Optimization options:
     
    15121514(define cdb-get get)
    15131515(define cdb-put! put!)
     1516
     1517
     1518;;; Load support files
     1519
     1520(define (load-identifier-database name)
     1521  (and-let* ((rp (repository-path))
     1522             (dbfile (file-exists? (make-pathname rp name))))
     1523    (dribble "loading identifier database ~a ..." dbfile)
     1524    (for-each
     1525     (lambda (e)
     1526       (##sys#put!
     1527        (car e) '##core#db
     1528        (append (or (##sys#get (car e) '##core#db) '()) (list (cdr e))) ))
     1529     (read-file dbfile))))
Note: See TracChangeset for help on using the changeset viewer.