From e98e35ee5b21dcba6a3548655565391e45f826cb Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 14 Oct 2019 13:01:16 -0400 Subject: [PATCH] Added `-no-call-history` flag Allow for faster executables at the expense of call history. --- CHANGELOG.md | 4 ++++ cyclone.scm | 13 ++++++++++++- scheme/cyclone/cgen.sld | 8 ++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2ab97e8..28a7c220 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ TODO: mention cyclone-winds even though not part of this official release https://github.com/cyclone-scheme/cyclone-winds +Features + + - Added the `-no-call-history` flag to potentially allow for faster executables at the expense of call history. + Bug Fixes - Fix `read-u8`, `peek-u8`, and `write-u8` to work with integers (bytes) instead of characters. diff --git a/cyclone.scm b/cyclone.scm index dfb62866..6144424d 100644 --- a/cyclone.scm +++ b/cyclone.scm @@ -25,6 +25,7 @@ (define *optimization-level* 2) ;; Default level (define *optimize:memoize-pure-functions* #t) ;; Memoize pure funcs by default +(define *cgen:track-call-history* #t) ; Placeholder for future enhancement to show elapsed time by phase: (define *start* (current-second)) @@ -463,6 +464,8 @@ ((eq? flag 'memoize-pure-functions) (and program? ;; Only for programs, because SRFI 69 becomes a new dep *optimize:memoize-pure-functions*)) + ((eq? flag 'track-call-history) + *cgen:track-call-history*) (else #f))) (when (> *optimization-level* 0) @@ -553,7 +556,8 @@ module-globals c-headers lib-deps - src-file) + src-file + flag-set?) (return '())))) ;; No codes to return ;; Read top-level imports from a program and return a cons of: @@ -769,6 +773,8 @@ (set! *optimize:memoize-pure-functions* #t)) (if (member "-no-memoization-optimizations" args) (set! *optimize:memoize-pure-functions* #f)) + (if (member "-no-call-history" args) + (set! *cgen:track-call-history* #f)) ;; TODO: place more optimization reading here as necessary ;; End optimizations (if (member "-t" args) @@ -811,6 +817,11 @@ Optimization options: where possible (enabled by default). -no-memoization-optimizations Disable the above memoization optimization. +Debug options + + -no-call-history Do not track call history in the compiled code. This + allows for a faster runtime at the cost of having + no call history in the event of an exception. ") (newline)) ((member "-v" args) diff --git a/scheme/cyclone/cgen.sld b/scheme/cyclone/cgen.sld index e93fc08e..9f8f42d8 100644 --- a/scheme/cyclone/cgen.sld +++ b/scheme/cyclone/cgen.sld @@ -40,6 +40,7 @@ st:->var) (begin +(define *cgen:track-call-history* #t) (define *optimize-well-known-lambdas* #f) (define (emit line) @@ -263,7 +264,8 @@ (define (st:->code trace) (if (or (not (pair? trace)) - (null? (cdr trace))) + (null? (cdr trace)) + (not *cgen:track-call-history*)) "" (string-append "Cyc_st_add(data, \"" @@ -1848,8 +1850,10 @@ globals c-headers required-libs - src-file) + src-file + flag-set?) (set! *global-syms* (append globals (lib:idb:ids import-db))) + (set! *cgen:track-call-history* (flag-set? 'track-call-history)) (set! num-lambdas (+ (adb:max-lambda-id) 1)) (set! cgen:mangle-global (lambda (ident)