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 / partial-read-barriers.md
Last active June 5, 2023 05:17
Partial read barriers and Common Lisp

The "partial read barrier" and Common Lisp

Most CLOS implementations use a representation for instances which uses an indirection, in order to implement class redefinition and change-class. In this document I propose a technique which avoids the indirection most of the time, describe how to optimise around the assumption that a class does not change, and how this technique fares with multiple threads.

The partial read barrier and Smalltalk

TODO stuff for SBCL mark-region GC

First, make the damn GC work consistently.

Done: Parallelise it.

Parallel marking seems easier than parallel copying. The GC is already designed after https://dl.acm.org/doi/pdf/10.1145/512529.512546 and has the same mark queue design. We presumably “just” need to make marking atomic,

@no-defun-allowed
no-defun-allowed / evm-versus-secd.md
Last active May 3, 2022 13:56
An unfair comparison of Ethereum VM mishaps to Netfarm's VM

Looking through the "checklist" on https://news.ycombinator.com/item?id=14691212. I think I made it out alive.

  1. Everything is 256 bits wide, including the "byte" type. This means that whilst byte[] is valid syntax, it will take up 32x more space than you expect. Storage space is extremely limited in Solidity programs. You should use "bytes" instead which is an actual byte array. The native 256-bit wide primitive type is called "bytes32" but the actual 8-bit wide byte type is called "int8".

Object size is an implementation detail.

  1. Strings. What can we say about this. There is a string type. It is useless. There is no support for string manipulation at all. String concatenation must be done by hand after casting to a byte array. Basics like indexOf() must also be written by hand or implementations copied into your program. To even learn the length of a string you must cast it to a byte array, but see above. In some versions of the Solidity compiler passing an empty string to a function would cause all
@no-defun-allowed
no-defun-allowed / ssl_lib.c
Created March 29, 2022 10:14
fix libbass.so not knowing how to use SSL in Garry's Mod
static int peek_failures = 0;
int SSL_peek(SSL *s, void *buf, int num)
{
if (s->handshake_func == 0) {
SSLerr(SSL_F_SSL_PEEK, SSL_R_UNINITIALIZED);
return -1;
}
if (s->shutdown & SSL_RECEIVED_SHUTDOWN) {
;; A grown up version of https://lists.gnu.org/archive/html/emacs-devel/2018-03/msg00127.html
(defvar-local *vpi-did-full-indent?* nil)
(defun vpi-find-start ()
(loop
(back-to-indentation)
(when (or (= (point-min) (point)) (zerop (current-column)))
(return))
(forward-line -1)))
#include <gc.h>
#include <cstddef>
#include <new>
void* operator new(std::size_t n) {
void *p = GC_MALLOC(n);
if (!p) throw std::bad_alloc();
return p;
}
@no-defun-allowed
no-defun-allowed / beaver.scm
Created January 23, 2022 09:04
A busy beaver in Scheme macros
(define-syntax beaver
(syntax-rules [a b c d quote]
[(beaver lefts 0 rights 'a)
(right lefts 1 rights 'b)]
[(beaver lefts 0 rights 'b)
(left lefts 1 rights 'a)]
[(beaver '(lefts ...) 0 '(rights ...) 'c)
'(lefts ... 1 rights ...)]
[(beaver lefts 0 rights 'd)
(right lefts 1 rights 'd)]
@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)