každý den se nějaký čůrák za volantem najde.
margaras.k47.cz/@k47/statuse...
@k47q.bsky.social
Eat the rich
každý den se nějaký čůrák za volantem najde.
margaras.k47.cz/@k47/statuse...
fun fact: PHP manages memory using reference counting, but xml extensions for some reason implement their own reference counting on top of general reference counting.
github.com/php/php-src/...
#PHP
if you just happen to write a very basic jit compiler (for PHP, lets say) that generates simple binary that's calling into opcode handlers, you are limited by throughput of call/ret instructions, which is not that good.
margaras.k47.cz/@k47/statuse...
#PHP
if you want to write PHP from scratch, the first you have decide how you are going to manage memory
margaras.k47.cz/@k47/statuse...
#PHP
to fight against despair i need a project
so what if i reimplemented php from scratch?
margaras.k47.cz/@k47/statuse...
#PHP
fun little php detail margaras.k47.cz/@k47/statuse... #PHP
30.08.2025 09:56 — 👍 0 🔁 1 💬 0 📌 0Podívejte, co plave na zdejších rybnících: Kachnička mandarinská. k47.cz/2025/kachnic...
08.08.2025 12:43 — 👍 0 🔁 0 💬 0 📌 0I wouldn't. On purpose. But bugs are evil things waiting to attack us when we are most vulnerable.
Imagine this
foreach ($items as &$i){}
for ($i=0;$i<100;$i++){}
We iterate an array to modify it in place, then use $i as index in unrelated loop and whoops, the the last element is suddenly changed
php references are hilarious. not even this simple loop is not guaranteed to terminate
for ($i = 0; $i < 100; $i++) {
$a = 0;
}
not if $a and $i are references to each other
$a = 0;
$i = &$a;
#PHP
and there it is: GCC supports preserve_none attribute on x86
gcc.gnu.org/git/?p=gcc.g...
it's a feature precisely targeting tailcalling interpreters...
margaras.k47.cz/@k47/statuse...
this is pretty interesting:
imagine you have an array of sorted integers
if you rotate each integer one bit to the right, you need single pass of 1-bit radix sort to make the sequence sorted again...
margaras.k47.cz/@k47/statuse...
"I'm married to my job."
"So, what do you do?"
"Unemployed."
PHP references are poison.
for example: what can we say about the type of variable $i?
for ($i = 0; $i < 1000; $i++) { f($i); }
one would expect that it can only be an integer, but no. function f can be something like this
function f(int &$arg) { $arg = "lol"; }
and then all bets are off.
#PHP
jsem bez peněz a teď mi ještě umírá laptop k47.cz/2025/pining-...
30.04.2025 12:06 — 👍 0 🔁 0 💬 1 📌 0error messages looks like this
ir_base[21].ops[1] insn reference (32825) is out of range
ir_base[21].ops[1] reference (32825) must be DATA
ir_base[21].ops[1] (32825) type is incompatible with...
reasonable if you just happen to be Dmitry Stogov, not if you are peasant like the rest of us
#PHP
poking around in php jit is delightful. two key data types are declared like this:
typedef int32_t ir_ref;
typedef uintptr_t zend_jit_addr;
typesafety? never heard about it.
#PHP
there's a little memory exhaustion attack againt #php for you: send this 21 byte json "[[[[[[[[[[1]]]]]]]]]]" and json_decode allocates 2160 bytes of memory. that's 100x amplification. 10MB malicious json that forces php to allocate 1GB of memory can be gzipped to 25 kB.
05.04.2025 09:28 — 👍 2 🔁 1 💬 0 📌 0It's time for a new version of phpmod.d - my library for painless #PHP extensions in D language.
github.com/kaja47/phpmo...
Summary here margaras.k47.cz/@k47/statuse...
Briefly: docs, debug build, multiple PHP versions, parity testing with PHP source, -fno-druntime, variadic functions and more.
Wikipedické faktoidy #13 (válka, atentáty, konspirace, další války a hyperinflace) k47.cz/2025/wiki-fa...
31.03.2025 20:58 — 👍 0 🔁 0 💬 0 📌 0I'm preparing new version of phpmod.d library for simple development of native #PHP extensions (github.com/kaja47/phpmo...) and so it's time to recap news in the current one:
margaras.k47.cz/@k47/statuse...