愿星光伴随你左右


  • 首页

  • todo

  • 思考

  • life

  • food

  • OS

  • lua

  • redis

  • Golang

  • C

  • TCP/IP

  • ebpf

  • p4

  • OpenVPN

  • IPSec

  • L2TP

  • DNS

  • distributed

  • web

  • OpenWRT

  • 运维

  • Git

  • 鸟哥的私房菜

  • IT杂谈

  • 投资

  • About Me

  • 友情链接

  • FTP

  • 搜索
close

linux ucontext族函数的原理及使用

时间: 2021-10-28   |   分类: c     |   阅读: 3415 字 ~7分钟

原文链接

ucontext函数族

这里的context族是偏向底层的,其实底层就是通过汇编来实现的,但是我们使用的时候就和平常使用变量和函数一样使用就行,因为大佬们已经将它们封装成C库里了的

阅读全文 »

WebAssembly完全入门了解wasm的前世今身

时间: 2021-10-20   |   分类: wasm     |   阅读: 4952 字 ~10分钟

首发于SH的全栈笔记

前言

接触WebAssembly之后,在google上看了很多资料。感觉对WebAssembly的使用、介绍、意义都说的比较模糊和笼统。感觉看了之后收获没有达到预期,要么是文章中的例子自己去实操不能成功,要么就是不知所云、一脸蒙蔽。本着业务催生技术的态度,这边文章就诞生了。前部分主要是对WebAssembly的背景做一些介绍,WebAssembly是怎么出现的,优势在哪儿。如果想直接开始撸代码试试效果,可以直接跳到最后一个板块。

阅读全文 »

十年磨一剑,WebAssembly是如何诞生的?

时间: 2021-10-20   |   分类: wasm     |   阅读: 6663 字 ~14分钟

首发于寒雁Talk

创造一个编程语言最好的时间是10年前,其次是现在。

从Emscripten到asm.js再到WebAssembly,从一个业余项目到W3C标准,差不多是整整10年。

阅读全文 »

深入浅出WebAssembly1-8链接

时间: 2021-10-20   |   分类: wasm     |   阅读: 200 字 ~1分钟

这系列主要是我对WASM研究的笔记,可能内容比较简略。总共包括:

  1. 深入浅出WebAssembly(1) Compilation
  2. 深入浅出WebAssembly(2) Basic Api
  3. [深入浅出WebAssembly(3) Instructions]((https://juejin.cn/post/6844904190150443015)
  4. 深入浅出WebAssembly(4) Validation
  5. 深入浅出WebAssembly(5) Memory
  6. 深入浅出WebAssembly(6) Binary Format
  7. 深入浅出WebAssembly(7) Future
  8. [深入浅出WebAssembly(8) Wasm in Rust(TODO)]

深入浅出WebAssembly(2) Basic API

时间: 2021-10-20   |   分类: wasm     |   阅读: 1585 字 ~4分钟

原文链接

这系列主要是我对WASM研究的笔记,可能内容比较简略。总共包括:

  1. 深入浅出WebAssembly(1) Compilation
  2. 深入浅出WebAssembly(2) Basic Api
  3. 深入浅出WebAssembly(3) Instructions
  4. 深入浅出WebAssembly(4) Validation
  5. 深入浅出WebAssembly(5) Memory
  6. 深入浅出WebAssembly(6) Binary Format
  7. 深入浅出WebAssembly(7) Future
  8. 深入浅出WebAssembly(8) Wasm in Rust(TODO)

API总览

//async version
WebAssembly.compile(bufferSource: ArrayBuffer): Promise<WebAssembly.Module>
WebAssembly.instantiate(bufferSource: ArrayBuffer, importObj?: any): Promise<{module: WebAssembly.Module, instance: WebAssembly.Instance}>
WebAssembly.instantiate(module: WebAssembly.Module, importObj?: any): Promise<WebAssembly.Instance>
WebAssembly.compileStreaming(source: Promise<Responce>): Promise<WebAssembly.Module> // wasm 请求头:Context-type: application/wasm

//sync version
new WebAssembly.Module(bufferSource: ArrayBuffer)
new WebAssembly.Instance(module: WebAssembly.Module, importObj?: any)

// helper
WebAssembly.Module.customSections(module:WebAssembly.Module, sectionName: string): ArrayBuffer[]
WebAssembly.Module.exports(module: WebAssembly.Module): { name: string, kind: "function|table|memory|global" }][]
WebAssembly.Module.imports(module: WebAssembly.Module): { module: string, name: string, kind: "function|table|memory|global" }][]

