Skip to content

Instantly share code, notes, and snippets.

View Aatch's full-sized avatar

James Miller Aatch

View GitHub Profile
@Aatch
Aatch / test.ll
Created June 23, 2013 01:54
#[no_drop_flag]
%struct.Foo = type { i64 }
define void @_ZN14__extensions__9meth_29568finalize16_d7d397690bb61803_00E({ i64, %tydesc*, i8*, i8*, i8 }*) #1 {
static_allocas:
br label %1
; <label>:1 ; preds = %static_allocas
br label %return
return: ; preds = %1
#[allow(default_methods)];
pub enum ParseResult<T> {
Err(ParseError),
Ok(T)
}
pub trait GenParser<T,S,A> {
pub fn parse<Tok:TokenStream<T>>(&mut self, &mut ParseState<Tok, S>) -> ParseResult<A>;
@Aatch
Aatch / dump-2.ll
Last active December 18, 2015 21:29
Optimization issues
; Function Attrs: uwtable
define internal fastcc void @_ZN4main16_d7d397690bb61803_00E() #1 {
static_allocas:
%tmp.i = alloca { i64, %tydesc*, {}*, {}*, { i64* } }, align 8
%tmp5 = alloca i64, align 8
%tmp13 = bitcast i64* %tmp5 to i8*
call void @llvm.lifetime.start(i64 8, i8* %tmp13)
store i64 543210, i64* %tmp5, align 8
%0 = bitcast { i64, %tydesc*, {}*, {}*, { i64* } }* %tmp.i to i8*
call void @llvm.lifetime.start(i64 40, i8* %0)
@Aatch
Aatch / hacky-hacky.rs
Created June 25, 2013 07:54
My Magnificent Hack
enum opaque {}
trait thing {
pub fn foo(&self);
}
impl thing for opaque {
pub fn foo(&self) {
unsafe {
let o : *[int,..8] = std::cast::transmute(self);
@Aatch
Aatch / trait_visitor.rs
Created June 26, 2013 07:41
Visitor impl using a trait & default methods.
#[allow(default_methods)];
extern mod syntax;
use std::os;
use syntax::abi::AbiSet;
use syntax::codemap::span;
use syntax::parse;
use syntax::opt_vec;
execve("./test", ["./test"], [/* 54 vars */]) = 0
brk(0) = 0x6f8000
readlink("/proc/self/exe", "/home/james/tmp/test", 4096) = 20
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb03fd5d000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/home/james/tmp/../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/tls/x86_64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/james/tmp/../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/tls/x86_64", 0x7fff360cf100) = -1 ENOENT (No such file or directory)
open("/home/james/tmp/../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/tls/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/james/tmp/../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/tls", 0x7fff360cf100) = -1 ENOENT (No such file or directory)
open("/home/james/tmp/../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib
#[allow(default_methods)];
trait Foo {
pub fn visit_crate(&mut self) {
self.visit_mod([1,2,3])
}
pub fn visit_mod(&mut self, a: &[uint]) {
for a.iter().advance |i| {
self.visit_item(i);
@Aatch
Aatch / rt_exit.s
Last active December 19, 2015 04:38
_ZN7rt_exit17_96fb77fd6c6361db3_00E:
.cfi_startproc
cmpq %fs:112, %rsp
ja .LBB5_2
movabsq $8, %r10
movabsq $0, %r11
callq __morestack
ret
.LBB5_2:
pushq %rbp
@Aatch
Aatch / ast_sizes.md
Last active December 19, 2015 11:09
AST Type sizes, before vs. after

Before

Structs

[struct]  	Lifetime: 48
[struct]  	Path: 104
[struct]  	def_id: 16
[struct]  	TyParam: 32
[struct]  	Generics: 16
extern mod std;
extern mod syntax;
use syntax::ast::*;
use std::sys::size_of;
macro_rules! type_size (
(S $t:ident) => (print_type_size::<$t>("struct", stringify!($t)));
(E $t:ident) => (print_type_size::<$t>("enum", stringify!($t)))
)