Skip to content

Instantly share code, notes, and snippets.

View lqd's full-sized avatar
💭
I may be slow to respond.

Rémy Rakic lqd

💭
I may be slow to respond.
View GitHub Profile
#![feature(intrinsics, lang_items, no_core, fundamental)]
#![no_core]
#[lang = "sized"]
#[fundamental]
pub trait Sized { }
#[lang = "copy"]
pub trait Copy : Clone { }
let is_trait_method = substs.self_ty().is_some();
let (nid, substs, sig) = if !is_trait_method {
let nid = self.tcx.map.as_local_node_id(fn_did).expect("");
(nid, *substs, sig)
} else {
let (resolved_def_id, resolved_substs) = traits::resolve_trait_method(self.tcx, fn_did, substs);
let nid = self.tcx.map.as_local_node_id(resolved_def_id).expect("");
let ty = self.tcx.lookup_item_type(resolved_def_id).ty;
let sig = ty.fn_sig().skip_binder();
@lqd
lqd / previously_valid_optimized_to_invalid.wast
Created July 5, 2016 13:00
The previous "valid" wast file, when ran through the optimizer now doesn't pass validation
[wasm-validator error in function $impls::_impl_Ord_for_i32_::cmp] 2 != 1: store value type must match, on
(i32.store
(i32.const 0)
(set_local $0
(if
(i32.eq
(get_local $0)
(get_local $1)
)
(i64.const 0)
@lqd
lqd / validates-interprets-crashes_shell.wast
Last active July 5, 2016 13:10
This is a buggy wast (I think because of i32 stores of i64s) - but passed binaryen validation and is "correctly" (for the tested subset) interpreted (should print 0 and it does), both through the API. But binaryen-shell crashes if you try to use this file.
(module
(memory 1 1)
(start $__wasm_start)
(type $print_i32 (func (param i32)))
(type $rustfn-0-6 (func (param i32)))
(type $rustfn-0-2 (func))
(type $__wasm_start (func))
(type $rustfn-0-12 (func))
(type $rustfn-0-11 (func (param i32)))
(type $rustfn-0-50 (func (param i32) (result i32)))
Process: servo [82307]
Path: /Applications/Servo.app/Contents/MacOS/servo
Identifier: org.servo.Servo22
Version: 0.0.1
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: servo [82307]
User ID: 501
Date/Time: 2016-07-02 20:02:00.326 +0200
unsafe fn generate_start_fn_wrapper(module: BinaryenModuleRef,
c_strings: &mut Vec<CString>,
did: DefId,
name: &str,
c_string: &CString) -> BinaryenFunctionRef {
// import print i32
let print_i32_name = CString::new("print_i32").expect("");
let print_i32 = print_i32_name.as_ptr();
c_strings.push(print_i32_name);
[wasm-validator error in function $_isize_as_Add_::add] 1 != 0: function body type must match, if function returns, on
(block
(block
(set_local $2
(get_local $0)
)
(set_local $3
(get_local $1)
)
(set_local $4
(module
(memory 0)
(type $rustfn-0-13 (func (param i32 i32) (result i32)))
(type $rustfn-0-24 (func (param i32 i32) (result i32)))
(type $rustfn-0-35 (func (param i32 i32) (result i32)))
(type $rustfn-0-46 (func (param i32 i32) (result i32)))
(type $rustfn-0-50 (func (param i32 i32)))
(type $rustfn-0-94 (func (param i32 i32) (result i32)))
(type $rustfn-0-103 (func (param i32 i32) (result i32)))
(type $rustfn-0-100 (func))
--- stdout
detected home dir change, cleaning out entire build directory
--- stderr
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 145, message: "Le r\u{e9}pertoire n\u{201
9}est pas vide." } }', ../src/libcore\result.rs:746
stack backtrace:
0: 0xb7f78a - std::rt::lang_start::h5b0863080165c75e
1: 0xb66ad3 - std::sys_common::unwind::begin_unwind_inner::h39d40f52add53ef7
2: 0xb68140 - std::sys_common::unwind::begin_unwind_fmt::h64c0ff793199cc1b
(module
(memory 0)
(type $rustfn-0-14 (func (param i32 i32) (result i32)))
(type $rustfn-0-28 (func (param i32 i32) (result i32)))
(type $rustfn-0-39 (func (param i32 i32) (result i32)))
(type $rustfn-0-42 (func (param i32) (result i32)))
(type $rustfn-0-44 (func (param i32 i32) (result i32)))
(export "main" $main)
(func $fibonacci_recursive (type $rustfn-0-42) (param $0 i32) (result i32)
(local $1 i32)