Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(stdlib): Fixed length and byteLength for strings over 2GiB. #1126

Merged
merged 1 commit into from
Feb 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions stdlib/string.gr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import WasmI32 from "runtime/unsafe/wasmi32"
import Memory from "runtime/unsafe/memory"
import Exception from "runtime/exception"
import Conv from "runtime/unsafe/conv"
import {
tagSimpleNumber,
allocateArray,
Expand Down Expand Up @@ -76,7 +77,7 @@ export let rec length = (string: String) => {
ptr = WasmI32.add(ptr, 1n)
}

let ret = tagSimpleNumber(len)
let ret = Conv.wasmI32ToNumber(len)
Memory.decRef(WasmI32.fromGrain(length))
Memory.decRef(WasmI32.fromGrain(string))
ret
Expand All @@ -103,7 +104,7 @@ let wasmSafeLength = (s: String) => {
@disableGC
export let rec byteLength = (string: String) => {
let string = WasmI32.fromGrain(string)
let ret = tagSimpleNumber(WasmI32.load(string, 4n))
let ret = Conv.wasmI32ToNumber(WasmI32.load(string, 4n))
Memory.decRef(WasmI32.fromGrain(byteLength))
Memory.decRef(WasmI32.fromGrain(string))
ret
Expand Down