Skip to content

Instantly share code, notes, and snippets.

View erikcorry's full-sized avatar
🏠
Working from home

Erik Corry erikcorry

🏠
Working from home
View GitHub Profile
@erikcorry
erikcorry / interpreter.txt
Created November 26, 2025 12:04
The LdaSmi bytecode in the V8 interpreter (it also checks if the next bytecode is store-a-on-stack and does that).
1958cc0: 43 0f be 5c 0c 01 movsbl 0x1(%r12,%r9,1),%ebx // ebx = load small int
1958cc6: 49 8d 51 02 lea 0x2(%r9),%rdx // rdx = next bytecode addr
1958cca: 43 0f b6 74 0c 02 movzbl 0x2(%r12,%r9,1),%esi // esi = peek at next bytecode
1958cd0: 8d 04 1b lea (%rbx,%rbx,1),%eax // eax = rbx * 2 (tag smi)
1958cd3: 40 80 fe c1 cmp $0xc1,%sil // is next bc star? (Store accumulator in 'register'.
1958cd7: 73 09 jae 1958ce2 <Builtins_LdaSmiHandler+0x22> // jmp if star
1958cd9: 49 8b 0c f7 mov (%r15,%rsi,8),%rcx // add bytecode to r15, load next bytecode handler.
1958cdd: 4c 8b ca mov %rdx,%r9 // Update bytecode program counter
1958ce0: ff e1 jmp *%rcx // Dispatch to next handler
1958ce2: 48 8b dd mov %rbp
@erikcorry
erikcorry / mask-test.cc
Created November 17, 2025 17:34
AVX load instructions can be made to ignore segfaults on unused data
#include <immintrin.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/mman.h>
// Compile with clang++ -g -mavx512bw -mavx512f -o mask-test mask-test.cc
int main() {
char* addr = (char*)mmap(0, 8192, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
python3 ../../tools/run.py ./mksnapshot --turbo_instruction_scheduling --stress-turbo-late-spilling --target_os=linux --target_arch=x64 --embedded_src gen/embedded.S --predictable --no-use-ic --embedded_variant Default --random-seed 314159265 --startup_src gen/snapshot.cc --native-code-counters --concurrent-builtin-generation --concurrent-turbofan-max-threads=0 --verify-heap
=================================================================
==1412959==ERROR: AddressSanitizer: heap-use-after-free on address 0x75a4a36202c0 at pc 0x5c2e6e9dca2f bp 0x7ffece69cad0 sp 0x7ffece69cac8
READ of size 8 at 0x75a4a36202c0 thread T0
#0 0x5c2e6e9dca2e in v8::internal::VirtualMemory::Free() src/utils/allocation.cc:286:52
#1 0x5c2e6cec2c69 in v8::internal::CodeRange::Free() src/heap/code-range.cc:361:24
#2 0x5c2e6cec2c69 in v8::internal::CodeRange::~CodeRange() src/heap/code-range.cc:93:27
#3 0x5c2e6d66c7c6 in std::__Cr::default_delete<v8::internal::CodeRange>::operator()(v8::internal::CodeRange*) const third_p
@erikcorry
erikcorry / gist:05dcf38ef52cd4f56895496abe850775
Created December 19, 2024 14:51
args.gn to repro test failure
clang_version = "20"
use_rtti = true
use_sysroot = false
v8_enable_pointer_compression_shared_cage = false
v8_enable_external_code_space = false
cppgc_enable_caged_heap = false
icu_use_data_file = false
# These are defines only relevant to Chromium not V8, no need to have them here.
use_aura = false
use_blink = false
$ (cd out.gn/x64.optdebug; gdb --args cctest test-api/TwoIsolateGroups --random-seed=-515469024 --nohard-abort --verify-heap --enable-slow-asserts --testing-d8-test-runner)
GNU gdb (GDB) 15.1
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
@erikcorry
erikcorry / huge-regexp.js
Created June 18, 2024 12:32
Huge regexp test for bug 40261789
const terms = `\u0446\u0435\u043b\u044c\u044e|\u0446\u0435\u043b\u044c \u0438\u0441\u0441\u043b\u0435|\u0440\u0435\u0437\u044e\u043c\u0435|\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442|\u043f\u0440\u0435\u0434\u043c\u0435\u0442|\u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0430|\u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b|\u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0438 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0430|\u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438|\u0432\u044b\u0432\u043e\u0434|\u0432\u0432\u0435\u0434\u0435\u043d\u0438|\u0426\u0435\u043b\u044c|\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b|\u041c\u0435\u0442\u043e\u0434\u044b|\u041a\u0440\u0430\u0442\u043a\u0438\u0435 \u0438\u0442\u043e\u0433\u0438|\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435|\u0412\u044b\u0432\u043e\u0434\u044b|\u0412\u0438\u0441\u043d\u043e\u0432\u043a\u0438|\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435|\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f|\

Memory use, performance, and Toit pixel display.

(March 2024).

Some applications using pixel displays may run out of memory, especially if you are running on a small ESP32 with no external PSRAM. This is especially the case if you are using the small jaguar server on the device for fast edit-compile-run development cycles.

/// Simple pretty-printer for JSON-compatible objects (maps, lists, strings,
/// numbers, booleans, and null).
pretty-print data --indent/string="" --prefix/string?=null --suffix/string?="" -> none:
str := json.stringify data
if str.size < 80:
print "$(prefix or indent)$str$suffix"
return
if data is Map:
print "$(prefix or indent){"
i := 0
#
# Automatically generated file. DO NOT EDIT.
# Espressif IoT Development Framework (ESP-IDF) Project Configuration
#
CONFIG_SOC_BROWNOUT_RESET_SUPPORTED="Not determined"
CONFIG_SOC_TWAI_BRP_DIV_SUPPORTED="Not determined"
CONFIG_SOC_DPORT_WORKAROUND="Not determined"
CONFIG_SOC_CAPS_ECO_VER_MAX=301
CONFIG_SOC_ADC_SUPPORTED=y
CONFIG_SOC_DAC_SUPPORTED=y
@erikcorry
erikcorry / esp-idf-march-august.diff
Created August 16, 2023 14:30
IRAM sizes esp-idf march 2023 to august
--- rolled-sizes.txt 2023-08-16 16:23:09.982969715 +0200
+++ unrolled-sizes.txt 2023-08-16 16:22:34.159637286 +0200
@@ -1,33 +1,33 @@
Total sizes:
-Used static DRAM: 49824 bytes ( 74756 remain, 40.0% used)
- .data size: 22008 bytes
- .bss size: 27816 bytes
-Used static IRAM: 132298 bytes ( -1226 remain, 100.9% used) Overflow detected!
- .text size: 131271 bytes
+Used static DRAM: 50092 bytes ( 74488 remain, 40.2% used)