Skip to content

Instantly share code, notes, and snippets.

View yurydelendik's full-sized avatar

Yury Delendik yurydelendik

View GitHub Profile
yury:~/Work/wasmtime$ cat t.c
#include <stdlib.h>
struct Test
{
int i;
int j;
};
struct Test t[2] = { {1, 2}, {3, 4}};

This document shows how to embed the wasmtime and run a simple wasm code.

Create wasm

Let's create a simple WebAssembly file with a single exported function that returns an integer:

(;; wat2wasm hello.wat -o $WASM_FILES/hello.wasm ;;)
(module
 (func (export "answer") (result i32)
diff --git a/bench/vm/bencher/project/BenchTestGenerator.py b/bench/vm/bencher/project/BenchTestGenerator.py
index a7b8ff41..933e6f2b 100644
--- a/bench/vm/bencher/project/BenchTestGenerator.py
+++ b/bench/vm/bencher/project/BenchTestGenerator.py
@@ -47,7 +47,7 @@ class BenchTestGenerator:
generated_tests_dir_full_path = join(out_dir, self.generated_tests_dir)
test_mv_cmd = "mv {} {}".format(
- join(out_dir, "wasm32-unknown-unknown", "release", "{}.wasm"),
+ join(out_dir, "wasm32-unknown-unknown", "release", "{}_wasm.wasm"),
@yurydelendik
yurydelendik / hello2.expanded.rs
Last active October 15, 2019 21:27
helloS.expanded.rs
#![feature(prelude_import)]
#![no_std]
#![doc = " Translation of hello example"]
#[prelude_import]
use ::std::prelude::v1::*;
#[macro_use]
extern crate std as std;
use failure::{bail, format_err, Error};
use std::cell::Ref;
use std::fs::read;
@yurydelendik
yurydelendik / node-wasi-sassc.patch
Created June 12, 2019 17:49
some fixes to node-wasi
diff --git a/run.js b/run.js
index 87928f1..94f353d 100755
--- a/run.js
+++ b/run.js
@@ -30,9 +30,11 @@ USAGE:
const bin = fs.readFileSync(process.argv[2]);
const mod = new WebAssembly.Module(bin);
+const preopenDirectories = {};
+preopenDirectories[process.cwd()] = process.cwd();
@yurydelendik
yurydelendik / lldb-jit-unwind.diff
Created February 12, 2019 18:31
Trust JIT unwind plan patch for lldb
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index 423b2e53c66..62dedbd75a6 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -829,6 +829,22 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
}
}
+ // The JIT generated module may generate their .eh_frame or .debug_frame
+ // sections. It makes sense to trust that unwind plan if it is valid.
@yurydelendik
yurydelendik / sourceURLPrefixes.md
Created August 29, 2018 21:19
sourceURLPrefixes WebAssembly custom section

sourceURLPrefixes WebAssembly custom section

This custom section is created to provide mapping of the local (or remote) file paths to network resources. Currently we can have DWARF sections inside the binary WebAssembly file, however debugger, in most of the cases, cannot retrive local files -- this file paths needs to be mapped to some networks server location.

Format

The custom section has the following format:

@yurydelendik
yurydelendik / dbg_value.diff
Last active January 20, 2019 05:13
Attept to extend DBG_VALUE functionality
Index: include/llvm/BinaryFormat/Dwarf.def
===================================================================
diff --git a/llvm/trunk/include/llvm/BinaryFormat/Dwarf.def b/llvm/trunk/include/llvm/BinaryFormat/Dwarf.def
--- a/llvm/trunk/include/llvm/BinaryFormat/Dwarf.def (revision 336356)
+++ b/llvm/trunk/include/llvm/BinaryFormat/Dwarf.def (working copy)
@@ -617,6 +617,8 @@
// Vendor extensions:
// Extensions for GNU-style thread-local storage.
HANDLE_DW_OP(0xe0, GNU_push_tls_address, 0, GNU)
+// Extensions for WebAssembly.
@yurydelendik
yurydelendik / from-mq-to-bookmarks.md
Last active May 12, 2018 11:39
Some version control operations

Overview

Provides set of operations to efficiently maintain set of patch for long time and be able to submit those for review.

GIT

Let's say we clone a repo and 'master' is upstream branch and we will keep it up-to-date on regular base.

We can created a branch for a new feature and will try to keep it fresh and with addressed reviews.

@yurydelendik
yurydelendik / mpc1.html
Last active December 11, 2017 23:22
Minimal example for mozPrintCallback
<!DOCTYPE html>
<html dir="ltr" mozdisallowselectionprint moznomarginboxes>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style>
* {
padding: 0;
margin: 0;
}