asm.js使用示例代碼
function mymodule(global, foreign, buffer) {
"use asm";
// -------------------------------------------------------------------------
// SECTION 1: imports
var H32 = new global.Int32Array(buffer);
var HU32 = new global.Uint32Array(buffer);
var log = foreign.consoleDotLog;
// -------------------------------------------------------------------------
// SECTION 2: functions
function f(x, y, z, w) {
// SECTION A: parameter type declarations
x = x|0; // int parameter
y = +y; // double parameter
// SECTION B: function body
log(x|0); // call into FFI -- must force the sign
log(y); // call into FFI -- already know it's a double
x = (x+3)|0; // signed addition
// SECTION C: unconditional return
return ((((x+1)|0)>>>0)/(x|0))>>>0; // compound expression
}
function g() {
g_f = +g_i; // read/write globals
return;
}
function g2() {
return;
}
function h(i, x) {
i = i|0;
x = x|0;
H32[(i&0xffffffff)>>4] = x; // masked by 2^k-1, shifted by byte count
ftable_2[(x-2)&2](); // dynamic call of functions in table 2
}
// -------------------------------------------------------------------------
// SECTION 3: function tables
var ftable_1 = [f];
var ftable_2 = [g, g2]; // all of the same type
// -------------------------------------------------------------------------
// SECTION 4: globals
var g_i = 0; // int global
var g_f = 0.0; // double global
// -------------------------------------------------------------------------
// SECTION 5: exports
return { f_export: f, goop: g };
}
相關(guān)文章
uniapp父子組件傳值3種方法(props、slot和ref)
這篇文章主要給大家介紹了關(guān)于uniapp父子組件傳值的3種方法,方法包括props、slot和ref,最近看到uniapp組件傳值的方法,這里記錄一下,需要的朋友可以參考下2023-07-07Javascript 入門基礎(chǔ)學(xué)習(xí)
習(xí).net已經(jīng)近2年了,最近學(xué)習(xí)Ajax時(shí)發(fā)現(xiàn)自己的很多技術(shù)功底很是欠缺,比如JavaScript。今后我會(huì)將我正在學(xué)習(xí)的也寫成筆記,有時(shí)間的話將以前的東西整理整理也傳上來(lái)。2010-03-03在JavaScript中處理時(shí)間之getHours()方法的使用
這篇文章主要介紹了在JavaScript中處理時(shí)間之getHours()方法的使用,是JS入門學(xué)些中的基礎(chǔ)知識(shí),需要的朋友可以參考下2015-06-06JavaScript中幾種排序算法的簡(jiǎn)單實(shí)現(xiàn)
這篇文章主要介紹了JavaScript中幾種排序算法的簡(jiǎn)單實(shí)現(xiàn),排序是各種編程語(yǔ)言學(xué)習(xí)中都是共通的必會(huì)的基礎(chǔ),需要的朋友可以參考下2015-07-07