// validation and error
WebAssembly.validate(bufferSource: ArrayBuffer):boolean

interface CommonError {
  message: string
  filename: string
  lineNumber: number
}
new WebAssembly.CompileError(message: string, fileName: string, lineNumber: number) // 解码,验证阶段
new WebAssembly.LinkError(message: string, fileName: string, lineNumber: number)  // 实例化阶段
new WebAssembly.RuntimeError(message: string, fileName: string, lineNumber: number) // 运行阶段
复制代码

如何初始化一个模块?

Async way:

fetch('./index.wasm').then(response =>
  response.arrayBuffer()
).then(bytes => WebAssembly.instantiate(bytes, {
  env: {
    yyy: xxx
  }
})).then(wasm => {
  const { module, instance } = wasm;
}).catch(console.error);
复制代码

Streaming way:

const source = fetch('./index.wasm')
WebAssembly.compileStreaming(source).then(module =>
  WebAssembly.instantiate(module, {
    env: {
      xxx: yyy
    }
  })
).then(instance => {
  //xxx
}).catch(console.error);
复制代码

Sync way:

const source = fetch('./index.wasm')
WebAssembly.compileStreaming(source).then(module =>
  WebAssembly.instantiate(module, {
    env: {
      xxx: yyy
    }
  })
).then(instance => {
  //xxx
}).catch(console.error);
复制代码

最好的方式是通过 WebAssembly.compileStreaming 的方式来加载。可以对wasm模块提前进行编译验证。

阅读全文 »

深入浅出WebAssembly(1) Compilation

时间: 2021-10-20   |   分类: wasm     |   阅读: 2950 字 ~6分钟

原文链接

这系列主要是我对WASM研究的笔记,可能内容比较简略。总共包括:

  1. 深入浅出WebAssembly(1) Compilation
  2. 深入浅出WebAssembly(2) Basic Api
  3. 深入浅出WebAssembly(3) Instructions
  4. 深入浅出WebAssembly(4) Validation
  5. 深入浅出WebAssembly(5) Memory
  6. 深入浅出WebAssembly(6) Binary Format
  7. 深入浅出WebAssembly(7) Future
  8. 深入浅出WebAssembly(8) Wasm in Rust(TODO)

JS是如何解析运行的?

词法分析

JS代码首先需要经过词法分析器(Lexer)来生成Token,如a = 1 + 2将被解析成{a, =, 1, +, 2}五个Token

阅读全文 »

编程语言、虚拟机和 webAssembly 三者有什么关系

时间: 2021-10-20   |   分类: wasm     |   阅读: 2055 字 ~5分钟

前言:今天我们聊一聊最近很火热的技术 webAssembly。webAssbemly 作为一项新的技术,自 2015 年诞生之初,就逐渐受到人们的关注。那究竟什么是 webAssembly ?它是一门新的编程语言吗?它跟虚拟机又有什么样的关系呢?它有着什么样的应用场景呢?接下来就让我们用 5-10分钟的时间来回答这些问题。

阅读全文 »

WebAssembly 系列(六)WebAssembly 的现在与未来

时间: 2021-10-20   |   分类: wasm     |   阅读: 2147 字 ~5分钟

本文作者:Lin Clark

翻译原文:http://huziketang.com/blog/posts/detail?postId=58ce7fd3a6d8a07e449fdd26

英文原文:Where is WebAssembly now and what’s next?

本文是关于 WebAssembly 系列的第六篇文章(本系列共六篇文章),也同时是本系列的收尾文章。如果你没有读先前文章的话,建议先读这里。如果对 WebAssembly 没概念,建议先读这里。

阅读全文 »
41 42 43 44 45 46 47 48 49

日志
分类
标签
RSS 订阅
GitHub
© 2009 - 2025
粤ICP备2021068940号-1 粤公网安备44011302003059
0%