mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
Fix possible out of bounds read in string UTF8 conversion
This commit is contained in:
parent
829af2285c
commit
51ede113dd
2
dist/asc.js
vendored
2
dist/asc.js
vendored
File diff suppressed because one or more lines are too long
2
dist/asc.js.map
vendored
2
dist/asc.js.map
vendored
File diff suppressed because one or more lines are too long
@ -414,57 +414,62 @@ export class String {
|
||||
}
|
||||
|
||||
get lengthUTF8(): i32 {
|
||||
var blen = 1; // null terminated
|
||||
for (let i: usize = 0, k = <usize>this.length; i < k;) {
|
||||
let c = <u32>load<u16>(changetype<usize>(this) + (i << 1), HEADER_SIZE);
|
||||
var len = 1; // null terminated
|
||||
var pos: usize = 0;
|
||||
var end = <usize>this.length;
|
||||
while (pos < end) {
|
||||
let c = <u32>load<u16>(changetype<usize>(this) + (pos << 1), HEADER_SIZE);
|
||||
if (c < 128) {
|
||||
blen += 1; ++i;
|
||||
len += 1; ++pos;
|
||||
} else if (c < 2048) {
|
||||
blen += 2; ++i;
|
||||
} else if (
|
||||
(c & 0xFC00) === 0xD800 &&
|
||||
(<u32>load<u16>(changetype<usize>(this) + ((i + 1) << 1), HEADER_SIZE) & 0xFC00) === 0xDC00
|
||||
) {
|
||||
blen += 4; i += 2;
|
||||
len += 2; ++pos;
|
||||
} else {
|
||||
blen += 3; ++i;
|
||||
if (
|
||||
(c & 0xFC00) == 0xD800 && pos + 1 < end &&
|
||||
(<u32>load<u16>(changetype<usize>(this) + ((pos + 1) << 1), HEADER_SIZE) & 0xFC00) == 0xDC00
|
||||
) {
|
||||
len += 4; pos += 2;
|
||||
} else {
|
||||
len += 3; ++pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
return blen;
|
||||
return len;
|
||||
}
|
||||
|
||||
toUTF8(): usize {
|
||||
var len = this.lengthUTF8;
|
||||
var buf = allocate_memory(len);
|
||||
var buf = allocate_memory(<usize>this.lengthUTF8);
|
||||
var pos: usize = 0;
|
||||
var end = <usize>this.length;
|
||||
var off: usize = 0;
|
||||
for (let i: usize = 0, k = <usize>this.length; i < k;) {
|
||||
let c1 = <u32>load<u16>(changetype<usize>(this) + (i << 1), HEADER_SIZE);
|
||||
while (pos < end) {
|
||||
let c1 = <u32>load<u16>(changetype<usize>(this) + (pos << 1), HEADER_SIZE);
|
||||
if (c1 < 128) {
|
||||
store<u8>(buf + off, c1);
|
||||
++off; ++i;
|
||||
++off; ++pos;
|
||||
} else if (c1 < 2048) {
|
||||
let pos = buf + off;
|
||||
store<u8>(pos, c1 >> 6 | 192);
|
||||
store<u8>(pos, c1 & 63 | 128, 1);
|
||||
off += 2; ++i;
|
||||
let ptr = buf + off;
|
||||
store<u8>(ptr, c1 >> 6 | 192);
|
||||
store<u8>(ptr, c1 & 63 | 128, 1);
|
||||
off += 2; ++pos;
|
||||
} else {
|
||||
let pos = buf + off;
|
||||
if ((c1 & 0xFC00) == 0xD800) {
|
||||
let c2 = <u32>load<u16>(changetype<usize>(this) + ((i + 1) << 1), HEADER_SIZE);
|
||||
let ptr = buf + off;
|
||||
if ((c1 & 0xFC00) == 0xD800 && pos + 1 < end) {
|
||||
let c2 = <u32>load<u16>(changetype<usize>(this) + ((pos + 1) << 1), HEADER_SIZE);
|
||||
if ((c2 & 0xFC00) == 0xDC00) {
|
||||
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
||||
store<u8>(pos, c1 >> 18 | 240);
|
||||
store<u8>(pos, c1 >> 12 & 63 | 128, 1);
|
||||
store<u8>(pos, c1 >> 6 & 63 | 128, 2);
|
||||
store<u8>(pos, c1 & 63 | 128, 3);
|
||||
off += 4; i += 2;
|
||||
store<u8>(ptr, c1 >> 18 | 240);
|
||||
store<u8>(ptr, c1 >> 12 & 63 | 128, 1);
|
||||
store<u8>(ptr, c1 >> 6 & 63 | 128, 2);
|
||||
store<u8>(ptr, c1 & 63 | 128, 3);
|
||||
off += 4; pos += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
store<u8>(pos, c1 >> 12 | 224);
|
||||
store<u8>(pos, c1 >> 6 & 63 | 128, 1);
|
||||
store<u8>(pos, c1 & 63 | 128, 2);
|
||||
off += 3; ++i;
|
||||
store<u8>(ptr, c1 >> 12 | 224);
|
||||
store<u8>(ptr, c1 >> 6 & 63 | 128, 1);
|
||||
store<u8>(ptr, c1 & 63 | 128, 2);
|
||||
off += 3; ++pos;
|
||||
}
|
||||
}
|
||||
store<u8>(buf + off, 0);
|
||||
|
@ -23,57 +23,39 @@
|
||||
(set_local $1
|
||||
(i32.const 1)
|
||||
)
|
||||
(block $break|0
|
||||
(set_local $4
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(loop $loop|0
|
||||
(br_if $break|0
|
||||
(i32.ge_u
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
(get_local $4)
|
||||
)
|
||||
(set_local $2
|
||||
(if (result i32)
|
||||
(i32.lt_u
|
||||
(tee_local $3
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
(block
|
||||
(set_local $2
|
||||
(if (result i32)
|
||||
(i32.lt_u
|
||||
(tee_local $3
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
(block (result i32)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(if (result i32)
|
||||
(i32.lt_u
|
||||
(get_local $3)
|
||||
(i32.const 2048)
|
||||
(i32.const 128)
|
||||
)
|
||||
(block (result i32)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.add
|
||||
@ -82,53 +64,15 @@
|
||||
)
|
||||
)
|
||||
(if (result i32)
|
||||
(if (result i32)
|
||||
(tee_local $3
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(get_local $3)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 55296)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 56320)
|
||||
)
|
||||
(i32.lt_u
|
||||
(get_local $3)
|
||||
(i32.const 2048)
|
||||
)
|
||||
(block (result i32)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(block (result i32)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(i32.add
|
||||
@ -136,11 +80,79 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(if (result i32)
|
||||
(if (result i32)
|
||||
(if (result i32)
|
||||
(tee_local $3
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(get_local $3)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 55296)
|
||||
)
|
||||
)
|
||||
(tee_local $3
|
||||
(i32.lt_u
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 56320)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(block (result i32)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(block (result i32)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
(br $loop|0)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
@ -249,268 +261,270 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|0
|
||||
(set_local $6
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $7
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(loop $loop|0
|
||||
(block $continue|0
|
||||
(br_if $break|0
|
||||
(i32.ge_u
|
||||
(get_local $2)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(if (result i32)
|
||||
(i32.lt_u
|
||||
(tee_local $1
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $3)
|
||||
(get_local $7)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.lt_u
|
||||
(tee_local $1
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
(block (result i32)
|
||||
(i32.const 128)
|
||||
)
|
||||
(block
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $2)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $1)
|
||||
(i32.const 2048)
|
||||
)
|
||||
(block
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $3)
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(i32.or
|
||||
(i32.shr_u
|
||||
(get_local $1)
|
||||
(i32.const 6)
|
||||
)
|
||||
(i32.const 192)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=1
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(if (result i32)
|
||||
(i32.lt_u
|
||||
(get_local $1)
|
||||
(i32.const 2048)
|
||||
)
|
||||
(block (result i32)
|
||||
(i32.store8
|
||||
(tee_local $4
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.or
|
||||
(i32.shr_u
|
||||
(get_local $1)
|
||||
(i32.const 6)
|
||||
)
|
||||
(i32.const 192)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=1
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(block (result i32)
|
||||
(set_local $4
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(if (result i32)
|
||||
(tee_local $6
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 55296)
|
||||
)
|
||||
)
|
||||
(i32.lt_u
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $7)
|
||||
)
|
||||
(get_local $6)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 55296)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(tee_local $7
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(tee_local $6
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 56320)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(block
|
||||
(i32.store8
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.shr_u
|
||||
(tee_local $1
|
||||
(i32.const 56320)
|
||||
)
|
||||
(block
|
||||
(i32.store8
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.shr_u
|
||||
(tee_local $1
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.shl
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 1023)
|
||||
)
|
||||
(i32.const 10)
|
||||
(i32.shl
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 1023)
|
||||
)
|
||||
(i32.const 65536)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $7)
|
||||
(i32.const 1023)
|
||||
(i32.const 10)
|
||||
)
|
||||
(i32.const 65536)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $6)
|
||||
(i32.const 1023)
|
||||
)
|
||||
)
|
||||
(i32.const 18)
|
||||
)
|
||||
(i32.const 240)
|
||||
(i32.const 18)
|
||||
)
|
||||
(i32.const 240)
|
||||
)
|
||||
(i32.store8 offset=1
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $1)
|
||||
(i32.const 12)
|
||||
)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=2
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $1)
|
||||
(i32.const 6)
|
||||
)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=3
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br $loop|0)
|
||||
)
|
||||
(i32.store8 offset=1
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $1)
|
||||
(i32.const 12)
|
||||
)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=2
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $1)
|
||||
(i32.const 6)
|
||||
)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=3
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
)
|
||||
(i32.store8
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.shr_u
|
||||
(get_local $1)
|
||||
(i32.const 12)
|
||||
)
|
||||
(i32.const 224)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=1
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $1)
|
||||
(i32.const 12)
|
||||
(i32.const 6)
|
||||
)
|
||||
(i32.const 224)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
(i32.store8 offset=1
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $1)
|
||||
(i32.const 6)
|
||||
)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=2
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.store8 offset=2
|
||||
(get_local $4)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $1)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
(br $loop|0)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
|
@ -29,68 +29,44 @@
|
||||
(set_local $1
|
||||
(i32.const 1)
|
||||
)
|
||||
(block $break|0
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
(loop $loop|0
|
||||
(block $continue|0
|
||||
(br_if $break|0
|
||||
(i32.eqz
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|0
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $4)
|
||||
(i32.const 128)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $4)
|
||||
(i32.const 2048)
|
||||
(i32.const 128)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
@ -101,57 +77,17 @@
|
||||
)
|
||||
)
|
||||
(if
|
||||
(if (result i32)
|
||||
(tee_local $5
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(get_local $4)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 55296)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 56320)
|
||||
)
|
||||
(get_local $5)
|
||||
(i32.lt_u
|
||||
(get_local $4)
|
||||
(i32.const 2048)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
@ -159,13 +95,84 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(if (result i32)
|
||||
(tee_local $5
|
||||
(if (result i32)
|
||||
(tee_local $5
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(get_local $4)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 55296)
|
||||
)
|
||||
)
|
||||
(i32.lt_u
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 56320)
|
||||
)
|
||||
(get_local $5)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
(nop)
|
||||
(br $loop|0)
|
||||
)
|
||||
)
|
||||
(return
|
||||
@ -290,116 +297,56 @@
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 i32)
|
||||
(set_local $1
|
||||
(call $~lib/string/String#get:lengthUTF8
|
||||
(get_local $0)
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(call $~lib/string/String#get:lengthUTF8
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(call $~lib/allocator/arena/allocate_memory
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.const 0)
|
||||
)
|
||||
(block $break|0
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.const 0)
|
||||
)
|
||||
(set_local $5
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $loop|0
|
||||
(block $continue|0
|
||||
(br_if $break|0
|
||||
(i32.eqz
|
||||
(i32.lt_u
|
||||
(get_local $4)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(block
|
||||
(set_local $6
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $6)
|
||||
(i32.const 128)
|
||||
)
|
||||
(block
|
||||
(i32.store8
|
||||
(block
|
||||
(set_local $5
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
(get_local $6)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $6)
|
||||
(i32.const 2048)
|
||||
(get_local $5)
|
||||
(i32.const 128)
|
||||
)
|
||||
(block
|
||||
(set_local $7
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(get_local $7)
|
||||
(i32.or
|
||||
(i32.shr_u
|
||||
(get_local $6)
|
||||
(i32.const 6)
|
||||
)
|
||||
(i32.const 192)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=1
|
||||
(get_local $7)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $6)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 2)
|
||||
(get_local $1)
|
||||
(get_local $4)
|
||||
)
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.add
|
||||
@ -407,190 +354,253 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $7
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(get_local $6)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 55296)
|
||||
)
|
||||
(block
|
||||
(set_local $8
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(get_local $8)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 56320)
|
||||
)
|
||||
(block
|
||||
(set_local $6
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.const 65536)
|
||||
(i32.shl
|
||||
(i32.and
|
||||
(get_local $6)
|
||||
(i32.const 1023)
|
||||
)
|
||||
(i32.const 10)
|
||||
)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $8)
|
||||
(i32.const 1023)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(get_local $7)
|
||||
(i32.or
|
||||
(i32.shr_u
|
||||
(get_local $6)
|
||||
(i32.const 18)
|
||||
)
|
||||
(i32.const 240)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=1
|
||||
(get_local $7)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $6)
|
||||
(i32.const 12)
|
||||
)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=2
|
||||
(get_local $7)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $6)
|
||||
(i32.const 6)
|
||||
)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=3
|
||||
(get_local $7)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $6)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $5)
|
||||
(i32.const 2048)
|
||||
)
|
||||
(i32.store8
|
||||
(get_local $7)
|
||||
(i32.or
|
||||
(i32.shr_u
|
||||
(get_local $6)
|
||||
(i32.const 12)
|
||||
(block
|
||||
(set_local $6
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 224)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=1
|
||||
(get_local $7)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.store8
|
||||
(get_local $6)
|
||||
(i32.or
|
||||
(i32.shr_u
|
||||
(get_local $6)
|
||||
(get_local $5)
|
||||
(i32.const 6)
|
||||
)
|
||||
(i32.const 63)
|
||||
(i32.const 192)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=2
|
||||
(get_local $7)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $6)
|
||||
(i32.const 63)
|
||||
(i32.store8 offset=1
|
||||
(get_local $6)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $5)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(i32.const 3)
|
||||
(block
|
||||
(set_local $6
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(i32.const 1)
|
||||
(if
|
||||
(if (result i32)
|
||||
(tee_local $7
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(get_local $5)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 55296)
|
||||
)
|
||||
)
|
||||
(i32.lt_u
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
(get_local $7)
|
||||
)
|
||||
(block
|
||||
(set_local $7
|
||||
(i32.load16_u offset=4
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(get_local $7)
|
||||
(i32.const 64512)
|
||||
)
|
||||
(i32.const 56320)
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.const 65536)
|
||||
(i32.shl
|
||||
(i32.and
|
||||
(get_local $5)
|
||||
(i32.const 1023)
|
||||
)
|
||||
(i32.const 10)
|
||||
)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $7)
|
||||
(i32.const 1023)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(get_local $6)
|
||||
(i32.or
|
||||
(i32.shr_u
|
||||
(get_local $5)
|
||||
(i32.const 18)
|
||||
)
|
||||
(i32.const 240)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=1
|
||||
(get_local $6)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $5)
|
||||
(i32.const 12)
|
||||
)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=2
|
||||
(get_local $6)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $5)
|
||||
(i32.const 6)
|
||||
)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=3
|
||||
(get_local $6)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $5)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(i32.const 4)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(get_local $6)
|
||||
(i32.or
|
||||
(i32.shr_u
|
||||
(get_local $5)
|
||||
(i32.const 12)
|
||||
)
|
||||
(i32.const 224)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=1
|
||||
(get_local $6)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(i32.shr_u
|
||||
(get_local $5)
|
||||
(i32.const 6)
|
||||
)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(i32.store8 offset=2
|
||||
(get_local $6)
|
||||
(i32.or
|
||||
(i32.and
|
||||
(get_local $5)
|
||||
(i32.const 63)
|
||||
)
|
||||
(i32.const 128)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
(nop)
|
||||
(br $loop|0)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
(get_local $1)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(return
|
||||
(get_local $2)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(func $~lib/allocator/arena/free_memory (; 4 ;) (type $iv) (param $0 i32)
|
||||
|
@ -980,7 +980,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 76)
|
||||
(i32.const 524)
|
||||
(i32.const 529)
|
||||
(i32.const 10)
|
||||
)
|
||||
(unreachable)
|
||||
|
@ -1159,7 +1159,7 @@
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 76)
|
||||
(i32.const 524)
|
||||
(i32.const 529)
|
||||
(i32.const 10)
|
||||
)
|
||||
(unreachable)
|
||||
|
Loading…
x
Reference in New Issue
Block a user