diff --git a/src/js/wasm/biditrie.wat b/src/js/wasm/biditrie.wat index b98d87951..ce0aa3ca7 100644 --- a/src/js/wasm/biditrie.wat +++ b/src/js/wasm/biditrie.wat @@ -64,92 +64,92 @@ (local $x i32) (local $y i32) ;; trie index is a uint32 offset, need to convert to uint8 offset - get_local $icell + local.get $icell i32.const 2 i32.shl - set_local $icell + local.set $icell ;; const buf32 = this.buf32; ;; const buf8 = this.buf8; ;; const char0 = buf32[CHAR0_SLOT]; i32.const 2060 i32.load align=4 - set_local $char0 + local.set $char0 ;; const aR = buf32[HAYSTACK_SIZE_SLOT]; i32.const 2048 i32.load align=4 - set_local $aR + local.set $aR ;; let al = ai; - get_local $ai - set_local $al + local.get $ai + local.set $al block $matchFound block $matchNotFound ;; for (;;) { loop $mainLoop ;; x = buf8[al]; - get_local $al + local.get $al i32.load8_u - set_local $x + local.set $x ;; al += 1; - get_local $al + local.get $al i32.const 1 i32.add - set_local $al + local.set $al ;; // find matching segment ;; for (;;) { block $nextSegment loop $findSegment ;; y = buf32[icell+SEGMENT_INFO]; - get_local $icell + local.get $icell i32.load offset=8 align=4 - tee_local $y + local.tee $y ;; bl = char0 + (y & 0x00FFFFFF); i32.const 0x00FFFFFF i32.and - get_local $char0 + local.get $char0 i32.add - tee_local $bl + local.tee $bl ;; if ( buf8[bl] === x ) { i32.load8_u - get_local $x + local.get $x i32.eq if ;; y = (y >>> 24) - 1; - get_local $y + local.get $y i32.const 24 i32.shr_u i32.const 1 i32.sub - tee_local $y + local.tee $y ;; if ( n !== 0 ) { if ;; x = al + y; - get_local $y - get_local $al + local.get $y + local.get $al i32.add - tee_local $x + local.tee $x ;; if ( x > aR ) { return 0; } - get_local $aR + local.get $aR i32.gt_u br_if $matchNotFound ;; for (;;) { loop ;; bl += 1; - get_local $bl + local.get $bl i32.const 1 i32.add - tee_local $bl + local.tee $bl ;; if ( buf8[bl] !== buf8[al] ) { return 0; } i32.load8_u - get_local $al + local.get $al i32.load8_u i32.ne br_if $matchNotFound ;; al += 1; - get_local $al + local.get $al i32.const 1 i32.add - tee_local $al + local.tee $al ;; if ( al === x ) { break; } - get_local $x + local.get $x i32.ne br_if 0 end @@ -158,11 +158,11 @@ br $nextSegment end ;; icell = buf32[icell+CELL_OR]; - get_local $icell + local.get $icell i32.load offset=4 align=4 i32.const 2 i32.shl - tee_local $icell + local.tee $icell ;; if ( icell === 0 ) { return 0; } i32.eqz br_if $matchNotFound @@ -171,14 +171,14 @@ end end ;; // next segment ;; icell = buf32[icell+CELL_AND]; - get_local $icell + local.get $icell i32.load align=4 i32.const 2 i32.shl - tee_local $icell + local.tee $icell ;; const x = buf32[icell+BCELL_EXTRA]; i32.load offset=8 align=4 - tee_local $x + local.tee $x ;; if ( x <= BCELL_EXTRA_MAX ) { i32.const 0x00FFFFFF i32.le_u @@ -186,43 +186,43 @@ ;; if ( x !== 0 && this.matchesExtra(ai, al, x) !== 0 ) { ;; return 1; ;; } - get_local $x + local.get $x if - get_local $ai - get_local $al - get_local $x + local.get $ai + local.get $al + local.get $x call $matchesExtra br_if $matchFound end ;; x = buf32[icell+BCELL_ALT_AND]; - get_local $icell + local.get $icell i32.load offset=4 align=4 i32.const 2 i32.shl - tee_local $x + local.tee $x ;; if ( x !== 0 && this.matchesLeft(x, ai, al) !== 0 ) { if - get_local $x - get_local $ai - get_local $al + local.get $x + local.get $ai + local.get $al call $matchesLeft br_if $matchFound ;; } end ;; icell = buf32[icell+BCELL_NEXT_AND]; - get_local $icell + local.get $icell i32.load align=4 i32.const 2 i32.shl - tee_local $icell + local.tee $icell ;; if ( icell === 0 ) { return 0; } i32.eqz br_if $matchNotFound ;; } end ;; if ( al === aR ) { return 0; } - get_local $al - get_local $aR + local.get $al + local.get $aR i32.ne br_if $mainLoop ;; } @@ -255,60 +255,60 @@ ;; const char0 = buf32[CHAR0_SLOT]; i32.const 2060 i32.load align=4 - set_local $char0 + local.set $char0 block $matchFound block $matchNotFound ;; for (;;) { loop $mainLoop ;; if ( ar === 0 ) { return 0; } - get_local $ar + local.get $ar i32.eqz br_if $matchNotFound ;; ar -= 1; - get_local $ar + local.get $ar i32.const 1 i32.sub - tee_local $ar + local.tee $ar ;; x = buf8[ar]; i32.load8_u - set_local $x + local.set $x ;; // find matching segment ;; for (;;) { block $nextSegment loop $findSegment ;; y = buf32[icell+SEGMENT_INFO]; - get_local $icell + local.get $icell i32.load offset=8 align=4 - tee_local $y + local.tee $y ;; br = char0 + (y & 0x00FFFFFF); i32.const 0x00FFFFFF i32.and - get_local $char0 + local.get $char0 i32.add - tee_local $br + local.tee $br ;; y = (y >>> 24) - 1; - get_local $y + local.get $y i32.const 24 i32.shr_u i32.const 1 i32.sub - tee_local $y + local.tee $y ;; br += y; i32.add - tee_local $br + local.tee $br ;; if ( buf8[br] === x ) { i32.load8_u - get_local $x + local.get $x i32.eq if ;; // all characters in segment must match ;; if ( y !== 0 ) { - get_local $y + local.get $y if ;; x = ar - y; - get_local $ar - get_local $y + local.get $ar + local.get $y i32.sub - tee_local $x + local.tee $x ;; if ( x < 0 ) { return 0; } i32.const 0 i32.lt_s @@ -317,21 +317,21 @@ loop ;; ar -= 1; br -= 1; ;; if ( buf8[ar] !== buf8[br] ) { return 0; } - get_local $ar + local.get $ar i32.const 1 i32.sub - tee_local $ar + local.tee $ar i32.load8_u - get_local $br + local.get $br i32.const 1 i32.sub - tee_local $br + local.tee $br i32.load8_u i32.ne br_if $matchNotFound ;; if ( ar === x ) { break; } - get_local $ar - get_local $x + local.get $ar + local.get $x i32.ne br_if 0 end @@ -340,11 +340,11 @@ br $nextSegment end ;; icell = buf32[icell+CELL_OR]; - get_local $icell + local.get $icell i32.load offset=4 align=4 i32.const 2 i32.shl - tee_local $icell + local.tee $icell ;; if ( icell === 0 ) { return 0; } i32.eqz br_if $matchNotFound @@ -353,14 +353,14 @@ end end ;; // next segment ;; icell = buf32[icell+CELL_AND]; - get_local $icell + local.get $icell i32.load align=4 i32.const 2 i32.shl - tee_local $icell + local.tee $icell ;; const x = buf32[icell+BCELL_EXTRA]; i32.load offset=8 align=4 - tee_local $x + local.tee $x ;; if ( x <= BCELL_EXTRA_MAX ) { i32.const 0x00FFFFFF i32.le_u @@ -368,20 +368,20 @@ ;; if ( x !== 0 && this.matchesExtra(ar, r, x) !== 0 ) { ;; return 1; ;; } - get_local $x + local.get $x if - get_local $ar - get_local $r - get_local $x + local.get $ar + local.get $r + local.get $x call $matchesExtra br_if $matchFound end ;; icell = buf32[icell+BCELL_NEXT_AND]; - get_local $icell + local.get $icell i32.load align=4 i32.const 2 i32.shl - tee_local $icell + local.tee $icell ;; if ( icell === 0 ) { return 0; } i32.eqz br_if $matchNotFound @@ -414,35 +414,35 @@ ;; if ( ix !== 1 ) { ;; const iu = this.extraHandler(l, r, ix); ;; if ( iu === 0 ) { return 0; } - get_local $ix + local.get $ix i32.const 1 i32.ne if - get_local $l - get_local $r - get_local $ix + local.get $l + local.get $r + local.get $ix call $extraHandler - tee_local $iu + local.tee $iu i32.eqz br_if $fail ;; } else { ;; iu = -1; else i32.const -1 - set_local $iu + local.set $iu ;; } end ;; this.buf32[RESULT_IU_SLOT] = iu; i32.const 2076 - get_local $iu + local.get $iu i32.store align=4 ;; this.buf32[RESULT_L_SLOT] = l; i32.const 2068 - get_local $l + local.get $l i32.store align=4 ;; this.buf32[RESULT_R_SLOT] = r; i32.const 2072 - get_local $r + local.get $r i32.store align=4 end ;; $succeed i32.const 1 @@ -470,49 +470,49 @@ ;; if ( haystackLeft < 0 || (haystackLeft + needleLen) > haystackRight ) { ;; return 0; ;; } - get_local $haystackLeft + local.get $haystackLeft i32.const 0 i32.lt_s br_if $fail - get_local $haystackLeft - get_local $needleLen + local.get $haystackLeft + local.get $needleLen i32.add - get_local $haystackRight + local.get $haystackRight i32.gt_u br_if $fail ;; const charCodes = this.buf8; ;; needleLeft += this.buf32[CHAR0_SLOT]; - get_local $needleLeft + local.get $needleLeft i32.const 2060 ;; CHAR0_SLOT memory address i32.load align=4 ;; CHAR0 memory address i32.add ;; needle memory address - tee_local $needleLeft + local.tee $needleLeft ;; const needleRight = needleLeft + needleLen; - get_local $needleLen + local.get $needleLen i32.add - set_local $needleRight + local.set $needleRight ;; while ( charCodes[haystackLeft] === charCodes[needleLeft] ) { loop $compare - get_local $haystackLeft + local.get $haystackLeft i32.load8_u - get_local $needleLeft + local.get $needleLeft i32.load8_u i32.ne br_if $fail ;; needleLeft += 1; - get_local $needleLeft + local.get $needleLeft i32.const 1 i32.add - tee_local $needleLeft + local.tee $needleLeft ;; if ( needleLeft === needleRight ) { return 1; } - get_local $needleRight + local.get $needleRight i32.eq br_if $succeed ;; haystackLeft += 1; i32.const 1 - get_local $haystackLeft + local.get $haystackLeft i32.add - set_local $haystackLeft + local.set $haystackLeft br $compare end ;; } @@ -545,76 +545,76 @@ block $fail block $succeed ;; if ( needleLen === 0 ) { return haystackLeft; } - get_local $needleLen + local.get $needleLen i32.eqz br_if $succeed ;; haystackEnd -= needleLen; - get_local $haystackEnd - get_local $needleLen + local.get $haystackEnd + local.get $needleLen i32.sub - tee_local $haystackEnd + local.tee $haystackEnd ;; if ( haystackEnd < haystackLeft ) { return -1; } - get_local $haystackLeft + local.get $haystackLeft i32.lt_s br_if $fail ;; needleLeft += this.buf32[CHAR0_SLOT]; - get_local $needleLeft + local.get $needleLeft i32.const 2060 ;; CHAR0_SLOT memory address i32.load align=4 ;; CHAR0 memory address i32.add ;; needle memory address - tee_local $needleLeft + local.tee $needleLeft ;; const needleRight = needleLeft + needleLen; - get_local $needleLen + local.get $needleLen i32.add - set_local $needleRight + local.set $needleRight ;; const charCodes = this.buf8; ;; for (;;) { loop $mainLoop ;; let i = haystackLeft; ;; let j = needleLeft; - get_local $haystackLeft - set_local $i - get_local $needleLeft - set_local $j + local.get $haystackLeft + local.set $i + local.get $needleLeft + local.set $j ;; while ( charCodes[i] === charCodes[j] ) { block $breakMatchChars loop $matchChars - get_local $i + local.get $i i32.load8_u - get_local $j + local.get $j i32.load8_u i32.ne br_if $breakMatchChars ;; j += 1; - get_local $j + local.get $j i32.const 1 i32.add - tee_local $j + local.tee $j ;; if ( j === needleRight ) { return haystackLeft; } - get_local $needleRight + local.get $needleRight i32.eq br_if $succeed ;; i += 1; - get_local $i + local.get $i i32.const 1 i32.add - set_local $i + local.set $i br $matchChars ;; } end end ;; haystackLeft += 1; - get_local $haystackLeft + local.get $haystackLeft i32.const 1 i32.add - tee_local $haystackLeft + local.tee $haystackLeft ;; if ( haystackLeft > haystackEnd ) { break; } - get_local $haystackEnd + local.get $haystackEnd i32.gt_u br_if $fail br $mainLoop ;; } end end ;; $succeed - get_local $haystackLeft + local.get $haystackLeft return end ;; $fail ;; return -1; @@ -640,82 +640,82 @@ (local $j i32) (local $c0 i32) ;; if ( needleLen === 0 ) { return haystackBeg; } - get_local $needleLen + local.get $needleLen i32.eqz if - get_local $haystackBeg + local.get $haystackBeg return end block $fail block $succeed ;; let haystackLeft = haystackEnd - needleLen; - get_local $haystackEnd - get_local $needleLen + local.get $haystackEnd + local.get $needleLen i32.sub - tee_local $haystackLeft + local.tee $haystackLeft ;; if ( haystackLeft < haystackBeg ) { return -1; } - get_local $haystackBeg + local.get $haystackBeg i32.lt_s br_if $fail ;; needleLeft += this.buf32[CHAR0_SLOT]; - get_local $needleLeft + local.get $needleLeft i32.const 2060 ;; CHAR0_SLOT memory address i32.load align=4 ;; CHAR0 memory address i32.add ;; needle memory address - tee_local $needleLeft + local.tee $needleLeft ;; const needleRight = needleLeft + needleLen; - get_local $needleLen + local.get $needleLen i32.add - set_local $needleRight + local.set $needleRight ;; const charCodes = this.buf8; ;; for (;;) { loop $mainLoop ;; let i = haystackLeft; ;; let j = needleLeft; - get_local $haystackLeft - set_local $i - get_local $needleLeft - set_local $j + local.get $haystackLeft + local.set $i + local.get $needleLeft + local.set $j ;; while ( charCodes[i] === charCodes[j] ) { block $breakMatchChars loop $matchChars - get_local $i + local.get $i i32.load8_u - get_local $j + local.get $j i32.load8_u i32.ne br_if $breakMatchChars ;; j += 1; - get_local $j + local.get $j i32.const 1 i32.add - tee_local $j + local.tee $j ;; if ( j === needleRight ) { return haystackLeft; } - get_local $needleRight + local.get $needleRight i32.eq br_if $succeed ;; i += 1; - get_local $i + local.get $i i32.const 1 i32.add - set_local $i + local.set $i br $matchChars ;; } end end ;; if ( haystackLeft === haystackBeg ) { break; } ;; haystackLeft -= 1; - get_local $haystackLeft - get_local $haystackBeg + local.get $haystackLeft + local.get $haystackBeg i32.eq br_if $fail - get_local $haystackLeft + local.get $haystackLeft i32.const 1 i32.sub - set_local $haystackLeft + local.set $haystackLeft br $mainLoop ;; } end end ;; $succeed - get_local $haystackLeft + local.get $haystackLeft return end ;; $fail ;; return -1; diff --git a/src/js/wasm/hntrie.wat b/src/js/wasm/hntrie.wat index cb62b4cc1..2bcc46fb1 100644 --- a/src/js/wasm/hntrie.wat +++ b/src/js/wasm/hntrie.wat @@ -64,19 +64,19 @@ ;; i32.const 264 ;; start of char section is stored at addr 264 i32.load - set_local $char0 + local.set $char0 ;; let ineedle = this.buf[255]; i32.const 255 ;; addr of needle is stored at addr 255 i32.load8_u - set_local $ineedle + local.set $ineedle ;; let icell = this.buf32[iroot+0]; - get_local $iroot + local.get $iroot i32.const 2 i32.shl i32.load i32.const 2 i32.shl - tee_local $icell + local.tee $icell ;; if ( icell === 0 ) { return -1; } i32.eqz if @@ -86,43 +86,43 @@ ;; for (;;) { block $noSegment loop $nextSegment ;; if ( ineedle === 0 ) { return -1; } - get_local $ineedle + local.get $ineedle i32.eqz if i32.const -1 return end ;; ineedle -= 1; - get_local $ineedle + local.get $ineedle i32.const -1 i32.add - tee_local $ineedle + local.tee $ineedle ;; let c = this.buf[ineedle]; i32.load8_u - set_local $c + local.set $c ;; for (;;) { block $foundSegment loop $findSegment ;; v = this.buf32[icell+2]; - get_local $icell + local.get $icell i32.load offset=8 - tee_local $v + local.tee $v ;; i0 = char0 + (v >>> 8); i32.const 8 i32.shr_u - get_local $char0 + local.get $char0 i32.add - tee_local $i0 + local.tee $i0 ;; if ( this.buf[i0] === c ) { break; } i32.load8_u - get_local $c + local.get $c i32.eq br_if $foundSegment ;; icell = this.buf32[icell+0]; - get_local $icell + local.get $icell i32.load i32.const 2 i32.shl - tee_local $icell + local.tee $icell i32.eqz if i32.const -1 @@ -131,44 +131,44 @@ br 0 end end ;; let n = v & 0x7F; - get_local $v + local.get $v i32.const 0x7F i32.and - tee_local $n + local.tee $n ;; if ( n > 1 ) { i32.const 1 i32.gt_u if ;; n -= 1; - get_local $n + local.get $n i32.const -1 i32.add - tee_local $n + local.tee $n ;; if ( n > ineedle ) { return -1; } - get_local $ineedle + local.get $ineedle i32.gt_u if i32.const -1 return end - get_local $i0 + local.get $i0 i32.const 1 i32.add - tee_local $i0 + local.tee $i0 ;; const i1 = i0 + n; - get_local $n + local.get $n i32.add - set_local $i1 + local.set $i1 ;; do { loop ;; ineedle -= 1; - get_local $ineedle + local.get $ineedle i32.const -1 i32.add - tee_local $ineedle + local.tee $ineedle ;; if ( this.buf[i0] !== this.buf[ineedle] ) { return -1; } i32.load8_u - get_local $i0 + local.get $i0 i32.load8_u i32.ne if @@ -176,47 +176,47 @@ return end ;; i0 += 1; - get_local $i0 + local.get $i0 i32.const 1 i32.add - tee_local $i0 + local.tee $i0 ;; } while ( i0 < i1 ); - get_local $i1 + local.get $i1 i32.lt_u br_if 0 end end ;; if ( (v & 0x80) !== 0 ) { - get_local $v + local.get $v i32.const 0x80 i32.and if ;; if ( ineedle === 0 || buf8[ineedle-1] === 0x2E /* '.' */ ) { ;; return ineedle; ;; } - get_local $ineedle + local.get $ineedle i32.eqz if i32.const 0 return end - get_local $ineedle + local.get $ineedle i32.const -1 i32.add i32.load8_u i32.const 0x2E i32.eq if - get_local $ineedle + local.get $ineedle return end end ;; icell = this.buf32[icell+1]; - get_local $icell + local.get $icell i32.load offset=4 i32.const 2 i32.shl - tee_local $icell + local.tee $icell ;; if ( icell === 0 ) { break; } br_if 0 end end @@ -245,7 +245,7 @@ ;; let lhnchar = this.buf[255]; i32.const 255 i32.load8_u - tee_local $lhnchar + local.tee $lhnchar ;; if ( lhnchar === 0 ) { return 0; } i32.eqz if @@ -281,21 +281,21 @@ end end ;; let icell = this.buf32[iroot+0]; - get_local $iroot + local.get $iroot i32.const 2 i32.shl - tee_local $iroot + local.tee $iroot i32.load i32.const 2 i32.shl - tee_local $icell + local.tee $icell ;; if ( this.buf32[icell+2] === 0 ) { i32.eqz if ;; this.buf32[iroot+0] = this.addLeafCell(lhnchar); ;; return 1; - get_local $iroot - get_local $lhnchar + local.get $iroot + local.get $lhnchar call $addLeafCell i32.store i32.const 1 @@ -304,37 +304,37 @@ ;; const char0 = this.buf32[HNBIGTRIE_CHAR0_SLOT]; i32.const 264 i32.load - set_local $char0 + local.set $char0 ;; for (;;) { loop $nextSegment ;; const v = this.buf32[icell+2]; - get_local $icell + local.get $icell i32.load offset=8 - tee_local $v + local.tee $v ;; let isegchar0 = char0 + (v >>> 8); i32.const 8 i32.shr_u - get_local $char0 + local.get $char0 i32.add - tee_local $isegchar0 + local.tee $isegchar0 ;; if ( this.buf[isegchar0] !== this.buf[lhnchar-1] ) { i32.load8_u - get_local $lhnchar + local.get $lhnchar i32.const -1 i32.add i32.load8_u i32.ne if ;; inext = this.buf32[icell+0]; - get_local $icell + local.get $icell i32.load - tee_local $inext + local.tee $inext ;; if ( inext === 0 ) { i32.eqz if ;; this.buf32[icell+0] = this.addLeafCell(lhnchar); - get_local $icell - get_local $lhnchar + local.get $icell + local.get $lhnchar call $addLeafCell i32.store ;; return 1; @@ -342,25 +342,25 @@ return end ;; icell = inext; - get_local $inext + local.get $inext i32.const 2 i32.shl - set_local $icell + local.set $icell br $nextSegment end ;; let isegchar = 1; i32.const 1 - set_local $isegchar + local.set $isegchar ;; lhnchar -= 1; - get_local $lhnchar + local.get $lhnchar i32.const -1 i32.add - set_local $lhnchar + local.set $lhnchar ;; const lsegchar = v & 0x7F; - get_local $v + local.get $v i32.const 0x7F i32.and - tee_local $lsegchar + local.tee $lsegchar ;; if ( lsegchar !== 1 ) { i32.const 1 i32.ne @@ -368,69 +368,69 @@ ;; for (;;) { block $mismatch loop ;; if ( isegchar === lsegchar ) { break; } - get_local $isegchar - get_local $lsegchar + local.get $isegchar + local.get $lsegchar i32.eq br_if $mismatch - get_local $lhnchar + local.get $lhnchar i32.eqz br_if $mismatch ;; if ( this.buf[isegchar0+isegchar] !== this.buf[lhnchar-1] ) { break; } - get_local $isegchar0 - get_local $isegchar + local.get $isegchar0 + local.get $isegchar i32.add i32.load8_u - get_local $lhnchar + local.get $lhnchar i32.const -1 i32.add i32.load8_u i32.ne br_if $mismatch ;; isegchar += 1; - get_local $isegchar + local.get $isegchar i32.const 1 i32.add - set_local $isegchar + local.set $isegchar ;; lhnchar -= 1; - get_local $lhnchar + local.get $lhnchar i32.const -1 i32.add - set_local $lhnchar + local.set $lhnchar br 0 end end end ;; const boundaryBit = v & 0x80; - get_local $v + local.get $v i32.const 0x80 i32.and - set_local $boundaryBit + local.set $boundaryBit ;; if ( isegchar === lsegchar ) { - get_local $isegchar - get_local $lsegchar + local.get $isegchar + local.get $lsegchar i32.eq if ;; if ( lhnchar === 0 ) { - get_local $lhnchar + local.get $lhnchar i32.eqz if ;; if ( boundaryBit !== 0 ) { return 0; } - get_local $boundaryBit + local.get $boundaryBit if i32.const 0 return end ;; this.buf32[icell+2] = v | 0x80; - get_local $icell - get_local $v + local.get $icell + local.get $v i32.const 0x80 i32.or i32.store offset=8 else ;; if ( boundaryBit !== 0 ) { - get_local $boundaryBit + local.get $boundaryBit if ;; if ( this.buf[lhnchar-1] === 0x2E /* '.' */ ) { return -1; } - get_local $lhnchar + local.get $lhnchar i32.const -1 i32.add i32.load8_u @@ -442,36 +442,36 @@ end end ;; inext = this.buf32[icell+1]; - get_local $icell + local.get $icell i32.load offset=4 - tee_local $inext + local.tee $inext ;; if ( inext !== 0 ) { if ;; icell = inext; - get_local $inext + local.get $inext i32.const 2 i32.shl - set_local $icell + local.set $icell ;; continue; br $nextSegment end ;; this.buf32[icell+1] = this.addLeafCell(lhnchar); - get_local $icell - get_local $lhnchar + local.get $icell + local.get $lhnchar call $addLeafCell i32.store offset=4 end else ;; isegchar0 -= char0; - get_local $icell - get_local $isegchar0 - get_local $char0 + local.get $icell + local.get $isegchar0 + local.get $char0 i32.sub - tee_local $isegchar0 + local.tee $isegchar0 ;; this.buf32[icell+2] = isegchar0 << 8 | isegchar; i32.const 8 i32.shl - get_local $isegchar + local.get $isegchar i32.or i32.store offset=8 ;; inext = this.addCell( @@ -479,39 +479,39 @@ ;; this.buf32[icell+1], ;; isegchar0 + isegchar << 8 | boundaryBit | lsegchar - isegchar ;; ); - get_local $icell + local.get $icell i32.const 0 - get_local $icell + local.get $icell i32.load offset=4 - get_local $isegchar0 - get_local $isegchar + local.get $isegchar0 + local.get $isegchar i32.add i32.const 8 i32.shl - get_local $boundaryBit + local.get $boundaryBit i32.or - get_local $lsegchar - get_local $isegchar + local.get $lsegchar + local.get $isegchar i32.sub i32.or call $addCell - tee_local $inext + local.tee $inext ;; this.buf32[icell+1] = inext; i32.store offset=4 ;; if ( lhnchar !== 0 ) { - get_local $lhnchar + local.get $lhnchar if ;; this.buf32[inext+0] = this.addLeafCell(lhnchar); - get_local $inext + local.get $inext i32.const 2 i32.shl - get_local $lhnchar + local.get $lhnchar call $addLeafCell i32.store else ;; this.buf32[icell+2] |= 0x80; - get_local $icell - get_local $icell + local.get $icell + local.get $icell i32.load offset=8 i32.const 0x80 i32.or @@ -547,24 +547,24 @@ i32.const 260 i32.const 260 i32.load - tee_local $icell + local.tee $icell i32.const 12 i32.add i32.store ;; this.buf32[icell+0] = idown; - get_local $icell - get_local $idown + local.get $icell + local.get $idown i32.store ;; this.buf32[icell+1] = iright; - get_local $icell - get_local $iright + local.get $icell + local.get $iright i32.store offset=4 ;; this.buf32[icell+2] = v; - get_local $icell - get_local $v + local.get $icell + local.get $v i32.store offset=8 ;; return icell; - get_local $icell + local.get $icell i32.const 2 i32.shr_u ) @@ -582,58 +582,58 @@ ;; const r = this.buf32[TRIE1_SLOT] >>> 2; i32.const 260 i32.load - tee_local $r + local.tee $r ;; let i = r; - set_local $i + local.set $i ;; while ( lsegchar > 127 ) { block $lastSegment loop - get_local $lsegchar + local.get $lsegchar i32.const 127 i32.le_u br_if $lastSegment ;; this.buf32[i+0] = 0; - get_local $i + local.get $i i32.const 0 i32.store ;; this.buf32[i+1] = i + 3; - get_local $i - get_local $i + local.get $i + local.get $i i32.const 12 i32.add i32.const 2 i32.shr_u i32.store offset=4 ;; this.buf32[i+2] = this.addSegment(lsegchar, lsegchar - 127); - get_local $i - get_local $lsegchar - get_local $lsegchar + local.get $i + local.get $lsegchar + local.get $lsegchar i32.const 127 i32.sub call $addSegment i32.store offset=8 ;; lsegchar -= 127; - get_local $lsegchar + local.get $lsegchar i32.const 127 i32.sub - set_local $lsegchar + local.set $lsegchar ;; i += 3; - get_local $i + local.get $i i32.const 12 i32.add - set_local $i + local.set $i br 0 end end ;; this.buf32[i+0] = 0; - get_local $i + local.get $i i32.const 0 i32.store ;; this.buf32[i+1] = 0; - get_local $i + local.get $i i32.const 0 i32.store offset=4 ;; this.buf32[i+2] = this.addSegment(lsegchar, 0) | 0x80; - get_local $i - get_local $lsegchar + local.get $i + local.get $lsegchar i32.const 0 call $addSegment i32.const 0x80 @@ -641,12 +641,12 @@ i32.store offset=8 ;; this.buf32[TRIE1_SLOT] = i + 3 << 2; i32.const 260 - get_local $i + local.get $i i32.const 12 i32.add i32.store ;; return r; - get_local $r + local.get $r i32.const 2 i32.shr_u ) @@ -666,7 +666,7 @@ (local $i i32) ;; iterator ;; ;; if ( lsegchar === 0 ) { return 0; } - get_local $lsegchar + local.get $lsegchar i32.eqz if i32.const 0 @@ -675,45 +675,45 @@ ;; let char1 = this.buf32[HNBIGTRIE_CHAR1_SLOT]; i32.const 268 i32.load - tee_local $char1 + local.tee $char1 ;; const isegchar = char1 - this.buf32[HNBIGTRIE_CHAR0_SLOT]; i32.const 264 i32.load i32.sub - set_local $isegchar + local.set $isegchar ;; let i = lsegchar; - get_local $lsegchar - set_local $i + local.get $lsegchar + local.set $i ;; do { loop ;; this.buf[char1++] = this.buf[--i]; - get_local $char1 - get_local $i + local.get $char1 + local.get $i i32.const -1 i32.add - tee_local $i + local.tee $i i32.load8_u i32.store8 - get_local $char1 + local.get $char1 i32.const 1 i32.add - set_local $char1 + local.set $char1 ;; } while ( i !== lsegend ); - get_local $i - get_local $lsegend + local.get $i + local.get $lsegend i32.ne br_if 0 end ;; this.buf32[HNBIGTRIE_CHAR1_SLOT] = char1; i32.const 268 - get_local $char1 + local.get $char1 i32.store ;; return isegchar << 8 | lsegchar - lsegend; - get_local $isegchar + local.get $isegchar i32.const 8 i32.shl - get_local $lsegchar - get_local $lsegend + local.get $lsegchar + local.get $lsegend i32.sub i32.or ) diff --git a/src/lib/lz4/lz4-block-codec.wat b/src/lib/lz4/lz4-block-codec.wat index 93e5dc16a..1181379ad 100644 --- a/src/lib/lz4/lz4-block-codec.wat +++ b/src/lib/lz4/lz4-block-codec.wat @@ -68,15 +68,15 @@ (func (export "lz4BlockEncodeBound") (param $ilen i32) (result i32) - get_local $ilen + local.get $ilen i32.const 0x7E000000 i32.gt_u if i32.const 0 return end - get_local $ilen - get_local $ilen + local.get $ilen + local.get $ilen i32.const 255 i32.div_u i32.add @@ -123,14 +123,14 @@ (local $llen i32) ;; length of found literals (local $moffset i32) ;; offset to found match from current input position (local $mlen i32) ;; length of found match - get_local $ilen ;; empty input = empty output + local.get $ilen ;; empty input = empty output i32.const 0x7E000000 ;; max input size: 0x7E000000 i32.gt_u if i32.const 0 return end - get_local $ilen ;; "blocks < 13 bytes cannot be compressed" + local.get $ilen ;; "blocks < 13 bytes cannot be compressed" i32.const 13 i32.lt_u if @@ -138,78 +138,78 @@ return end call $getLinearMemoryOffset ;; hash table is at start of usable memory - set_local $hashPtrBeg - get_local $inPtr - tee_local $anchorPtr - get_local $ilen + local.set $hashPtrBeg + local.get $inPtr + local.tee $anchorPtr + local.get $ilen i32.add - tee_local $inPtrEnd + local.tee $inPtrEnd i32.const -5 ;; "The last 5 bytes are always literals." i32.add - tee_local $inPtrEnd2 + local.tee $inPtrEnd2 i32.const -7 ;; "The last match must start at least 12 bytes before end of block" i32.add - set_local $inPtrEnd1 - get_local $outPtr - set_local $outPtrBeg + local.set $inPtrEnd1 + local.get $outPtr + local.set $outPtrBeg ;; ;; sequence processing loop ;; block $noMoreSequence loop $nextSequence - get_local $inPtr - get_local $inPtrEnd1 + local.get $inPtr + local.get $inPtrEnd1 i32.ge_u ;; 5 or less bytes left? br_if $noMoreSequence - get_local $inPtr ;; first sequence of 3 bytes before match-finding loop + local.get $inPtr ;; first sequence of 3 bytes before match-finding loop i32.load8_u i32.const 8 i32.shl - get_local $inPtr + local.get $inPtr i32.load8_u offset=1 i32.const 16 i32.shl i32.or - get_local $inPtr + local.get $inPtr i32.load8_u offset=2 i32.const 24 i32.shl i32.or - set_local $seq32 + local.set $seq32 ;; ;; match-finding loop ;; loop $findMatch block $noMatchFound - get_local $inPtr - get_local $inPtrEnd2 + local.get $inPtr + local.get $inPtrEnd2 i32.gt_u ;; less than 12 bytes left? br_if $noMoreSequence - get_local $seq32 ;; update last byte of current sequence + local.get $seq32 ;; update last byte of current sequence i32.const 8 i32.shr_u - get_local $inPtr + local.get $inPtr i32.load8_u offset=3 i32.const 24 i32.shl i32.or - tee_local $seq32 + local.tee $seq32 i32.const 0x9E3779B1 ;; compute 16-bit hash i32.mul i32.const 16 i32.shr_u ;; hash value is at top of stack i32.const 2 ;; lookup refPtr at hash entry i32.shl - get_local $hashPtrBeg + local.get $hashPtrBeg i32.add - tee_local $hashPtr + local.tee $hashPtr i32.load - set_local $refPtr - get_local $hashPtr ;; update hash entry with inPtr - get_local $inPtr + local.set $refPtr + local.get $hashPtr ;; update hash entry with inPtr + local.get $inPtr i32.store - get_local $inPtr - get_local $refPtr + local.get $inPtr + local.get $refPtr i32.sub - tee_local $moffset ;; remember match offset, we will need it in case of match + local.tee $moffset ;; remember match offset, we will need it in case of match i32.const 0xFFFF i32.gt_s ;; match offset > 65535 = unusable match br_if $noMatchFound @@ -217,177 +217,177 @@ ;; confirm match: different sequences can yield same hash ;; compare-branch each byte to potentially save memory read ops ;; - get_local $seq32 ;; byte 0 + local.get $seq32 ;; byte 0 i32.const 0xFF i32.and - get_local $refPtr + local.get $refPtr i32.load8_u i32.ne ;; refPtr[0] !== inPtr[0] br_if $noMatchFound - get_local $seq32 ;; byte 1 + local.get $seq32 ;; byte 1 i32.const 8 i32.shr_u i32.const 0xFF i32.and - get_local $refPtr + local.get $refPtr i32.load8_u offset=1 i32.ne br_if $noMatchFound ;; refPtr[1] !== inPtr[1] - get_local $seq32 ;; byte 2 + local.get $seq32 ;; byte 2 i32.const 16 i32.shr_u i32.const 0xFF i32.and - get_local $refPtr + local.get $refPtr i32.load8_u offset=2 i32.ne ;; refPtr[2] !== inPtr[2] br_if $noMatchFound - get_local $seq32 ;; byte 3 + local.get $seq32 ;; byte 3 i32.const 24 i32.shr_u i32.const 0xFF i32.and - get_local $refPtr + local.get $refPtr i32.load8_u offset=3 i32.ne ;; refPtr[3] !== inPtr[3] br_if $noMatchFound ;; ;; a valid match has been found at this point ;; - get_local $inPtr ;; compute length of literals - get_local $anchorPtr + local.get $inPtr ;; compute length of literals + local.get $anchorPtr i32.sub - set_local $llen - get_local $inPtr ;; find match length + local.set $llen + local.get $inPtr ;; find match length i32.const 4 ;; skip over confirmed 4-byte match i32.add - set_local $inPtr - get_local $refPtr + local.set $inPtr + local.get $refPtr i32.const 4 i32.add - tee_local $mlen ;; remember refPtr to later compute match length - set_local $refPtr + local.tee $mlen ;; remember refPtr to later compute match length + local.set $refPtr block $endOfMatch loop ;; scan input buffer until match ends - get_local $inPtr - get_local $inPtrEnd2 + local.get $inPtr + local.get $inPtrEnd2 i32.ge_u br_if $endOfMatch - get_local $inPtr + local.get $inPtr i32.load8_u - get_local $refPtr + local.get $refPtr i32.load8_u i32.ne br_if $endOfMatch - get_local $inPtr + local.get $inPtr i32.const 1 i32.add - set_local $inPtr - get_local $refPtr + local.set $inPtr + local.get $refPtr i32.const 1 i32.add - set_local $refPtr + local.set $refPtr br 0 end end $endOfMatch ;; encode token - get_local $outPtr ;; output token - get_local $llen - get_local $refPtr - get_local $mlen + local.get $outPtr ;; output token + local.get $llen + local.get $refPtr + local.get $mlen i32.sub - tee_local $mlen + local.tee $mlen call $writeToken - get_local $outPtr + local.get $outPtr i32.const 1 i32.add - set_local $outPtr - get_local $llen ;; encode/write length of literals if needed + local.set $outPtr + local.get $llen ;; encode/write length of literals if needed i32.const 15 i32.ge_s if - get_local $outPtr - get_local $llen + local.get $outPtr + local.get $llen call $writeLength - set_local $outPtr + local.set $outPtr end ;; copy literals - get_local $outPtr - get_local $anchorPtr - get_local $llen + local.get $outPtr + local.get $anchorPtr + local.get $llen call $copy - get_local $outPtr - get_local $llen + local.get $outPtr + local.get $llen i32.add - set_local $outPtr + local.set $outPtr ;; encode match offset - get_local $outPtr - get_local $moffset + local.get $outPtr + local.get $moffset i32.store8 - get_local $outPtr - get_local $moffset + local.get $outPtr + local.get $moffset i32.const 8 i32.shr_u i32.store8 offset=1 - get_local $outPtr + local.get $outPtr i32.const 2 i32.add - set_local $outPtr - get_local $mlen ;; encode/write length of match if needed + local.set $outPtr + local.get $mlen ;; encode/write length of match if needed i32.const 15 i32.ge_s if - get_local $outPtr - get_local $mlen + local.get $outPtr + local.get $mlen call $writeLength - set_local $outPtr + local.set $outPtr end - get_local $inPtr ;; advance anchor to current position - set_local $anchorPtr + local.get $inPtr ;; advance anchor to current position + local.set $anchorPtr br $nextSequence end $noMatchFound - get_local $inPtr ;; no match found: advance to next byte + local.get $inPtr ;; no match found: advance to next byte i32.const 1 i32.add - set_local $inPtr + local.set $inPtr br $findMatch end ;; match offset > 65535 = unusable match end end $noMoreSequence ;; ;; generate last (match-less) sequence if compression succeeded ;; - get_local $outPtr - get_local $outPtrBeg + local.get $outPtr + local.get $outPtrBeg i32.eq if i32.const 0 return end - get_local $outPtr - get_local $inPtrEnd - get_local $anchorPtr + local.get $outPtr + local.get $inPtrEnd + local.get $anchorPtr i32.sub - tee_local $llen + local.tee $llen i32.const 0 call $writeToken - get_local $outPtr + local.get $outPtr i32.const 1 i32.add - set_local $outPtr - get_local $llen + local.set $outPtr + local.get $llen i32.const 15 i32.ge_u if - get_local $outPtr - get_local $llen + local.get $outPtr + local.get $llen call $writeLength - set_local $outPtr + local.set $outPtr end - get_local $outPtr - get_local $anchorPtr - get_local $llen + local.get $outPtr + local.get $anchorPtr + local.get $llen call $copy - get_local $outPtr ;; return number of written bytes - get_local $llen + local.get $outPtr ;; return number of written bytes + local.get $llen i32.add - get_local $outPtrBeg + local.get $outPtrBeg i32.sub ) @@ -413,128 +413,128 @@ (local $token i32) ;; sequence token (local $clen i32) ;; number of bytes to copy (local $_ i32) ;; general purpose variable - get_local $ilen ;; if ( ilen == 0 ) { return 0; } + local.get $ilen ;; if ( ilen == 0 ) { return 0; } i32.eqz if i32.const 0 return end - get_local $inPtr0 - tee_local $inPtr ;; current position in input buffer - get_local $ilen + local.get $inPtr0 + local.tee $inPtr ;; current position in input buffer + local.get $ilen i32.add - set_local $inPtrEnd - get_local $outPtr0 ;; start of output buffer - set_local $outPtr ;; current position in output buffer + local.set $inPtrEnd + local.get $outPtr0 ;; start of output buffer + local.set $outPtr ;; current position in output buffer block $noMoreSequence loop ;; iterate through all sequences - get_local $inPtr - get_local $inPtrEnd + local.get $inPtr + local.get $inPtrEnd i32.ge_u br_if $noMoreSequence ;; break when nothing left to read in input buffer - get_local $inPtr ;; read token -- consume one byte + local.get $inPtr ;; read token -- consume one byte i32.load8_u - get_local $inPtr + local.get $inPtr i32.const 1 i32.add - set_local $inPtr - tee_local $token ;; extract length of literals from token + local.set $inPtr + local.tee $token ;; extract length of literals from token i32.const 4 i32.shr_u - tee_local $clen ;; consume extra length bytes if present + local.tee $clen ;; consume extra length bytes if present i32.eqz if else - get_local $clen + local.get $clen i32.const 15 i32.eq if loop - get_local $inPtr + local.get $inPtr i32.load8_u - get_local $inPtr + local.get $inPtr i32.const 1 i32.add - set_local $inPtr - tee_local $_ - get_local $clen + local.set $inPtr + local.tee $_ + local.get $clen i32.add - set_local $clen - get_local $_ + local.set $clen + local.get $_ i32.const 255 i32.eq br_if 0 end end - get_local $outPtr ;; copy literals to ouput buffer - get_local $inPtr - get_local $clen + local.get $outPtr ;; copy literals to ouput buffer + local.get $inPtr + local.get $clen call $copy - get_local $outPtr ;; advance output buffer pointer past copy - get_local $clen + local.get $outPtr ;; advance output buffer pointer past copy + local.get $clen i32.add - set_local $outPtr - get_local $clen ;; advance input buffer pointer past literals - get_local $inPtr + local.set $outPtr + local.get $clen ;; advance input buffer pointer past literals + local.get $inPtr i32.add - tee_local $inPtr - get_local $inPtrEnd ;; exit if this is the last sequence + local.tee $inPtr + local.get $inPtrEnd ;; exit if this is the last sequence i32.eq br_if $noMoreSequence end - get_local $outPtr ;; read match offset - get_local $inPtr + local.get $outPtr ;; read match offset + local.get $inPtr i32.load8_u - get_local $inPtr + local.get $inPtr i32.load8_u offset=1 i32.const 8 i32.shl i32.or i32.sub - tee_local $matchPtr - get_local $outPtr ;; match position can't be outside input buffer bounds + local.tee $matchPtr + local.get $outPtr ;; match position can't be outside input buffer bounds i32.eq br_if $noMoreSequence - get_local $matchPtr - get_local $inPtrEnd + local.get $matchPtr + local.get $inPtrEnd i32.lt_u br_if $noMoreSequence - get_local $inPtr ;; advance input pointer past match offset bytes + local.get $inPtr ;; advance input pointer past match offset bytes i32.const 2 i32.add - set_local $inPtr - get_local $token ;; extract length of match from token + local.set $inPtr + local.get $token ;; extract length of match from token i32.const 15 i32.and i32.const 4 i32.add - tee_local $clen + local.tee $clen i32.const 19 ;; consume extra length bytes if present i32.eq if loop - get_local $inPtr + local.get $inPtr i32.load8_u - get_local $inPtr + local.get $inPtr i32.const 1 i32.add - set_local $inPtr - tee_local $_ - get_local $clen + local.set $inPtr + local.tee $_ + local.get $clen i32.add - set_local $clen - get_local $_ + local.set $clen + local.get $_ i32.const 255 i32.eq br_if 0 end end - get_local $outPtr ;; copy match to ouput buffer - get_local $matchPtr - get_local $clen + local.get $outPtr ;; copy match to ouput buffer + local.get $matchPtr + local.get $clen call $copy - get_local $clen ;; advance output buffer pointer past copy - get_local $outPtr + local.get $clen ;; advance output buffer pointer past copy + local.get $outPtr i32.add - set_local $outPtr + local.set $outPtr br 0 end end $noMoreSequence - get_local $outPtr ;; return number of written bytes - get_local $outPtr0 + local.get $outPtr ;; return number of written bytes + local.get $outPtr0 i32.sub ) @@ -552,18 +552,18 @@ (param $outPtr i32) (param $llen i32) (param $mlen i32) - get_local $outPtr - get_local $llen + local.get $outPtr + local.get $llen i32.const 15 - get_local $llen + local.get $llen i32.const 15 i32.lt_u select i32.const 4 i32.shl - get_local $mlen + local.get $mlen i32.const 15 - get_local $mlen + local.get $mlen i32.const 15 i32.lt_u select @@ -582,32 +582,32 @@ (param $outPtr i32) (param $len i32) (result i32) - get_local $len + local.get $len i32.const 15 i32.sub - set_local $len + local.set $len loop - get_local $outPtr - get_local $len + local.get $outPtr + local.get $len i32.const 255 - get_local $len + local.get $len i32.const 255 i32.lt_u select i32.store8 - get_local $outPtr + local.get $outPtr i32.const 1 i32.add - set_local $outPtr - get_local $len + local.set $outPtr + local.get $len i32.const 255 i32.sub - tee_local $len + local.tee $len i32.const 0 i32.ge_s br_if 0 end - get_local $outPtr + local.get $outPtr ) ;; @@ -621,119 +621,119 @@ (param $src i32) (param $len i32) block $lessThan8 loop - get_local $len + local.get $len i32.const 8 i32.lt_u br_if $lessThan8 - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u i32.store8 - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u offset=1 i32.store8 offset=1 - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u offset=2 i32.store8 offset=2 - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u offset=3 i32.store8 offset=3 - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u offset=4 i32.store8 offset=4 - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u offset=5 i32.store8 offset=5 - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u offset=6 i32.store8 offset=6 - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u offset=7 i32.store8 offset=7 - get_local $dst + local.get $dst i32.const 8 i32.add - set_local $dst - get_local $src + local.set $dst + local.get $src i32.const 8 i32.add - set_local $src - get_local $len + local.set $src + local.get $len i32.const -8 i32.add - set_local $len + local.set $len br 0 end end $lessThan8 - get_local $len + local.get $len i32.const 4 i32.ge_u if - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u i32.store8 - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u offset=1 i32.store8 offset=1 - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u offset=2 i32.store8 offset=2 - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u offset=3 i32.store8 offset=3 - get_local $dst + local.get $dst i32.const 4 i32.add - set_local $dst - get_local $src + local.set $dst + local.get $src i32.const 4 i32.add - set_local $src - get_local $len + local.set $src + local.get $len i32.const -4 i32.add - set_local $len + local.set $len end - get_local $len + local.get $len i32.const 2 i32.ge_u if - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u i32.store8 - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u offset=1 i32.store8 offset=1 - get_local $dst + local.get $dst i32.const 2 i32.add - set_local $dst - get_local $src + local.set $dst + local.get $src i32.const 2 i32.add - set_local $src - get_local $len + local.set $src + local.get $len i32.const -2 i32.add - set_local $len + local.set $len end - get_local $len + local.get $len i32.eqz if else - get_local $dst - get_local $src + local.get $dst + local.get $src i32.load8_u i32.store8 end diff --git a/src/lib/publicsuffixlist/wasm/publicsuffixlist.wat b/src/lib/publicsuffixlist/wasm/publicsuffixlist.wat index ee002a13a..8ea7381ac 100644 --- a/src/lib/publicsuffixlist/wasm/publicsuffixlist.wat +++ b/src/lib/publicsuffixlist/wasm/publicsuffixlist.wat @@ -83,133 +83,133 @@ ;; const iCharData = buf32[CHARDATA_PTR_SLOT]; i32.const 404 i32.load - set_local $iCharData + local.set $iCharData ;; let iNode = pslBuffer32[RULES_PTR_SLOT]; i32.const 400 i32.load i32.const 2 i32.shl - set_local $iNode + local.set $iNode ;; let iLabel = LABEL_INDICES_SLOT; i32.const 256 - set_local $iLabel + local.set $iLabel ;; let cursorPos = -1; i32.const -1 - set_local $cursorPos + local.set $cursorPos ;; label-lookup loop ;; for (;;) { block $labelLookupDone loop $labelLookup ;; // Extract label indices ;; const labelBeg = buf8[iLabel+1]; ;; const labelLen = buf8[iLabel+0] - labelBeg; - get_local $iLabel + local.get $iLabel i32.load8_u - get_local $iLabel + local.get $iLabel i32.load8_u offset=1 - tee_local $labelBeg + local.tee $labelBeg i32.sub - set_local $labelLen + local.set $labelLen ;; // Match-lookup loop: binary search ;; let r = buf32[iNode+0] >>> 16; ;; if ( r === 0 ) { break; } - get_local $iNode + local.get $iNode i32.load16_u offset=2 - tee_local $r + local.tee $r i32.eqz br_if $labelLookupDone ;; const iCandidates = buf32[iNode+2]; - get_local $iNode + local.get $iNode i32.load offset=8 i32.const 2 i32.shl - set_local $iCandidates + local.set $iCandidates ;; let l = 0; ;; let iFound = 0; i32.const 0 - tee_local $l - set_local $iFound + local.tee $l + local.set $iFound ;; while ( l < r ) { block $binarySearchDone loop $binarySearch - get_local $l - get_local $r + local.get $l + local.get $r i32.ge_u br_if $binarySearchDone ;; const iCandidate = l + r >>> 1; - get_local $l - get_local $r + local.get $l + local.get $r i32.add i32.const 1 i32.shr_u - tee_local $iCandidate + local.tee $iCandidate ;; const iCandidateNode = iCandidates + iCandidate + (iCandidate << 1); i32.const 2 i32.shl - tee_local $_1 - get_local $_1 + local.tee $_1 + local.get $_1 i32.const 1 i32.shl i32.add - get_local $iCandidates + local.get $iCandidates i32.add - tee_local $iCandidateNode + local.tee $iCandidateNode ;; const candidateLen = buf32[iCandidateNode+0] & 0x000000FF; i32.load8_u - set_local $candidateLen + local.set $candidateLen ;; let d = labelLen - candidateLen; - get_local $labelLen - get_local $candidateLen + local.get $labelLen + local.get $candidateLen i32.sub - tee_local $d + local.tee $d ;; if ( d === 0 ) { i32.eqz if ;; const iCandidateChar = candidateLen <= 4 - get_local $candidateLen + local.get $candidateLen i32.const 4 i32.le_u if ;; ? iCandidateNode + 1 << 2 - get_local $iCandidateNode + local.get $iCandidateNode i32.const 4 i32.add - set_local $iCandidateChar + local.set $iCandidateChar else ;; : buf32[CHARDATA_PTR_SLOT] + buf32[iCandidateNode+1]; - get_local $iCharData - get_local $iCandidateNode + local.get $iCharData + local.get $iCandidateNode i32.load offset=4 i32.add - set_local $iCandidateChar + local.set $iCandidateChar end ;; for ( let i = 0; i < labelLen; i++ ) { - get_local $labelBeg - tee_local $_1 - get_local $labelLen + local.get $labelBeg + local.tee $_1 + local.get $labelLen i32.add - set_local $_3 - get_local $iCandidateChar - set_local $_2 + local.set $_3 + local.get $iCandidateChar + local.set $_2 block $findDiffDone loop $findDiff ;; d = buf8[labelBeg+i] - buf8[iCandidateChar+i]; ;; if ( d !== 0 ) { break; } - get_local $_1 + local.get $_1 i32.load8_u - get_local $_2 + local.get $_2 i32.load8_u i32.sub - tee_local $d + local.tee $d br_if $findDiffDone - get_local $_1 + local.get $_1 i32.const 1 i32.add - tee_local $_1 - get_local $_3 + local.tee $_1 + local.get $_3 i32.eq br_if $findDiffDone - get_local $_2 + local.get $_2 i32.const 1 i32.add - set_local $_2 + local.set $_2 br $findDiff ;; } end end @@ -217,32 +217,32 @@ end ;; if ( d < 0 ) { ;; r = iCandidate; - get_local $d + local.get $d i32.const 0 i32.lt_s if - get_local $iCandidate - set_local $r + local.get $iCandidate + local.set $r br $binarySearch end ;; } else if ( d > 0 ) { ;; l = iCandidate + 1; - get_local $d + local.get $d i32.const 0 i32.gt_s if - get_local $iCandidate + local.get $iCandidate i32.const 1 i32.add - set_local $l + local.set $l br $binarySearch end ;; } else /* if ( d === 0 ) */ { ;; iFound = iCandidateNode; ;; break; ;; } - get_local $iCandidateNode - set_local $iFound + local.get $iCandidateNode + local.set $iFound end end ;; } ;; // 2. If no rules match, the prevailing rule is "*". @@ -251,10 +251,10 @@ ;; buf8[SUFFIX_NOT_FOUND_SLOT] = 1; ;; iFound = iCandidates; ;; } - get_local $iFound + local.get $iFound i32.eqz if - get_local $iCandidates + local.get $iCandidates i32.load offset=4 i32.const 0x2A i32.ne @@ -262,12 +262,12 @@ i32.const 399 i32.const 1 i32.store8 - get_local $iCandidates - set_local $iFound + local.get $iCandidates + local.set $iFound end ;; iNode = iFound; - get_local $iFound - tee_local $iNode + local.get $iFound + local.tee $iNode ;; // 5. If the prevailing rule is a exception rule, modify it by ;; // removing the leftmost label. ;; if ( (buf32[iNode+0] & 0x00000200) !== 0 ) { @@ -277,15 +277,15 @@ ;; break; ;; } i32.load8_u offset=1 - tee_local $_1 + local.tee $_1 i32.const 0x02 i32.and if - get_local $iLabel + local.get $iLabel i32.const 256 i32.gt_u if - get_local $iLabel + local.get $iLabel i32.const -2 i32.add return @@ -295,25 +295,25 @@ ;; if ( (buf32[iNode+0] & 0x00000100) !== 0 ) { ;; cursorPos = labelBeg; ;; } - get_local $_1 + local.get $_1 i32.const 0x01 i32.and if - get_local $iLabel - set_local $cursorPos + local.get $iLabel + local.set $cursorPos end ;; if ( labelBeg === 0 ) { break; } - get_local $labelBeg + local.get $labelBeg i32.eqz br_if $labelLookupDone ;; iLabel += 2; - get_local $iLabel + local.get $iLabel i32.const 2 i32.add - set_local $iLabel + local.set $iLabel br $labelLookup end end - get_local $cursorPos + local.get $cursorPos ) ;;