This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(module | |
(type $t0 (func (param i32))) | |
(type $t1 (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32))) | |
(type $t2 (func (param i32 i32))) | |
(type $t3 (func (param i32) (result i32))) | |
(type $t4 (func (param i32 i32 i32))) | |
(type $t5 (func (param i32 i32) (result i32))) | |
(type $t6 (func (param i32 i32 i32) (result i32))) | |
(type $t7 (func (param f64) (result f64))) | |
(func $log2 (type $t7) (param $p0 f64) (result f64) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::iter; | |
fn optimized_sieve(limit: usize) -> impl Iterator<Item = usize> { | |
let map_func = |cmpsts: Vec<u32>| { | |
move |i| { | |
if i < 0 { | |
Some(2) | |
} else { | |
if cmpsts[i as usize >> 5] & (1u32 << (i & 31)) == 0 { | |
Some((i + i + 3) as usize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; rdi = vmctx | |
mov [rsp + 0x20], rdi | |
; eax = callee_idx | |
mov eax, 0 | |
mov [rsp + 0x34], eax | |
mov rax, [rsp + 0x20] | |
; eax = vmctx->tables[table_idx].len | |
mov eax, [rax + 0x68] | |
; ecx = callee_idx | |
mov ecx, [rsp + 0x34] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait DisplayField { | |
fn display_field(&self, field: u64, f: &mut fmt::Formatter); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def .L1_end :: [i32, i32]: | |
def .L2 :: [i32, i32] num_callers=1: | |
def .L3 :: [i32, i32] has_backwards_callers: | |
def .L3_end :: [i32, i32]: | |
def .L4 :: [i32, i32] num_callers=1: | |
.fn_0: | |
const 0i32 | |
const 1i32 | |
swap 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/content/posts/wasm-is-not-a-stack-machine.md b/content/posts/wasm-is-not-a-stack-machine.md | |
index f8a944c..34bb3a5 100644 | |
--- a/content/posts/wasm-is-not-a-stack-machine.md | |
+++ b/content/posts/wasm-is-not-a-stack-machine.md | |
@@ -7,7 +7,9 @@ draft: false | |
> ### Preamble | |
> This article assumes some familiarity with virtual machines, compilers and WebAssembly, but I'll try to link to relevant information where necessary so even if you're not you can follow along. | |
> <br/><br/> | |
-> Also, this series is going to come off as if I dislike WebAssembly. I love WebAssembly! In fact, I love it so much that I want it to be the best that it can be, and this series is me working through my complaints with the design in the hope that some or all of these issues can be addressed soon, while the ink is still fresh on the specification. | |
+> Also, this series is going to come off as if I dislike WebAssembly. I love WebAssembly! I wrote a [whole article about how great it is][wasm-on-the-blockchain]! In fact, I love i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fib: | |
push rbp | |
mov rbp, rsp | |
sub rsp, 0x10 | |
xor eax, eax | |
cmp rsi, 0 | |
sete al | |
test eax, eax | |
; If `rsi` is _not_ zero, then jump to .fib-then | |
je .fib_then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INPUT: | |
(module | |
(func | |
(call $assert-return (call $as-binary-operand) (i32.const 12)) | |
(call $assert-return (call $break-bare) (i32.const 19)) | |
(call $assert-return (call $break-value) (i32.const 18)) | |
(call $assert-return (call $break-repeated) (i32.const 18)) | |
(call $assert-return (call $break-inner) (i32.const 0x7)) | |
) | |
(func $dummy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
push rbp | push rbp | |
mov rbp, rsp | mov rbp, rsp | |
sub rsp, 0x20 | sub rsp, 0x10 | |
mov edx, 1 | mov qword ptr [rsp + 8], rdi | |
xor eax, eax | mov eax, 0 | |
cmp esi, 2 | push rax | |
setb al | mov rax, qword ptr [rsp + 0x10] | |
test eax, eax | push rax | |
je 0x2d | pop rax | |
jmp 0x8e | pop rcx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
push rbp | |
mov rbp, rsp | |
sub rsp, 0x10 | |
mov qword ptr [rsp + 8], rdi | |
mov eax, 0 | |
push rax | |
mov rax, qword ptr [rsp + 0x10] | |
push rax | |
pop rax | |
pop rcx |