WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
266942
generateWasm.py: return value can be wrong due IEEE 754 precision
https://bugs.webkit.org/show_bug.cgi?id=266942
Summary
generateWasm.py: return value can be wrong due IEEE 754 precision
Conrad Kostecki
Reported
2023-12-30 16:59:11 PST
The assert function currently checks, if power number raised to the number fits memorybits. This seems not always work on every system, as it happens, that the float numbers are not correctly rounded. I suspect, that this is related to the IEEE 754 precision. It looks like, that 'math.log' always produced a float. This patch adds an int, so its being rounded to a full number and works on my system, where otherwise the rounding would fail. The return method also returns the result as an int. Example: * start python (tested with 3.11 and 3.12) $ import math $ 2 ** 3 = 8 $ 2.0 ** 3.0 = 7.999999999999999 $ int(2.0) ** int(3.0) = 8 $ 2 ** int(3.0) = 8 diff --git a/Source/JavaScriptCore/wasm/generateWasm.py b/Source/JavaScriptCore/wasm/generateWasm.py index 434223d346a0d..7a99210b60a21 100755 --- a/Source/JavaScriptCore/wasm/generateWasm.py +++ b/Source/JavaScriptCore/wasm/generateWasm.py @@ -136,5 +136,5 @@ def memoryLog2Alignment(op): if not match: print(op["name"]) memoryBits = int(match.group(2) if match.group(2) else match.group(1)) - assert 2 ** math.log(memoryBits, 2) == memoryBits + assert 2 ** int(math.log(memoryBits, 2)) == memoryBits return str(int(math.log(memoryBits / 8, 2)))
Attachments
Add attachment
proposed patch, testcase, etc.
EWS
Comment 1
2024-01-02 12:26:49 PST
Committed
272577@main
(509b303bf565): <
https://commits.webkit.org/272577@main
> Reviewed commits have been landed. Closing PR #22270 and removing active labels.
Radar WebKit Bug Importer
Comment 2
2024-01-02 12:27:18 PST
<
rdar://problem/120382432
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug