Skip to content

Instantly share code, notes, and snippets.

View no-defun-allowed's full-sized avatar

Hayley Patton no-defun-allowed

View GitHub Profile
@no-defun-allowed
no-defun-allowed / distances.lisp
Created December 22, 2021 00:17
SBCL pointer distances
(defun distance-histogram ()
(let ((hist (make-array 128
:element-type '(unsigned-byte 64)
:initial-element 0)))
(flet ((measure (object referenced)
(when (typep referenced '(or cons array standard-object))
(let* ((object (sb-kernel:get-lisp-obj-address object))
(referenced (sb-kernel:get-lisp-obj-address referenced))
(delta (ash (- object referenced) -3))
(size (* (signum delta) (integer-length (abs delta)))))
@no-defun-allowed
no-defun-allowed / notes.org
Last active November 23, 2021 07:59
Notes on Pauseless Immix with Thread-Local Heaps (sometimes)

Notes on Pauseless Immix with Thread-Local Heaps (sometimes)

Introduction

We want a thread-local GC for SICL. If most collections are thread-local, we would improve upon latency and throughput, even with many threads.

The plan for a while was to use something like the Doligez-Leroy-Gonthier (DLG) collector [fn:thread-local-ml]. However,

@no-defun-allowed
no-defun-allowed / remove-redundant-assignments.lisp
Created June 18, 2021 07:28
Remove redundant assignments and locations in Cleavir IR
;;; Remove any assignment instructions and locations which appear to
;;; be redundant. We define a "redundant" assignment to be one which
;;; assigns from a lexical location to another, either with only one
;;; defining instruction; i.e. the assignment does not cause any
;;; visible effect.
(defun remove-redundant-assignments (enter-instruction)
(cleavir-ir:map-instructions-arbitrary-order
(lambda (instruction)
(when (typep instruction 'cleavir-ir:assignment-instruction)
@no-defun-allowed
no-defun-allowed / sicl_rack_update.tla
Last active June 15, 2021 02:18
Safe CHANGE-CLASS on SICL objects with no double-word CAS
-------------------------- MODULE sicl_rack_update --------------------------
EXTENDS Naturals, TLC
(* --algorithm basic
variables object = <<0, 0>>;
process ChangeClass \in 1..4
variables oldclass = 0, oldrack = 0;
begin
LoadClass:
@no-defun-allowed
no-defun-allowed / dbyol.org
Last active December 27, 2025 05:31
Don't Build Your Own Lisp

Don’t Build Your Own Lisp

I feel somewhat pressed to give a negative review of this book. This comes from someone who has worked on various Lisp implementations, and written some amount of C, but that isn’t an excuse to be overly harsh. This book, however, does not provide many nice things to say, and plenty of un-nice things. My apologies in advance.

First off: God help you if you are going to write your first interpreter in C of all things. No one I know thinks it’s a good idea to start

@no-defun-allowed
no-defun-allowed / base64-cl-simd.lisp
Created March 25, 2021 04:26
1 hour of cl-simd and chill and it gives you this look
(defun char- (character offset)
(- (char-code character) offset))
(defconstant +encode-shift-lut+
(sse:setr-pi8
(char- #\a 26) #1=(char- #\0 52) #1# #1# #1# #1#
#1# #1# #1# #1# #1# (char- #\+ 62)
(char- #\/ 63) (char-code #\A) 0 0))
(declaim (inline encode-lookup))
@no-defun-allowed
no-defun-allowed / 00-TL-DR.md
Last active February 16, 2021 22:11
Some dynamic language benchmarks

The results

Note that only the C "control" example has type information; every other implementation either uses inference or generic arithmetic.

Implementation Language Time (ms) Time rel. C Arithmetic Compilation model
GCC C 20.3 1 mod 2^n AOT
SBCL Common Lisp 36.4 1.79 bignum AOT
SpiderMonkey JavaScript 56.0 2.75 float JIT
Chez Scheme 93.7 4.62 bignum AOT
@no-defun-allowed
no-defun-allowed / selling-lisp-by-the-pound.org
Last active December 25, 2025 23:57
Selling Lisp by the pound

Selling Lisp by the Pound

“Paper late!” cried a voice in the crowd,

“Old man dies!” The note he left was signed,

‘Old Kiczales’ - it seems he’s drowned!

@no-defun-allowed
no-defun-allowed / point.lisp
Last active May 4, 2022 05:56
A metaclass which allocates instance slots in contiguous vectors
(defclass point ()
((x :initarg :x
:reader x
:type single-float
:pool-name *point-xs*)
(y :initarg :y
:reader y
:type single-float
:pool-name *point-ys*))
(:metaclass pooled-class))
@no-defun-allowed
no-defun-allowed / cas-words.lisp
Last active December 31, 2020 15:59
CAS elements of (unsigned-byte 64) words on SBCL
(defpackage cas-word
(:use :cl)
(:export #:word-ref #:run-tests))
(in-package :sb-vm)
(sb-c:defknown cas-word::%cas-word
((simple-array (unsigned-byte 64) 1) fixnum (unsigned-byte 64) (unsigned-byte 64))
(unsigned-byte 64)
()