tracing bug with expand-out-images

This commit is contained in:
Danny Yoo 2011-11-02 15:42:23 -04:00
parent 95fba70f4d
commit b78eddfa42
3 changed files with 39 additions and 52 deletions

View File

@ -1,7 +1,6 @@
#lang racket/base #lang racket/base
(require racket/path (require racket/path
racket/runtime-path racket/runtime-path
syntax/modcode
"language-namespace.rkt" "language-namespace.rkt"
"logger.rkt" "logger.rkt"
"expand-out-images.rkt") "expand-out-images.rkt")
@ -20,42 +19,27 @@
(define (get-module-bytecode x) (define (get-module-bytecode x)
(log-debug "grabbing module bytecode for ~s" x) (log-debug "grabbing module bytecode for ~s" x)
(define-values (compiled-code alternative-f) (define compiled-code
(cond (cond
;; Assumed to be a path string ;; Assumed to be a path string
[(string? x) [(string? x)
(log-debug "assuming path string") (log-debug "assuming path string")
(values (get-compiled-code-from-path (normalize-path (build-path x))) (call-with-input-file* (normalize-path (build-path x))
(lambda () get-compiled-code-from-port)]
(call-with-input-file* (normalize-path (build-path x))
get-compiled-code-from-port) [(path? x)
))] (call-with-input-file* x get-compiled-code-from-port)]
[(path? x) ;; Input port is assumed to contain the text of a module.
(values (get-compiled-code-from-path x) [(input-port? x)
(lambda () (get-compiled-code-from-port x)]
(call-with-input-file* x get-compiled-code-from-port)))]
[else
;; Input port is assumed to contain the text of a module. (error 'get-module-bytecode)]))
[(input-port? x)
(values (get-compiled-code-from-port x)
(lambda ()
(get-compiled-code-from-port x)))]
[else
(error 'get-module-bytecode)]))
(with-handlers ([exn? (lambda (exn) (define op (open-output-bytes))
;(printf "error? ~s\n" (exn-message exn)) (write compiled-code op)
(define op (open-output-bytes)) (get-output-bytes op))
;(printf "trying alternative to get bytecode\n")
(define bytecode (alternative-f))
;(printf "got the bytecode\n")
(write bytecode op)
(get-output-bytes op))])
(define op (open-output-bytes))
(write compiled-code op)
(get-output-bytes op)))
@ -69,21 +53,23 @@
;; Tries to use get-module-code to grab at module bytecode. Sometimes ;; ;; Tries to use get-module-code to grab at module bytecode. Sometimes
;; this fails because it appears get-module-code tries to write to ;; ;; this fails because it appears get-module-code tries to write to
;; compiled/. ;; ;; compiled/.
(define (get-compiled-code-from-path p) ;; (define (get-compiled-code-from-path p)
(log-debug "get-compiled-code-from-path") ;; (log-debug "get-compiled-code-from-path")
(with-handlers ([exn? (lambda (exn) ;; (with-handlers ([exn? (lambda (exn)
;; Failsafe: try to do it from scratch ;; ;; Failsafe: try to do it from scratch
(log-debug "parsing from scratch") ;; (log-debug "parsing from scratch")
(call-with-input-file* p ;; (call-with-input-file* p
(lambda (ip) ;; (lambda (ip)
(get-compiled-code-from-port ip))) ;; (get-compiled-code-from-port ip)))
)]) ;; )])
;; Note: we're trying to preserve the context, to avoid code expansion. ;; ;; Note: we're trying to preserve the context, to avoid code expansion.
(parameterize ([compile-context-preservation-enabled #t]) ;; (parameterize ([compile-context-preservation-enabled #t])
(get-module-code p)))) ;; (get-module-code p))))
;; get-compiled-code-from-port: input-port -> compiled-code ;; get-compiled-code-from-port: input-port -> compiled-code

View File

@ -64,7 +64,8 @@
;; Sets up the compiler parameters we need to do javascript-specific compilation. ;; Sets up the compiler parameters we need to do javascript-specific compilation.
(define (with-compiler-params thunk) (define (with-compiler-params thunk)
(parameterize ([current-primitive-identifier? (parameterize ([compile-context-preservation-enabled #t]
[current-primitive-identifier?
(lambda (a-name) (lambda (a-name)
(set-member? primitive-identifiers-set a-name))]) (set-member? primitive-identifiers-set a-name))])
(thunk))) (thunk)))

View File

@ -6,4 +6,4 @@
(provide version) (provide version)
(: version String) (: version String)
(define version "1.51") (define version "1.53")