Skip to content

Commit 3dd461d

Browse files
committed
Code review + add test
1 parent d8a4541 commit 3dd461d

5 files changed

Lines changed: 25 additions & 1 deletion

File tree

lib/Common/Common/MathUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Math
4545

4646
static bool FitsInDWord(int32 value) { return true; }
4747
static bool FitsInDWord(size_t value) { return ((size_t)(signed int)(value & 0xFFFFFFFF) == value); }
48-
static bool FitsInDWord(int64 value) { return FitsInDWord((size_t)value); }
48+
static bool FitsInDWord(int64 value) { return ((int64)(signed int)(value & 0xFFFFFFFF) == value); }
4949

5050
static UINT_PTR Rand();
5151
static bool IsPow2(int32 val) { return (val > 0 && ((val-1) & val) == 0); }
41 Bytes
Binary file not shown.

test/wasm/bugs.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft Corporation and contributors. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
WScript.Flag("-wasmI64");
6+
async function main() {
7+
const {instance: {exports: {foo}}} = await WebAssembly.instantiate(readbuffer("binaries/bug_fitsdword.wasm"));
8+
foo();
9+
}
10+
11+
main().then(() => console.log("PASSED"), console.log);

test/wasm/rlexe.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@
128128
<compile-flags>-wasm</compile-flags>
129129
</default>
130130
</test>
131+
<test>
132+
<default>
133+
<files>bugs.js</files>
134+
<compile-flags>-wasm</compile-flags>
135+
</default>
136+
</test>
131137
<test>
132138
<default>
133139
<files>debugger.js</files>

test/wasm/wasts/bug_fitsdword.wast

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
;;-------------------------------------------------------------------------------------------------------
2+
;; Copyright (C) Microsoft. All rights reserved.
3+
;; Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
;;-------------------------------------------------------------------------------------------------------
5+
(module
6+
(func (export "foo") (result i64) (i64.extend_u/i32 (i32.const 0x80000000)))
7+
)

0 commit comments

Comments
 (0)