fixing the logs so we don't run into format errors

This commit is contained in:
Danny Yoo 2011-08-01 11:46:40 -04:00
parent b7ebab1428
commit 665c3e1897
3 changed files with 23 additions and 6 deletions

View File

@ -1667,8 +1667,10 @@
;; We should do more here eventually, including things like type inference or flow analysis, so that ;; We should do more here eventually, including things like type inference or flow analysis, so that
;; we can generate better code. ;; we can generate better code.
(define (extract-static-knowledge exp cenv) (define (extract-static-knowledge exp cenv)
(log-debug (format "Trying to discover information about ~s" exp))
(cond (cond
[(Lam? exp) [(Lam? exp)
(log-debug "known to be a lambda")
(make-StaticallyKnownLam (Lam-name exp) (make-StaticallyKnownLam (Lam-name exp)
(Lam-entry-label exp) (Lam-entry-label exp)
(if (Lam-rest? exp) (if (Lam-rest? exp)
@ -1677,9 +1679,11 @@
[(and (LocalRef? exp) [(and (LocalRef? exp)
(not (LocalRef-unbox? exp))) (not (LocalRef-unbox? exp)))
(let ([entry (list-ref cenv (LocalRef-depth exp))]) (let ([entry (list-ref cenv (LocalRef-depth exp))])
(log-debug (format "known to be ~s" entry))
entry)] entry)]
[(ToplevelRef? exp) [(ToplevelRef? exp)
(log-debug (format "toplevel reference of ~a" exp))
(when (ToplevelRef-constant? exp) (when (ToplevelRef-constant? exp)
(log-debug (format "toplevel reference ~a should be known constant" exp))) (log-debug (format "toplevel reference ~a should be known constant" exp)))
(let: ([name : (U Symbol False GlobalBucket ModuleVariable) (let: ([name : (U Symbol False GlobalBucket ModuleVariable)
@ -1687,10 +1691,12 @@
(ToplevelRef-pos exp))]) (ToplevelRef-pos exp))])
(cond (cond
[(ModuleVariable? name) [(ModuleVariable? name)
(log-debug (format "toplevel reference is to ~s" name))
name] name]
[(GlobalBucket? name) [(GlobalBucket? name)
'?] '?]
[else [else
(log-debug (format "nothing statically known about ~s" exp))
'?]))] '?]))]
[(Constant? exp) [(Constant? exp)
@ -1700,6 +1706,7 @@
exp] exp]
[else [else
(log-debug (format "nothing statically known about ~s" exp))
'?])) '?]))
@ -2002,8 +2009,11 @@
(: compile-apply-values (ApplyValues CompileTimeEnvironment Target Linkage -> InstructionSequence)) (: compile-apply-values (ApplyValues CompileTimeEnvironment Target Linkage -> InstructionSequence))
(define (compile-apply-values exp cenv target linkage) (define (compile-apply-values exp cenv target linkage)
(log-debug (format "apply values ~a" exp))
(let ([on-zero (make-label 'onZero)] (let ([on-zero (make-label 'onZero)]
[after-args-evaluated (make-label 'afterArgsEvaluated)]) [after-args-evaluated (make-label 'afterArgsEvaluated)]
[consumer-info
(extract-static-knowledge (ApplyValues-proc exp) cenv)])
(append-instruction-sequences (append-instruction-sequences
;; Save the procedure value temporarily in a control stack frame ;; Save the procedure value temporarily in a control stack frame
@ -2038,7 +2048,10 @@
(make-instruction-sequence (make-instruction-sequence
`(,(make-PopControlFrame))) `(,(make-PopControlFrame)))
;; Finally, do the generic call into the function.
;; Finally, do the generic call into the consumer function.
;; FIXME: we have more static knowledge here of what the operator is.
;; We can make this faster.
(compile-general-procedure-call cenv (make-Reg 'argcount) target linkage)))) (compile-general-procedure-call cenv (make-Reg 'argcount) target linkage))))

View File

@ -1,5 +1,6 @@
#lang racket/base #lang racket/base
(require racket/match) (require racket/match
racket/list)
;; A small module to provide logging for Whalesong. ;; A small module to provide logging for Whalesong.
@ -12,20 +13,20 @@
(define (log-debug message . args) (define (log-debug message . args)
(log-message whalesong-logger (log-message whalesong-logger
'debug 'debug
(apply format message args) (if (empty? args) message (apply format message args))
#f)) #f))
(define (log-warning message . args) (define (log-warning message . args)
(log-message whalesong-logger (log-message whalesong-logger
'warning 'warning
(apply format message args) (if (empty? args) message (apply format message args))
#f)) #f))
(define (log-error message . args) (define (log-error message . args)
(log-message whalesong-logger (log-message whalesong-logger
'error 'error
(apply format message args) (if (empty? args) message (apply format message args))
#f)) #f))

View File

@ -1,4 +1,7 @@
#lang planet dyoo/whalesong #lang planet dyoo/whalesong
(provide (all-defined-out))
(define (f x) (define (f x)
(* x x)) (* x x))