Instrument TR casts / asserts for feature-specific profiling.
original commit: 5502bf5b1ba8782badb8ef8a58d3e8ec947418ad
This commit is contained in:
parent
f122d7dc54
commit
2b7423a5e0
|
@ -1,15 +1,23 @@
|
|||
#lang racket/base
|
||||
(require (for-syntax racket/base))
|
||||
(provide assert defined?)
|
||||
|
||||
(define-syntax assert
|
||||
(syntax-rules ()
|
||||
((assert v)
|
||||
(let ([val v])
|
||||
(or val (error (format "Assertion failed on ~v" val)))))
|
||||
((assert v pred)
|
||||
(let ((val v))
|
||||
(if ((#%expression pred) val)
|
||||
val
|
||||
(error (format "Assertion ~a failed on ~v" pred val)))))))
|
||||
(define-syntax (assert stx)
|
||||
(syntax-case stx ()
|
||||
[(assert v)
|
||||
#`(let ([val v])
|
||||
#,(syntax-property
|
||||
(syntax/loc stx
|
||||
(or val (error (format "Assertion failed on ~v" val))))
|
||||
'feature-profile:TR-dynamic-check #t))]
|
||||
[(assert v p)
|
||||
#`(let ([val v]
|
||||
[pred p])
|
||||
#,(syntax-property
|
||||
(quasisyntax/loc stx
|
||||
(if (pred val)
|
||||
val
|
||||
(error (format "Assertion ~a failed on ~v" pred val))))
|
||||
'feature-profile:TR-dynamic-check #t))]))
|
||||
|
||||
(define (defined? v) #t)
|
||||
|
|
|
@ -332,17 +332,20 @@ This file defines two sorts of primitives. All of them are provided into any mod
|
|||
[(_ v:expr ty:expr)
|
||||
(define (apply-contract ctc-expr)
|
||||
#`(#%expression
|
||||
(ann
|
||||
#,(ignore-some
|
||||
#`(let-values (((val) #,(with-type* #'v #'Any)))
|
||||
(contract
|
||||
#,ctc-expr
|
||||
val
|
||||
'cast
|
||||
'typed-world
|
||||
val
|
||||
(quote-syntax #,stx))))
|
||||
ty)))
|
||||
(ann
|
||||
#,(ignore-some
|
||||
#`(let-values (((val) #,(with-type* #'v #'Any)))
|
||||
#,(syntax-property
|
||||
(quasisyntax/loc stx
|
||||
(contract
|
||||
#,ctc-expr
|
||||
val
|
||||
'cast
|
||||
'typed-world
|
||||
val
|
||||
(quote-syntax #,stx)))
|
||||
'feature-profile:TR-dynamic-check #t)))
|
||||
ty)))
|
||||
|
||||
(cond [(not (unbox typed-context?)) ; no-check, don't check
|
||||
#'v]
|
||||
|
@ -1267,10 +1270,14 @@ This file defines two sorts of primitives. All of them are provided into any mod
|
|||
(error "Assertion failed")])])
|
||||
(syntax-parse stx
|
||||
[(_ (c:with-asserts-clause ...) body:expr ...+)
|
||||
(syntax/loc stx
|
||||
(cond c.cond-clause
|
||||
...
|
||||
[else body ...]))]))
|
||||
(syntax-property
|
||||
(quasisyntax/loc stx
|
||||
(cond c.cond-clause
|
||||
...
|
||||
[else #,(syntax-property
|
||||
#'(begin body ...)
|
||||
'feature-profile:TR-dynamic-check 'antimark)]))
|
||||
'feature-profile:TR-dynamic-check #t)]))
|
||||
|
||||
(define-syntax (typecheck-fail stx)
|
||||
(syntax-parse stx
|
||||
|
|
Loading…
Reference in New Issue
Block a user