
commonizatio pass and support for specifying default record equal and hash procedures: - more staid and consistent Mf-cross main target Mf-cross - cpletrec now replaces the incoming prelexes with new ones so that it doesn't have to alter the flags on the incoming ones, since the same expander output is passed through the compiler twice while compiling a file with macro definitions or libraries. we were getting away without this just by luck. cpletrec.ss - pure? and ivory? now return #t for a primref only if the prim is declared to be a proc, since some non-proc prims are mutable, e.g., $active-threads and $collect-request-pending. cp0.ss - $error-handling-mode? and $eol-style? are now properly declared to be procs rather than system state variables. primdata.ss - the new pass $check-prelex-flags verifies that prelex referenced, multiply-referenced, and assigned flags are set when they should be. (it doesn't, however, complain if a flag is set when it need not be.) when the new system parameter $enable-check-prelex-flags is set, $check-prelex-flags is called after each major pass that produces Lsrc forms to verify that the flags are set correctly in the output of the pass. this parameter is unset by default but set when running the mats. cprep.ss, back.ss, compile.ss, primdata.ss, mats/Mf-base - removed the unnecessary set of prelex referenced flag from the build-ref routines when we've just established that it is set. syntax.ss, compile.ss - equivalent-expansion? now prints differences to the current output port to aid in debugging. mat.ss - the nanopass that patches calls to library globals into calls to their local counterparts during whole-program optimization now creates new prelexes and sets the prelex referenced, multiply referenced, and assigned flags on the new prelexes rather than destructively setting flags on the incoming prelexes. The only known problems this fixes are (1) the multiply referenced flag was not previously being set for cross-library calls when it should have been, resulting in overly aggressive inlining of library exports during whole-program optimization, and (2) the referenced flag could sometimes be set for library exports that aren't actually used in the final program, which could prevent some unreachable code from being eliminated. compile.ss - added support for specifying default record-equal and record-hash procedures. primdata.ss, cmacros.ss, cpnanopass.ss, prims.ss, newhash.ss, gc.c, record.ms - added missing call to relocate for subset-mode tc field, which wasn't burning us because the only valid non-false value, the symbol system, is in the static generation after the initial heap compaction. gc.c - added a lambda-commonization pass that runs after the other source optimizations, particularly inlining, and a new parameter that controls how hard it works. the value of commonization-level ranges from 0 through 9, with 0 disabling commonization and 9 maximizing it. The default value is 0 (disabled). At present, for non-zero level n, the commonizer attempts to commonize lambda expressions consisting of 2^(10-n) or more nodes. commonization of one or more lambda expressions requires that they have identical structure down to the leaf nodes for quote expressions, references to unassigned variables, and primitives. So that various downstream optimizations aren't disabled, there are some additional restrictions, the most important of which being that call-position expressions must be identical. The commonizer works by abstracting the code into a helper that takes the values of the differing leaf nodes as arguments. the name of the helper is formed by concatenating the names of the original procedures, separated by '&', and this is the name that will show up in a stack trace. The source location will be that of one of the original procedures. Profiling inhibits commonization, because commonization requires profile source locations to be identical. cpcommonize.ss (new), compile.ss, interpret.ss, cprep.ss, primdata.ss, s/Mf-base, mats/Mf-base - cpletrec now always produces a letrec rather than a let for single immutable lambda bindings, even when not recursive, for consistent expand/optimize output whether the commonizer is run or not. cpletrec.ss, record.ms - trans-make-ftype-pointer no longer generates a call to $verify-ftype-address if the address expression is a call to ftype-pointer-address. ftype.ss original commit: b6a3dcc814b64faacc9310fec4a4531fb3f18dcd
170 lines
5.7 KiB
Scheme
170 lines
5.7 KiB
Scheme
"back.ss"
|
|
;;; back.ss
|
|
;;; Copyright 1984-2017 Cisco Systems, Inc.
|
|
;;;
|
|
;;; Licensed under the Apache License, Version 2.0 (the "License");
|
|
;;; you may not use this file except in compliance with the License.
|
|
;;; You may obtain a copy of the License at
|
|
;;;
|
|
;;; http://www.apache.org/licenses/LICENSE-2.0
|
|
;;;
|
|
;;; Unless required by applicable law or agreed to in writing, software
|
|
;;; distributed under the License is distributed on an "AS IS" BASIS,
|
|
;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
;;; See the License for the specific language governing permissions and
|
|
;;; limitations under the License.
|
|
|
|
(define-who trace-output-port
|
|
($make-thread-parameter
|
|
(console-output-port)
|
|
(lambda (x)
|
|
(unless (and (output-port? x) (textual-port? x))
|
|
($oops who "~s is not a textual output port" x))
|
|
x)))
|
|
|
|
(define-who trace-print
|
|
($make-thread-parameter
|
|
pretty-print
|
|
(lambda (x)
|
|
(unless (procedure? x)
|
|
($oops who "~s is not a procedure" x))
|
|
x)))
|
|
|
|
(define suppress-greeting (make-parameter #f (lambda (x) (and x #t))))
|
|
|
|
(define-who eval-syntax-expanders-when
|
|
($make-thread-parameter '(compile load eval)
|
|
(lambda (x)
|
|
(unless (let check ([x x] [l '(compile load eval visit revisit)])
|
|
(or (null? x)
|
|
(and (pair? x)
|
|
(memq (car x) l)
|
|
(check (cdr x) (remq (car x) l)))))
|
|
($oops who "invalid eval-when list ~s" x))
|
|
x)))
|
|
|
|
(define-who collect-maximum-generation
|
|
(let ([$get-maximum-generation (foreign-procedure "(cs)maxgen" () fixnum)]
|
|
[$set-maximum-generation! (foreign-procedure "(cs)set_maxgen" (fixnum) void)])
|
|
(case-lambda
|
|
[() ($get-maximum-generation)]
|
|
[(g)
|
|
(unless (and (fixnum? g) (fx>= g 0)) ($oops who "invalid generation ~s" g))
|
|
(when (fx= g 0) ($oops who "new maximum generation must be at least 1"))
|
|
(let ([limit (fx- (constant static-generation) 1)])
|
|
(when (fx> g limit) ($oops who "~s exceeds maximum supported value ~s" g limit)))
|
|
($set-maximum-generation! g)])))
|
|
|
|
(define-who release-minimum-generation
|
|
(let ([$get-release-minimum-generation (foreign-procedure "(cs)minfreegen" () fixnum)]
|
|
[$set-release-minimum-generation! (foreign-procedure "(cs)set_minfreegen" (fixnum) void)])
|
|
(case-lambda
|
|
[() ($get-release-minimum-generation)]
|
|
[(g)
|
|
(unless (and (fixnum? g) (fx>= g 0)) ($oops who "invalid generation ~s" g))
|
|
(unless (fx<= g (collect-maximum-generation))
|
|
($oops who "new release minimum generation must not be be greater than collect-maximum-generation"))
|
|
($set-release-minimum-generation! g)])))
|
|
|
|
(define-who enable-object-counts
|
|
(let ([$get-enable-object-counts (foreign-procedure "(cs)enable_object_counts" () boolean)]
|
|
[$set-enable-object-counts (foreign-procedure "(cs)set_enable_object_counts" (boolean) void)])
|
|
(case-lambda
|
|
[() ($get-enable-object-counts)]
|
|
[(b) ($set-enable-object-counts b)])))
|
|
|
|
(define-who collect-trip-bytes
|
|
(make-parameter
|
|
(constant default-collect-trip-bytes)
|
|
(lambda (x)
|
|
(unless (and (fixnum? x) (fx< 0 x))
|
|
($oops who "~s is not a positive fixnum" x))
|
|
($set-collect-trip-bytes x)
|
|
x)))
|
|
|
|
(define-who heap-reserve-ratio
|
|
(case-lambda
|
|
[() $heap-reserve-ratio]
|
|
[(x) (unless (number? x)
|
|
($oops who "~s is not a number" x))
|
|
(let ([y (inexact x)])
|
|
(unless (and (flonum? y) (>= y 0))
|
|
($oops who "invalid heap reserve ratio ~s" x))
|
|
(set! $heap-reserve-ratio y))]))
|
|
|
|
(define-who $assembly-output
|
|
($make-thread-parameter #f
|
|
(lambda (x)
|
|
(cond
|
|
[(or (not x) (and (output-port? x) (textual-port? x))) x]
|
|
[(eq? x #t) (current-output-port)]
|
|
[else ($oops who "~s is not a textual output port or #f" x)]))))
|
|
|
|
(define-who expand-output
|
|
($make-thread-parameter #f
|
|
(lambda (x)
|
|
(unless (or (not x) (and (output-port? x) (textual-port? x)))
|
|
($oops who "~s is not a textual output port or #f" x))
|
|
x)))
|
|
|
|
(define-who expand/optimize-output
|
|
($make-thread-parameter #f
|
|
(lambda (x)
|
|
(unless (or (not x) (and (output-port? x) (textual-port? x)))
|
|
($oops who "~s is not a textual output port or #f" x))
|
|
x)))
|
|
|
|
(define generate-wpo-files
|
|
($make-thread-parameter #f
|
|
(lambda (x)
|
|
(and x #t))))
|
|
|
|
(define $enable-check-prelex-flags
|
|
($make-thread-parameter #f
|
|
(lambda (x)
|
|
(and x #t))))
|
|
|
|
(define-who run-cp0
|
|
($make-thread-parameter
|
|
(default-run-cp0)
|
|
(lambda (x)
|
|
(unless (procedure? x)
|
|
($oops who "~s is not a procedure" x))
|
|
x)))
|
|
|
|
(define compile-compressed
|
|
($make-thread-parameter #t (lambda (x) (and x #t))))
|
|
|
|
(define compile-file-message
|
|
($make-thread-parameter #t (lambda (x) (and x #t))))
|
|
|
|
(define compile-imported-libraries
|
|
($make-thread-parameter #f (lambda (x) (and x #t))))
|
|
|
|
(define-who compile-library-handler
|
|
($make-thread-parameter
|
|
(lambda (ifn ofn) (compile-library ifn ofn))
|
|
(lambda (x)
|
|
(unless (procedure? x) ($oops who "~s is not a procedure" x))
|
|
x)))
|
|
|
|
(define-who compile-program-handler
|
|
($make-thread-parameter
|
|
(lambda (ifn ofn) (compile-program ifn ofn))
|
|
(lambda (x)
|
|
(unless (procedure? x) ($oops who "~s is not a procedure" x))
|
|
x)))
|
|
|
|
(define-who debug-level
|
|
($make-thread-parameter
|
|
1
|
|
(lambda (x)
|
|
(unless (and (fixnum? x) (<= 0 x 3))
|
|
($oops who "invalid level ~s" x))
|
|
x)))
|
|
|
|
(define internal-defines-as-letrec*
|
|
($make-thread-parameter #t (lambda (x) (and x #t))))
|
|
|
|
(set! $scheme-version (string->symbol ($format-scheme-version (constant scheme-version))))
|