Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the compiler-macro-notes Reference Manual, version 0.2.0, generated automatically by Declt version 3.0 "Montgomery Scott" on Sun May 15 04:30:54 2022 GMT+0.
• Introduction | What compiler-macro-notes is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
Another attempt at compiler-macro.
Here, we do not treat compiler notes as warnings, but instead these are a separate class of conditions. These are also not errors.
Two main condition classes are provided: compiler-macro-notes:note and compiler-macro-notes:optimization-failure-note. While the latter is a subclass of the former, the latter notes are printed in a slightly different manner to the former.
To be able to correctly print the expansion path that led to the condition, user code is expected to avoid performing a nonlocal exit to a place outside with-notes.
Notes may be muffled by
eval
to - say - test somethingThe effect is that the notes are signalled but not printed.
(defun foo (a b)
(+ a b))
(define-condition not-a-number (optimization-failure-note)
((form :initarg :form :reader form))
(:report (lambda (c s)
(format s "~S is not a number" (form c)))))
(define-compiler-macro foo (&whole form a b &environment env)
(with-notes (form env)
(unless (numberp a)
(signal 'not-a-number :form a))
(unless (numberp b)
(signal 'not-a-number :form b))
(return-from foo (+ a b))))
(defun bar (a b) (foo a b))
; Compiler-macro of FOO is unable to optimize
; (FOO A B)
; because:
;
; A is not a number
(defun bar (a b)
(declare (muffle not-a-number)) ; no note printed
(foo a b))
(disassemble 'bar)
; disassembly for BAR
; Size: 29 bytes. Origin: #x52DB5C53 ; BAR
; 53: 498B4510 MOV RAX, [R13+16] ; thread.binding-stack-pointer
; 57: 488945F8 MOV [RBP-8], RAX
; 5B: 488BD6 MOV RDX, RSI
; 5E: 488BFB MOV RDI, RBX
; 61: B904000000 MOV ECX, 4
; 66: FF7508 PUSH QWORD PTR [RBP+8]
; 69: E9F42F66FD JMP #x50418C62 ; #<FDEFN FOO>
; 6E: CC10 INT3 16 ; Invalid argument count trap
(defun baz () (foo 4 5))
(disassemble 'baz)
; disassembly for BAZ
; Size: 21 bytes. Origin: #x52DB5CEC ; BAZ
; CEC: 498B4510 MOV RAX, [R13+16] ; thread.binding-stack-pointer
; CF0: 488945F8 MOV [RBP-8], RAX
; CF4: BA12000000 MOV EDX, 18
; CF9: 488BE5 MOV RSP, RBP
; CFC: F8 CLC
; CFD: 5D POP RBP
; CFE: C3 RET
; CFF: CC10 INT3 16 ; Invalid argument count trap
Variable
Default Value: NIL
Bound to a type. Notes that are of type given by the value of this variable will not be printed. Example:
The compile time value of this variable is OR-ed with the muffle declarations to decide which notes to muffle.
Function: (muffle note)
Do not print this note
.
As a declaration, this takes in type specifiers as arguments.
Condition
Condition
Macro: (with-notes
(form env &key (name) (unwind-on-signal t) (other-conditions NIL)
(per-line-prefix ; ) (optimization-note-condition t))
&body body)
A macro to readably signal compiler-macro-notes:note for end-users:
env
to evaluate to an environment suitable for passing to
CL-ENVIRONMENTS.CLTL2:DEFINE-DECLARATIONbody
is surrounded by a (BLOCK with-notes
...) on the outsidewith-notes
also wraps the body
in an UNWIND-PROTECT and prints the
conditions that were signalled before exiting. If unwind-on-signal
is non-NIL,
then returns form
if a condition was signalled, else if no condition was
signalled returns the (primary) return value of body
.unwind-on-signal
is NIL, surrounds body
in a HANDLER-BIND and prints all
the compiler notes that were signalled. If non-NIL, prints only the first
signalled note.optimization-note-condition
form evaluates to non-NIL: optimization-note-condition
is expected to be a
form.other-conditions
is a type-specifier that indicates which other conditions
should be reported.with-notes
. Not
doing so could result in an incorrect print of the expansion paths.Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The compiler-macro-notes system |
Shubhamkar B. Ayare
MIT
Provides a macro and some conditions for use within macros and compiler-macros.
0.2.0
compiler-macro-notes.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The compiler-macro-notes.asd file | ||
• The compiler-macro-notes/package.lisp file | ||
• The compiler-macro-notes/notes.lisp file | ||
• The compiler-macro-notes/with-notes.lisp file |
Next: The compiler-macro-notes/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
compiler-macro-notes.asd
compiler-macro-notes (system)
Next: The compiler-macro-notes/notes․lisp file, Previous: The compiler-macro-notes․asd file, Up: Lisp files [Contents][Index]
compiler-macro-notes (system)
package.lisp
Next: The compiler-macro-notes/with-notes․lisp file, Previous: The compiler-macro-notes/package․lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
compiler-macro-notes (system)
notes.lisp
Previous: The compiler-macro-notes/notes․lisp file, Up: Lisp files [Contents][Index]
notes.lisp (file)
compiler-macro-notes (system)
with-notes.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The compiler-macro-notes package |
package.lisp (file)
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported special variables | ||
• Exported macros | ||
• Exported functions | ||
• Exported conditions |
Next: Exported macros, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Bound to a type. Notes that are of type given by the value of this variable
will not be printed.
Example:
- No notes will be printed if values is T.
- Optimization notes will not be printed if values is
COMPILER-MACRO-NOTES:OPTIMIZATION-FAILURE-NOTE
The compile time value of this variable is OR-ed with the MUFFLE declarations to decide which notes to muffle.
with-notes.lisp (file)
Next: Exported functions, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
A macro to readably signal COMPILER-MACRO-NOTES:NOTE for end-users:
- Expects ENV to evaluate to an environment suitable for passing to
CL-ENVIRONMENTS.CLTL2:DEFINE-DECLARATION
- BODY is surrounded by a (BLOCK WITH-NOTES ...) on the outside
- Further, WITH-NOTES also wraps the BODY in an UNWIND-PROTECT and prints the
conditions that were signalled before exiting. If UNWIND-ON-SIGNAL is non-NIL,
then returns FORM if a condition was signalled, else if no condition was
signalled returns the (primary) return value of BODY.
- If UNWIND-ON-SIGNAL is NIL, surrounds BODY in a HANDLER-BIND and prints all
the compiler notes that were signalled. If non-NIL, prints only the first
signalled note.
- OPTIMIZATION-FAILURE-NOTEs are printed only if OPTIMIZATION-NOTE-CONDITION
form evaluates to non-NIL: OPTIMIZATION-NOTE-CONDITION is expected to be a
form.
- OTHER-CONDITIONS is a type-specifier that indicates which other conditions
should be reported.
- If the user code in BODY does result in an expansion, then it is expected to
avoid performing a nonlocal exit to a place outside WITH-NOTES. Not
doing so could result in an incorrect print of the expansion paths.
with-notes.lisp (file)
Next: Exported conditions, Previous: Exported macros, Up: Exported definitions [Contents][Index]
Do not print this NOTE.
As a declaration, this takes in type specifiers as arguments.
notes.lisp (file)
Previous: Exported functions, Up: Exported definitions [Contents][Index]
notes.lisp (file)
condition (condition)
optimization-failure-note (condition)
:datum
datum (generic function)
:args
args (generic function)
(quote nil)
muffled-p (generic function)
(setf muffled-p) (generic function)
notes.lisp (file)
note (condition)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal generic functions |
Previous: Internal definitions, Up: Internal definitions [Contents][Index]
notes.lisp (file)
notes.lisp (file)
notes.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | C F L |
---|
Jump to: | C F L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
A D F G M W |
---|
Jump to: | (
A D F G M W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
A D M S |
---|
Jump to: | *
A D M S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C N O P S |
---|
Jump to: | C N O P S |
---|