├── .gitignore ├── as-pect.config.js ├── assembly ├── __tests__ │ └── example.spec.ts ├── index.ts └── tsconfig.json ├── benchmarks ├── node.js └── rabin-pure.js ├── build ├── .gitignore ├── optimized.wat └── untouched.wat ├── cli ├── bin.js └── rabin-stream.js ├── package.json ├── readme.md ├── src ├── index.js └── rabin.js ├── test.html ├── test ├── 1MiB.txt ├── rand_5MiB.zst └── test.js └── tools ├── wasm2js ├── wasm2js.js └── wasm2js.node.js /.gitignore: -------------------------------------------------------------------------------- 1 | package-lock.json 2 | node_modules 3 | dist 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /as-pect.config.js: -------------------------------------------------------------------------------- 1 | // Docs https://tenner-joshua.gitbook.io/as-pect/cli-configuration 2 | 3 | module.exports = { 4 | include: ["assembly/__tests__/**/*.spec.ts"], 5 | add: ["assembly/__tests__/**/*.include.ts"], 6 | flags: { 7 | "--runtime": ["stub"] 8 | }, 9 | disclude: [/node_modules/], 10 | imports: {}, 11 | performance: { 12 | /** Enable performance statistics gathering for every test. */ 13 | enabled: false, 14 | /** Set the maximum number of samples to run for every test. */ 15 | maxSamples: 10000, 16 | /** Set the maximum test run time in milliseconds for every test. */ 17 | maxTestRunTime: 2000, 18 | /** Report the median time in the default reporter for every test. */ 19 | reportMedian: true, 20 | /** Report the average time in milliseconds for every test. */ 21 | reportAverage: true, 22 | /** Report the standard deviation for every test. */ 23 | reportStandardDeviation: false, 24 | /** Report the maximum run time in milliseconds for every test. */ 25 | reportMax: false, 26 | /** Report the minimum run time in milliseconds for every test. */ 27 | reportMin: false, 28 | }, 29 | outputBinary: false 30 | }; 31 | -------------------------------------------------------------------------------- /assembly/__tests__/example.spec.ts: -------------------------------------------------------------------------------- 1 | import { degree, mod, Rabin } from '../index'; 2 | 3 | NativeMath.seedRandom(2777792873); 4 | 5 | function getRandomArbitrary(min: f64, max: f64): f64 { 6 | return NativeMath.random() * (max - min) + min; 7 | } 8 | 9 | describe("rabin degree", () => { 10 | it("degree should be truthy", () => { 11 | expect(degree(0)).toBe(-1); 12 | }); 13 | 14 | it("mod should be truthy", () => { 15 | expect(mod((0) << 0x3DA3358B4DC173, 0x3DA3358B4DC173)).toBe(0); 16 | }); 17 | 18 | it("fingerprint", () => { 19 | let r = new Rabin(124, 1 * 8, 2 * 8, 64); 20 | let file = new Uint8Array(1024); 21 | for (let i = 0; i < file.length; i++) { 22 | file[i] = getRandomArbitrary(128, 8888); 23 | } 24 | const out = r.fingerprint(file, new Int32Array(file.length / 128)); 25 | 26 | log(out); 27 | const expected = new Int32Array(1); 28 | expected[0] = 16; 29 | expect(out[0]).toBe(expected[0]); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /assembly/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | export const Int32Array_ID = idof(); 3 | export const Uint8Array_ID = idof(); 4 | 5 | const POLYNOMIAL_DEGREE = 53; 6 | const POLYNOMIAL_SHIFT = POLYNOMIAL_DEGREE - 8; 7 | 8 | let tables_initialized = false; 9 | 10 | const modTable = new Uint64Array(256); 11 | const outTable = new Uint64Array(256); 12 | 13 | 14 | @inline 15 | export function degree(polynom: u64): i32 { 16 | return 63 - clz(polynom); 17 | } 18 | 19 | @inline 20 | export function mod(x: u64, p: u64): u64 { 21 | let shift: i32; 22 | let dp = degree(p); 23 | while ((shift = degree(x) - dp) >= 0) { 24 | x ^= p << shift; 25 | } 26 | return x; 27 | } 28 | 29 | @inline 30 | function append_byte(hash: u64, b: u8, pol: u64): u64 { 31 | hash <<= 8; 32 | hash |= b; 33 | 34 | return mod(hash, pol); 35 | } 36 | 37 | @inline 38 | function calc_tables(h: Rabin): void { 39 | for (let b = 0; b < 256; b++) { 40 | let hash: u64 = 0; 41 | 42 | hash = append_byte(hash, b, h.polynomial); 43 | for (let i = 0; i < h.window_size-1; i++) { 44 | hash = append_byte(hash, 0, h.polynomial); 45 | } 46 | unchecked(outTable[b] = hash); 47 | } 48 | 49 | let k = degree(h.polynomial); 50 | for (let b = 0; b < 256; b++) { 51 | const bk = (b) << k; 52 | unchecked(modTable[b] = mod(bk, h.polynomial) | bk); 53 | } 54 | } 55 | 56 | @inline 57 | function rabin_append(h: Rabin, b: u8): void { 58 | let digest = h.digest; 59 | let index = i32(digest >> POLYNOMIAL_SHIFT); 60 | 61 | h.digest = ((digest << 8) | b) ^ unchecked(modTable[index]); 62 | } 63 | 64 | @inline 65 | function rabin_slide(h: Rabin, b: u8): void { 66 | let out = h.window[h.wpos]; 67 | unchecked(h.window[h.wpos] = b); 68 | h.digest ^= unchecked(outTable[out]); 69 | h.wpos = (h.wpos + 1) % h.window_size; 70 | rabin_append(h, b); 71 | } 72 | 73 | @inline 74 | function rabin_reset(h: Rabin): void { 75 | for (let i = 0; i < h.window_size; i++) { 76 | h.window[i] = 0; 77 | } 78 | h.digest = 0; 79 | h.wpos = 0; 80 | h.count = 0; 81 | h.digest = 0; 82 | 83 | rabin_slide(h, 1); 84 | } 85 | 86 | @inline 87 | function rabin_next_chunk(h: Rabin, buf: usize, len: i32): i32 { 88 | for (let i = 0; i < len; i++) { 89 | let b = load(buf + i); 90 | 91 | rabin_slide(h, b); 92 | 93 | h.count++; 94 | h.pos++; 95 | if ((h.count >= h.minsize && ((h.digest & h.mask) == 0)) || h.count >= h.maxsize) { 96 | h.chunk_start = h.start; 97 | h.chunk_length = h.count; 98 | h.chunk_cut_fingerprint = h.digest; 99 | 100 | rabin_reset(h); 101 | return i + 1; 102 | } 103 | } 104 | 105 | return -1; 106 | } 107 | 108 | @inline 109 | function rabin_init(h: Rabin): Rabin { 110 | if (!tables_initialized) { 111 | calc_tables(h); 112 | tables_initialized = true; 113 | } 114 | 115 | h.pos = 0; 116 | h.start = 0; 117 | rabin_reset(h); 118 | 119 | return h; 120 | } 121 | 122 | export class Rabin { 123 | window: Uint8Array 124 | window_size: i32 125 | wpos: i32 126 | count: u64 127 | pos: u64 128 | start: u64 129 | digest: u64 130 | chunk_start: u64 131 | chunk_length: u64 132 | chunk_cut_fingerprint: u64 133 | polynomial: u64 134 | minsize: u64 135 | maxsize: u64 136 | mask: u64 137 | 138 | constructor(average_bits: u32, minsize: u32, maxsize: u32, window_size: i32) { 139 | this.minsize = minsize; 140 | this.maxsize = maxsize; 141 | this.window = new Uint8Array(window_size); 142 | this.window_size = window_size; 143 | this.mask = (1 << average_bits) - 1; 144 | this.polynomial = 0x3DA3358B4DC173; 145 | 146 | rabin_init(this); 147 | } 148 | 149 | fingerprint(buf: Uint8Array, lengths: Int32Array): Int32Array { 150 | let idx = 0; 151 | let len = buf.length; 152 | let ptr = buf.dataStart; 153 | while (true) { 154 | let remaining = rabin_next_chunk(this, ptr, len); 155 | if (remaining < 0) { 156 | break; 157 | } 158 | len -= remaining; 159 | ptr += remaining; 160 | let c = idx++; 161 | // lengths.push(this.chunk_length) 162 | unchecked(lengths[c] = this.chunk_length); 163 | } 164 | return lengths; 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /assembly/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../node_modules/assemblyscript/std/assembly.json", 3 | "include": [ 4 | "./**/*.ts" 5 | ] 6 | } -------------------------------------------------------------------------------- /benchmarks/node.js: -------------------------------------------------------------------------------- 1 | const Benchmark = require('benchmark') 2 | const Rabin = require('rabin') 3 | const RabinWasm = require('../cli/rabin-stream') 4 | const RabinJs = require('./rabin-pure') 5 | const randomStream = require('iso-random-stream') 6 | const suite = new Benchmark.Suite(); 7 | 8 | // add tests 9 | suite 10 | .add('native rabin', { 11 | defer: true, 12 | fn(deferred) { 13 | const rabin = new Rabin() 14 | const data = randomStream(100 * 1000 * 1024) 15 | data.pipe(rabin) 16 | rabin.on('data', () => {}) 17 | 18 | rabin.on('end', () => deferred.resolve()) 19 | } 20 | }) 21 | .add('wasm rabin', { 22 | defer: true, 23 | fn(deferred) { 24 | const rabin = new RabinWasm() 25 | const data = randomStream(100 * 1000 * 1024) 26 | data.pipe(rabin) 27 | rabin.on('data', () => {}) 28 | rabin.on('end', () => deferred.resolve()) 29 | } 30 | }) 31 | // .add('js rabin', { 32 | // defer: true, 33 | // fn(deferred) { 34 | // const rabin = new RabinJs() 35 | // const data = randomStream(100 * 1000 * 1024) 36 | // data.pipe(rabin) 37 | // rabin.on('data', () => {}) 38 | // rabin.on('end', () => deferred.resolve()) 39 | // } 40 | // }) 41 | // add listeners 42 | .on('cycle', function(event) { 43 | console.log(String(event.target)); 44 | }) 45 | .on('complete', function() { 46 | console.log('Fastest is ' + this.filter('fastest').map('name')); 47 | }) 48 | // run async 49 | .run({ 'async': true }); -------------------------------------------------------------------------------- /benchmarks/rabin-pure.js: -------------------------------------------------------------------------------- 1 | const Long = require('long') 2 | class Rabin { 3 | constructor (options = {}) { 4 | this.window = new Array(options.window || 64).fill(Long.fromInt(0)) 5 | this.wpos = 0 6 | this.count = 0 7 | this.digest = Long.fromInt(0) 8 | this.chunkLength = 0 9 | this.polynomial = options.polynomial || 17437180132763653 10 | this.polynomialDegree = 53 11 | this.polynomialShift = this.polynomialDegree - 8 12 | this.averageBits = options.bits || 12 13 | this.minSize = options.min || 8 * 1024 14 | this.maxSize = options.max || 32 * 1024 15 | this.mask = Long.fromInt(1).shiftLeft(this.averageBits).subtract(1) 16 | this.modTable = [] 17 | this.outTable = [] 18 | 19 | this.calculateTables() 20 | } 21 | 22 | calculateTables () { 23 | for (let i = 0; i < 256; i++) { 24 | let hash = Long.fromInt(0, true) 25 | 26 | hash = this.appendByte(hash, i) 27 | 28 | for (let j = 0; j < this.window.length - 1; j++) { 29 | hash = this.appendByte(hash, 0) 30 | } 31 | 32 | this.outTable[i] = hash 33 | } 34 | 35 | const k = this.deg(this.polynomial) 36 | 37 | for (let i = 0; i < 256; i++) { 38 | const b = Long.fromInt(i, true) 39 | 40 | this.modTable[i] = b.shiftLeft(k) 41 | .modulo(this.polynomial) 42 | .or(b.shiftLeft(k)) 43 | } 44 | } 45 | 46 | deg (p) { 47 | let mask = Long.fromString('0x8000000000000000', true, 16) 48 | 49 | for (let i = 0; i < 64; i++) { 50 | if (mask.and(p).greaterThan(0)) { 51 | return Long.fromInt(63 - i) 52 | } 53 | 54 | mask = mask.shiftRight(1) 55 | } 56 | 57 | return Long.fromInt(-1) 58 | } 59 | 60 | appendByte (hash, b) { 61 | hash = hash.shiftLeft(8) 62 | hash = hash.or(b) 63 | 64 | return hash.modulo(this.polynomial) 65 | } 66 | 67 | getFingerprints (bufs) { 68 | const lengths = [] 69 | 70 | for (let i = 0; i < bufs.length; i++) { 71 | let buf = bufs[i] 72 | 73 | while (true) { 74 | const remaining = this.nextChunk(buf) 75 | 76 | if (remaining < 0) { 77 | break 78 | } 79 | 80 | buf = buf.slice(remaining) 81 | 82 | lengths.push(this.chunkLength) 83 | } 84 | } 85 | 86 | return lengths 87 | } 88 | 89 | nextChunk (buf) { 90 | for (let i = 0; i < buf.length; i++) { 91 | const val = Long.fromInt(buf[i]) 92 | 93 | this.slide(val) 94 | 95 | this.count++ 96 | 97 | if ((this.count >= this.minSize && this.digest.and(this.mask).equals(0)) || this.count >= this.maxSize) { 98 | this.chunkLength = this.count 99 | 100 | this.reset() 101 | 102 | return i + 1 103 | } 104 | } 105 | 106 | return -1 107 | } 108 | 109 | slide (value) { 110 | const out = this.window[this.wpos].toInt() & 255 111 | this.window[this.wpos] = value 112 | this.digest = this.digest.xor(this.outTable[out]) 113 | this.wpos = (this.wpos + 1) % this.window.length 114 | 115 | this.append(value) 116 | } 117 | 118 | reset () { 119 | this.window = this.window.map(() => Long.fromInt(0)) 120 | this.wpos = 0 121 | this.count = 0 122 | this.digest = Long.fromInt(0) 123 | 124 | this.slide(Long.fromInt(1)) 125 | } 126 | 127 | append (value) { 128 | const index = this.digest.shiftRight(this.polynomialShift).toInt() & 255 129 | this.digest = this.digest.shiftLeft(8) 130 | this.digest = this.digest.or(value) 131 | 132 | const entry = this.modTable[index] 133 | 134 | if (entry) { 135 | this.digest = this.digest.xor(entry) 136 | } 137 | } 138 | } 139 | 140 | const fs = require('fs'); 141 | const stream = require('readable-stream') 142 | const util = require('util') 143 | const BufferList = require('bl') 144 | const debug = require('debug')('rabin') 145 | 146 | module.exports = RabinStream 147 | 148 | function RabinStream (opts = {}) { 149 | stream.Duplex.call(this) 150 | this._readableState.highWaterMark = 16 151 | this._readableState.objectMode = true 152 | this.destroyed = false 153 | var avgBits = +opts.bits || 12 154 | var min = +opts.min || 8 * 1024 155 | var max = +opts.max || 32 * 1024 156 | this.rabin = new Rabin() 157 | this.nextCb = null 158 | this.buffers = new BufferList() 159 | this.pending = [] 160 | this.on('finish', this._finish) 161 | } 162 | 163 | util.inherits(RabinStream, stream.Duplex) 164 | 165 | RabinStream.prototype._finish = function () { 166 | if (this.destroyed) return 167 | if (this.buffers.length) this.push(this.buffers.slice(0, this.buffers.length)) 168 | this.push(null) 169 | } 170 | 171 | RabinStream.prototype._writev = function (batch, cb) { 172 | if (this.destroyed) return cb() 173 | 174 | for (var i = 0; i < batch.length; i++) { 175 | this.buffers.append(batch[i].chunk) 176 | this.pending.push(batch[i].chunk) 177 | } 178 | this._process(cb) 179 | } 180 | 181 | RabinStream.prototype._read = function (size) { 182 | var nextCb = this.nextCb 183 | if (nextCb) { 184 | this.nextCb = null 185 | nextCb() 186 | } 187 | } 188 | 189 | RabinStream.prototype._write = function (data, enc, cb) { 190 | if (this.destroyed) return cb() 191 | 192 | this.buffers.append(data) 193 | this.pending.push(data) 194 | this._process(cb) 195 | } 196 | 197 | RabinStream.prototype._process = function (cb) { 198 | var drained = true 199 | var sizes = this.rabin.getFingerprints(this.pending) 200 | 201 | this.pending = [] 202 | 203 | debug('chunks', sizes) 204 | 205 | for (var i = 0; i < sizes.length; i++) { 206 | var size = sizes[i] 207 | if(size === 0) break 208 | var buf = this.buffers.slice(0, size) 209 | this.buffers.consume(size) 210 | drained = this.push(buf) 211 | } 212 | 213 | if (drained) cb() 214 | else this.nextCb = cb 215 | } 216 | 217 | RabinStream.prototype.destroy = function (err) { 218 | if (this.destroyed) return 219 | this.destroyed = true 220 | if (err) this.emit('error', err) 221 | this.emit('close') 222 | } -------------------------------------------------------------------------------- /build/.gitignore: -------------------------------------------------------------------------------- 1 | *.wasm 2 | *.wasm.map 3 | *.asm.js 4 | -------------------------------------------------------------------------------- /build/optimized.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_i64_=>_none (func (param i32 i64))) 3 | (type $i32_=>_i64 (func (param i32) (result i64))) 4 | (type $i32_i32_=>_none (func (param i32 i32))) 5 | (type $i32_=>_i32 (func (param i32) (result i32))) 6 | (type $i32_=>_none (func (param i32))) 7 | (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) 8 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 9 | (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) 10 | (type $none_=>_none (func)) 11 | (type $none_=>_i32 (func (result i32))) 12 | (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) 13 | (type $i32_i32_i64_=>_none (func (param i32 i32 i64))) 14 | (type $i32_i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32 i32) (result i32))) 15 | (type $i64_=>_i32 (func (param i64) (result i32))) 16 | (type $i32_i32_=>_i64 (func (param i32 i32) (result i64))) 17 | (type $i64_i64_=>_i64 (func (param i64 i64) (result i64))) 18 | (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) 19 | (memory $0 1) 20 | (data (i32.const 16) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") 21 | (data (i32.const 64) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e") 22 | (data (i32.const 128) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s") 23 | (data (i32.const 176) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") 24 | (data (i32.const 224) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") 25 | (data (i32.const 288) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e") 26 | (data (i32.const 352) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00~\00l\00i\00b\00/\00t\00y\00p\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s") 27 | (data (i32.const 416) "\07\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\91\04\00\00\02\00\00\001\00\00\00\02\00\00\00\11\01\00\00\02\00\00\00\10") 28 | (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) 29 | (global $~lib/rt/tlsf/collectLock (mut i32) (i32.const 0)) 30 | (global $assembly/index/Int32Array_ID i32 (i32.const 3)) 31 | (global $assembly/index/Uint8Array_ID i32 (i32.const 4)) 32 | (global $assembly/index/tables_initialized (mut i32) (i32.const 0)) 33 | (global $assembly/index/modTable (mut i32) (i32.const 0)) 34 | (global $assembly/index/outTable (mut i32) (i32.const 0)) 35 | (global $~lib/rt/__rtti_base i32 (i32.const 416)) 36 | (global $assembly/index/Rabin i32 (i32.const 6)) 37 | (export "memory" (memory $0)) 38 | (export "__alloc" (func $~lib/rt/tlsf/__alloc)) 39 | (export "__retain" (func $~lib/rt/pure/__retain)) 40 | (export "__release" (func $~lib/rt/pure/__release)) 41 | (export "__collect" (func $~lib/rt/pure/__collect)) 42 | (export "__rtti_base" (global $~lib/rt/__rtti_base)) 43 | (export "Int32Array_ID" (global $assembly/index/Int32Array_ID)) 44 | (export "Uint8Array_ID" (global $assembly/index/Uint8Array_ID)) 45 | (export "degree" (func $assembly/index/degree)) 46 | (export "mod" (func $assembly/index/mod)) 47 | (export "Rabin" (global $assembly/index/Rabin)) 48 | (export "Rabin#get:window" (func $assembly/index/Rabin#get:window)) 49 | (export "Rabin#set:window" (func $assembly/index/Rabin#set:window)) 50 | (export "Rabin#get:window_size" (func $assembly/index/Rabin#get:window_size)) 51 | (export "Rabin#set:window_size" (func $assembly/index/Rabin#set:window_size)) 52 | (export "Rabin#get:wpos" (func $assembly/index/Rabin#get:wpos)) 53 | (export "Rabin#set:wpos" (func $assembly/index/Rabin#set:wpos)) 54 | (export "Rabin#get:count" (func $assembly/index/Rabin#get:count)) 55 | (export "Rabin#set:count" (func $assembly/index/Rabin#set:count)) 56 | (export "Rabin#get:pos" (func $assembly/index/Rabin#get:pos)) 57 | (export "Rabin#set:pos" (func $assembly/index/Rabin#set:pos)) 58 | (export "Rabin#get:start" (func $assembly/index/Rabin#get:start)) 59 | (export "Rabin#set:start" (func $assembly/index/Rabin#set:start)) 60 | (export "Rabin#get:digest" (func $assembly/index/Rabin#get:digest)) 61 | (export "Rabin#set:digest" (func $assembly/index/Rabin#set:digest)) 62 | (export "Rabin#get:chunk_start" (func $assembly/index/Rabin#get:chunk_start)) 63 | (export "Rabin#set:chunk_start" (func $assembly/index/Rabin#set:chunk_start)) 64 | (export "Rabin#get:chunk_length" (func $assembly/index/Rabin#get:chunk_length)) 65 | (export "Rabin#set:chunk_length" (func $assembly/index/Rabin#set:chunk_length)) 66 | (export "Rabin#get:chunk_cut_fingerprint" (func $assembly/index/Rabin#get:chunk_cut_fingerprint)) 67 | (export "Rabin#set:chunk_cut_fingerprint" (func $assembly/index/Rabin#set:chunk_cut_fingerprint)) 68 | (export "Rabin#get:polynomial" (func $assembly/index/Rabin#get:polynomial)) 69 | (export "Rabin#set:polynomial" (func $assembly/index/Rabin#set:polynomial)) 70 | (export "Rabin#get:minsize" (func $assembly/index/Rabin#get:minsize)) 71 | (export "Rabin#set:minsize" (func $assembly/index/Rabin#set:minsize)) 72 | (export "Rabin#get:maxsize" (func $assembly/index/Rabin#get:maxsize)) 73 | (export "Rabin#set:maxsize" (func $assembly/index/Rabin#set:maxsize)) 74 | (export "Rabin#get:mask" (func $assembly/index/Rabin#get:mask)) 75 | (export "Rabin#set:mask" (func $assembly/index/Rabin#set:mask)) 76 | (export "Rabin#constructor" (func $assembly/index/Rabin#constructor)) 77 | (export "Rabin#fingerprint" (func $assembly/index/Rabin#fingerprint)) 78 | (start $~start) 79 | (func $~lib/rt/tlsf/removeBlock (; 1 ;) (param $0 i32) (param $1 i32) 80 | (local $2 i32) 81 | (local $3 i32) 82 | (local $4 i32) 83 | (local $5 i32) 84 | local.get $1 85 | i32.load 86 | local.tee $3 87 | i32.const 1 88 | i32.and 89 | i32.eqz 90 | if 91 | i32.const 0 92 | i32.const 32 93 | i32.const 277 94 | i32.const 13 95 | call $~lib/builtins/abort 96 | unreachable 97 | end 98 | local.get $3 99 | i32.const -4 100 | i32.and 101 | local.tee $2 102 | i32.const 16 103 | i32.ge_u 104 | if (result i32) 105 | local.get $2 106 | i32.const 1073741808 107 | i32.lt_u 108 | else 109 | i32.const 0 110 | end 111 | i32.eqz 112 | if 113 | i32.const 0 114 | i32.const 32 115 | i32.const 279 116 | i32.const 13 117 | call $~lib/builtins/abort 118 | unreachable 119 | end 120 | local.get $2 121 | i32.const 256 122 | i32.lt_u 123 | if (result i32) 124 | local.get $2 125 | i32.const 4 126 | i32.shr_u 127 | local.set $2 128 | i32.const 0 129 | else 130 | local.get $2 131 | i32.const 31 132 | local.get $2 133 | i32.clz 134 | i32.sub 135 | local.tee $3 136 | i32.const 4 137 | i32.sub 138 | i32.shr_u 139 | i32.const 16 140 | i32.xor 141 | local.set $2 142 | local.get $3 143 | i32.const 7 144 | i32.sub 145 | end 146 | local.tee $3 147 | i32.const 23 148 | i32.lt_u 149 | if (result i32) 150 | local.get $2 151 | i32.const 16 152 | i32.lt_u 153 | else 154 | i32.const 0 155 | end 156 | i32.eqz 157 | if 158 | i32.const 0 159 | i32.const 32 160 | i32.const 292 161 | i32.const 13 162 | call $~lib/builtins/abort 163 | unreachable 164 | end 165 | local.get $1 166 | i32.load offset=20 167 | local.set $4 168 | local.get $1 169 | i32.load offset=16 170 | local.tee $5 171 | if 172 | local.get $5 173 | local.get $4 174 | i32.store offset=20 175 | end 176 | local.get $4 177 | if 178 | local.get $4 179 | local.get $5 180 | i32.store offset=16 181 | end 182 | local.get $1 183 | local.get $0 184 | local.get $2 185 | local.get $3 186 | i32.const 4 187 | i32.shl 188 | i32.add 189 | i32.const 2 190 | i32.shl 191 | i32.add 192 | i32.load offset=96 193 | i32.eq 194 | if 195 | local.get $0 196 | local.get $2 197 | local.get $3 198 | i32.const 4 199 | i32.shl 200 | i32.add 201 | i32.const 2 202 | i32.shl 203 | i32.add 204 | local.get $4 205 | i32.store offset=96 206 | local.get $4 207 | i32.eqz 208 | if 209 | local.get $0 210 | local.get $3 211 | i32.const 2 212 | i32.shl 213 | i32.add 214 | local.get $0 215 | local.get $3 216 | i32.const 2 217 | i32.shl 218 | i32.add 219 | i32.load offset=4 220 | i32.const 1 221 | local.get $2 222 | i32.shl 223 | i32.const -1 224 | i32.xor 225 | i32.and 226 | local.tee $1 227 | i32.store offset=4 228 | local.get $1 229 | i32.eqz 230 | if 231 | local.get $0 232 | local.get $0 233 | i32.load 234 | i32.const 1 235 | local.get $3 236 | i32.shl 237 | i32.const -1 238 | i32.xor 239 | i32.and 240 | i32.store 241 | end 242 | end 243 | end 244 | ) 245 | (func $~lib/rt/tlsf/insertBlock (; 2 ;) (param $0 i32) (param $1 i32) 246 | (local $2 i32) 247 | (local $3 i32) 248 | (local $4 i32) 249 | (local $5 i32) 250 | (local $6 i32) 251 | (local $7 i32) 252 | local.get $1 253 | i32.eqz 254 | if 255 | i32.const 0 256 | i32.const 32 257 | i32.const 205 258 | i32.const 13 259 | call $~lib/builtins/abort 260 | unreachable 261 | end 262 | local.get $1 263 | i32.load 264 | local.tee $3 265 | i32.const 1 266 | i32.and 267 | i32.eqz 268 | if 269 | i32.const 0 270 | i32.const 32 271 | i32.const 207 272 | i32.const 13 273 | call $~lib/builtins/abort 274 | unreachable 275 | end 276 | local.get $1 277 | i32.const 16 278 | i32.add 279 | local.get $1 280 | i32.load 281 | i32.const -4 282 | i32.and 283 | i32.add 284 | local.tee $4 285 | i32.load 286 | local.tee $5 287 | i32.const 1 288 | i32.and 289 | if 290 | local.get $3 291 | i32.const -4 292 | i32.and 293 | i32.const 16 294 | i32.add 295 | local.get $5 296 | i32.const -4 297 | i32.and 298 | i32.add 299 | local.tee $2 300 | i32.const 1073741808 301 | i32.lt_u 302 | if 303 | local.get $0 304 | local.get $4 305 | call $~lib/rt/tlsf/removeBlock 306 | local.get $1 307 | local.get $2 308 | local.get $3 309 | i32.const 3 310 | i32.and 311 | i32.or 312 | local.tee $3 313 | i32.store 314 | local.get $1 315 | i32.const 16 316 | i32.add 317 | local.get $1 318 | i32.load 319 | i32.const -4 320 | i32.and 321 | i32.add 322 | local.tee $4 323 | i32.load 324 | local.set $5 325 | end 326 | end 327 | local.get $3 328 | i32.const 2 329 | i32.and 330 | if 331 | local.get $1 332 | i32.const 4 333 | i32.sub 334 | i32.load 335 | local.tee $2 336 | i32.load 337 | local.tee $6 338 | i32.const 1 339 | i32.and 340 | i32.eqz 341 | if 342 | i32.const 0 343 | i32.const 32 344 | i32.const 228 345 | i32.const 15 346 | call $~lib/builtins/abort 347 | unreachable 348 | end 349 | local.get $6 350 | i32.const -4 351 | i32.and 352 | i32.const 16 353 | i32.add 354 | local.get $3 355 | i32.const -4 356 | i32.and 357 | i32.add 358 | local.tee $7 359 | i32.const 1073741808 360 | i32.lt_u 361 | if 362 | local.get $0 363 | local.get $2 364 | call $~lib/rt/tlsf/removeBlock 365 | local.get $2 366 | local.get $7 367 | local.get $6 368 | i32.const 3 369 | i32.and 370 | i32.or 371 | local.tee $3 372 | i32.store 373 | local.get $2 374 | local.set $1 375 | end 376 | end 377 | local.get $4 378 | local.get $5 379 | i32.const 2 380 | i32.or 381 | i32.store 382 | local.get $3 383 | i32.const -4 384 | i32.and 385 | local.tee $2 386 | i32.const 16 387 | i32.ge_u 388 | if (result i32) 389 | local.get $2 390 | i32.const 1073741808 391 | i32.lt_u 392 | else 393 | i32.const 0 394 | end 395 | i32.eqz 396 | if 397 | i32.const 0 398 | i32.const 32 399 | i32.const 243 400 | i32.const 13 401 | call $~lib/builtins/abort 402 | unreachable 403 | end 404 | local.get $2 405 | local.get $1 406 | i32.const 16 407 | i32.add 408 | i32.add 409 | local.get $4 410 | i32.ne 411 | if 412 | i32.const 0 413 | i32.const 32 414 | i32.const 244 415 | i32.const 13 416 | call $~lib/builtins/abort 417 | unreachable 418 | end 419 | local.get $4 420 | i32.const 4 421 | i32.sub 422 | local.get $1 423 | i32.store 424 | local.get $2 425 | i32.const 256 426 | i32.lt_u 427 | if (result i32) 428 | local.get $2 429 | i32.const 4 430 | i32.shr_u 431 | local.set $4 432 | i32.const 0 433 | else 434 | local.get $2 435 | i32.const 31 436 | local.get $2 437 | i32.clz 438 | i32.sub 439 | local.tee $2 440 | i32.const 4 441 | i32.sub 442 | i32.shr_u 443 | i32.const 16 444 | i32.xor 445 | local.set $4 446 | local.get $2 447 | i32.const 7 448 | i32.sub 449 | end 450 | local.tee $3 451 | i32.const 23 452 | i32.lt_u 453 | if (result i32) 454 | local.get $4 455 | i32.const 16 456 | i32.lt_u 457 | else 458 | i32.const 0 459 | end 460 | i32.eqz 461 | if 462 | i32.const 0 463 | i32.const 32 464 | i32.const 260 465 | i32.const 13 466 | call $~lib/builtins/abort 467 | unreachable 468 | end 469 | local.get $0 470 | local.get $4 471 | local.get $3 472 | i32.const 4 473 | i32.shl 474 | i32.add 475 | i32.const 2 476 | i32.shl 477 | i32.add 478 | i32.load offset=96 479 | local.set $2 480 | local.get $1 481 | i32.const 0 482 | i32.store offset=16 483 | local.get $1 484 | local.get $2 485 | i32.store offset=20 486 | local.get $2 487 | if 488 | local.get $2 489 | local.get $1 490 | i32.store offset=16 491 | end 492 | local.get $0 493 | local.get $4 494 | local.get $3 495 | i32.const 4 496 | i32.shl 497 | i32.add 498 | i32.const 2 499 | i32.shl 500 | i32.add 501 | local.get $1 502 | i32.store offset=96 503 | local.get $0 504 | local.get $0 505 | i32.load 506 | i32.const 1 507 | local.get $3 508 | i32.shl 509 | i32.or 510 | i32.store 511 | local.get $0 512 | local.get $3 513 | i32.const 2 514 | i32.shl 515 | i32.add 516 | local.get $0 517 | local.get $3 518 | i32.const 2 519 | i32.shl 520 | i32.add 521 | i32.load offset=4 522 | i32.const 1 523 | local.get $4 524 | i32.shl 525 | i32.or 526 | i32.store offset=4 527 | ) 528 | (func $~lib/rt/tlsf/addMemory (; 3 ;) (param $0 i32) (param $1 i32) (param $2 i32) 529 | (local $3 i32) 530 | (local $4 i32) 531 | local.get $2 532 | i32.const 15 533 | i32.and 534 | i32.eqz 535 | i32.const 0 536 | local.get $1 537 | i32.const 15 538 | i32.and 539 | i32.eqz 540 | i32.const 0 541 | local.get $1 542 | local.get $2 543 | i32.le_u 544 | select 545 | select 546 | i32.eqz 547 | if 548 | i32.const 0 549 | i32.const 32 550 | i32.const 386 551 | i32.const 4 552 | call $~lib/builtins/abort 553 | unreachable 554 | end 555 | local.get $0 556 | i32.load offset=1568 557 | local.tee $3 558 | if 559 | local.get $1 560 | local.get $3 561 | i32.const 16 562 | i32.add 563 | i32.lt_u 564 | if 565 | i32.const 0 566 | i32.const 32 567 | i32.const 396 568 | i32.const 15 569 | call $~lib/builtins/abort 570 | unreachable 571 | end 572 | local.get $3 573 | local.get $1 574 | i32.const 16 575 | i32.sub 576 | i32.eq 577 | if 578 | local.get $3 579 | i32.load 580 | local.set $4 581 | local.get $1 582 | i32.const 16 583 | i32.sub 584 | local.set $1 585 | end 586 | else 587 | local.get $1 588 | local.get $0 589 | i32.const 1572 590 | i32.add 591 | i32.lt_u 592 | if 593 | i32.const 0 594 | i32.const 32 595 | i32.const 408 596 | i32.const 4 597 | call $~lib/builtins/abort 598 | unreachable 599 | end 600 | end 601 | local.get $2 602 | local.get $1 603 | i32.sub 604 | local.tee $2 605 | i32.const 48 606 | i32.lt_u 607 | if 608 | return 609 | end 610 | local.get $1 611 | local.get $4 612 | i32.const 2 613 | i32.and 614 | local.get $2 615 | i32.const 32 616 | i32.sub 617 | i32.const 1 618 | i32.or 619 | i32.or 620 | i32.store 621 | local.get $1 622 | i32.const 0 623 | i32.store offset=16 624 | local.get $1 625 | i32.const 0 626 | i32.store offset=20 627 | local.get $1 628 | local.get $2 629 | i32.add 630 | i32.const 16 631 | i32.sub 632 | local.tee $2 633 | i32.const 2 634 | i32.store 635 | local.get $0 636 | local.get $2 637 | i32.store offset=1568 638 | local.get $0 639 | local.get $1 640 | call $~lib/rt/tlsf/insertBlock 641 | ) 642 | (func $~lib/rt/tlsf/maybeInitialize (; 4 ;) (result i32) 643 | (local $0 i32) 644 | (local $1 i32) 645 | (local $2 i32) 646 | global.get $~lib/rt/tlsf/ROOT 647 | local.tee $0 648 | i32.eqz 649 | if 650 | i32.const 1 651 | memory.size 652 | local.tee $0 653 | i32.gt_s 654 | if (result i32) 655 | i32.const 1 656 | local.get $0 657 | i32.sub 658 | memory.grow 659 | i32.const 0 660 | i32.lt_s 661 | else 662 | i32.const 0 663 | end 664 | if 665 | unreachable 666 | end 667 | i32.const 480 668 | local.tee $0 669 | i32.const 0 670 | i32.store 671 | i32.const 2048 672 | i32.const 0 673 | i32.store 674 | loop $for-loop|0 675 | local.get $1 676 | i32.const 23 677 | i32.lt_u 678 | if 679 | local.get $1 680 | i32.const 2 681 | i32.shl 682 | i32.const 480 683 | i32.add 684 | i32.const 0 685 | i32.store offset=4 686 | i32.const 0 687 | local.set $2 688 | loop $for-loop|1 689 | local.get $2 690 | i32.const 16 691 | i32.lt_u 692 | if 693 | local.get $1 694 | i32.const 4 695 | i32.shl 696 | local.get $2 697 | i32.add 698 | i32.const 2 699 | i32.shl 700 | i32.const 480 701 | i32.add 702 | i32.const 0 703 | i32.store offset=96 704 | local.get $2 705 | i32.const 1 706 | i32.add 707 | local.set $2 708 | br $for-loop|1 709 | end 710 | end 711 | local.get $1 712 | i32.const 1 713 | i32.add 714 | local.set $1 715 | br $for-loop|0 716 | end 717 | end 718 | i32.const 480 719 | i32.const 2064 720 | memory.size 721 | i32.const 16 722 | i32.shl 723 | call $~lib/rt/tlsf/addMemory 724 | i32.const 480 725 | global.set $~lib/rt/tlsf/ROOT 726 | end 727 | local.get $0 728 | ) 729 | (func $~lib/rt/tlsf/prepareSize (; 5 ;) (param $0 i32) (result i32) 730 | local.get $0 731 | i32.const 1073741808 732 | i32.ge_u 733 | if 734 | i32.const 80 735 | i32.const 32 736 | i32.const 457 737 | i32.const 29 738 | call $~lib/builtins/abort 739 | unreachable 740 | end 741 | local.get $0 742 | i32.const 15 743 | i32.add 744 | i32.const -16 745 | i32.and 746 | local.tee $0 747 | i32.const 16 748 | local.get $0 749 | i32.const 16 750 | i32.gt_u 751 | select 752 | ) 753 | (func $~lib/rt/tlsf/searchBlock (; 6 ;) (param $0 i32) (param $1 i32) (result i32) 754 | (local $2 i32) 755 | local.get $1 756 | i32.const 256 757 | i32.lt_u 758 | if (result i32) 759 | local.get $1 760 | i32.const 4 761 | i32.shr_u 762 | local.set $1 763 | i32.const 0 764 | else 765 | local.get $1 766 | i32.const 536870904 767 | i32.lt_u 768 | if 769 | local.get $1 770 | i32.const 1 771 | i32.const 27 772 | local.get $1 773 | i32.clz 774 | i32.sub 775 | i32.shl 776 | i32.add 777 | i32.const 1 778 | i32.sub 779 | local.set $1 780 | end 781 | local.get $1 782 | i32.const 31 783 | local.get $1 784 | i32.clz 785 | i32.sub 786 | local.tee $2 787 | i32.const 4 788 | i32.sub 789 | i32.shr_u 790 | i32.const 16 791 | i32.xor 792 | local.set $1 793 | local.get $2 794 | i32.const 7 795 | i32.sub 796 | end 797 | local.tee $2 798 | i32.const 23 799 | i32.lt_u 800 | if (result i32) 801 | local.get $1 802 | i32.const 16 803 | i32.lt_u 804 | else 805 | i32.const 0 806 | end 807 | i32.eqz 808 | if 809 | i32.const 0 810 | i32.const 32 811 | i32.const 338 812 | i32.const 13 813 | call $~lib/builtins/abort 814 | unreachable 815 | end 816 | local.get $0 817 | local.get $2 818 | i32.const 2 819 | i32.shl 820 | i32.add 821 | i32.load offset=4 822 | i32.const -1 823 | local.get $1 824 | i32.shl 825 | i32.and 826 | local.tee $1 827 | if (result i32) 828 | local.get $0 829 | local.get $1 830 | i32.ctz 831 | local.get $2 832 | i32.const 4 833 | i32.shl 834 | i32.add 835 | i32.const 2 836 | i32.shl 837 | i32.add 838 | i32.load offset=96 839 | else 840 | local.get $0 841 | i32.load 842 | i32.const -1 843 | local.get $2 844 | i32.const 1 845 | i32.add 846 | i32.shl 847 | i32.and 848 | local.tee $1 849 | if (result i32) 850 | local.get $0 851 | local.get $1 852 | i32.ctz 853 | local.tee $1 854 | i32.const 2 855 | i32.shl 856 | i32.add 857 | i32.load offset=4 858 | local.tee $2 859 | i32.eqz 860 | if 861 | i32.const 0 862 | i32.const 32 863 | i32.const 351 864 | i32.const 17 865 | call $~lib/builtins/abort 866 | unreachable 867 | end 868 | local.get $0 869 | local.get $2 870 | i32.ctz 871 | local.get $1 872 | i32.const 4 873 | i32.shl 874 | i32.add 875 | i32.const 2 876 | i32.shl 877 | i32.add 878 | i32.load offset=96 879 | else 880 | i32.const 0 881 | end 882 | end 883 | ) 884 | (func $~lib/rt/tlsf/growMemory (; 7 ;) (param $0 i32) (param $1 i32) 885 | (local $2 i32) 886 | memory.size 887 | local.tee $2 888 | i32.const 16 889 | local.get $0 890 | i32.load offset=1568 891 | local.get $2 892 | i32.const 16 893 | i32.shl 894 | i32.const 16 895 | i32.sub 896 | i32.ne 897 | i32.shl 898 | local.get $1 899 | i32.const 1 900 | i32.const 27 901 | local.get $1 902 | i32.clz 903 | i32.sub 904 | i32.shl 905 | i32.const 1 906 | i32.sub 907 | i32.add 908 | local.get $1 909 | local.get $1 910 | i32.const 536870904 911 | i32.lt_u 912 | select 913 | i32.add 914 | i32.const 65535 915 | i32.add 916 | i32.const -65536 917 | i32.and 918 | i32.const 16 919 | i32.shr_u 920 | local.tee $1 921 | local.get $2 922 | local.get $1 923 | i32.gt_s 924 | select 925 | memory.grow 926 | i32.const 0 927 | i32.lt_s 928 | if 929 | local.get $1 930 | memory.grow 931 | i32.const 0 932 | i32.lt_s 933 | if 934 | unreachable 935 | end 936 | end 937 | local.get $0 938 | local.get $2 939 | i32.const 16 940 | i32.shl 941 | memory.size 942 | i32.const 16 943 | i32.shl 944 | call $~lib/rt/tlsf/addMemory 945 | ) 946 | (func $~lib/rt/tlsf/prepareBlock (; 8 ;) (param $0 i32) (param $1 i32) (param $2 i32) 947 | (local $3 i32) 948 | (local $4 i32) 949 | local.get $1 950 | i32.load 951 | local.set $3 952 | local.get $2 953 | i32.const 15 954 | i32.and 955 | if 956 | i32.const 0 957 | i32.const 32 958 | i32.const 365 959 | i32.const 13 960 | call $~lib/builtins/abort 961 | unreachable 962 | end 963 | local.get $3 964 | i32.const -4 965 | i32.and 966 | local.get $2 967 | i32.sub 968 | local.tee $4 969 | i32.const 32 970 | i32.ge_u 971 | if 972 | local.get $1 973 | local.get $2 974 | local.get $3 975 | i32.const 2 976 | i32.and 977 | i32.or 978 | i32.store 979 | local.get $2 980 | local.get $1 981 | i32.const 16 982 | i32.add 983 | i32.add 984 | local.tee $1 985 | local.get $4 986 | i32.const 16 987 | i32.sub 988 | i32.const 1 989 | i32.or 990 | i32.store 991 | local.get $0 992 | local.get $1 993 | call $~lib/rt/tlsf/insertBlock 994 | else 995 | local.get $1 996 | local.get $3 997 | i32.const -2 998 | i32.and 999 | i32.store 1000 | local.get $1 1001 | i32.const 16 1002 | i32.add 1003 | local.get $1 1004 | i32.load 1005 | i32.const -4 1006 | i32.and 1007 | i32.add 1008 | local.get $1 1009 | i32.const 16 1010 | i32.add 1011 | local.get $1 1012 | i32.load 1013 | i32.const -4 1014 | i32.and 1015 | i32.add 1016 | i32.load 1017 | i32.const -3 1018 | i32.and 1019 | i32.store 1020 | end 1021 | ) 1022 | (func $~lib/rt/tlsf/allocateBlock (; 9 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) 1023 | (local $3 i32) 1024 | (local $4 i32) 1025 | global.get $~lib/rt/tlsf/collectLock 1026 | if 1027 | i32.const 0 1028 | i32.const 32 1029 | i32.const 490 1030 | i32.const 13 1031 | call $~lib/builtins/abort 1032 | unreachable 1033 | end 1034 | local.get $0 1035 | local.get $1 1036 | call $~lib/rt/tlsf/prepareSize 1037 | local.tee $4 1038 | call $~lib/rt/tlsf/searchBlock 1039 | local.tee $3 1040 | i32.eqz 1041 | if 1042 | i32.const 1 1043 | global.set $~lib/rt/tlsf/collectLock 1044 | i32.const 0 1045 | global.set $~lib/rt/tlsf/collectLock 1046 | local.get $0 1047 | local.get $4 1048 | call $~lib/rt/tlsf/searchBlock 1049 | local.tee $3 1050 | i32.eqz 1051 | if 1052 | local.get $0 1053 | local.get $4 1054 | call $~lib/rt/tlsf/growMemory 1055 | local.get $0 1056 | local.get $4 1057 | call $~lib/rt/tlsf/searchBlock 1058 | local.tee $3 1059 | i32.eqz 1060 | if 1061 | i32.const 0 1062 | i32.const 32 1063 | i32.const 502 1064 | i32.const 19 1065 | call $~lib/builtins/abort 1066 | unreachable 1067 | end 1068 | end 1069 | end 1070 | local.get $3 1071 | i32.load 1072 | i32.const -4 1073 | i32.and 1074 | local.get $4 1075 | i32.lt_u 1076 | if 1077 | i32.const 0 1078 | i32.const 32 1079 | i32.const 510 1080 | i32.const 13 1081 | call $~lib/builtins/abort 1082 | unreachable 1083 | end 1084 | local.get $3 1085 | i32.const 0 1086 | i32.store offset=4 1087 | local.get $3 1088 | local.get $2 1089 | i32.store offset=8 1090 | local.get $3 1091 | local.get $1 1092 | i32.store offset=12 1093 | local.get $0 1094 | local.get $3 1095 | call $~lib/rt/tlsf/removeBlock 1096 | local.get $0 1097 | local.get $3 1098 | local.get $4 1099 | call $~lib/rt/tlsf/prepareBlock 1100 | local.get $3 1101 | ) 1102 | (func $~lib/rt/tlsf/__alloc (; 10 ;) (param $0 i32) (param $1 i32) (result i32) 1103 | call $~lib/rt/tlsf/maybeInitialize 1104 | local.get $0 1105 | local.get $1 1106 | call $~lib/rt/tlsf/allocateBlock 1107 | i32.const 16 1108 | i32.add 1109 | ) 1110 | (func $~lib/rt/pure/increment (; 11 ;) (param $0 i32) 1111 | (local $1 i32) 1112 | local.get $0 1113 | i32.load offset=4 1114 | local.tee $1 1115 | i32.const -268435456 1116 | i32.and 1117 | local.get $1 1118 | i32.const 1 1119 | i32.add 1120 | i32.const -268435456 1121 | i32.and 1122 | i32.ne 1123 | if 1124 | i32.const 0 1125 | i32.const 144 1126 | i32.const 109 1127 | i32.const 2 1128 | call $~lib/builtins/abort 1129 | unreachable 1130 | end 1131 | local.get $0 1132 | local.get $1 1133 | i32.const 1 1134 | i32.add 1135 | i32.store offset=4 1136 | local.get $0 1137 | i32.load 1138 | i32.const 1 1139 | i32.and 1140 | if 1141 | i32.const 0 1142 | i32.const 144 1143 | i32.const 112 1144 | i32.const 13 1145 | call $~lib/builtins/abort 1146 | unreachable 1147 | end 1148 | ) 1149 | (func $~lib/rt/pure/__retain (; 12 ;) (param $0 i32) (result i32) 1150 | local.get $0 1151 | i32.const 476 1152 | i32.gt_u 1153 | if 1154 | local.get $0 1155 | i32.const 16 1156 | i32.sub 1157 | call $~lib/rt/pure/increment 1158 | end 1159 | local.get $0 1160 | ) 1161 | (func $~lib/rt/pure/__release (; 13 ;) (param $0 i32) 1162 | local.get $0 1163 | i32.const 476 1164 | i32.gt_u 1165 | if 1166 | local.get $0 1167 | i32.const 16 1168 | i32.sub 1169 | call $~lib/rt/pure/decrement 1170 | end 1171 | ) 1172 | (func $~lib/memory/memory.fill (; 14 ;) (param $0 i32) (param $1 i32) 1173 | (local $2 i32) 1174 | block $~lib/util/memory/memset|inlined.0 1175 | local.get $1 1176 | i32.eqz 1177 | br_if $~lib/util/memory/memset|inlined.0 1178 | local.get $0 1179 | i32.const 0 1180 | i32.store8 1181 | local.get $0 1182 | local.get $1 1183 | i32.add 1184 | i32.const 1 1185 | i32.sub 1186 | i32.const 0 1187 | i32.store8 1188 | local.get $1 1189 | i32.const 2 1190 | i32.le_u 1191 | br_if $~lib/util/memory/memset|inlined.0 1192 | local.get $0 1193 | i32.const 1 1194 | i32.add 1195 | i32.const 0 1196 | i32.store8 1197 | local.get $0 1198 | i32.const 2 1199 | i32.add 1200 | i32.const 0 1201 | i32.store8 1202 | local.get $0 1203 | local.get $1 1204 | i32.add 1205 | local.tee $2 1206 | i32.const 2 1207 | i32.sub 1208 | i32.const 0 1209 | i32.store8 1210 | local.get $2 1211 | i32.const 3 1212 | i32.sub 1213 | i32.const 0 1214 | i32.store8 1215 | local.get $1 1216 | i32.const 6 1217 | i32.le_u 1218 | br_if $~lib/util/memory/memset|inlined.0 1219 | local.get $0 1220 | i32.const 3 1221 | i32.add 1222 | i32.const 0 1223 | i32.store8 1224 | local.get $0 1225 | local.get $1 1226 | i32.add 1227 | i32.const 4 1228 | i32.sub 1229 | i32.const 0 1230 | i32.store8 1231 | local.get $1 1232 | i32.const 8 1233 | i32.le_u 1234 | br_if $~lib/util/memory/memset|inlined.0 1235 | local.get $1 1236 | i32.const 0 1237 | local.get $0 1238 | i32.sub 1239 | i32.const 3 1240 | i32.and 1241 | local.tee $1 1242 | i32.sub 1243 | local.set $2 1244 | local.get $0 1245 | local.get $1 1246 | i32.add 1247 | local.tee $0 1248 | i32.const 0 1249 | i32.store 1250 | local.get $0 1251 | local.get $2 1252 | i32.const -4 1253 | i32.and 1254 | local.tee $1 1255 | i32.add 1256 | i32.const 4 1257 | i32.sub 1258 | i32.const 0 1259 | i32.store 1260 | local.get $1 1261 | i32.const 8 1262 | i32.le_u 1263 | br_if $~lib/util/memory/memset|inlined.0 1264 | local.get $0 1265 | i32.const 4 1266 | i32.add 1267 | i32.const 0 1268 | i32.store 1269 | local.get $0 1270 | i32.const 8 1271 | i32.add 1272 | i32.const 0 1273 | i32.store 1274 | local.get $0 1275 | local.get $1 1276 | i32.add 1277 | local.tee $2 1278 | i32.const 12 1279 | i32.sub 1280 | i32.const 0 1281 | i32.store 1282 | local.get $2 1283 | i32.const 8 1284 | i32.sub 1285 | i32.const 0 1286 | i32.store 1287 | local.get $1 1288 | i32.const 24 1289 | i32.le_u 1290 | br_if $~lib/util/memory/memset|inlined.0 1291 | local.get $0 1292 | i32.const 12 1293 | i32.add 1294 | i32.const 0 1295 | i32.store 1296 | local.get $0 1297 | i32.const 16 1298 | i32.add 1299 | i32.const 0 1300 | i32.store 1301 | local.get $0 1302 | i32.const 20 1303 | i32.add 1304 | i32.const 0 1305 | i32.store 1306 | local.get $0 1307 | i32.const 24 1308 | i32.add 1309 | i32.const 0 1310 | i32.store 1311 | local.get $0 1312 | local.get $1 1313 | i32.add 1314 | local.tee $2 1315 | i32.const 28 1316 | i32.sub 1317 | i32.const 0 1318 | i32.store 1319 | local.get $2 1320 | i32.const 24 1321 | i32.sub 1322 | i32.const 0 1323 | i32.store 1324 | local.get $2 1325 | i32.const 20 1326 | i32.sub 1327 | i32.const 0 1328 | i32.store 1329 | local.get $2 1330 | i32.const 16 1331 | i32.sub 1332 | i32.const 0 1333 | i32.store 1334 | local.get $0 1335 | local.get $0 1336 | i32.const 4 1337 | i32.and 1338 | i32.const 24 1339 | i32.add 1340 | local.tee $2 1341 | i32.add 1342 | local.set $0 1343 | local.get $1 1344 | local.get $2 1345 | i32.sub 1346 | local.set $1 1347 | loop $while-continue|0 1348 | local.get $1 1349 | i32.const 32 1350 | i32.ge_u 1351 | if 1352 | local.get $0 1353 | i64.const 0 1354 | i64.store 1355 | local.get $0 1356 | i32.const 8 1357 | i32.add 1358 | i64.const 0 1359 | i64.store 1360 | local.get $0 1361 | i32.const 16 1362 | i32.add 1363 | i64.const 0 1364 | i64.store 1365 | local.get $0 1366 | i32.const 24 1367 | i32.add 1368 | i64.const 0 1369 | i64.store 1370 | local.get $1 1371 | i32.const 32 1372 | i32.sub 1373 | local.set $1 1374 | local.get $0 1375 | i32.const 32 1376 | i32.add 1377 | local.set $0 1378 | br $while-continue|0 1379 | end 1380 | end 1381 | end 1382 | ) 1383 | (func $~lib/arraybuffer/ArrayBufferView#constructor (; 15 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) 1384 | (local $3 i32) 1385 | (local $4 i32) 1386 | local.get $1 1387 | i32.const 1073741808 1388 | local.get $2 1389 | i32.shr_u 1390 | i32.gt_u 1391 | if 1392 | i32.const 192 1393 | i32.const 240 1394 | i32.const 23 1395 | i32.const 56 1396 | call $~lib/builtins/abort 1397 | unreachable 1398 | end 1399 | local.get $1 1400 | local.get $2 1401 | i32.shl 1402 | local.tee $3 1403 | i32.const 0 1404 | call $~lib/rt/tlsf/__alloc 1405 | local.tee $2 1406 | local.get $3 1407 | call $~lib/memory/memory.fill 1408 | local.get $0 1409 | i32.eqz 1410 | if 1411 | i32.const 12 1412 | i32.const 2 1413 | call $~lib/rt/tlsf/__alloc 1414 | call $~lib/rt/pure/__retain 1415 | local.set $0 1416 | end 1417 | local.get $0 1418 | i32.const 0 1419 | i32.store 1420 | local.get $0 1421 | i32.const 0 1422 | i32.store offset=4 1423 | local.get $0 1424 | i32.const 0 1425 | i32.store offset=8 1426 | local.get $2 1427 | local.set $1 1428 | local.get $2 1429 | local.get $0 1430 | i32.load 1431 | local.tee $4 1432 | i32.ne 1433 | if 1434 | local.get $1 1435 | call $~lib/rt/pure/__retain 1436 | local.set $1 1437 | local.get $4 1438 | call $~lib/rt/pure/__release 1439 | end 1440 | local.get $0 1441 | local.get $1 1442 | i32.store 1443 | local.get $0 1444 | local.get $2 1445 | i32.store offset=4 1446 | local.get $0 1447 | local.get $3 1448 | i32.store offset=8 1449 | local.get $0 1450 | ) 1451 | (func $~lib/typedarray/Uint64Array#constructor (; 16 ;) (result i32) 1452 | i32.const 12 1453 | i32.const 5 1454 | call $~lib/rt/tlsf/__alloc 1455 | call $~lib/rt/pure/__retain 1456 | i32.const 256 1457 | i32.const 3 1458 | call $~lib/arraybuffer/ArrayBufferView#constructor 1459 | ) 1460 | (func $assembly/index/degree (; 17 ;) (param $0 i64) (result i32) 1461 | i32.const 63 1462 | local.get $0 1463 | i64.clz 1464 | i32.wrap_i64 1465 | i32.sub 1466 | ) 1467 | (func $assembly/index/mod (; 18 ;) (param $0 i64) (param $1 i64) (result i64) 1468 | (local $2 i32) 1469 | (local $3 i32) 1470 | i32.const 63 1471 | local.get $1 1472 | i64.clz 1473 | i32.wrap_i64 1474 | i32.sub 1475 | local.set $2 1476 | loop $while-continue|0 1477 | i32.const 63 1478 | local.get $0 1479 | i64.clz 1480 | i32.wrap_i64 1481 | i32.sub 1482 | local.get $2 1483 | i32.sub 1484 | local.tee $3 1485 | i32.const 0 1486 | i32.ge_s 1487 | if 1488 | local.get $0 1489 | local.get $1 1490 | local.get $3 1491 | i64.extend_i32_s 1492 | i64.shl 1493 | i64.xor 1494 | local.set $0 1495 | br $while-continue|0 1496 | end 1497 | end 1498 | local.get $0 1499 | ) 1500 | (func $~lib/typedarray/Uint64Array#__uset (; 19 ;) (param $0 i32) (param $1 i32) (param $2 i64) 1501 | local.get $0 1502 | i32.load offset=4 1503 | local.get $1 1504 | i32.const 3 1505 | i32.shl 1506 | i32.add 1507 | local.get $2 1508 | i64.store 1509 | ) 1510 | (func $~lib/typedarray/Uint8Array#__set (; 20 ;) (param $0 i32) (param $1 i32) 1511 | local.get $1 1512 | local.get $0 1513 | i32.load offset=8 1514 | i32.ge_u 1515 | if 1516 | i32.const 304 1517 | i32.const 368 1518 | i32.const 163 1519 | i32.const 44 1520 | call $~lib/builtins/abort 1521 | unreachable 1522 | end 1523 | local.get $1 1524 | local.get $0 1525 | i32.load offset=4 1526 | i32.add 1527 | i32.const 0 1528 | i32.store8 1529 | ) 1530 | (func $~lib/typedarray/Uint8Array#__get (; 21 ;) (param $0 i32) (param $1 i32) (result i32) 1531 | local.get $1 1532 | local.get $0 1533 | i32.load offset=8 1534 | i32.ge_u 1535 | if 1536 | i32.const 304 1537 | i32.const 368 1538 | i32.const 152 1539 | i32.const 44 1540 | call $~lib/builtins/abort 1541 | unreachable 1542 | end 1543 | local.get $1 1544 | local.get $0 1545 | i32.load offset=4 1546 | i32.add 1547 | i32.load8_u 1548 | ) 1549 | (func $~lib/typedarray/Uint8Array#__uset (; 22 ;) (param $0 i32) (param $1 i32) (param $2 i32) 1550 | local.get $1 1551 | local.get $0 1552 | i32.load offset=4 1553 | i32.add 1554 | local.get $2 1555 | i32.store8 1556 | ) 1557 | (func $~lib/typedarray/Uint64Array#__uget (; 23 ;) (param $0 i32) (param $1 i32) (result i64) 1558 | local.get $0 1559 | i32.load offset=4 1560 | local.get $1 1561 | i32.const 3 1562 | i32.shl 1563 | i32.add 1564 | i64.load 1565 | ) 1566 | (func $assembly/index/Rabin#constructor (; 24 ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) 1567 | (local $5 i64) 1568 | (local $6 i64) 1569 | (local $7 i64) 1570 | (local $8 i64) 1571 | local.get $0 1572 | i32.eqz 1573 | if 1574 | i32.const 104 1575 | i32.const 6 1576 | call $~lib/rt/tlsf/__alloc 1577 | call $~lib/rt/pure/__retain 1578 | local.set $0 1579 | end 1580 | local.get $0 1581 | i32.const 0 1582 | i32.store 1583 | local.get $0 1584 | i32.const 0 1585 | i32.store offset=4 1586 | local.get $0 1587 | i32.const 0 1588 | i32.store offset=8 1589 | local.get $0 1590 | i64.const 0 1591 | i64.store offset=16 1592 | local.get $0 1593 | i64.const 0 1594 | i64.store offset=24 1595 | local.get $0 1596 | i64.const 0 1597 | i64.store offset=32 1598 | local.get $0 1599 | i64.const 0 1600 | i64.store offset=40 1601 | local.get $0 1602 | i64.const 0 1603 | i64.store offset=48 1604 | local.get $0 1605 | i64.const 0 1606 | i64.store offset=56 1607 | local.get $0 1608 | i64.const 0 1609 | i64.store offset=64 1610 | local.get $0 1611 | i64.const 0 1612 | i64.store offset=72 1613 | local.get $0 1614 | i64.const 0 1615 | i64.store offset=80 1616 | local.get $0 1617 | i64.const 0 1618 | i64.store offset=88 1619 | local.get $0 1620 | i64.const 0 1621 | i64.store offset=96 1622 | local.get $0 1623 | local.get $2 1624 | i64.extend_i32_u 1625 | i64.store offset=80 1626 | local.get $0 1627 | local.get $3 1628 | i64.extend_i32_u 1629 | i64.store offset=88 1630 | i32.const 12 1631 | i32.const 4 1632 | call $~lib/rt/tlsf/__alloc 1633 | call $~lib/rt/pure/__retain 1634 | local.get $4 1635 | i32.const 0 1636 | call $~lib/arraybuffer/ArrayBufferView#constructor 1637 | local.set $2 1638 | local.get $0 1639 | i32.load 1640 | call $~lib/rt/pure/__release 1641 | local.get $0 1642 | local.get $2 1643 | i32.store 1644 | local.get $0 1645 | local.get $4 1646 | i32.store offset=4 1647 | local.get $0 1648 | i64.const 1 1649 | local.get $1 1650 | i64.extend_i32_u 1651 | i64.shl 1652 | i64.const 1 1653 | i64.sub 1654 | i64.store offset=96 1655 | local.get $0 1656 | i64.const 17349423945073011 1657 | i64.store offset=72 1658 | global.get $assembly/index/tables_initialized 1659 | i32.eqz 1660 | if 1661 | i32.const 0 1662 | local.set $2 1663 | loop $for-loop|0 1664 | local.get $2 1665 | i32.const 256 1666 | i32.lt_s 1667 | if 1668 | local.get $2 1669 | i32.const 255 1670 | i32.and 1671 | i64.extend_i32_u 1672 | local.set $5 1673 | local.get $0 1674 | i64.load offset=72 1675 | local.tee $6 1676 | local.set $7 1677 | i32.const 63 1678 | local.get $6 1679 | i64.clz 1680 | i32.wrap_i64 1681 | i32.sub 1682 | local.set $1 1683 | loop $while-continue|1 1684 | i32.const 63 1685 | local.get $5 1686 | i64.clz 1687 | i32.wrap_i64 1688 | i32.sub 1689 | local.get $1 1690 | i32.sub 1691 | local.tee $3 1692 | i32.const 0 1693 | i32.ge_s 1694 | if 1695 | local.get $5 1696 | local.get $7 1697 | local.get $3 1698 | i64.extend_i32_s 1699 | i64.shl 1700 | i64.xor 1701 | local.set $5 1702 | br $while-continue|1 1703 | end 1704 | end 1705 | i32.const 0 1706 | local.set $4 1707 | loop $for-loop|2 1708 | local.get $4 1709 | local.get $0 1710 | i32.load offset=4 1711 | i32.const 1 1712 | i32.sub 1713 | i32.lt_s 1714 | if 1715 | local.get $5 1716 | i64.const 8 1717 | i64.shl 1718 | local.set $5 1719 | local.get $0 1720 | i64.load offset=72 1721 | local.tee $6 1722 | local.set $7 1723 | i32.const 63 1724 | local.get $6 1725 | i64.clz 1726 | i32.wrap_i64 1727 | i32.sub 1728 | local.set $1 1729 | loop $while-continue|3 1730 | i32.const 63 1731 | local.get $5 1732 | i64.clz 1733 | i32.wrap_i64 1734 | i32.sub 1735 | local.get $1 1736 | i32.sub 1737 | local.tee $3 1738 | i32.const 0 1739 | i32.ge_s 1740 | if 1741 | local.get $5 1742 | local.get $7 1743 | local.get $3 1744 | i64.extend_i32_s 1745 | i64.shl 1746 | i64.xor 1747 | local.set $5 1748 | br $while-continue|3 1749 | end 1750 | end 1751 | local.get $4 1752 | i32.const 1 1753 | i32.add 1754 | local.set $4 1755 | br $for-loop|2 1756 | end 1757 | end 1758 | global.get $assembly/index/outTable 1759 | local.get $2 1760 | local.get $5 1761 | call $~lib/typedarray/Uint64Array#__uset 1762 | local.get $2 1763 | i32.const 1 1764 | i32.add 1765 | local.set $2 1766 | br $for-loop|0 1767 | end 1768 | end 1769 | i32.const 63 1770 | local.get $0 1771 | i64.load offset=72 1772 | i64.clz 1773 | i32.wrap_i64 1774 | i32.sub 1775 | i64.extend_i32_s 1776 | local.set $6 1777 | i32.const 0 1778 | local.set $2 1779 | loop $for-loop|4 1780 | local.get $2 1781 | i32.const 256 1782 | i32.lt_s 1783 | if 1784 | global.get $assembly/index/modTable 1785 | local.get $2 1786 | i64.extend_i32_s 1787 | local.get $6 1788 | i64.shl 1789 | local.tee $7 1790 | local.set $5 1791 | i32.const 63 1792 | local.get $0 1793 | i64.load offset=72 1794 | local.tee $8 1795 | i64.clz 1796 | i32.wrap_i64 1797 | i32.sub 1798 | local.set $3 1799 | loop $while-continue|5 1800 | i32.const 63 1801 | local.get $5 1802 | i64.clz 1803 | i32.wrap_i64 1804 | i32.sub 1805 | local.get $3 1806 | i32.sub 1807 | local.tee $4 1808 | i32.const 0 1809 | i32.ge_s 1810 | if 1811 | local.get $5 1812 | local.get $8 1813 | local.get $4 1814 | i64.extend_i32_s 1815 | i64.shl 1816 | i64.xor 1817 | local.set $5 1818 | br $while-continue|5 1819 | end 1820 | end 1821 | local.get $2 1822 | local.get $5 1823 | local.get $7 1824 | i64.or 1825 | call $~lib/typedarray/Uint64Array#__uset 1826 | local.get $2 1827 | i32.const 1 1828 | i32.add 1829 | local.set $2 1830 | br $for-loop|4 1831 | end 1832 | end 1833 | i32.const 1 1834 | global.set $assembly/index/tables_initialized 1835 | end 1836 | local.get $0 1837 | i64.const 0 1838 | i64.store offset=24 1839 | local.get $0 1840 | i64.const 0 1841 | i64.store offset=32 1842 | i32.const 0 1843 | local.set $2 1844 | loop $for-loop|6 1845 | local.get $2 1846 | local.get $0 1847 | i32.load offset=4 1848 | i32.lt_s 1849 | if 1850 | local.get $0 1851 | i32.load 1852 | local.get $2 1853 | call $~lib/typedarray/Uint8Array#__set 1854 | local.get $2 1855 | i32.const 1 1856 | i32.add 1857 | local.set $2 1858 | br $for-loop|6 1859 | end 1860 | end 1861 | local.get $0 1862 | i64.const 0 1863 | i64.store offset=40 1864 | local.get $0 1865 | i32.const 0 1866 | i32.store offset=8 1867 | local.get $0 1868 | i64.const 0 1869 | i64.store offset=16 1870 | local.get $0 1871 | i64.const 0 1872 | i64.store offset=40 1873 | local.get $0 1874 | i32.load 1875 | local.get $0 1876 | i32.load offset=8 1877 | call $~lib/typedarray/Uint8Array#__get 1878 | local.set $1 1879 | local.get $0 1880 | i32.load 1881 | local.get $0 1882 | i32.load offset=8 1883 | i32.const 1 1884 | call $~lib/typedarray/Uint8Array#__uset 1885 | local.get $0 1886 | local.get $0 1887 | i64.load offset=40 1888 | global.get $assembly/index/outTable 1889 | local.get $1 1890 | call $~lib/typedarray/Uint64Array#__uget 1891 | i64.xor 1892 | i64.store offset=40 1893 | local.get $0 1894 | local.get $0 1895 | i32.load offset=8 1896 | i32.const 1 1897 | i32.add 1898 | local.get $0 1899 | i32.load offset=4 1900 | i32.rem_s 1901 | i32.store offset=8 1902 | local.get $0 1903 | global.get $assembly/index/modTable 1904 | local.get $0 1905 | i64.load offset=40 1906 | local.tee $5 1907 | i64.const 45 1908 | i64.shr_u 1909 | i32.wrap_i64 1910 | call $~lib/typedarray/Uint64Array#__uget 1911 | local.get $5 1912 | i64.const 8 1913 | i64.shl 1914 | i64.const 1 1915 | i64.or 1916 | i64.xor 1917 | i64.store offset=40 1918 | local.get $0 1919 | ) 1920 | (func $assembly/index/Rabin#get:window (; 25 ;) (param $0 i32) (result i32) 1921 | local.get $0 1922 | i32.load 1923 | call $~lib/rt/pure/__retain 1924 | ) 1925 | (func $assembly/index/Rabin#set:window (; 26 ;) (param $0 i32) (param $1 i32) 1926 | (local $2 i32) 1927 | local.get $1 1928 | local.get $0 1929 | i32.load 1930 | local.tee $2 1931 | i32.ne 1932 | if 1933 | local.get $1 1934 | call $~lib/rt/pure/__retain 1935 | drop 1936 | local.get $2 1937 | call $~lib/rt/pure/__release 1938 | end 1939 | local.get $0 1940 | local.get $1 1941 | i32.store 1942 | ) 1943 | (func $assembly/index/Rabin#get:window_size (; 27 ;) (param $0 i32) (result i32) 1944 | local.get $0 1945 | i32.load offset=4 1946 | ) 1947 | (func $assembly/index/Rabin#set:window_size (; 28 ;) (param $0 i32) (param $1 i32) 1948 | local.get $0 1949 | local.get $1 1950 | i32.store offset=4 1951 | ) 1952 | (func $assembly/index/Rabin#get:wpos (; 29 ;) (param $0 i32) (result i32) 1953 | local.get $0 1954 | i32.load offset=8 1955 | ) 1956 | (func $assembly/index/Rabin#set:wpos (; 30 ;) (param $0 i32) (param $1 i32) 1957 | local.get $0 1958 | local.get $1 1959 | i32.store offset=8 1960 | ) 1961 | (func $assembly/index/Rabin#get:count (; 31 ;) (param $0 i32) (result i64) 1962 | local.get $0 1963 | i64.load offset=16 1964 | ) 1965 | (func $assembly/index/Rabin#set:count (; 32 ;) (param $0 i32) (param $1 i64) 1966 | local.get $0 1967 | local.get $1 1968 | i64.store offset=16 1969 | ) 1970 | (func $assembly/index/Rabin#get:pos (; 33 ;) (param $0 i32) (result i64) 1971 | local.get $0 1972 | i64.load offset=24 1973 | ) 1974 | (func $assembly/index/Rabin#set:pos (; 34 ;) (param $0 i32) (param $1 i64) 1975 | local.get $0 1976 | local.get $1 1977 | i64.store offset=24 1978 | ) 1979 | (func $assembly/index/Rabin#get:start (; 35 ;) (param $0 i32) (result i64) 1980 | local.get $0 1981 | i64.load offset=32 1982 | ) 1983 | (func $assembly/index/Rabin#set:start (; 36 ;) (param $0 i32) (param $1 i64) 1984 | local.get $0 1985 | local.get $1 1986 | i64.store offset=32 1987 | ) 1988 | (func $assembly/index/Rabin#get:digest (; 37 ;) (param $0 i32) (result i64) 1989 | local.get $0 1990 | i64.load offset=40 1991 | ) 1992 | (func $assembly/index/Rabin#set:digest (; 38 ;) (param $0 i32) (param $1 i64) 1993 | local.get $0 1994 | local.get $1 1995 | i64.store offset=40 1996 | ) 1997 | (func $assembly/index/Rabin#get:chunk_start (; 39 ;) (param $0 i32) (result i64) 1998 | local.get $0 1999 | i64.load offset=48 2000 | ) 2001 | (func $assembly/index/Rabin#set:chunk_start (; 40 ;) (param $0 i32) (param $1 i64) 2002 | local.get $0 2003 | local.get $1 2004 | i64.store offset=48 2005 | ) 2006 | (func $assembly/index/Rabin#get:chunk_length (; 41 ;) (param $0 i32) (result i64) 2007 | local.get $0 2008 | i64.load offset=56 2009 | ) 2010 | (func $assembly/index/Rabin#set:chunk_length (; 42 ;) (param $0 i32) (param $1 i64) 2011 | local.get $0 2012 | local.get $1 2013 | i64.store offset=56 2014 | ) 2015 | (func $assembly/index/Rabin#get:chunk_cut_fingerprint (; 43 ;) (param $0 i32) (result i64) 2016 | local.get $0 2017 | i64.load offset=64 2018 | ) 2019 | (func $assembly/index/Rabin#set:chunk_cut_fingerprint (; 44 ;) (param $0 i32) (param $1 i64) 2020 | local.get $0 2021 | local.get $1 2022 | i64.store offset=64 2023 | ) 2024 | (func $assembly/index/Rabin#get:polynomial (; 45 ;) (param $0 i32) (result i64) 2025 | local.get $0 2026 | i64.load offset=72 2027 | ) 2028 | (func $assembly/index/Rabin#set:polynomial (; 46 ;) (param $0 i32) (param $1 i64) 2029 | local.get $0 2030 | local.get $1 2031 | i64.store offset=72 2032 | ) 2033 | (func $assembly/index/Rabin#get:minsize (; 47 ;) (param $0 i32) (result i64) 2034 | local.get $0 2035 | i64.load offset=80 2036 | ) 2037 | (func $assembly/index/Rabin#set:minsize (; 48 ;) (param $0 i32) (param $1 i64) 2038 | local.get $0 2039 | local.get $1 2040 | i64.store offset=80 2041 | ) 2042 | (func $assembly/index/Rabin#get:maxsize (; 49 ;) (param $0 i32) (result i64) 2043 | local.get $0 2044 | i64.load offset=88 2045 | ) 2046 | (func $assembly/index/Rabin#set:maxsize (; 50 ;) (param $0 i32) (param $1 i64) 2047 | local.get $0 2048 | local.get $1 2049 | i64.store offset=88 2050 | ) 2051 | (func $assembly/index/Rabin#get:mask (; 51 ;) (param $0 i32) (result i64) 2052 | local.get $0 2053 | i64.load offset=96 2054 | ) 2055 | (func $assembly/index/Rabin#set:mask (; 52 ;) (param $0 i32) (param $1 i64) 2056 | local.get $0 2057 | local.get $1 2058 | i64.store offset=96 2059 | ) 2060 | (func $assembly/index/Rabin#fingerprint (; 53 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) 2061 | (local $3 i32) 2062 | (local $4 i32) 2063 | (local $5 i32) 2064 | (local $6 i64) 2065 | (local $7 i32) 2066 | (local $8 i32) 2067 | local.get $2 2068 | call $~lib/rt/pure/__retain 2069 | local.set $7 2070 | i32.const 0 2071 | local.set $2 2072 | local.get $1 2073 | i32.load offset=8 2074 | local.set $4 2075 | local.get $1 2076 | i32.load offset=4 2077 | local.set $5 2078 | loop $while-continue|0 2079 | block $assembly/index/rabin_next_chunk|inlined.0 (result i32) 2080 | i32.const 0 2081 | local.set $3 2082 | loop $for-loop|1 2083 | local.get $3 2084 | local.get $4 2085 | i32.lt_s 2086 | if 2087 | local.get $3 2088 | local.get $5 2089 | i32.add 2090 | i32.load8_u 2091 | local.set $1 2092 | local.get $0 2093 | i32.load 2094 | local.get $0 2095 | i32.load offset=8 2096 | call $~lib/typedarray/Uint8Array#__get 2097 | local.set $8 2098 | local.get $0 2099 | i32.load 2100 | local.get $0 2101 | i32.load offset=8 2102 | local.get $1 2103 | call $~lib/typedarray/Uint8Array#__uset 2104 | local.get $0 2105 | local.get $0 2106 | i64.load offset=40 2107 | global.get $assembly/index/outTable 2108 | local.get $8 2109 | call $~lib/typedarray/Uint64Array#__uget 2110 | i64.xor 2111 | i64.store offset=40 2112 | local.get $0 2113 | local.get $0 2114 | i32.load offset=8 2115 | i32.const 1 2116 | i32.add 2117 | local.get $0 2118 | i32.load offset=4 2119 | i32.rem_s 2120 | i32.store offset=8 2121 | local.get $0 2122 | global.get $assembly/index/modTable 2123 | local.get $0 2124 | i64.load offset=40 2125 | local.tee $6 2126 | i64.const 45 2127 | i64.shr_u 2128 | i32.wrap_i64 2129 | call $~lib/typedarray/Uint64Array#__uget 2130 | local.get $1 2131 | i64.extend_i32_u 2132 | local.get $6 2133 | i64.const 8 2134 | i64.shl 2135 | i64.or 2136 | i64.xor 2137 | i64.store offset=40 2138 | local.get $0 2139 | local.get $0 2140 | i64.load offset=16 2141 | i64.const 1 2142 | i64.add 2143 | i64.store offset=16 2144 | local.get $0 2145 | local.get $0 2146 | i64.load offset=24 2147 | i64.const 1 2148 | i64.add 2149 | i64.store offset=24 2150 | local.get $0 2151 | i64.load offset=16 2152 | local.get $0 2153 | i64.load offset=80 2154 | i64.ge_u 2155 | if (result i32) 2156 | local.get $0 2157 | i64.load offset=40 2158 | local.get $0 2159 | i64.load offset=96 2160 | i64.and 2161 | i64.eqz 2162 | else 2163 | i32.const 0 2164 | end 2165 | if (result i32) 2166 | i32.const 1 2167 | else 2168 | local.get $0 2169 | i64.load offset=16 2170 | local.get $0 2171 | i64.load offset=88 2172 | i64.ge_u 2173 | end 2174 | if 2175 | local.get $0 2176 | local.get $0 2177 | i64.load offset=32 2178 | i64.store offset=48 2179 | local.get $0 2180 | local.get $0 2181 | i64.load offset=16 2182 | i64.store offset=56 2183 | local.get $0 2184 | local.get $0 2185 | i64.load offset=40 2186 | i64.store offset=64 2187 | i32.const 0 2188 | local.set $1 2189 | loop $for-loop|2 2190 | local.get $1 2191 | local.get $0 2192 | i32.load offset=4 2193 | i32.lt_s 2194 | if 2195 | local.get $0 2196 | i32.load 2197 | local.get $1 2198 | call $~lib/typedarray/Uint8Array#__set 2199 | local.get $1 2200 | i32.const 1 2201 | i32.add 2202 | local.set $1 2203 | br $for-loop|2 2204 | end 2205 | end 2206 | local.get $0 2207 | i64.const 0 2208 | i64.store offset=40 2209 | local.get $0 2210 | i32.const 0 2211 | i32.store offset=8 2212 | local.get $0 2213 | i64.const 0 2214 | i64.store offset=16 2215 | local.get $0 2216 | i64.const 0 2217 | i64.store offset=40 2218 | local.get $0 2219 | i32.load 2220 | local.get $0 2221 | i32.load offset=8 2222 | call $~lib/typedarray/Uint8Array#__get 2223 | local.set $1 2224 | local.get $0 2225 | i32.load 2226 | local.get $0 2227 | i32.load offset=8 2228 | i32.const 1 2229 | call $~lib/typedarray/Uint8Array#__uset 2230 | local.get $0 2231 | local.get $0 2232 | i64.load offset=40 2233 | global.get $assembly/index/outTable 2234 | local.get $1 2235 | call $~lib/typedarray/Uint64Array#__uget 2236 | i64.xor 2237 | i64.store offset=40 2238 | local.get $0 2239 | local.get $0 2240 | i32.load offset=8 2241 | i32.const 1 2242 | i32.add 2243 | local.get $0 2244 | i32.load offset=4 2245 | i32.rem_s 2246 | i32.store offset=8 2247 | local.get $0 2248 | global.get $assembly/index/modTable 2249 | local.get $0 2250 | i64.load offset=40 2251 | local.tee $6 2252 | i64.const 45 2253 | i64.shr_u 2254 | i32.wrap_i64 2255 | call $~lib/typedarray/Uint64Array#__uget 2256 | local.get $6 2257 | i64.const 8 2258 | i64.shl 2259 | i64.const 1 2260 | i64.or 2261 | i64.xor 2262 | i64.store offset=40 2263 | local.get $3 2264 | i32.const 1 2265 | i32.add 2266 | br $assembly/index/rabin_next_chunk|inlined.0 2267 | end 2268 | local.get $3 2269 | i32.const 1 2270 | i32.add 2271 | local.set $3 2272 | br $for-loop|1 2273 | end 2274 | end 2275 | i32.const -1 2276 | end 2277 | local.tee $1 2278 | i32.const 0 2279 | i32.ge_s 2280 | if 2281 | local.get $4 2282 | local.get $1 2283 | i32.sub 2284 | local.set $4 2285 | local.get $1 2286 | local.get $5 2287 | i32.add 2288 | local.set $5 2289 | local.get $2 2290 | local.tee $1 2291 | i32.const 1 2292 | i32.add 2293 | local.set $2 2294 | local.get $7 2295 | i32.load offset=4 2296 | local.get $1 2297 | i32.const 2 2298 | i32.shl 2299 | i32.add 2300 | local.get $0 2301 | i64.load offset=56 2302 | i64.store32 2303 | br $while-continue|0 2304 | end 2305 | end 2306 | local.get $7 2307 | ) 2308 | (func $~start (; 54 ;) 2309 | call $~lib/typedarray/Uint64Array#constructor 2310 | global.set $assembly/index/modTable 2311 | call $~lib/typedarray/Uint64Array#constructor 2312 | global.set $assembly/index/outTable 2313 | ) 2314 | (func $~lib/rt/pure/__collect (; 55 ;) 2315 | nop 2316 | ) 2317 | (func $~lib/rt/pure/decrement (; 56 ;) (param $0 i32) 2318 | (local $1 i32) 2319 | (local $2 i32) 2320 | local.get $0 2321 | i32.load offset=4 2322 | local.tee $2 2323 | i32.const 268435455 2324 | i32.and 2325 | local.set $1 2326 | local.get $0 2327 | i32.load 2328 | i32.const 1 2329 | i32.and 2330 | if 2331 | i32.const 0 2332 | i32.const 144 2333 | i32.const 122 2334 | i32.const 13 2335 | call $~lib/builtins/abort 2336 | unreachable 2337 | end 2338 | local.get $1 2339 | i32.const 1 2340 | i32.eq 2341 | if 2342 | local.get $0 2343 | i32.const 16 2344 | i32.add 2345 | call $~lib/rt/__visit_members 2346 | local.get $2 2347 | i32.const -2147483648 2348 | i32.and 2349 | if 2350 | i32.const 0 2351 | i32.const 144 2352 | i32.const 126 2353 | i32.const 17 2354 | call $~lib/builtins/abort 2355 | unreachable 2356 | end 2357 | local.get $0 2358 | local.get $0 2359 | i32.load 2360 | i32.const 1 2361 | i32.or 2362 | i32.store 2363 | global.get $~lib/rt/tlsf/ROOT 2364 | local.get $0 2365 | call $~lib/rt/tlsf/insertBlock 2366 | else 2367 | local.get $1 2368 | i32.const 0 2369 | i32.le_u 2370 | if 2371 | i32.const 0 2372 | i32.const 144 2373 | i32.const 136 2374 | i32.const 15 2375 | call $~lib/builtins/abort 2376 | unreachable 2377 | end 2378 | local.get $0 2379 | local.get $1 2380 | i32.const 1 2381 | i32.sub 2382 | local.get $2 2383 | i32.const -268435456 2384 | i32.and 2385 | i32.or 2386 | i32.store offset=4 2387 | end 2388 | ) 2389 | (func $~lib/rt/__visit_members (; 57 ;) (param $0 i32) 2390 | block $switch$1$default 2391 | block $switch$1$case$4 2392 | block $switch$1$case$2 2393 | local.get $0 2394 | i32.const 8 2395 | i32.sub 2396 | i32.load 2397 | br_table $switch$1$case$2 $switch$1$case$2 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$default 2398 | end 2399 | return 2400 | end 2401 | local.get $0 2402 | i32.load 2403 | local.tee $0 2404 | if 2405 | local.get $0 2406 | i32.const 476 2407 | i32.ge_u 2408 | if 2409 | local.get $0 2410 | i32.const 16 2411 | i32.sub 2412 | call $~lib/rt/pure/decrement 2413 | end 2414 | end 2415 | return 2416 | end 2417 | unreachable 2418 | ) 2419 | ) 2420 | -------------------------------------------------------------------------------- /build/untouched.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_i64_=>_none (func (param i32 i64))) 3 | (type $i32_=>_i64 (func (param i32) (result i64))) 4 | (type $i32_i32_=>_none (func (param i32 i32))) 5 | (type $i32_=>_i32 (func (param i32) (result i32))) 6 | (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) 7 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 8 | (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) 9 | (type $none_=>_none (func)) 10 | (type $i32_=>_none (func (param i32))) 11 | (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) 12 | (type $i32_i32_i64_=>_none (func (param i32 i32 i64))) 13 | (type $none_=>_i32 (func (result i32))) 14 | (type $i32_i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32 i32) (result i32))) 15 | (type $i64_=>_i32 (func (param i64) (result i32))) 16 | (type $i32_i32_=>_i64 (func (param i32 i32) (result i64))) 17 | (type $i64_i64_=>_i64 (func (param i64 i64) (result i64))) 18 | (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) 19 | (memory $0 1) 20 | (data (i32.const 16) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s\00") 21 | (data (i32.const 64) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00") 22 | (data (i32.const 128) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00") 23 | (data (i32.const 176) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h\00") 24 | (data (i32.const 224) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") 25 | (data (i32.const 288) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e\00") 26 | (data (i32.const 352) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00~\00l\00i\00b\00/\00t\00y\00p\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s\00") 27 | (data (i32.const 416) "\07\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\91\04\00\00\02\00\00\001\00\00\00\02\00\00\00\11\01\00\00\02\00\00\00\10\00\00\00\00\00\00\00") 28 | (table $0 1 funcref) 29 | (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) 30 | (global $~lib/rt/tlsf/collectLock (mut i32) (i32.const 0)) 31 | (global $~lib/gc/gc.auto (mut i32) (i32.const 1)) 32 | (global $assembly/index/Int32Array_ID i32 (i32.const 3)) 33 | (global $assembly/index/Uint8Array_ID i32 (i32.const 4)) 34 | (global $assembly/index/POLYNOMIAL_DEGREE i32 (i32.const 53)) 35 | (global $assembly/index/POLYNOMIAL_SHIFT i32 (i32.const 45)) 36 | (global $assembly/index/tables_initialized (mut i32) (i32.const 0)) 37 | (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) 38 | (global $assembly/index/modTable (mut i32) (i32.const 0)) 39 | (global $assembly/index/outTable (mut i32) (i32.const 0)) 40 | (global $~lib/rt/__rtti_base i32 (i32.const 416)) 41 | (global $~lib/heap/__heap_base i32 (i32.const 476)) 42 | (global $assembly/index/Rabin i32 (i32.const 6)) 43 | (export "memory" (memory $0)) 44 | (export "__alloc" (func $~lib/rt/tlsf/__alloc)) 45 | (export "__retain" (func $~lib/rt/pure/__retain)) 46 | (export "__release" (func $~lib/rt/pure/__release)) 47 | (export "__collect" (func $~lib/rt/pure/__collect)) 48 | (export "__rtti_base" (global $~lib/rt/__rtti_base)) 49 | (export "Int32Array_ID" (global $assembly/index/Int32Array_ID)) 50 | (export "Uint8Array_ID" (global $assembly/index/Uint8Array_ID)) 51 | (export "degree" (func $assembly/index/degree)) 52 | (export "mod" (func $assembly/index/mod)) 53 | (export "Rabin" (global $assembly/index/Rabin)) 54 | (export "Rabin#get:window" (func $assembly/index/Rabin#get:window)) 55 | (export "Rabin#set:window" (func $assembly/index/Rabin#set:window)) 56 | (export "Rabin#get:window_size" (func $assembly/index/Rabin#get:window_size)) 57 | (export "Rabin#set:window_size" (func $assembly/index/Rabin#set:window_size)) 58 | (export "Rabin#get:wpos" (func $assembly/index/Rabin#get:wpos)) 59 | (export "Rabin#set:wpos" (func $assembly/index/Rabin#set:wpos)) 60 | (export "Rabin#get:count" (func $assembly/index/Rabin#get:count)) 61 | (export "Rabin#set:count" (func $assembly/index/Rabin#set:count)) 62 | (export "Rabin#get:pos" (func $assembly/index/Rabin#get:pos)) 63 | (export "Rabin#set:pos" (func $assembly/index/Rabin#set:pos)) 64 | (export "Rabin#get:start" (func $assembly/index/Rabin#get:start)) 65 | (export "Rabin#set:start" (func $assembly/index/Rabin#set:start)) 66 | (export "Rabin#get:digest" (func $assembly/index/Rabin#get:digest)) 67 | (export "Rabin#set:digest" (func $assembly/index/Rabin#set:digest)) 68 | (export "Rabin#get:chunk_start" (func $assembly/index/Rabin#get:chunk_start)) 69 | (export "Rabin#set:chunk_start" (func $assembly/index/Rabin#set:chunk_start)) 70 | (export "Rabin#get:chunk_length" (func $assembly/index/Rabin#get:chunk_length)) 71 | (export "Rabin#set:chunk_length" (func $assembly/index/Rabin#set:chunk_length)) 72 | (export "Rabin#get:chunk_cut_fingerprint" (func $assembly/index/Rabin#get:chunk_cut_fingerprint)) 73 | (export "Rabin#set:chunk_cut_fingerprint" (func $assembly/index/Rabin#set:chunk_cut_fingerprint)) 74 | (export "Rabin#get:polynomial" (func $assembly/index/Rabin#get:polynomial)) 75 | (export "Rabin#set:polynomial" (func $assembly/index/Rabin#set:polynomial)) 76 | (export "Rabin#get:minsize" (func $assembly/index/Rabin#get:minsize)) 77 | (export "Rabin#set:minsize" (func $assembly/index/Rabin#set:minsize)) 78 | (export "Rabin#get:maxsize" (func $assembly/index/Rabin#get:maxsize)) 79 | (export "Rabin#set:maxsize" (func $assembly/index/Rabin#set:maxsize)) 80 | (export "Rabin#get:mask" (func $assembly/index/Rabin#get:mask)) 81 | (export "Rabin#set:mask" (func $assembly/index/Rabin#set:mask)) 82 | (export "Rabin#constructor" (func $assembly/index/Rabin#constructor)) 83 | (export "Rabin#fingerprint" (func $assembly/index/Rabin#fingerprint)) 84 | (start $~start) 85 | (func $~lib/rt/tlsf/removeBlock (; 1 ;) (param $0 i32) (param $1 i32) 86 | (local $2 i32) 87 | (local $3 i32) 88 | (local $4 i32) 89 | (local $5 i32) 90 | (local $6 i32) 91 | (local $7 i32) 92 | (local $8 i32) 93 | (local $9 i32) 94 | (local $10 i32) 95 | (local $11 i32) 96 | local.get $1 97 | i32.load 98 | local.set $2 99 | local.get $2 100 | i32.const 1 101 | i32.and 102 | i32.eqz 103 | if 104 | i32.const 0 105 | i32.const 32 106 | i32.const 277 107 | i32.const 13 108 | call $~lib/builtins/abort 109 | unreachable 110 | end 111 | local.get $2 112 | i32.const 3 113 | i32.const -1 114 | i32.xor 115 | i32.and 116 | local.set $3 117 | local.get $3 118 | i32.const 16 119 | i32.ge_u 120 | if (result i32) 121 | local.get $3 122 | i32.const 1073741808 123 | i32.lt_u 124 | else 125 | i32.const 0 126 | end 127 | i32.eqz 128 | if 129 | i32.const 0 130 | i32.const 32 131 | i32.const 279 132 | i32.const 13 133 | call $~lib/builtins/abort 134 | unreachable 135 | end 136 | local.get $3 137 | i32.const 256 138 | i32.lt_u 139 | if 140 | i32.const 0 141 | local.set $4 142 | local.get $3 143 | i32.const 4 144 | i32.shr_u 145 | local.set $5 146 | else 147 | i32.const 31 148 | local.get $3 149 | i32.clz 150 | i32.sub 151 | local.set $4 152 | local.get $3 153 | local.get $4 154 | i32.const 4 155 | i32.sub 156 | i32.shr_u 157 | i32.const 1 158 | i32.const 4 159 | i32.shl 160 | i32.xor 161 | local.set $5 162 | local.get $4 163 | i32.const 8 164 | i32.const 1 165 | i32.sub 166 | i32.sub 167 | local.set $4 168 | end 169 | local.get $4 170 | i32.const 23 171 | i32.lt_u 172 | if (result i32) 173 | local.get $5 174 | i32.const 16 175 | i32.lt_u 176 | else 177 | i32.const 0 178 | end 179 | i32.eqz 180 | if 181 | i32.const 0 182 | i32.const 32 183 | i32.const 292 184 | i32.const 13 185 | call $~lib/builtins/abort 186 | unreachable 187 | end 188 | local.get $1 189 | i32.load offset=16 190 | local.set $6 191 | local.get $1 192 | i32.load offset=20 193 | local.set $7 194 | local.get $6 195 | if 196 | local.get $6 197 | local.get $7 198 | i32.store offset=20 199 | end 200 | local.get $7 201 | if 202 | local.get $7 203 | local.get $6 204 | i32.store offset=16 205 | end 206 | local.get $1 207 | local.get $0 208 | local.set $10 209 | local.get $4 210 | local.set $9 211 | local.get $5 212 | local.set $8 213 | local.get $10 214 | local.get $9 215 | i32.const 4 216 | i32.shl 217 | local.get $8 218 | i32.add 219 | i32.const 2 220 | i32.shl 221 | i32.add 222 | i32.load offset=96 223 | i32.eq 224 | if 225 | local.get $0 226 | local.set $11 227 | local.get $4 228 | local.set $10 229 | local.get $5 230 | local.set $9 231 | local.get $7 232 | local.set $8 233 | local.get $11 234 | local.get $10 235 | i32.const 4 236 | i32.shl 237 | local.get $9 238 | i32.add 239 | i32.const 2 240 | i32.shl 241 | i32.add 242 | local.get $8 243 | i32.store offset=96 244 | local.get $7 245 | i32.eqz 246 | if 247 | local.get $0 248 | local.set $9 249 | local.get $4 250 | local.set $8 251 | local.get $9 252 | local.get $8 253 | i32.const 2 254 | i32.shl 255 | i32.add 256 | i32.load offset=4 257 | local.set $9 258 | local.get $0 259 | local.set $8 260 | local.get $4 261 | local.set $11 262 | local.get $9 263 | i32.const 1 264 | local.get $5 265 | i32.shl 266 | i32.const -1 267 | i32.xor 268 | i32.and 269 | local.tee $9 270 | local.set $10 271 | local.get $8 272 | local.get $11 273 | i32.const 2 274 | i32.shl 275 | i32.add 276 | local.get $10 277 | i32.store offset=4 278 | local.get $9 279 | i32.eqz 280 | if 281 | local.get $0 282 | local.get $0 283 | i32.load 284 | i32.const 1 285 | local.get $4 286 | i32.shl 287 | i32.const -1 288 | i32.xor 289 | i32.and 290 | i32.store 291 | end 292 | end 293 | end 294 | ) 295 | (func $~lib/rt/tlsf/insertBlock (; 2 ;) (param $0 i32) (param $1 i32) 296 | (local $2 i32) 297 | (local $3 i32) 298 | (local $4 i32) 299 | (local $5 i32) 300 | (local $6 i32) 301 | (local $7 i32) 302 | (local $8 i32) 303 | (local $9 i32) 304 | (local $10 i32) 305 | (local $11 i32) 306 | (local $12 i32) 307 | (local $13 i32) 308 | local.get $1 309 | i32.eqz 310 | if 311 | i32.const 0 312 | i32.const 32 313 | i32.const 205 314 | i32.const 13 315 | call $~lib/builtins/abort 316 | unreachable 317 | end 318 | local.get $1 319 | i32.load 320 | local.set $2 321 | local.get $2 322 | i32.const 1 323 | i32.and 324 | i32.eqz 325 | if 326 | i32.const 0 327 | i32.const 32 328 | i32.const 207 329 | i32.const 13 330 | call $~lib/builtins/abort 331 | unreachable 332 | end 333 | local.get $1 334 | local.set $3 335 | local.get $3 336 | i32.const 16 337 | i32.add 338 | local.get $3 339 | i32.load 340 | i32.const 3 341 | i32.const -1 342 | i32.xor 343 | i32.and 344 | i32.add 345 | local.set $4 346 | local.get $4 347 | i32.load 348 | local.set $5 349 | local.get $5 350 | i32.const 1 351 | i32.and 352 | if 353 | local.get $2 354 | i32.const 3 355 | i32.const -1 356 | i32.xor 357 | i32.and 358 | i32.const 16 359 | i32.add 360 | local.get $5 361 | i32.const 3 362 | i32.const -1 363 | i32.xor 364 | i32.and 365 | i32.add 366 | local.set $3 367 | local.get $3 368 | i32.const 1073741808 369 | i32.lt_u 370 | if 371 | local.get $0 372 | local.get $4 373 | call $~lib/rt/tlsf/removeBlock 374 | local.get $1 375 | local.get $2 376 | i32.const 3 377 | i32.and 378 | local.get $3 379 | i32.or 380 | local.tee $2 381 | i32.store 382 | local.get $1 383 | local.set $6 384 | local.get $6 385 | i32.const 16 386 | i32.add 387 | local.get $6 388 | i32.load 389 | i32.const 3 390 | i32.const -1 391 | i32.xor 392 | i32.and 393 | i32.add 394 | local.set $4 395 | local.get $4 396 | i32.load 397 | local.set $5 398 | end 399 | end 400 | local.get $2 401 | i32.const 2 402 | i32.and 403 | if 404 | local.get $1 405 | local.set $6 406 | local.get $6 407 | i32.const 4 408 | i32.sub 409 | i32.load 410 | local.set $6 411 | local.get $6 412 | i32.load 413 | local.set $3 414 | local.get $3 415 | i32.const 1 416 | i32.and 417 | i32.eqz 418 | if 419 | i32.const 0 420 | i32.const 32 421 | i32.const 228 422 | i32.const 15 423 | call $~lib/builtins/abort 424 | unreachable 425 | end 426 | local.get $3 427 | i32.const 3 428 | i32.const -1 429 | i32.xor 430 | i32.and 431 | i32.const 16 432 | i32.add 433 | local.get $2 434 | i32.const 3 435 | i32.const -1 436 | i32.xor 437 | i32.and 438 | i32.add 439 | local.set $7 440 | local.get $7 441 | i32.const 1073741808 442 | i32.lt_u 443 | if 444 | local.get $0 445 | local.get $6 446 | call $~lib/rt/tlsf/removeBlock 447 | local.get $6 448 | local.get $3 449 | i32.const 3 450 | i32.and 451 | local.get $7 452 | i32.or 453 | local.tee $2 454 | i32.store 455 | local.get $6 456 | local.set $1 457 | end 458 | end 459 | local.get $4 460 | local.get $5 461 | i32.const 2 462 | i32.or 463 | i32.store 464 | local.get $2 465 | i32.const 3 466 | i32.const -1 467 | i32.xor 468 | i32.and 469 | local.set $8 470 | local.get $8 471 | i32.const 16 472 | i32.ge_u 473 | if (result i32) 474 | local.get $8 475 | i32.const 1073741808 476 | i32.lt_u 477 | else 478 | i32.const 0 479 | end 480 | i32.eqz 481 | if 482 | i32.const 0 483 | i32.const 32 484 | i32.const 243 485 | i32.const 13 486 | call $~lib/builtins/abort 487 | unreachable 488 | end 489 | local.get $1 490 | i32.const 16 491 | i32.add 492 | local.get $8 493 | i32.add 494 | local.get $4 495 | i32.eq 496 | i32.eqz 497 | if 498 | i32.const 0 499 | i32.const 32 500 | i32.const 244 501 | i32.const 13 502 | call $~lib/builtins/abort 503 | unreachable 504 | end 505 | local.get $4 506 | i32.const 4 507 | i32.sub 508 | local.get $1 509 | i32.store 510 | local.get $8 511 | i32.const 256 512 | i32.lt_u 513 | if 514 | i32.const 0 515 | local.set $9 516 | local.get $8 517 | i32.const 4 518 | i32.shr_u 519 | local.set $10 520 | else 521 | i32.const 31 522 | local.get $8 523 | i32.clz 524 | i32.sub 525 | local.set $9 526 | local.get $8 527 | local.get $9 528 | i32.const 4 529 | i32.sub 530 | i32.shr_u 531 | i32.const 1 532 | i32.const 4 533 | i32.shl 534 | i32.xor 535 | local.set $10 536 | local.get $9 537 | i32.const 8 538 | i32.const 1 539 | i32.sub 540 | i32.sub 541 | local.set $9 542 | end 543 | local.get $9 544 | i32.const 23 545 | i32.lt_u 546 | if (result i32) 547 | local.get $10 548 | i32.const 16 549 | i32.lt_u 550 | else 551 | i32.const 0 552 | end 553 | i32.eqz 554 | if 555 | i32.const 0 556 | i32.const 32 557 | i32.const 260 558 | i32.const 13 559 | call $~lib/builtins/abort 560 | unreachable 561 | end 562 | local.get $0 563 | local.set $7 564 | local.get $9 565 | local.set $3 566 | local.get $10 567 | local.set $6 568 | local.get $7 569 | local.get $3 570 | i32.const 4 571 | i32.shl 572 | local.get $6 573 | i32.add 574 | i32.const 2 575 | i32.shl 576 | i32.add 577 | i32.load offset=96 578 | local.set $11 579 | local.get $1 580 | i32.const 0 581 | i32.store offset=16 582 | local.get $1 583 | local.get $11 584 | i32.store offset=20 585 | local.get $11 586 | if 587 | local.get $11 588 | local.get $1 589 | i32.store offset=16 590 | end 591 | local.get $0 592 | local.set $12 593 | local.get $9 594 | local.set $7 595 | local.get $10 596 | local.set $3 597 | local.get $1 598 | local.set $6 599 | local.get $12 600 | local.get $7 601 | i32.const 4 602 | i32.shl 603 | local.get $3 604 | i32.add 605 | i32.const 2 606 | i32.shl 607 | i32.add 608 | local.get $6 609 | i32.store offset=96 610 | local.get $0 611 | local.get $0 612 | i32.load 613 | i32.const 1 614 | local.get $9 615 | i32.shl 616 | i32.or 617 | i32.store 618 | local.get $0 619 | local.set $13 620 | local.get $9 621 | local.set $12 622 | local.get $0 623 | local.set $3 624 | local.get $9 625 | local.set $6 626 | local.get $3 627 | local.get $6 628 | i32.const 2 629 | i32.shl 630 | i32.add 631 | i32.load offset=4 632 | i32.const 1 633 | local.get $10 634 | i32.shl 635 | i32.or 636 | local.set $7 637 | local.get $13 638 | local.get $12 639 | i32.const 2 640 | i32.shl 641 | i32.add 642 | local.get $7 643 | i32.store offset=4 644 | ) 645 | (func $~lib/rt/tlsf/addMemory (; 3 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) 646 | (local $3 i32) 647 | (local $4 i32) 648 | (local $5 i32) 649 | (local $6 i32) 650 | (local $7 i32) 651 | (local $8 i32) 652 | (local $9 i32) 653 | local.get $1 654 | local.get $2 655 | i32.le_u 656 | if (result i32) 657 | local.get $1 658 | i32.const 15 659 | i32.and 660 | i32.eqz 661 | else 662 | i32.const 0 663 | end 664 | if (result i32) 665 | local.get $2 666 | i32.const 15 667 | i32.and 668 | i32.eqz 669 | else 670 | i32.const 0 671 | end 672 | i32.eqz 673 | if 674 | i32.const 0 675 | i32.const 32 676 | i32.const 386 677 | i32.const 4 678 | call $~lib/builtins/abort 679 | unreachable 680 | end 681 | local.get $0 682 | local.set $3 683 | local.get $3 684 | i32.load offset=1568 685 | local.set $4 686 | i32.const 0 687 | local.set $5 688 | local.get $4 689 | if 690 | local.get $1 691 | local.get $4 692 | i32.const 16 693 | i32.add 694 | i32.ge_u 695 | i32.eqz 696 | if 697 | i32.const 0 698 | i32.const 32 699 | i32.const 396 700 | i32.const 15 701 | call $~lib/builtins/abort 702 | unreachable 703 | end 704 | local.get $1 705 | i32.const 16 706 | i32.sub 707 | local.get $4 708 | i32.eq 709 | if 710 | local.get $1 711 | i32.const 16 712 | i32.sub 713 | local.set $1 714 | local.get $4 715 | i32.load 716 | local.set $5 717 | else 718 | nop 719 | end 720 | else 721 | local.get $1 722 | local.get $0 723 | i32.const 1572 724 | i32.add 725 | i32.ge_u 726 | i32.eqz 727 | if 728 | i32.const 0 729 | i32.const 32 730 | i32.const 408 731 | i32.const 4 732 | call $~lib/builtins/abort 733 | unreachable 734 | end 735 | end 736 | local.get $2 737 | local.get $1 738 | i32.sub 739 | local.set $6 740 | local.get $6 741 | i32.const 48 742 | i32.lt_u 743 | if 744 | i32.const 0 745 | return 746 | end 747 | local.get $6 748 | i32.const 16 749 | i32.const 1 750 | i32.shl 751 | i32.sub 752 | local.set $7 753 | local.get $1 754 | local.set $8 755 | local.get $8 756 | local.get $7 757 | i32.const 1 758 | i32.or 759 | local.get $5 760 | i32.const 2 761 | i32.and 762 | i32.or 763 | i32.store 764 | local.get $8 765 | i32.const 0 766 | i32.store offset=16 767 | local.get $8 768 | i32.const 0 769 | i32.store offset=20 770 | local.get $1 771 | local.get $6 772 | i32.add 773 | i32.const 16 774 | i32.sub 775 | local.set $4 776 | local.get $4 777 | i32.const 0 778 | i32.const 2 779 | i32.or 780 | i32.store 781 | local.get $0 782 | local.set $9 783 | local.get $4 784 | local.set $3 785 | local.get $9 786 | local.get $3 787 | i32.store offset=1568 788 | local.get $0 789 | local.get $8 790 | call $~lib/rt/tlsf/insertBlock 791 | i32.const 1 792 | ) 793 | (func $~lib/rt/tlsf/maybeInitialize (; 4 ;) (result i32) 794 | (local $0 i32) 795 | (local $1 i32) 796 | (local $2 i32) 797 | (local $3 i32) 798 | (local $4 i32) 799 | (local $5 i32) 800 | (local $6 i32) 801 | (local $7 i32) 802 | (local $8 i32) 803 | (local $9 i32) 804 | (local $10 i32) 805 | (local $11 i32) 806 | global.get $~lib/rt/tlsf/ROOT 807 | local.set $0 808 | local.get $0 809 | i32.eqz 810 | if 811 | global.get $~lib/heap/__heap_base 812 | i32.const 15 813 | i32.add 814 | i32.const -16 815 | i32.and 816 | local.set $1 817 | memory.size 818 | local.set $2 819 | local.get $1 820 | i32.const 1572 821 | i32.add 822 | i32.const 65535 823 | i32.add 824 | i32.const 65535 825 | i32.const -1 826 | i32.xor 827 | i32.and 828 | i32.const 16 829 | i32.shr_u 830 | local.set $3 831 | local.get $3 832 | local.get $2 833 | i32.gt_s 834 | if (result i32) 835 | local.get $3 836 | local.get $2 837 | i32.sub 838 | memory.grow 839 | i32.const 0 840 | i32.lt_s 841 | else 842 | i32.const 0 843 | end 844 | if 845 | unreachable 846 | end 847 | local.get $1 848 | local.set $0 849 | local.get $0 850 | i32.const 0 851 | i32.store 852 | local.get $0 853 | local.set $5 854 | i32.const 0 855 | local.set $4 856 | local.get $5 857 | local.get $4 858 | i32.store offset=1568 859 | i32.const 0 860 | local.set $5 861 | loop $for-loop|0 862 | local.get $5 863 | i32.const 23 864 | i32.lt_u 865 | local.set $4 866 | local.get $4 867 | if 868 | local.get $0 869 | local.set $8 870 | local.get $5 871 | local.set $7 872 | i32.const 0 873 | local.set $6 874 | local.get $8 875 | local.get $7 876 | i32.const 2 877 | i32.shl 878 | i32.add 879 | local.get $6 880 | i32.store offset=4 881 | i32.const 0 882 | local.set $8 883 | loop $for-loop|1 884 | local.get $8 885 | i32.const 16 886 | i32.lt_u 887 | local.set $7 888 | local.get $7 889 | if 890 | local.get $0 891 | local.set $11 892 | local.get $5 893 | local.set $10 894 | local.get $8 895 | local.set $9 896 | i32.const 0 897 | local.set $6 898 | local.get $11 899 | local.get $10 900 | i32.const 4 901 | i32.shl 902 | local.get $9 903 | i32.add 904 | i32.const 2 905 | i32.shl 906 | i32.add 907 | local.get $6 908 | i32.store offset=96 909 | local.get $8 910 | i32.const 1 911 | i32.add 912 | local.set $8 913 | br $for-loop|1 914 | end 915 | end 916 | local.get $5 917 | i32.const 1 918 | i32.add 919 | local.set $5 920 | br $for-loop|0 921 | end 922 | end 923 | local.get $0 924 | local.get $1 925 | i32.const 1572 926 | i32.add 927 | i32.const 15 928 | i32.add 929 | i32.const 15 930 | i32.const -1 931 | i32.xor 932 | i32.and 933 | memory.size 934 | i32.const 16 935 | i32.shl 936 | call $~lib/rt/tlsf/addMemory 937 | drop 938 | local.get $0 939 | global.set $~lib/rt/tlsf/ROOT 940 | end 941 | local.get $0 942 | ) 943 | (func $~lib/rt/tlsf/prepareSize (; 5 ;) (param $0 i32) (result i32) 944 | (local $1 i32) 945 | (local $2 i32) 946 | local.get $0 947 | i32.const 1073741808 948 | i32.ge_u 949 | if 950 | i32.const 80 951 | i32.const 32 952 | i32.const 457 953 | i32.const 29 954 | call $~lib/builtins/abort 955 | unreachable 956 | end 957 | local.get $0 958 | i32.const 15 959 | i32.add 960 | i32.const 15 961 | i32.const -1 962 | i32.xor 963 | i32.and 964 | local.tee $1 965 | i32.const 16 966 | local.tee $2 967 | local.get $1 968 | local.get $2 969 | i32.gt_u 970 | select 971 | ) 972 | (func $~lib/rt/tlsf/searchBlock (; 6 ;) (param $0 i32) (param $1 i32) (result i32) 973 | (local $2 i32) 974 | (local $3 i32) 975 | (local $4 i32) 976 | (local $5 i32) 977 | (local $6 i32) 978 | (local $7 i32) 979 | (local $8 i32) 980 | (local $9 i32) 981 | local.get $1 982 | i32.const 256 983 | i32.lt_u 984 | if 985 | i32.const 0 986 | local.set $2 987 | local.get $1 988 | i32.const 4 989 | i32.shr_u 990 | local.set $3 991 | else 992 | local.get $1 993 | i32.const 536870904 994 | i32.lt_u 995 | if (result i32) 996 | local.get $1 997 | i32.const 1 998 | i32.const 27 999 | local.get $1 1000 | i32.clz 1001 | i32.sub 1002 | i32.shl 1003 | i32.add 1004 | i32.const 1 1005 | i32.sub 1006 | else 1007 | local.get $1 1008 | end 1009 | local.set $4 1010 | i32.const 31 1011 | local.get $4 1012 | i32.clz 1013 | i32.sub 1014 | local.set $2 1015 | local.get $4 1016 | local.get $2 1017 | i32.const 4 1018 | i32.sub 1019 | i32.shr_u 1020 | i32.const 1 1021 | i32.const 4 1022 | i32.shl 1023 | i32.xor 1024 | local.set $3 1025 | local.get $2 1026 | i32.const 8 1027 | i32.const 1 1028 | i32.sub 1029 | i32.sub 1030 | local.set $2 1031 | end 1032 | local.get $2 1033 | i32.const 23 1034 | i32.lt_u 1035 | if (result i32) 1036 | local.get $3 1037 | i32.const 16 1038 | i32.lt_u 1039 | else 1040 | i32.const 0 1041 | end 1042 | i32.eqz 1043 | if 1044 | i32.const 0 1045 | i32.const 32 1046 | i32.const 338 1047 | i32.const 13 1048 | call $~lib/builtins/abort 1049 | unreachable 1050 | end 1051 | local.get $0 1052 | local.set $5 1053 | local.get $2 1054 | local.set $4 1055 | local.get $5 1056 | local.get $4 1057 | i32.const 2 1058 | i32.shl 1059 | i32.add 1060 | i32.load offset=4 1061 | i32.const 0 1062 | i32.const -1 1063 | i32.xor 1064 | local.get $3 1065 | i32.shl 1066 | i32.and 1067 | local.set $6 1068 | i32.const 0 1069 | local.set $7 1070 | local.get $6 1071 | i32.eqz 1072 | if 1073 | local.get $0 1074 | i32.load 1075 | i32.const 0 1076 | i32.const -1 1077 | i32.xor 1078 | local.get $2 1079 | i32.const 1 1080 | i32.add 1081 | i32.shl 1082 | i32.and 1083 | local.set $5 1084 | local.get $5 1085 | i32.eqz 1086 | if 1087 | i32.const 0 1088 | local.set $7 1089 | else 1090 | local.get $5 1091 | i32.ctz 1092 | local.set $2 1093 | local.get $0 1094 | local.set $8 1095 | local.get $2 1096 | local.set $4 1097 | local.get $8 1098 | local.get $4 1099 | i32.const 2 1100 | i32.shl 1101 | i32.add 1102 | i32.load offset=4 1103 | local.set $6 1104 | local.get $6 1105 | i32.eqz 1106 | if 1107 | i32.const 0 1108 | i32.const 32 1109 | i32.const 351 1110 | i32.const 17 1111 | call $~lib/builtins/abort 1112 | unreachable 1113 | end 1114 | local.get $0 1115 | local.set $9 1116 | local.get $2 1117 | local.set $8 1118 | local.get $6 1119 | i32.ctz 1120 | local.set $4 1121 | local.get $9 1122 | local.get $8 1123 | i32.const 4 1124 | i32.shl 1125 | local.get $4 1126 | i32.add 1127 | i32.const 2 1128 | i32.shl 1129 | i32.add 1130 | i32.load offset=96 1131 | local.set $7 1132 | end 1133 | else 1134 | local.get $0 1135 | local.set $9 1136 | local.get $2 1137 | local.set $8 1138 | local.get $6 1139 | i32.ctz 1140 | local.set $4 1141 | local.get $9 1142 | local.get $8 1143 | i32.const 4 1144 | i32.shl 1145 | local.get $4 1146 | i32.add 1147 | i32.const 2 1148 | i32.shl 1149 | i32.add 1150 | i32.load offset=96 1151 | local.set $7 1152 | end 1153 | local.get $7 1154 | ) 1155 | (func $~lib/rt/tlsf/growMemory (; 7 ;) (param $0 i32) (param $1 i32) 1156 | (local $2 i32) 1157 | (local $3 i32) 1158 | (local $4 i32) 1159 | (local $5 i32) 1160 | (local $6 i32) 1161 | (local $7 i32) 1162 | local.get $1 1163 | i32.const 536870904 1164 | i32.lt_u 1165 | if 1166 | local.get $1 1167 | i32.const 1 1168 | i32.const 27 1169 | local.get $1 1170 | i32.clz 1171 | i32.sub 1172 | i32.shl 1173 | i32.const 1 1174 | i32.sub 1175 | i32.add 1176 | local.set $1 1177 | end 1178 | memory.size 1179 | local.set $2 1180 | local.get $1 1181 | i32.const 16 1182 | local.get $2 1183 | i32.const 16 1184 | i32.shl 1185 | i32.const 16 1186 | i32.sub 1187 | local.get $0 1188 | local.set $3 1189 | local.get $3 1190 | i32.load offset=1568 1191 | i32.ne 1192 | i32.shl 1193 | i32.add 1194 | local.set $1 1195 | local.get $1 1196 | i32.const 65535 1197 | i32.add 1198 | i32.const 65535 1199 | i32.const -1 1200 | i32.xor 1201 | i32.and 1202 | i32.const 16 1203 | i32.shr_u 1204 | local.set $4 1205 | local.get $2 1206 | local.tee $3 1207 | local.get $4 1208 | local.tee $5 1209 | local.get $3 1210 | local.get $5 1211 | i32.gt_s 1212 | select 1213 | local.set $6 1214 | local.get $6 1215 | memory.grow 1216 | i32.const 0 1217 | i32.lt_s 1218 | if 1219 | local.get $4 1220 | memory.grow 1221 | i32.const 0 1222 | i32.lt_s 1223 | if 1224 | unreachable 1225 | end 1226 | end 1227 | memory.size 1228 | local.set $7 1229 | local.get $0 1230 | local.get $2 1231 | i32.const 16 1232 | i32.shl 1233 | local.get $7 1234 | i32.const 16 1235 | i32.shl 1236 | call $~lib/rt/tlsf/addMemory 1237 | drop 1238 | ) 1239 | (func $~lib/rt/tlsf/prepareBlock (; 8 ;) (param $0 i32) (param $1 i32) (param $2 i32) 1240 | (local $3 i32) 1241 | (local $4 i32) 1242 | (local $5 i32) 1243 | local.get $1 1244 | i32.load 1245 | local.set $3 1246 | local.get $2 1247 | i32.const 15 1248 | i32.and 1249 | i32.eqz 1250 | i32.eqz 1251 | if 1252 | i32.const 0 1253 | i32.const 32 1254 | i32.const 365 1255 | i32.const 13 1256 | call $~lib/builtins/abort 1257 | unreachable 1258 | end 1259 | local.get $3 1260 | i32.const 3 1261 | i32.const -1 1262 | i32.xor 1263 | i32.and 1264 | local.get $2 1265 | i32.sub 1266 | local.set $4 1267 | local.get $4 1268 | i32.const 32 1269 | i32.ge_u 1270 | if 1271 | local.get $1 1272 | local.get $2 1273 | local.get $3 1274 | i32.const 2 1275 | i32.and 1276 | i32.or 1277 | i32.store 1278 | local.get $1 1279 | i32.const 16 1280 | i32.add 1281 | local.get $2 1282 | i32.add 1283 | local.set $5 1284 | local.get $5 1285 | local.get $4 1286 | i32.const 16 1287 | i32.sub 1288 | i32.const 1 1289 | i32.or 1290 | i32.store 1291 | local.get $0 1292 | local.get $5 1293 | call $~lib/rt/tlsf/insertBlock 1294 | else 1295 | local.get $1 1296 | local.get $3 1297 | i32.const 1 1298 | i32.const -1 1299 | i32.xor 1300 | i32.and 1301 | i32.store 1302 | local.get $1 1303 | local.set $5 1304 | local.get $5 1305 | i32.const 16 1306 | i32.add 1307 | local.get $5 1308 | i32.load 1309 | i32.const 3 1310 | i32.const -1 1311 | i32.xor 1312 | i32.and 1313 | i32.add 1314 | local.get $1 1315 | local.set $5 1316 | local.get $5 1317 | i32.const 16 1318 | i32.add 1319 | local.get $5 1320 | i32.load 1321 | i32.const 3 1322 | i32.const -1 1323 | i32.xor 1324 | i32.and 1325 | i32.add 1326 | i32.load 1327 | i32.const 2 1328 | i32.const -1 1329 | i32.xor 1330 | i32.and 1331 | i32.store 1332 | end 1333 | ) 1334 | (func $~lib/rt/tlsf/allocateBlock (; 9 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) 1335 | (local $3 i32) 1336 | (local $4 i32) 1337 | global.get $~lib/rt/tlsf/collectLock 1338 | i32.eqz 1339 | i32.eqz 1340 | if 1341 | i32.const 0 1342 | i32.const 32 1343 | i32.const 490 1344 | i32.const 13 1345 | call $~lib/builtins/abort 1346 | unreachable 1347 | end 1348 | local.get $1 1349 | call $~lib/rt/tlsf/prepareSize 1350 | local.set $3 1351 | local.get $0 1352 | local.get $3 1353 | call $~lib/rt/tlsf/searchBlock 1354 | local.set $4 1355 | local.get $4 1356 | i32.eqz 1357 | if 1358 | global.get $~lib/gc/gc.auto 1359 | if 1360 | i32.const 1 1361 | global.set $~lib/rt/tlsf/collectLock 1362 | call $~lib/rt/pure/__collect 1363 | i32.const 0 1364 | global.set $~lib/rt/tlsf/collectLock 1365 | local.get $0 1366 | local.get $3 1367 | call $~lib/rt/tlsf/searchBlock 1368 | local.set $4 1369 | local.get $4 1370 | i32.eqz 1371 | if 1372 | local.get $0 1373 | local.get $3 1374 | call $~lib/rt/tlsf/growMemory 1375 | local.get $0 1376 | local.get $3 1377 | call $~lib/rt/tlsf/searchBlock 1378 | local.set $4 1379 | local.get $4 1380 | i32.eqz 1381 | if 1382 | i32.const 0 1383 | i32.const 32 1384 | i32.const 502 1385 | i32.const 19 1386 | call $~lib/builtins/abort 1387 | unreachable 1388 | end 1389 | end 1390 | else 1391 | local.get $0 1392 | local.get $3 1393 | call $~lib/rt/tlsf/growMemory 1394 | local.get $0 1395 | local.get $3 1396 | call $~lib/rt/tlsf/searchBlock 1397 | local.set $4 1398 | local.get $4 1399 | i32.eqz 1400 | if 1401 | i32.const 0 1402 | i32.const 32 1403 | i32.const 507 1404 | i32.const 17 1405 | call $~lib/builtins/abort 1406 | unreachable 1407 | end 1408 | end 1409 | end 1410 | local.get $4 1411 | i32.load 1412 | i32.const -4 1413 | i32.and 1414 | local.get $3 1415 | i32.ge_u 1416 | i32.eqz 1417 | if 1418 | i32.const 0 1419 | i32.const 32 1420 | i32.const 510 1421 | i32.const 13 1422 | call $~lib/builtins/abort 1423 | unreachable 1424 | end 1425 | local.get $4 1426 | i32.const 0 1427 | i32.store offset=4 1428 | local.get $4 1429 | local.get $2 1430 | i32.store offset=8 1431 | local.get $4 1432 | local.get $1 1433 | i32.store offset=12 1434 | local.get $0 1435 | local.get $4 1436 | call $~lib/rt/tlsf/removeBlock 1437 | local.get $0 1438 | local.get $4 1439 | local.get $3 1440 | call $~lib/rt/tlsf/prepareBlock 1441 | local.get $4 1442 | ) 1443 | (func $~lib/rt/tlsf/__alloc (; 10 ;) (param $0 i32) (param $1 i32) (result i32) 1444 | call $~lib/rt/tlsf/maybeInitialize 1445 | local.get $0 1446 | local.get $1 1447 | call $~lib/rt/tlsf/allocateBlock 1448 | i32.const 16 1449 | i32.add 1450 | ) 1451 | (func $~lib/rt/pure/increment (; 11 ;) (param $0 i32) 1452 | (local $1 i32) 1453 | local.get $0 1454 | i32.load offset=4 1455 | local.set $1 1456 | local.get $1 1457 | i32.const -268435456 1458 | i32.and 1459 | local.get $1 1460 | i32.const 1 1461 | i32.add 1462 | i32.const -268435456 1463 | i32.and 1464 | i32.eq 1465 | i32.eqz 1466 | if 1467 | i32.const 0 1468 | i32.const 144 1469 | i32.const 109 1470 | i32.const 2 1471 | call $~lib/builtins/abort 1472 | unreachable 1473 | end 1474 | local.get $0 1475 | local.get $1 1476 | i32.const 1 1477 | i32.add 1478 | i32.store offset=4 1479 | local.get $0 1480 | i32.load 1481 | i32.const 1 1482 | i32.and 1483 | i32.eqz 1484 | i32.eqz 1485 | if 1486 | i32.const 0 1487 | i32.const 144 1488 | i32.const 112 1489 | i32.const 13 1490 | call $~lib/builtins/abort 1491 | unreachable 1492 | end 1493 | ) 1494 | (func $~lib/rt/pure/__retain (; 12 ;) (param $0 i32) (result i32) 1495 | local.get $0 1496 | global.get $~lib/heap/__heap_base 1497 | i32.gt_u 1498 | if 1499 | local.get $0 1500 | i32.const 16 1501 | i32.sub 1502 | call $~lib/rt/pure/increment 1503 | end 1504 | local.get $0 1505 | ) 1506 | (func $~lib/rt/pure/__release (; 13 ;) (param $0 i32) 1507 | local.get $0 1508 | global.get $~lib/heap/__heap_base 1509 | i32.gt_u 1510 | if 1511 | local.get $0 1512 | i32.const 16 1513 | i32.sub 1514 | call $~lib/rt/pure/decrement 1515 | end 1516 | ) 1517 | (func $~lib/memory/memory.fill (; 14 ;) (param $0 i32) (param $1 i32) (param $2 i32) 1518 | (local $3 i32) 1519 | (local $4 i32) 1520 | (local $5 i32) 1521 | (local $6 i32) 1522 | (local $7 i32) 1523 | (local $8 i64) 1524 | (local $9 i32) 1525 | block $~lib/util/memory/memset|inlined.0 1526 | local.get $0 1527 | local.set $5 1528 | local.get $1 1529 | local.set $4 1530 | local.get $2 1531 | local.set $3 1532 | local.get $3 1533 | i32.eqz 1534 | if 1535 | br $~lib/util/memory/memset|inlined.0 1536 | end 1537 | local.get $5 1538 | local.get $4 1539 | i32.store8 1540 | local.get $5 1541 | local.get $3 1542 | i32.add 1543 | i32.const 1 1544 | i32.sub 1545 | local.get $4 1546 | i32.store8 1547 | local.get $3 1548 | i32.const 2 1549 | i32.le_u 1550 | if 1551 | br $~lib/util/memory/memset|inlined.0 1552 | end 1553 | local.get $5 1554 | i32.const 1 1555 | i32.add 1556 | local.get $4 1557 | i32.store8 1558 | local.get $5 1559 | i32.const 2 1560 | i32.add 1561 | local.get $4 1562 | i32.store8 1563 | local.get $5 1564 | local.get $3 1565 | i32.add 1566 | i32.const 2 1567 | i32.sub 1568 | local.get $4 1569 | i32.store8 1570 | local.get $5 1571 | local.get $3 1572 | i32.add 1573 | i32.const 3 1574 | i32.sub 1575 | local.get $4 1576 | i32.store8 1577 | local.get $3 1578 | i32.const 6 1579 | i32.le_u 1580 | if 1581 | br $~lib/util/memory/memset|inlined.0 1582 | end 1583 | local.get $5 1584 | i32.const 3 1585 | i32.add 1586 | local.get $4 1587 | i32.store8 1588 | local.get $5 1589 | local.get $3 1590 | i32.add 1591 | i32.const 4 1592 | i32.sub 1593 | local.get $4 1594 | i32.store8 1595 | local.get $3 1596 | i32.const 8 1597 | i32.le_u 1598 | if 1599 | br $~lib/util/memory/memset|inlined.0 1600 | end 1601 | i32.const 0 1602 | local.get $5 1603 | i32.sub 1604 | i32.const 3 1605 | i32.and 1606 | local.set $6 1607 | local.get $5 1608 | local.get $6 1609 | i32.add 1610 | local.set $5 1611 | local.get $3 1612 | local.get $6 1613 | i32.sub 1614 | local.set $3 1615 | local.get $3 1616 | i32.const -4 1617 | i32.and 1618 | local.set $3 1619 | i32.const -1 1620 | i32.const 255 1621 | i32.div_u 1622 | local.get $4 1623 | i32.const 255 1624 | i32.and 1625 | i32.mul 1626 | local.set $7 1627 | local.get $5 1628 | local.get $7 1629 | i32.store 1630 | local.get $5 1631 | local.get $3 1632 | i32.add 1633 | i32.const 4 1634 | i32.sub 1635 | local.get $7 1636 | i32.store 1637 | local.get $3 1638 | i32.const 8 1639 | i32.le_u 1640 | if 1641 | br $~lib/util/memory/memset|inlined.0 1642 | end 1643 | local.get $5 1644 | i32.const 4 1645 | i32.add 1646 | local.get $7 1647 | i32.store 1648 | local.get $5 1649 | i32.const 8 1650 | i32.add 1651 | local.get $7 1652 | i32.store 1653 | local.get $5 1654 | local.get $3 1655 | i32.add 1656 | i32.const 12 1657 | i32.sub 1658 | local.get $7 1659 | i32.store 1660 | local.get $5 1661 | local.get $3 1662 | i32.add 1663 | i32.const 8 1664 | i32.sub 1665 | local.get $7 1666 | i32.store 1667 | local.get $3 1668 | i32.const 24 1669 | i32.le_u 1670 | if 1671 | br $~lib/util/memory/memset|inlined.0 1672 | end 1673 | local.get $5 1674 | i32.const 12 1675 | i32.add 1676 | local.get $7 1677 | i32.store 1678 | local.get $5 1679 | i32.const 16 1680 | i32.add 1681 | local.get $7 1682 | i32.store 1683 | local.get $5 1684 | i32.const 20 1685 | i32.add 1686 | local.get $7 1687 | i32.store 1688 | local.get $5 1689 | i32.const 24 1690 | i32.add 1691 | local.get $7 1692 | i32.store 1693 | local.get $5 1694 | local.get $3 1695 | i32.add 1696 | i32.const 28 1697 | i32.sub 1698 | local.get $7 1699 | i32.store 1700 | local.get $5 1701 | local.get $3 1702 | i32.add 1703 | i32.const 24 1704 | i32.sub 1705 | local.get $7 1706 | i32.store 1707 | local.get $5 1708 | local.get $3 1709 | i32.add 1710 | i32.const 20 1711 | i32.sub 1712 | local.get $7 1713 | i32.store 1714 | local.get $5 1715 | local.get $3 1716 | i32.add 1717 | i32.const 16 1718 | i32.sub 1719 | local.get $7 1720 | i32.store 1721 | i32.const 24 1722 | local.get $5 1723 | i32.const 4 1724 | i32.and 1725 | i32.add 1726 | local.set $6 1727 | local.get $5 1728 | local.get $6 1729 | i32.add 1730 | local.set $5 1731 | local.get $3 1732 | local.get $6 1733 | i32.sub 1734 | local.set $3 1735 | local.get $7 1736 | i64.extend_i32_u 1737 | local.get $7 1738 | i64.extend_i32_u 1739 | i64.const 32 1740 | i64.shl 1741 | i64.or 1742 | local.set $8 1743 | loop $while-continue|0 1744 | local.get $3 1745 | i32.const 32 1746 | i32.ge_u 1747 | local.set $9 1748 | local.get $9 1749 | if 1750 | local.get $5 1751 | local.get $8 1752 | i64.store 1753 | local.get $5 1754 | i32.const 8 1755 | i32.add 1756 | local.get $8 1757 | i64.store 1758 | local.get $5 1759 | i32.const 16 1760 | i32.add 1761 | local.get $8 1762 | i64.store 1763 | local.get $5 1764 | i32.const 24 1765 | i32.add 1766 | local.get $8 1767 | i64.store 1768 | local.get $3 1769 | i32.const 32 1770 | i32.sub 1771 | local.set $3 1772 | local.get $5 1773 | i32.const 32 1774 | i32.add 1775 | local.set $5 1776 | br $while-continue|0 1777 | end 1778 | end 1779 | end 1780 | ) 1781 | (func $~lib/arraybuffer/ArrayBufferView#constructor (; 15 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) 1782 | (local $3 i32) 1783 | (local $4 i32) 1784 | (local $5 i32) 1785 | (local $6 i32) 1786 | local.get $1 1787 | i32.const 1073741808 1788 | local.get $2 1789 | i32.shr_u 1790 | i32.gt_u 1791 | if 1792 | i32.const 192 1793 | i32.const 240 1794 | i32.const 23 1795 | i32.const 56 1796 | call $~lib/builtins/abort 1797 | unreachable 1798 | end 1799 | local.get $1 1800 | local.get $2 1801 | i32.shl 1802 | local.tee $1 1803 | i32.const 0 1804 | call $~lib/rt/tlsf/__alloc 1805 | local.set $3 1806 | local.get $3 1807 | i32.const 0 1808 | local.get $1 1809 | call $~lib/memory/memory.fill 1810 | local.get $0 1811 | i32.eqz 1812 | if 1813 | i32.const 12 1814 | i32.const 2 1815 | call $~lib/rt/tlsf/__alloc 1816 | call $~lib/rt/pure/__retain 1817 | local.set $0 1818 | end 1819 | local.get $0 1820 | i32.const 0 1821 | i32.store 1822 | local.get $0 1823 | i32.const 0 1824 | i32.store offset=4 1825 | local.get $0 1826 | i32.const 0 1827 | i32.store offset=8 1828 | local.get $0 1829 | local.tee $4 1830 | local.get $3 1831 | local.tee $5 1832 | local.get $4 1833 | i32.load 1834 | local.tee $6 1835 | i32.ne 1836 | if 1837 | local.get $5 1838 | call $~lib/rt/pure/__retain 1839 | local.set $5 1840 | local.get $6 1841 | call $~lib/rt/pure/__release 1842 | end 1843 | local.get $5 1844 | i32.store 1845 | local.get $0 1846 | local.get $3 1847 | i32.store offset=4 1848 | local.get $0 1849 | local.get $1 1850 | i32.store offset=8 1851 | local.get $0 1852 | ) 1853 | (func $~lib/typedarray/Uint64Array#constructor (; 16 ;) (param $0 i32) (param $1 i32) (result i32) 1854 | local.get $0 1855 | if (result i32) 1856 | local.get $0 1857 | else 1858 | i32.const 12 1859 | i32.const 5 1860 | call $~lib/rt/tlsf/__alloc 1861 | call $~lib/rt/pure/__retain 1862 | end 1863 | local.get $1 1864 | i32.const 3 1865 | call $~lib/arraybuffer/ArrayBufferView#constructor 1866 | local.set $0 1867 | local.get $0 1868 | ) 1869 | (func $start:assembly/index (; 17 ;) 1870 | i32.const 0 1871 | i32.const 256 1872 | call $~lib/typedarray/Uint64Array#constructor 1873 | global.set $assembly/index/modTable 1874 | i32.const 0 1875 | i32.const 256 1876 | call $~lib/typedarray/Uint64Array#constructor 1877 | global.set $assembly/index/outTable 1878 | ) 1879 | (func $assembly/index/degree (; 18 ;) (param $0 i64) (result i32) 1880 | i32.const 63 1881 | local.get $0 1882 | i64.clz 1883 | i32.wrap_i64 1884 | i32.sub 1885 | ) 1886 | (func $assembly/index/mod (; 19 ;) (param $0 i64) (param $1 i64) (result i64) 1887 | (local $2 i32) 1888 | (local $3 i64) 1889 | (local $4 i32) 1890 | (local $5 i32) 1891 | local.get $1 1892 | local.set $3 1893 | i32.const 63 1894 | local.get $3 1895 | i64.clz 1896 | i32.wrap_i64 1897 | i32.sub 1898 | local.set $4 1899 | loop $while-continue|0 1900 | local.get $0 1901 | local.set $3 1902 | i32.const 63 1903 | local.get $3 1904 | i64.clz 1905 | i32.wrap_i64 1906 | i32.sub 1907 | local.get $4 1908 | i32.sub 1909 | local.tee $2 1910 | i32.const 0 1911 | i32.ge_s 1912 | local.set $5 1913 | local.get $5 1914 | if 1915 | local.get $0 1916 | local.get $1 1917 | local.get $2 1918 | i64.extend_i32_s 1919 | i64.shl 1920 | i64.xor 1921 | local.set $0 1922 | br $while-continue|0 1923 | end 1924 | end 1925 | local.get $0 1926 | ) 1927 | (func $~lib/typedarray/Uint8Array#constructor (; 20 ;) (param $0 i32) (param $1 i32) (result i32) 1928 | local.get $0 1929 | if (result i32) 1930 | local.get $0 1931 | else 1932 | i32.const 12 1933 | i32.const 4 1934 | call $~lib/rt/tlsf/__alloc 1935 | call $~lib/rt/pure/__retain 1936 | end 1937 | local.get $1 1938 | i32.const 0 1939 | call $~lib/arraybuffer/ArrayBufferView#constructor 1940 | local.set $0 1941 | local.get $0 1942 | ) 1943 | (func $~lib/typedarray/Uint64Array#__uset (; 21 ;) (param $0 i32) (param $1 i32) (param $2 i64) 1944 | local.get $0 1945 | i32.load offset=4 1946 | local.get $1 1947 | i32.const 3 1948 | i32.shl 1949 | i32.add 1950 | local.get $2 1951 | i64.store 1952 | ) 1953 | (func $~lib/typedarray/Uint8Array#__set (; 22 ;) (param $0 i32) (param $1 i32) (param $2 i32) 1954 | local.get $1 1955 | local.get $0 1956 | i32.load offset=8 1957 | i32.ge_u 1958 | if 1959 | i32.const 304 1960 | i32.const 368 1961 | i32.const 163 1962 | i32.const 44 1963 | call $~lib/builtins/abort 1964 | unreachable 1965 | end 1966 | local.get $0 1967 | i32.load offset=4 1968 | local.get $1 1969 | i32.add 1970 | local.get $2 1971 | i32.store8 1972 | ) 1973 | (func $~lib/typedarray/Uint8Array#__get (; 23 ;) (param $0 i32) (param $1 i32) (result i32) 1974 | local.get $1 1975 | local.get $0 1976 | i32.load offset=8 1977 | i32.ge_u 1978 | if 1979 | i32.const 304 1980 | i32.const 368 1981 | i32.const 152 1982 | i32.const 44 1983 | call $~lib/builtins/abort 1984 | unreachable 1985 | end 1986 | local.get $0 1987 | i32.load offset=4 1988 | local.get $1 1989 | i32.add 1990 | i32.load8_u 1991 | ) 1992 | (func $~lib/typedarray/Uint8Array#__uset (; 24 ;) (param $0 i32) (param $1 i32) (param $2 i32) 1993 | local.get $0 1994 | i32.load offset=4 1995 | local.get $1 1996 | i32.add 1997 | local.get $2 1998 | i32.store8 1999 | ) 2000 | (func $~lib/typedarray/Uint64Array#__uget (; 25 ;) (param $0 i32) (param $1 i32) (result i64) 2001 | local.get $0 2002 | i32.load offset=4 2003 | local.get $1 2004 | i32.const 3 2005 | i32.shl 2006 | i32.add 2007 | i64.load 2008 | ) 2009 | (func $assembly/index/Rabin#constructor (; 26 ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) 2010 | (local $5 i32) 2011 | (local $6 i32) 2012 | (local $7 i32) 2013 | (local $8 i32) 2014 | (local $9 i64) 2015 | (local $10 i64) 2016 | (local $11 i32) 2017 | (local $12 i64) 2018 | (local $13 i64) 2019 | (local $14 i64) 2020 | (local $15 i32) 2021 | (local $16 i64) 2022 | (local $17 i32) 2023 | (local $18 i32) 2024 | (local $19 i32) 2025 | (local $20 i32) 2026 | local.get $0 2027 | i32.eqz 2028 | if 2029 | i32.const 104 2030 | i32.const 6 2031 | call $~lib/rt/tlsf/__alloc 2032 | call $~lib/rt/pure/__retain 2033 | local.set $0 2034 | end 2035 | local.get $0 2036 | i32.const 0 2037 | i32.store 2038 | local.get $0 2039 | i32.const 0 2040 | i32.store offset=4 2041 | local.get $0 2042 | i32.const 0 2043 | i32.store offset=8 2044 | local.get $0 2045 | i64.const 0 2046 | i64.store offset=16 2047 | local.get $0 2048 | i64.const 0 2049 | i64.store offset=24 2050 | local.get $0 2051 | i64.const 0 2052 | i64.store offset=32 2053 | local.get $0 2054 | i64.const 0 2055 | i64.store offset=40 2056 | local.get $0 2057 | i64.const 0 2058 | i64.store offset=48 2059 | local.get $0 2060 | i64.const 0 2061 | i64.store offset=56 2062 | local.get $0 2063 | i64.const 0 2064 | i64.store offset=64 2065 | local.get $0 2066 | i64.const 0 2067 | i64.store offset=72 2068 | local.get $0 2069 | i64.const 0 2070 | i64.store offset=80 2071 | local.get $0 2072 | i64.const 0 2073 | i64.store offset=88 2074 | local.get $0 2075 | i64.const 0 2076 | i64.store offset=96 2077 | local.get $0 2078 | local.get $2 2079 | i64.extend_i32_u 2080 | i64.store offset=80 2081 | local.get $0 2082 | local.get $3 2083 | i64.extend_i32_u 2084 | i64.store offset=88 2085 | local.get $0 2086 | local.tee $5 2087 | i32.const 0 2088 | local.get $4 2089 | call $~lib/typedarray/Uint8Array#constructor 2090 | local.set $6 2091 | local.get $5 2092 | i32.load 2093 | call $~lib/rt/pure/__release 2094 | local.get $6 2095 | i32.store 2096 | local.get $0 2097 | local.get $4 2098 | i32.store offset=4 2099 | local.get $0 2100 | i64.const 1 2101 | local.get $1 2102 | i64.extend_i32_u 2103 | i64.shl 2104 | i64.const 1 2105 | i64.sub 2106 | i64.store offset=96 2107 | local.get $0 2108 | i64.const 17349423945073011 2109 | i64.store offset=72 2110 | local.get $0 2111 | call $~lib/rt/pure/__retain 2112 | local.set $6 2113 | global.get $assembly/index/tables_initialized 2114 | i32.eqz 2115 | if 2116 | local.get $6 2117 | call $~lib/rt/pure/__retain 2118 | local.set $5 2119 | i32.const 0 2120 | local.set $7 2121 | loop $for-loop|0 2122 | local.get $7 2123 | i32.const 256 2124 | i32.lt_s 2125 | local.set $8 2126 | local.get $8 2127 | if 2128 | i64.const 0 2129 | local.set $9 2130 | local.get $9 2131 | local.set $12 2132 | local.get $7 2133 | local.set $11 2134 | local.get $5 2135 | i64.load offset=72 2136 | local.set $10 2137 | local.get $12 2138 | i64.const 8 2139 | i64.shl 2140 | local.set $12 2141 | local.get $12 2142 | local.get $11 2143 | i32.const 255 2144 | i32.and 2145 | i64.extend_i32_u 2146 | i64.or 2147 | local.set $12 2148 | local.get $12 2149 | local.set $14 2150 | local.get $10 2151 | local.set $13 2152 | local.get $13 2153 | local.set $16 2154 | i32.const 63 2155 | local.get $16 2156 | i64.clz 2157 | i32.wrap_i64 2158 | i32.sub 2159 | local.set $17 2160 | loop $while-continue|1 2161 | local.get $14 2162 | local.set $16 2163 | i32.const 63 2164 | local.get $16 2165 | i64.clz 2166 | i32.wrap_i64 2167 | i32.sub 2168 | local.get $17 2169 | i32.sub 2170 | local.tee $15 2171 | i32.const 0 2172 | i32.ge_s 2173 | local.set $18 2174 | local.get $18 2175 | if 2176 | local.get $14 2177 | local.get $13 2178 | local.get $15 2179 | i64.extend_i32_s 2180 | i64.shl 2181 | i64.xor 2182 | local.set $14 2183 | br $while-continue|1 2184 | end 2185 | end 2186 | local.get $14 2187 | local.set $9 2188 | i32.const 0 2189 | local.set $11 2190 | loop $for-loop|2 2191 | local.get $11 2192 | local.get $5 2193 | i32.load offset=4 2194 | i32.const 1 2195 | i32.sub 2196 | i32.lt_s 2197 | local.set $17 2198 | local.get $17 2199 | if 2200 | local.get $9 2201 | local.set $13 2202 | i32.const 0 2203 | local.set $18 2204 | local.get $5 2205 | i64.load offset=72 2206 | local.set $16 2207 | local.get $13 2208 | i64.const 8 2209 | i64.shl 2210 | local.set $13 2211 | local.get $13 2212 | local.get $18 2213 | i64.extend_i32_u 2214 | i64.or 2215 | local.set $13 2216 | local.get $13 2217 | local.set $10 2218 | local.get $16 2219 | local.set $14 2220 | local.get $14 2221 | local.set $12 2222 | i32.const 63 2223 | local.get $12 2224 | i64.clz 2225 | i32.wrap_i64 2226 | i32.sub 2227 | local.set $19 2228 | loop $while-continue|3 2229 | local.get $10 2230 | local.set $12 2231 | i32.const 63 2232 | local.get $12 2233 | i64.clz 2234 | i32.wrap_i64 2235 | i32.sub 2236 | local.get $19 2237 | i32.sub 2238 | local.tee $15 2239 | i32.const 0 2240 | i32.ge_s 2241 | local.set $20 2242 | local.get $20 2243 | if 2244 | local.get $10 2245 | local.get $14 2246 | local.get $15 2247 | i64.extend_i32_s 2248 | i64.shl 2249 | i64.xor 2250 | local.set $10 2251 | br $while-continue|3 2252 | end 2253 | end 2254 | local.get $10 2255 | local.set $9 2256 | local.get $11 2257 | i32.const 1 2258 | i32.add 2259 | local.set $11 2260 | br $for-loop|2 2261 | end 2262 | end 2263 | global.get $assembly/index/outTable 2264 | local.get $7 2265 | local.get $9 2266 | call $~lib/typedarray/Uint64Array#__uset 2267 | local.get $7 2268 | i32.const 1 2269 | i32.add 2270 | local.set $7 2271 | br $for-loop|0 2272 | end 2273 | end 2274 | local.get $5 2275 | i64.load offset=72 2276 | local.set $12 2277 | i32.const 63 2278 | local.get $12 2279 | i64.clz 2280 | i32.wrap_i64 2281 | i32.sub 2282 | i64.extend_i32_s 2283 | local.set $12 2284 | i32.const 0 2285 | local.set $7 2286 | loop $for-loop|4 2287 | local.get $7 2288 | i32.const 256 2289 | i32.lt_s 2290 | local.set $8 2291 | local.get $8 2292 | if 2293 | local.get $7 2294 | i64.extend_i32_s 2295 | local.get $12 2296 | i64.shl 2297 | local.set $9 2298 | global.get $assembly/index/modTable 2299 | local.get $7 2300 | local.get $9 2301 | local.set $10 2302 | local.get $5 2303 | i64.load offset=72 2304 | local.set $14 2305 | local.get $14 2306 | local.set $16 2307 | i32.const 63 2308 | local.get $16 2309 | i64.clz 2310 | i32.wrap_i64 2311 | i32.sub 2312 | local.set $17 2313 | loop $while-continue|5 2314 | local.get $10 2315 | local.set $13 2316 | i32.const 63 2317 | local.get $13 2318 | i64.clz 2319 | i32.wrap_i64 2320 | i32.sub 2321 | local.get $17 2322 | i32.sub 2323 | local.tee $11 2324 | i32.const 0 2325 | i32.ge_s 2326 | local.set $18 2327 | local.get $18 2328 | if 2329 | local.get $10 2330 | local.get $14 2331 | local.get $11 2332 | i64.extend_i32_s 2333 | i64.shl 2334 | i64.xor 2335 | local.set $10 2336 | br $while-continue|5 2337 | end 2338 | end 2339 | local.get $10 2340 | local.get $9 2341 | i64.or 2342 | call $~lib/typedarray/Uint64Array#__uset 2343 | local.get $7 2344 | i32.const 1 2345 | i32.add 2346 | local.set $7 2347 | br $for-loop|4 2348 | end 2349 | end 2350 | local.get $5 2351 | call $~lib/rt/pure/__release 2352 | i32.const 1 2353 | global.set $assembly/index/tables_initialized 2354 | end 2355 | local.get $6 2356 | i64.const 0 2357 | i64.store offset=24 2358 | local.get $6 2359 | i64.const 0 2360 | i64.store offset=32 2361 | local.get $6 2362 | call $~lib/rt/pure/__retain 2363 | local.set $20 2364 | i32.const 0 2365 | local.set $5 2366 | loop $for-loop|6 2367 | local.get $5 2368 | local.get $20 2369 | i32.load offset=4 2370 | i32.lt_s 2371 | local.set $7 2372 | local.get $7 2373 | if 2374 | local.get $20 2375 | i32.load 2376 | local.get $5 2377 | i32.const 0 2378 | call $~lib/typedarray/Uint8Array#__set 2379 | local.get $5 2380 | i32.const 1 2381 | i32.add 2382 | local.set $5 2383 | br $for-loop|6 2384 | end 2385 | end 2386 | local.get $20 2387 | i64.const 0 2388 | i64.store offset=40 2389 | local.get $20 2390 | i32.const 0 2391 | i32.store offset=8 2392 | local.get $20 2393 | i64.const 0 2394 | i64.store offset=16 2395 | local.get $20 2396 | i64.const 0 2397 | i64.store offset=40 2398 | local.get $20 2399 | call $~lib/rt/pure/__retain 2400 | local.set $19 2401 | i32.const 1 2402 | local.set $15 2403 | local.get $19 2404 | i32.load 2405 | local.get $19 2406 | i32.load offset=8 2407 | call $~lib/typedarray/Uint8Array#__get 2408 | local.set $5 2409 | local.get $19 2410 | i32.load 2411 | local.get $19 2412 | i32.load offset=8 2413 | local.get $15 2414 | call $~lib/typedarray/Uint8Array#__uset 2415 | local.get $19 2416 | local.get $19 2417 | i64.load offset=40 2418 | global.get $assembly/index/outTable 2419 | local.get $5 2420 | call $~lib/typedarray/Uint64Array#__uget 2421 | i64.xor 2422 | i64.store offset=40 2423 | local.get $19 2424 | local.get $19 2425 | i32.load offset=8 2426 | i32.const 1 2427 | i32.add 2428 | local.get $19 2429 | i32.load offset=4 2430 | i32.rem_s 2431 | i32.store offset=8 2432 | local.get $19 2433 | call $~lib/rt/pure/__retain 2434 | local.set $11 2435 | local.get $15 2436 | local.set $18 2437 | local.get $11 2438 | i64.load offset=40 2439 | local.set $12 2440 | local.get $12 2441 | global.get $assembly/index/POLYNOMIAL_SHIFT 2442 | i64.extend_i32_s 2443 | i64.shr_u 2444 | i32.wrap_i64 2445 | local.set $7 2446 | local.get $11 2447 | local.get $12 2448 | i64.const 8 2449 | i64.shl 2450 | local.get $18 2451 | i64.extend_i32_u 2452 | i64.or 2453 | global.get $assembly/index/modTable 2454 | local.get $7 2455 | call $~lib/typedarray/Uint64Array#__uget 2456 | i64.xor 2457 | i64.store offset=40 2458 | local.get $11 2459 | call $~lib/rt/pure/__release 2460 | local.get $19 2461 | call $~lib/rt/pure/__release 2462 | local.get $20 2463 | call $~lib/rt/pure/__release 2464 | local.get $6 2465 | call $~lib/rt/pure/__release 2466 | local.get $0 2467 | ) 2468 | (func $assembly/index/Rabin#get:window (; 27 ;) (param $0 i32) (result i32) 2469 | local.get $0 2470 | i32.load 2471 | call $~lib/rt/pure/__retain 2472 | ) 2473 | (func $assembly/index/Rabin#set:window (; 28 ;) (param $0 i32) (param $1 i32) 2474 | (local $2 i32) 2475 | local.get $0 2476 | local.get $1 2477 | local.get $0 2478 | i32.load 2479 | local.tee $2 2480 | i32.ne 2481 | if 2482 | local.get $1 2483 | call $~lib/rt/pure/__retain 2484 | drop 2485 | local.get $2 2486 | call $~lib/rt/pure/__release 2487 | end 2488 | local.get $1 2489 | i32.store 2490 | ) 2491 | (func $assembly/index/Rabin#get:window_size (; 29 ;) (param $0 i32) (result i32) 2492 | local.get $0 2493 | i32.load offset=4 2494 | ) 2495 | (func $assembly/index/Rabin#set:window_size (; 30 ;) (param $0 i32) (param $1 i32) 2496 | local.get $0 2497 | local.get $1 2498 | i32.store offset=4 2499 | ) 2500 | (func $assembly/index/Rabin#get:wpos (; 31 ;) (param $0 i32) (result i32) 2501 | local.get $0 2502 | i32.load offset=8 2503 | ) 2504 | (func $assembly/index/Rabin#set:wpos (; 32 ;) (param $0 i32) (param $1 i32) 2505 | local.get $0 2506 | local.get $1 2507 | i32.store offset=8 2508 | ) 2509 | (func $assembly/index/Rabin#get:count (; 33 ;) (param $0 i32) (result i64) 2510 | local.get $0 2511 | i64.load offset=16 2512 | ) 2513 | (func $assembly/index/Rabin#set:count (; 34 ;) (param $0 i32) (param $1 i64) 2514 | local.get $0 2515 | local.get $1 2516 | i64.store offset=16 2517 | ) 2518 | (func $assembly/index/Rabin#get:pos (; 35 ;) (param $0 i32) (result i64) 2519 | local.get $0 2520 | i64.load offset=24 2521 | ) 2522 | (func $assembly/index/Rabin#set:pos (; 36 ;) (param $0 i32) (param $1 i64) 2523 | local.get $0 2524 | local.get $1 2525 | i64.store offset=24 2526 | ) 2527 | (func $assembly/index/Rabin#get:start (; 37 ;) (param $0 i32) (result i64) 2528 | local.get $0 2529 | i64.load offset=32 2530 | ) 2531 | (func $assembly/index/Rabin#set:start (; 38 ;) (param $0 i32) (param $1 i64) 2532 | local.get $0 2533 | local.get $1 2534 | i64.store offset=32 2535 | ) 2536 | (func $assembly/index/Rabin#get:digest (; 39 ;) (param $0 i32) (result i64) 2537 | local.get $0 2538 | i64.load offset=40 2539 | ) 2540 | (func $assembly/index/Rabin#set:digest (; 40 ;) (param $0 i32) (param $1 i64) 2541 | local.get $0 2542 | local.get $1 2543 | i64.store offset=40 2544 | ) 2545 | (func $assembly/index/Rabin#get:chunk_start (; 41 ;) (param $0 i32) (result i64) 2546 | local.get $0 2547 | i64.load offset=48 2548 | ) 2549 | (func $assembly/index/Rabin#set:chunk_start (; 42 ;) (param $0 i32) (param $1 i64) 2550 | local.get $0 2551 | local.get $1 2552 | i64.store offset=48 2553 | ) 2554 | (func $assembly/index/Rabin#get:chunk_length (; 43 ;) (param $0 i32) (result i64) 2555 | local.get $0 2556 | i64.load offset=56 2557 | ) 2558 | (func $assembly/index/Rabin#set:chunk_length (; 44 ;) (param $0 i32) (param $1 i64) 2559 | local.get $0 2560 | local.get $1 2561 | i64.store offset=56 2562 | ) 2563 | (func $assembly/index/Rabin#get:chunk_cut_fingerprint (; 45 ;) (param $0 i32) (result i64) 2564 | local.get $0 2565 | i64.load offset=64 2566 | ) 2567 | (func $assembly/index/Rabin#set:chunk_cut_fingerprint (; 46 ;) (param $0 i32) (param $1 i64) 2568 | local.get $0 2569 | local.get $1 2570 | i64.store offset=64 2571 | ) 2572 | (func $assembly/index/Rabin#get:polynomial (; 47 ;) (param $0 i32) (result i64) 2573 | local.get $0 2574 | i64.load offset=72 2575 | ) 2576 | (func $assembly/index/Rabin#set:polynomial (; 48 ;) (param $0 i32) (param $1 i64) 2577 | local.get $0 2578 | local.get $1 2579 | i64.store offset=72 2580 | ) 2581 | (func $assembly/index/Rabin#get:minsize (; 49 ;) (param $0 i32) (result i64) 2582 | local.get $0 2583 | i64.load offset=80 2584 | ) 2585 | (func $assembly/index/Rabin#set:minsize (; 50 ;) (param $0 i32) (param $1 i64) 2586 | local.get $0 2587 | local.get $1 2588 | i64.store offset=80 2589 | ) 2590 | (func $assembly/index/Rabin#get:maxsize (; 51 ;) (param $0 i32) (result i64) 2591 | local.get $0 2592 | i64.load offset=88 2593 | ) 2594 | (func $assembly/index/Rabin#set:maxsize (; 52 ;) (param $0 i32) (param $1 i64) 2595 | local.get $0 2596 | local.get $1 2597 | i64.store offset=88 2598 | ) 2599 | (func $assembly/index/Rabin#get:mask (; 53 ;) (param $0 i32) (result i64) 2600 | local.get $0 2601 | i64.load offset=96 2602 | ) 2603 | (func $assembly/index/Rabin#set:mask (; 54 ;) (param $0 i32) (param $1 i64) 2604 | local.get $0 2605 | local.get $1 2606 | i64.store offset=96 2607 | ) 2608 | (func $~lib/typedarray/Uint8Array#get:length (; 55 ;) (param $0 i32) (result i32) 2609 | local.get $0 2610 | i32.load offset=8 2611 | ) 2612 | (func $~lib/typedarray/Int32Array#__uset (; 56 ;) (param $0 i32) (param $1 i32) (param $2 i32) 2613 | local.get $0 2614 | i32.load offset=4 2615 | local.get $1 2616 | i32.const 2 2617 | i32.shl 2618 | i32.add 2619 | local.get $2 2620 | i32.store 2621 | ) 2622 | (func $assembly/index/Rabin#fingerprint (; 57 ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) 2623 | (local $3 i32) 2624 | (local $4 i32) 2625 | (local $5 i32) 2626 | (local $6 i32) 2627 | (local $7 i32) 2628 | (local $8 i32) 2629 | (local $9 i32) 2630 | (local $10 i32) 2631 | (local $11 i32) 2632 | (local $12 i32) 2633 | (local $13 i32) 2634 | (local $14 i32) 2635 | (local $15 i32) 2636 | (local $16 i32) 2637 | (local $17 i32) 2638 | (local $18 i64) 2639 | (local $19 i32) 2640 | (local $20 i32) 2641 | (local $21 i32) 2642 | local.get $1 2643 | call $~lib/rt/pure/__retain 2644 | local.set $1 2645 | local.get $2 2646 | call $~lib/rt/pure/__retain 2647 | local.set $2 2648 | i32.const 0 2649 | local.set $3 2650 | local.get $1 2651 | call $~lib/typedarray/Uint8Array#get:length 2652 | local.set $4 2653 | local.get $1 2654 | i32.load offset=4 2655 | local.set $5 2656 | block $while-break|0 2657 | loop $while-continue|0 2658 | i32.const 1 2659 | local.set $6 2660 | local.get $6 2661 | if 2662 | block $assembly/index/rabin_next_chunk|inlined.0 (result i32) 2663 | local.get $0 2664 | call $~lib/rt/pure/__retain 2665 | local.set $9 2666 | local.get $5 2667 | local.set $8 2668 | local.get $4 2669 | local.set $7 2670 | i32.const 0 2671 | local.set $10 2672 | loop $for-loop|1 2673 | local.get $10 2674 | local.get $7 2675 | i32.lt_s 2676 | local.set $11 2677 | local.get $11 2678 | if 2679 | local.get $8 2680 | local.get $10 2681 | i32.add 2682 | i32.load8_u 2683 | local.set $12 2684 | local.get $9 2685 | call $~lib/rt/pure/__retain 2686 | local.set $14 2687 | local.get $12 2688 | local.set $13 2689 | local.get $14 2690 | i32.load 2691 | local.get $14 2692 | i32.load offset=8 2693 | call $~lib/typedarray/Uint8Array#__get 2694 | local.set $15 2695 | local.get $14 2696 | i32.load 2697 | local.get $14 2698 | i32.load offset=8 2699 | local.get $13 2700 | call $~lib/typedarray/Uint8Array#__uset 2701 | local.get $14 2702 | local.get $14 2703 | i64.load offset=40 2704 | global.get $assembly/index/outTable 2705 | local.get $15 2706 | call $~lib/typedarray/Uint64Array#__uget 2707 | i64.xor 2708 | i64.store offset=40 2709 | local.get $14 2710 | local.get $14 2711 | i32.load offset=8 2712 | i32.const 1 2713 | i32.add 2714 | local.get $14 2715 | i32.load offset=4 2716 | i32.rem_s 2717 | i32.store offset=8 2718 | local.get $14 2719 | call $~lib/rt/pure/__retain 2720 | local.set $17 2721 | local.get $13 2722 | local.set $16 2723 | local.get $17 2724 | i64.load offset=40 2725 | local.set $18 2726 | local.get $18 2727 | global.get $assembly/index/POLYNOMIAL_SHIFT 2728 | i64.extend_i32_s 2729 | i64.shr_u 2730 | i32.wrap_i64 2731 | local.set $19 2732 | local.get $17 2733 | local.get $18 2734 | i64.const 8 2735 | i64.shl 2736 | local.get $16 2737 | i64.extend_i32_u 2738 | i64.or 2739 | global.get $assembly/index/modTable 2740 | local.get $19 2741 | call $~lib/typedarray/Uint64Array#__uget 2742 | i64.xor 2743 | i64.store offset=40 2744 | local.get $17 2745 | call $~lib/rt/pure/__release 2746 | local.get $14 2747 | call $~lib/rt/pure/__release 2748 | local.get $9 2749 | local.get $9 2750 | i64.load offset=16 2751 | i64.const 1 2752 | i64.add 2753 | i64.store offset=16 2754 | local.get $9 2755 | local.get $9 2756 | i64.load offset=24 2757 | i64.const 1 2758 | i64.add 2759 | i64.store offset=24 2760 | local.get $9 2761 | i64.load offset=16 2762 | local.get $9 2763 | i64.load offset=80 2764 | i64.ge_u 2765 | if (result i32) 2766 | local.get $9 2767 | i64.load offset=40 2768 | local.get $9 2769 | i64.load offset=96 2770 | i64.and 2771 | i64.const 0 2772 | i64.eq 2773 | else 2774 | i32.const 0 2775 | end 2776 | if (result i32) 2777 | i32.const 1 2778 | else 2779 | local.get $9 2780 | i64.load offset=16 2781 | local.get $9 2782 | i64.load offset=88 2783 | i64.ge_u 2784 | end 2785 | if 2786 | local.get $9 2787 | local.get $9 2788 | i64.load offset=32 2789 | i64.store offset=48 2790 | local.get $9 2791 | local.get $9 2792 | i64.load offset=16 2793 | i64.store offset=56 2794 | local.get $9 2795 | local.get $9 2796 | i64.load offset=40 2797 | i64.store offset=64 2798 | local.get $9 2799 | call $~lib/rt/pure/__retain 2800 | local.set $16 2801 | i32.const 0 2802 | local.set $15 2803 | loop $for-loop|2 2804 | local.get $15 2805 | local.get $16 2806 | i32.load offset=4 2807 | i32.lt_s 2808 | local.set $14 2809 | local.get $14 2810 | if 2811 | local.get $16 2812 | i32.load 2813 | local.get $15 2814 | i32.const 0 2815 | call $~lib/typedarray/Uint8Array#__set 2816 | local.get $15 2817 | i32.const 1 2818 | i32.add 2819 | local.set $15 2820 | br $for-loop|2 2821 | end 2822 | end 2823 | local.get $16 2824 | i64.const 0 2825 | i64.store offset=40 2826 | local.get $16 2827 | i32.const 0 2828 | i32.store offset=8 2829 | local.get $16 2830 | i64.const 0 2831 | i64.store offset=16 2832 | local.get $16 2833 | i64.const 0 2834 | i64.store offset=40 2835 | local.get $16 2836 | call $~lib/rt/pure/__retain 2837 | local.set $19 2838 | i32.const 1 2839 | local.set $17 2840 | local.get $19 2841 | i32.load 2842 | local.get $19 2843 | i32.load offset=8 2844 | call $~lib/typedarray/Uint8Array#__get 2845 | local.set $15 2846 | local.get $19 2847 | i32.load 2848 | local.get $19 2849 | i32.load offset=8 2850 | local.get $17 2851 | call $~lib/typedarray/Uint8Array#__uset 2852 | local.get $19 2853 | local.get $19 2854 | i64.load offset=40 2855 | global.get $assembly/index/outTable 2856 | local.get $15 2857 | call $~lib/typedarray/Uint64Array#__uget 2858 | i64.xor 2859 | i64.store offset=40 2860 | local.get $19 2861 | local.get $19 2862 | i32.load offset=8 2863 | i32.const 1 2864 | i32.add 2865 | local.get $19 2866 | i32.load offset=4 2867 | i32.rem_s 2868 | i32.store offset=8 2869 | local.get $19 2870 | call $~lib/rt/pure/__retain 2871 | local.set $14 2872 | local.get $17 2873 | local.set $13 2874 | local.get $14 2875 | i64.load offset=40 2876 | local.set $18 2877 | local.get $18 2878 | global.get $assembly/index/POLYNOMIAL_SHIFT 2879 | i64.extend_i32_s 2880 | i64.shr_u 2881 | i32.wrap_i64 2882 | local.set $20 2883 | local.get $14 2884 | local.get $18 2885 | i64.const 8 2886 | i64.shl 2887 | local.get $13 2888 | i64.extend_i32_u 2889 | i64.or 2890 | global.get $assembly/index/modTable 2891 | local.get $20 2892 | call $~lib/typedarray/Uint64Array#__uget 2893 | i64.xor 2894 | i64.store offset=40 2895 | local.get $14 2896 | call $~lib/rt/pure/__release 2897 | local.get $19 2898 | call $~lib/rt/pure/__release 2899 | local.get $16 2900 | call $~lib/rt/pure/__release 2901 | local.get $10 2902 | i32.const 1 2903 | i32.add 2904 | local.set $16 2905 | local.get $9 2906 | call $~lib/rt/pure/__release 2907 | local.get $16 2908 | br $assembly/index/rabin_next_chunk|inlined.0 2909 | end 2910 | local.get $10 2911 | i32.const 1 2912 | i32.add 2913 | local.set $10 2914 | br $for-loop|1 2915 | end 2916 | end 2917 | i32.const -1 2918 | local.set $10 2919 | local.get $9 2920 | call $~lib/rt/pure/__release 2921 | local.get $10 2922 | end 2923 | local.set $21 2924 | local.get $21 2925 | i32.const 0 2926 | i32.lt_s 2927 | if 2928 | br $while-break|0 2929 | end 2930 | local.get $4 2931 | local.get $21 2932 | i32.sub 2933 | local.set $4 2934 | local.get $5 2935 | local.get $21 2936 | i32.add 2937 | local.set $5 2938 | local.get $3 2939 | local.tee $9 2940 | i32.const 1 2941 | i32.add 2942 | local.set $3 2943 | local.get $9 2944 | local.set $9 2945 | local.get $2 2946 | local.get $9 2947 | local.get $0 2948 | i64.load offset=56 2949 | i32.wrap_i64 2950 | call $~lib/typedarray/Int32Array#__uset 2951 | br $while-continue|0 2952 | end 2953 | end 2954 | end 2955 | local.get $2 2956 | local.set $6 2957 | local.get $1 2958 | call $~lib/rt/pure/__release 2959 | local.get $6 2960 | ) 2961 | (func $~start (; 58 ;) 2962 | call $start:assembly/index 2963 | ) 2964 | (func $~lib/rt/pure/__collect (; 59 ;) 2965 | return 2966 | ) 2967 | (func $~lib/rt/tlsf/freeBlock (; 60 ;) (param $0 i32) (param $1 i32) 2968 | (local $2 i32) 2969 | local.get $1 2970 | i32.load 2971 | local.set $2 2972 | local.get $1 2973 | local.get $2 2974 | i32.const 1 2975 | i32.or 2976 | i32.store 2977 | local.get $0 2978 | local.get $1 2979 | call $~lib/rt/tlsf/insertBlock 2980 | ) 2981 | (func $~lib/rt/pure/decrement (; 61 ;) (param $0 i32) 2982 | (local $1 i32) 2983 | (local $2 i32) 2984 | local.get $0 2985 | i32.load offset=4 2986 | local.set $1 2987 | local.get $1 2988 | i32.const 268435455 2989 | i32.and 2990 | local.set $2 2991 | local.get $0 2992 | i32.load 2993 | i32.const 1 2994 | i32.and 2995 | i32.eqz 2996 | i32.eqz 2997 | if 2998 | i32.const 0 2999 | i32.const 144 3000 | i32.const 122 3001 | i32.const 13 3002 | call $~lib/builtins/abort 3003 | unreachable 3004 | end 3005 | local.get $2 3006 | i32.const 1 3007 | i32.eq 3008 | if 3009 | local.get $0 3010 | i32.const 16 3011 | i32.add 3012 | i32.const 1 3013 | call $~lib/rt/__visit_members 3014 | local.get $1 3015 | i32.const -2147483648 3016 | i32.and 3017 | i32.eqz 3018 | i32.eqz 3019 | if 3020 | i32.const 0 3021 | i32.const 144 3022 | i32.const 126 3023 | i32.const 17 3024 | call $~lib/builtins/abort 3025 | unreachable 3026 | end 3027 | global.get $~lib/rt/tlsf/ROOT 3028 | local.get $0 3029 | call $~lib/rt/tlsf/freeBlock 3030 | else 3031 | local.get $2 3032 | i32.const 0 3033 | i32.gt_u 3034 | i32.eqz 3035 | if 3036 | i32.const 0 3037 | i32.const 144 3038 | i32.const 136 3039 | i32.const 15 3040 | call $~lib/builtins/abort 3041 | unreachable 3042 | end 3043 | local.get $0 3044 | local.get $1 3045 | i32.const 268435455 3046 | i32.const -1 3047 | i32.xor 3048 | i32.and 3049 | local.get $2 3050 | i32.const 1 3051 | i32.sub 3052 | i32.or 3053 | i32.store offset=4 3054 | end 3055 | ) 3056 | (func $~lib/rt/pure/__visit (; 62 ;) (param $0 i32) (param $1 i32) 3057 | local.get $0 3058 | global.get $~lib/heap/__heap_base 3059 | i32.lt_u 3060 | if 3061 | return 3062 | end 3063 | local.get $1 3064 | i32.const 1 3065 | i32.eq 3066 | i32.eqz 3067 | if 3068 | i32.const 0 3069 | i32.const 144 3070 | i32.const 69 3071 | i32.const 15 3072 | call $~lib/builtins/abort 3073 | unreachable 3074 | end 3075 | local.get $0 3076 | i32.const 16 3077 | i32.sub 3078 | call $~lib/rt/pure/decrement 3079 | ) 3080 | (func $~lib/rt/__visit_members (; 63 ;) (param $0 i32) (param $1 i32) 3081 | (local $2 i32) 3082 | block $switch$1$default 3083 | block $switch$1$case$4 3084 | block $switch$1$case$2 3085 | local.get $0 3086 | i32.const 8 3087 | i32.sub 3088 | i32.load 3089 | br_table $switch$1$case$2 $switch$1$case$2 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$case$4 $switch$1$default 3090 | end 3091 | return 3092 | end 3093 | local.get $0 3094 | i32.load 3095 | local.tee $2 3096 | if 3097 | local.get $2 3098 | local.get $1 3099 | call $~lib/rt/pure/__visit 3100 | end 3101 | return 3102 | end 3103 | unreachable 3104 | ) 3105 | ) 3106 | -------------------------------------------------------------------------------- /cli/bin.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var fs = require('fs') 3 | var crypto = require('crypto') 4 | var args = require('minimist')(process.argv.slice(2)) 5 | var Rabin = require('./rabin-stream') 6 | var rabin = new Rabin(args) 7 | var offset = 0 8 | var rs = fs.createReadStream(args._[0]) 9 | var count = 0 10 | rs.pipe(rabin).on('data', function (ch) { 11 | offset += ch.length 12 | count++ 13 | var hash = crypto.createHash('sha256').update(ch).digest('hex') 14 | var data = { 15 | length: ch.length, 16 | offset: offset - ch.length, 17 | hash: hash 18 | } 19 | console.log(JSON.stringify(data)) 20 | }).on('end', function () { 21 | console.error('average', ~~(offset / count)) 22 | }) -------------------------------------------------------------------------------- /cli/rabin-stream.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const stream = require('readable-stream') 3 | const Rabin = require('../src/rabin') 4 | const util = require('util') 5 | const BufferList = require('bl') 6 | const debug = require('debug')('rabin') 7 | 8 | const { instantiateSync } = require("@assemblyscript/loader"); 9 | const imports = {}; 10 | const compiled = instantiateSync(fs.readFileSync(__dirname + "/../dist/rabin.wasm"), imports); 11 | 12 | module.exports = RabinStream 13 | 14 | function RabinStream (opts = {}) { 15 | stream.Duplex.call(this) 16 | this._readableState.highWaterMark = 16 17 | this._readableState.objectMode = true 18 | this.destroyed = false 19 | var avgBits = +opts.bits || 12 20 | var min = +opts.min || 8 * 1024 21 | var max = +opts.max || 32 * 1024 22 | this.rabin = new Rabin(compiled, avgBits, min, max, 64) 23 | this.nextCb = null 24 | this.buffers = new BufferList() 25 | this.pending = [] 26 | this.on('finish', this._finish) 27 | } 28 | 29 | util.inherits(RabinStream, stream.Duplex) 30 | 31 | RabinStream.prototype._finish = function () { 32 | if (this.destroyed) return 33 | if (this.buffers.length) this.push(this.buffers.slice(0, this.buffers.length)) 34 | this.push(null) 35 | } 36 | 37 | RabinStream.prototype._writev = function (batch, cb) { 38 | if (this.destroyed) return cb() 39 | 40 | for (var i = 0; i < batch.length; i++) { 41 | this.buffers.append(batch[i].chunk) 42 | this.pending.push(batch[i].chunk) 43 | } 44 | this._process(cb) 45 | } 46 | 47 | RabinStream.prototype._read = function (size) { 48 | var nextCb = this.nextCb 49 | if (nextCb) { 50 | this.nextCb = null 51 | nextCb() 52 | } 53 | } 54 | 55 | RabinStream.prototype._write = function (data, enc, cb) { 56 | if (this.destroyed) return cb() 57 | 58 | this.buffers.append(data) 59 | this.pending.push(data) 60 | this._process(cb) 61 | } 62 | 63 | RabinStream.prototype._process = function (cb) { 64 | var drained = true 65 | var sizes = this.rabin.fingerprint(Buffer.concat(this.pending)) 66 | 67 | this.pending = [] 68 | 69 | debug('chunks', sizes) 70 | 71 | for (var i = 0; i < sizes.length; i++) { 72 | var size = sizes[i] 73 | if(size === 0) break 74 | var buf = this.buffers.slice(0, size) 75 | this.buffers.consume(size) 76 | drained = this.push(buf) 77 | } 78 | 79 | if (drained) cb() 80 | else this.nextCb = cb 81 | } 82 | 83 | RabinStream.prototype.destroy = function (err) { 84 | if (this.destroyed) return 85 | this.destroyed = true 86 | if (err) this.emit('error', err) 87 | this.emit('close') 88 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rabin-wasm", 3 | "version": "0.1.5", 4 | "description": "Rabin fingerprinting implemented in AssemblyScript", 5 | "homepage": "https://github.com/hugomrdias/rabin-wasm", 6 | "bugs": { 7 | "url": "https://github.com/hugomrdias/rabin-wasm/issues" 8 | }, 9 | "license": "MIT", 10 | "author": "Hugo Dias", 11 | "bin": "cli/bin.js", 12 | "main": "src/index.js", 13 | "browser": { 14 | "./dist/rabin-wasm.node.js": "./dist/rabin-wasm.js" 15 | }, 16 | "files": [ 17 | "src", 18 | "dist", 19 | "cli" 20 | ], 21 | "scripts": { 22 | "asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --sourceMap --validate --debug", 23 | "asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat --sourceMap --validate --optimize", 24 | "asbuild": "npm run asbuild:untouched && npm run asbuild:optimized", 25 | "build": "asc assembly/index.ts -b dist/rabin.wasm -d dist/rabin-wasm.d.ts --runtime full --sourceMap --validate -O3 --noAssert && ./tools/wasm2js dist/rabin.wasm -o dist/rabin-wasm.js && browserify src/index.js -s Rabin -o dist/rabin.umd.js", 26 | "size": "size-limit dist/rabin.umd.js", 27 | "test": "asp --nortrace && yarn build && npx tape test/test.js", 28 | "prepublishOnly": "npm run build" 29 | }, 30 | "repository": { 31 | "type": "git", 32 | "url": "git+https://github.com/hugomrdias/rabin-wasm.git" 33 | }, 34 | "dependencies": { 35 | "@assemblyscript/loader": "^0.9.4", 36 | "bl": "^5.0.0", 37 | "debug": "^4.3.1", 38 | "minimist": "^1.2.5", 39 | "node-fetch": "^2.6.1", 40 | "readable-stream": "^3.6.0" 41 | }, 42 | "devDependencies": { 43 | "@as-pect/cli": "^2.8.1", 44 | "@size-limit/preset-small-lib": "^4.2.1", 45 | "assemblyscript": "^0.9.4", 46 | "benchmark": "^2.1.4", 47 | "browserify": "^16.3.0", 48 | "buffer": "^6.0.3", 49 | "iso-random-stream": "^2.0.0", 50 | "long": "^4.0.0", 51 | "np": "^6.2.0", 52 | "rabin": "^2.0.0", 53 | "size-limit": "^4.2.1", 54 | "tape": "^4.13.2" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | port of https://github.com/datproject/rabin to assembly script -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | const Rabin = require('./rabin') 2 | const getRabin = require('../dist/rabin-wasm.node.js') 3 | 4 | const create = async (avg, min, max, windowSize, polynomial) => { 5 | const compiled = await getRabin() 6 | return new Rabin(compiled, avg, min, max, windowSize, polynomial) 7 | } 8 | 9 | module.exports = { 10 | Rabin, 11 | create 12 | } 13 | -------------------------------------------------------------------------------- /src/rabin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Rabin fingerprinting 3 | * 4 | * @class Rabin 5 | */ 6 | class Rabin { 7 | /** 8 | * Creates an instance of Rabin. 9 | * @param { import("./../dist/rabin-wasm") } asModule 10 | * @param {number} [bits=12] 11 | * @param {number} [min=8 * 1024] 12 | * @param {number} [max=32 * 1024] 13 | * @param {number} polynomial 14 | * @memberof Rabin 15 | */ 16 | constructor(asModule, bits = 12, min = 8 * 1024, max = 32 * 1024, windowSize = 64, polynomial) { 17 | this.bits = bits 18 | this.min = min 19 | this.max = max 20 | this.asModule = asModule 21 | this.rabin = new asModule.Rabin(bits, min, max, windowSize, polynomial) 22 | this.polynomial = polynomial 23 | } 24 | 25 | /** 26 | * Fingerprints the buffer 27 | * 28 | * @param {Uint8Array} buf 29 | * @returns {Array} 30 | * @memberof Rabin 31 | */ 32 | fingerprint(buf) { 33 | const { 34 | __retain, 35 | __release, 36 | __allocArray, 37 | __getInt32Array, 38 | Int32Array_ID, 39 | Uint8Array_ID 40 | } = this.asModule 41 | 42 | const lengths = new Int32Array(Math.ceil(buf.length/this.min)) 43 | const lengthsPtr = __retain(__allocArray(Int32Array_ID, lengths)) 44 | const pointer = __retain(__allocArray(Uint8Array_ID, buf)) 45 | 46 | const out = this.rabin.fingerprint(pointer, lengthsPtr) 47 | const processed = __getInt32Array(out) 48 | 49 | __release(pointer) 50 | __release(lengthsPtr) 51 | 52 | const end = processed.indexOf(0); 53 | return end >= 0 ? processed.subarray(0, end) : processed; 54 | } 55 | } 56 | 57 | module.exports = Rabin -------------------------------------------------------------------------------- /test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 |
15 |
16 |
17 | 18 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /test/1MiB.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hugomrdias/rabin-wasm/f0cf7ce248a268cc65c389ece6882df25f92fc02/test/1MiB.txt -------------------------------------------------------------------------------- /test/rand_5MiB.zst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hugomrdias/rabin-wasm/f0cf7ce248a268cc65c389ece6882df25f92fc02/test/rand_5MiB.zst -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const test = require('tape') 4 | const fs = require('fs') 5 | const path = require('path') 6 | const {create} = require('../src') 7 | const {Buffer} = require('buffer') 8 | 9 | test('chunks for 1MiB.txt', async (t)=>{ 10 | const buf = fs.readFileSync(path.join(__dirname, '1MiB.txt')) 11 | const file = Buffer.concat([buf, Buffer.from('hello')]) 12 | const Rabin = await create(18, 87381.33333333333, 393216, 64) 13 | const sizes = Rabin.fingerprint(file) 14 | t.deepEqual(sizes, [ 366598, 239921, 260915 ]) 15 | t.end() 16 | }) 17 | 18 | test('shoud be empty', async (t)=>{ 19 | const b1 = Buffer.alloc(10 * 256) 20 | b1.fill('a') 21 | const Rabin = await create(8, 18, 262144, 64) 22 | const sizes = Rabin.fingerprint(b1) 23 | t.deepEqual(sizes, []) 24 | t.end() 25 | }) 26 | 27 | test('shoud respect window size', async (t)=>{ 28 | const b1 = Buffer.alloc(2 * 256) 29 | const b2 = Buffer.alloc(1 * 119) 30 | const b3 = Buffer.alloc(5 * 256) 31 | 32 | b1.fill('a') 33 | b2.fill('b') 34 | b3.fill('c') 35 | const Rabin = await create(6, 48, 192, 64) 36 | const sizes = Rabin.fingerprint(Buffer.concat([b1, b2, b3])) 37 | t.deepEqual(sizes, [192, 192, 192, 65, 192, 192, 192, 192, 192, 192]) 38 | t.end() 39 | }) 40 | 41 | // TODO fix passing polynomial https://github.com/AssemblyScript/assemblyscript/issues/162#issuecomment-403870965 42 | // https://github.com/whyrusleeping/chunker/blob/master/chunker.go#L16 43 | // https://github.com/ipfs/go-ipfs-chunker/blob/master/rabin.go#L11 44 | // https://github.com/ribasushi/temporary_tesdata_2020_03/blob/master/leaf_chunklists_random_source.csv 45 | // needs to be a BigInt and on the AS side needs to be a i64 46 | test.skip('chunks for rand_5MiB.zst', async (t)=>{ 47 | const file = fs.readFileSync(path.join(__dirname, 'rand_5MiB.zst')) 48 | const avg = Math.floor(Math.log2(524288)) 49 | const Rabin = await create(avg, 262144, 1048576, 16, 17437180132763653n) 50 | const sizes = Rabin.fingerprint(file) 51 | t.deepEqual(sizes, [ 895059,686255,467859,626819,280748,310603,734239,499556,741742 ]) 52 | t.end() 53 | }) -------------------------------------------------------------------------------- /tools/wasm2js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | process.title = 'wasm2js' 4 | 5 | const minimist = require('minimist') 6 | const fs = require('fs') 7 | const path = require('path') 8 | const wasm2js = require('./wasm2js.js') 9 | const wasm2jsNode = require('./wasm2js.node.js') 10 | 11 | const argv = minimist(process.argv.slice(2), { 12 | alias: {output: 'o', watch: 'w'}, 13 | boolean: ['w'] 14 | }) 15 | 16 | const inp = argv._[0] 17 | 18 | if (!inp) { 19 | console.error(` 20 | Usage: wasm2js [input.wasm file] [options...] 21 | --output, -o [output.js file] 22 | --watch, -w [recompile on input.wat change] 23 | `.trim()) 24 | process.exit(1) 25 | } 26 | 27 | if (argv.watch && !argv.output) { 28 | console.error('--watch requires --output') 29 | process.exit(2) 30 | } 31 | 32 | if (argv.watch) fs.watch(inp, build) 33 | build() 34 | 35 | function build() { 36 | const wasmBuffer = fs.readFileSync(inp) 37 | const src = wasm2js(wasmBuffer) 38 | const srcNode = wasm2jsNode(wasmBuffer) 39 | if (argv.output) { 40 | fs.writeFileSync(argv.output, src) 41 | fs.writeFileSync(path.join(path.dirname(argv.output), path.basename(argv.output, 'js') + 'node.js'), srcNode) 42 | } 43 | else process.stdout.write(src) 44 | } -------------------------------------------------------------------------------- /tools/wasm2js.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /** 4 | * Takes a `.wasm` binary and wraps it inside a commonJS module that can be required 5 | * in Node.js and the browser. 6 | * 7 | * @name wasm2js 8 | * 9 | * @param {Buffer} wasmBuf a buffer of the .wasm code 10 | * @returns {String} the commonJS module code that wraps the wasm 11 | */ 12 | module.exports = function wasm2js(wasmBuf) { 13 | 14 | return ` 15 | const { instantiate } = require("@assemblyscript/loader"); 16 | 17 | loadWebAssembly.supported = typeof WebAssembly !== 'undefined' 18 | 19 | function loadWebAssembly (imp = {}) { 20 | if (!loadWebAssembly.supported) return null 21 | 22 | var wasm = new Uint8Array([${wasmBuf.join(',')}]) 23 | // make it work async because browsers throw when a wasm module is bigger than 4kb and load sync 24 | return instantiate(new Response(new Blob([wasm], {type: 'application/wasm'})), imp) 25 | } 26 | module.exports = loadWebAssembly 27 | `.replace(/^ {4}/gm, '') 28 | } -------------------------------------------------------------------------------- /tools/wasm2js.node.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /** 4 | * Takes a `.wasm` binary and wraps it inside a commonJS module that can be required 5 | * in Node.js and the browser. 6 | * 7 | * @name wasm2js 8 | * 9 | * @param {Buffer} wasmBuf a buffer of the .wasm code 10 | * @returns {String} the commonJS module code that wraps the wasm 11 | */ 12 | module.exports = function wasm2js(wasmBuf) { 13 | 14 | return ` 15 | const { instantiateSync } = require("@assemblyscript/loader"); 16 | const fs = require('fs') 17 | 18 | loadWebAssembly.supported = typeof WebAssembly !== 'undefined' 19 | 20 | async function loadWebAssembly (imp = {}) { 21 | if (!loadWebAssembly.supported) return null 22 | 23 | return instantiateSync(fs.readFileSync(__dirname + "/../dist/rabin.wasm"), imp); 24 | } 25 | module.exports = loadWebAssembly 26 | `.replace(/^ {4}/gm, '') 27 | } --------------------------------------------------------------------------------