Skip to content

Instantly share code, notes, and snippets.

View eira-fransham's full-sized avatar

Eira Fransham eira-fransham

  • Berlin
View GitHub Profile
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
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)
@eira-fransham
eira-fransham / lightbeam-fib-comparison
Last active January 17, 2019 10:28
Lightbeam fibonacci generated code before and after #12
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
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
@eira-fransham
eira-fransham / pollock.rs
Created September 26, 2018 15:05
Example of using pollock.rs to make some simple sketches
#![feature(nll)]
#[macro_use]
extern crate pollock;
extern crate serde;
#[macro_use]
extern crate serde_derive;
use pollock::*;
#![feature(nll)]
extern crate pollock;
extern crate serde;
#[macro_use]
extern crate serde_derive;
use pollock::*;
#[derive(Serialize, Deserialize)]
This file has been truncated, but you can view the full file.
# callgrind format
version: 1
creator: callgrind-3.13.0
pid: 6359
cmd: target/release/rustfest-5c3dd55c20998644 --bench
part: 1
desc: I1 cache: 32768 B, 64 B, 8-way associative
desc: D1 cache: 32768 B, 64 B, 8-way associative
@eira-fransham
eira-fransham / unsound-insert.rs
Last active November 27, 2019 03:35
Explanation of unsoundness in `SmallVec::insert_many`
extern crate smallvec;
use smallvec::SmallVec;
struct Printer(usize);
impl Drop for Printer {
fn drop(&mut self) {
println!("Dropping {}", self.0);
}
@eira-fransham
eira-fransham / bigint-native.s
Created May 14, 2018 14:44
Disassembly of `U256::full_mul` when using `-C target-cpu=native`
libbigint.so`disassemble:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq 0x10(%rbp), %r14
use std::{str, mem, ptr, slice};
use std::ops::Deref;
pub struct CowStr<'a>(CowVec<'a, u8>);
impl<'a> CowStr<'a> {
#[inline]
pub fn borrowed(b: &'a str) -> Self {
CowStr(CowVec::borrowed(b.as_bytes()))
}