aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2025-09-29 16:14:24 -0400
committerDavid Chase <drchase@google.com>2025-09-30 06:37:45 -0700
commit742f92063e5acc3671a0bd9982e7678d864008f0 (patch)
tree8e5e964c9e991059bd9af171fa96cfa006672bc4 /src/runtime
parentdb10db6be361f4eaf5f81890e487a9cbf3ca5a53 (diff)
downloadgo-742f92063e5acc3671a0bd9982e7678d864008f0.tar.xz
cmd/compile, runtime: always enable Wasm signext and satconv features
These features have been standardized since at least Wasm 2.0. Always enable them. The corresponding GOWASM settings are now no-op. Change-Id: I0e59f21696a69a4e289127988aad629a720b002b Reviewed-on: https://go-review.googlesource.com/c/go/+/707855 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/conv_wasm_test.go45
-rw-r--r--src/runtime/sys_wasm.s58
2 files changed, 24 insertions, 79 deletions
diff --git a/src/runtime/conv_wasm_test.go b/src/runtime/conv_wasm_test.go
index 5054fca04d..3979a7b618 100644
--- a/src/runtime/conv_wasm_test.go
+++ b/src/runtime/conv_wasm_test.go
@@ -11,6 +11,8 @@ import (
var res int64
var ures uint64
+// TODO: This test probably should be in a different place.
+
func TestFloatTruncation(t *testing.T) {
testdata := []struct {
input float64
@@ -21,36 +23,37 @@ func TestFloatTruncation(t *testing.T) {
// max +- 1
{
input: 0x7fffffffffffffff,
- convInt64: -0x8000000000000000,
+ convInt64: 0x7fffffffffffffff,
convUInt64: 0x8000000000000000,
},
// For out-of-bounds conversion, the result is implementation-dependent.
- // This test verifies the implementation of wasm architecture.
+ // This test verifies the implementation of wasm architecture, which is,
+ // saturating to the min/max value.
{
input: 0x8000000000000000,
- convInt64: -0x8000000000000000,
+ convInt64: 0x7fffffffffffffff,
convUInt64: 0x8000000000000000,
},
{
input: 0x7ffffffffffffffe,
- convInt64: -0x8000000000000000,
+ convInt64: 0x7fffffffffffffff,
convUInt64: 0x8000000000000000,
},
// neg max +- 1
{
input: -0x8000000000000000,
convInt64: -0x8000000000000000,
- convUInt64: 0x8000000000000000,
+ convUInt64: 0,
},
{
input: -0x8000000000000001,
convInt64: -0x8000000000000000,
- convUInt64: 0x8000000000000000,
+ convUInt64: 0,
},
{
input: -0x7fffffffffffffff,
convInt64: -0x8000000000000000,
- convUInt64: 0x8000000000000000,
+ convUInt64: 0,
},
// trunc point +- 1
{
@@ -60,7 +63,7 @@ func TestFloatTruncation(t *testing.T) {
},
{
input: 0x7ffffffffffffe00,
- convInt64: -0x8000000000000000,
+ convInt64: 0x7fffffffffffffff,
convUInt64: 0x8000000000000000,
},
{
@@ -72,48 +75,48 @@ func TestFloatTruncation(t *testing.T) {
{
input: -0x7ffffffffffffdff,
convInt64: -0x7ffffffffffffc00,
- convUInt64: 0x8000000000000000,
+ convUInt64: 0,
},
{
input: -0x7ffffffffffffe00,
convInt64: -0x8000000000000000,
- convUInt64: 0x8000000000000000,
+ convUInt64: 0,
},
{
input: -0x7ffffffffffffdfe,
convInt64: -0x7ffffffffffffc00,
- convUInt64: 0x8000000000000000,
+ convUInt64: 0,
},
// umax +- 1
{
input: 0xffffffffffffffff,
- convInt64: -0x8000000000000000,
- convUInt64: 0x8000000000000000,
+ convInt64: 0x7fffffffffffffff,
+ convUInt64: 0xffffffffffffffff,
},
{
input: 0x10000000000000000,
- convInt64: -0x8000000000000000,
- convUInt64: 0x8000000000000000,
+ convInt64: 0x7fffffffffffffff,
+ convUInt64: 0xffffffffffffffff,
},
{
input: 0xfffffffffffffffe,
- convInt64: -0x8000000000000000,
- convUInt64: 0x8000000000000000,
+ convInt64: 0x7fffffffffffffff,
+ convUInt64: 0xffffffffffffffff,
},
// umax trunc +- 1
{
input: 0xfffffffffffffbff,
- convInt64: -0x8000000000000000,
+ convInt64: 0x7fffffffffffffff,
convUInt64: 0xfffffffffffff800,
},
{
input: 0xfffffffffffffc00,
- convInt64: -0x8000000000000000,
- convUInt64: 0x8000000000000000,
+ convInt64: 0x7fffffffffffffff,
+ convUInt64: 0xffffffffffffffff,
},
{
input: 0xfffffffffffffbfe,
- convInt64: -0x8000000000000000,
+ convInt64: 0x7fffffffffffffff,
convUInt64: 0xfffffffffffff800,
},
}
diff --git a/src/runtime/sys_wasm.s b/src/runtime/sys_wasm.s
index b7965ec3fa..95c162eb85 100644
--- a/src/runtime/sys_wasm.s
+++ b/src/runtime/sys_wasm.s
@@ -22,64 +22,6 @@ TEXT runtime·wasmDiv(SB), NOSPLIT, $0-0
I64DivS
Return
-TEXT runtime·wasmTruncS(SB), NOSPLIT, $0-0
- Get R0
- Get R0
- F64Ne // NaN
- If
- I64Const $0x8000000000000000
- Return
- End
-
- Get R0
- F64Const $0x7ffffffffffffc00p0 // Maximum truncated representation of 0x7fffffffffffffff
- F64Gt
- If
- I64Const $0x8000000000000000
- Return
- End
-
- Get R0
- F64Const $-0x7ffffffffffffc00p0 // Minimum truncated representation of -0x8000000000000000
- F64Lt
- If
- I64Const $0x8000000000000000
- Return
- End
-
- Get R0
- I64TruncF64S
- Return
-
-TEXT runtime·wasmTruncU(SB), NOSPLIT, $0-0
- Get R0
- Get R0
- F64Ne // NaN
- If
- I64Const $0x8000000000000000
- Return
- End
-
- Get R0
- F64Const $0xfffffffffffff800p0 // Maximum truncated representation of 0xffffffffffffffff
- F64Gt
- If
- I64Const $0x8000000000000000
- Return
- End
-
- Get R0
- F64Const $0.
- F64Lt
- If
- I64Const $0x8000000000000000
- Return
- End
-
- Get R0
- I64TruncF64U
- Return
-
TEXT runtime·exitThread(SB), NOSPLIT, $0-0
UNDEF