Skip to content

Commit

Permalink
Enable sign extension ops by default (AssemblyScript#1869)
Browse files Browse the repository at this point in the history
BREAKING: With all major browsers now shipping them, sign extension operations are now enabled by default. To disable: `--disable sign-extension`.
  • Loading branch information
MaxGraey authored May 27, 2021
1 parent 6540a2d commit f67e61a
Show file tree
Hide file tree
Showing 24 changed files with 4,104 additions and 2,379 deletions.
3 changes: 1 addition & 2 deletions cli/asc.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@
"description": [
"Enables WebAssembly features being disabled by default.",
"",
" sign-extension Sign-extension operations",
" nontrapping-f2i Non-trapping float to integer ops.",
" bulk-memory Bulk memory operations.",
" simd SIMD types and operations.",
Expand All @@ -233,6 +232,7 @@
"Disables WebAssembly features being enabled by default.",
"",
" mutable-globals Mutable global imports and exports.",
" sign-extension Sign-extension operations",
""
],
"type": "S",
Expand Down Expand Up @@ -376,7 +376,6 @@
" ...": {
"description": "Specifies node.js options (CLI only). See: node --help"
},

"-Os": { "value": { "optimizeLevel": 0, "shrinkLevel": 1 } },
"-Oz": { "value": { "optimizeLevel": 0, "shrinkLevel": 2 } },
"-O0": { "value": { "optimizeLevel": 0, "shrinkLevel": 0 } },
Expand Down
2 changes: 1 addition & 1 deletion src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class Options {
/** Global aliases, mapping alias names as the key to internal names to be aliased as the value. */
globalAliases: Map<string,string> | null = null;
/** Features to activate by default. These are the finished proposals. */
features: Feature = Feature.MUTABLE_GLOBALS;
features: Feature = Feature.MUTABLE_GLOBALS | Feature.SIGN_EXTENSION;
/** If true, disallows unsafe features in user code. */
noUnsafe: bool = false;
/** If true, enables pedantic diagnostics. */
Expand Down
42 changes: 10 additions & 32 deletions tests/compiler/abi.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
i32.const 256
local.set $0
local.get $0
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
i32.eqz
i32.eqz
if
Expand All @@ -50,28 +47,19 @@
global.get $abi/condition
if
local.get $0
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
i32.const 2
i32.div_s
local.set $0
else
local.get $0
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
i32.const 2
i32.div_s
local.set $0
end
local.get $0
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
i32.eqz
i32.eqz
if
Expand All @@ -87,10 +75,7 @@
global.get $abi/condition
if
local.get $0
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
i32.const 24
i32.const 7
i32.and
Expand All @@ -103,6 +88,7 @@
local.set $0
end
local.get $0
i32.extend8_s
i32.eqz
i32.eqz
if
Expand All @@ -114,10 +100,7 @@
unreachable
end
i32.const 256
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
global.set $abi/y
global.get $abi/y
i32.eqz
Expand Down Expand Up @@ -189,20 +172,15 @@
)
(func $abi/exported (result i32)
i32.const 128
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
)
(func $abi/exportedExported (result i32)
call $abi/exported
i32.extend8_s
)
(func $abi/exportedInternal (result i32)
call $abi/internal
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
)
(func $~start
call $start:abi
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/asc-constants.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(global $~lib/ASC_MEMORY_BASE i32 (i32.const 0))
(global $~lib/ASC_OPTIMIZE_LEVEL i32 (i32.const 0))
(global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0))
(global $~lib/ASC_FEATURE_SIGN_EXTENSION i32 (i32.const 0))
(global $~lib/ASC_FEATURE_SIGN_EXTENSION i32 (i32.const 1))
(global $~lib/ASC_FEATURE_MUTABLE_GLOBALS i32 (i32.const 1))
(global $~lib/ASC_FEATURE_NONTRAPPING_F2I i32 (i32.const 0))
(global $~lib/ASC_FEATURE_BULK_MEMORY i32 (i32.const 0))
Expand Down Expand Up @@ -36,7 +36,7 @@
drop
i32.const 0
drop
i32.const 0
i32.const 1
drop
i32.const 1
drop
Expand Down
55 changes: 11 additions & 44 deletions tests/compiler/builtins.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,10 @@
(local $4 i32)
(local $5 i32)
local.get $0
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
local.tee $5
local.get $1
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
local.tee $3
local.get $2
local.tee $4
Expand All @@ -369,26 +363,17 @@
i32.and
i32.shr_u
i32.or
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
)
(func $builtins/rotr3 (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
local.get $0
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
local.tee $5
local.get $1
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
local.tee $3
local.get $2
local.tee $4
Expand All @@ -415,10 +400,7 @@
i32.and
i32.shl
i32.or
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
)
(func $builtins/test
nop
Expand Down Expand Up @@ -556,10 +538,7 @@
i32.const 1
i32.const 2
i32.add
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
global.set $builtins/l
global.get $builtins/l
i32.const 3
Expand All @@ -576,10 +555,7 @@
i32.const 2
i32.const 1
i32.sub
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
global.set $builtins/l
global.get $builtins/l
i32.const 1
Expand Down Expand Up @@ -612,10 +588,7 @@
i32.const 6
i32.const 2
i32.div_s
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
global.set $builtins/l
global.get $builtins/l
i32.const 3
Expand Down Expand Up @@ -2058,10 +2031,7 @@
drop
global.get $~lib/builtins/i8.MIN_VALUE
i32.const 128
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
i32.eq
drop
global.get $~lib/builtins/i8.MAX_VALUE
Expand All @@ -2070,10 +2040,7 @@
drop
global.get $~lib/builtins/i16.MIN_VALUE
i32.const 32768
i32.const 16
i32.shl
i32.const 16
i32.shr_s
i32.extend16_s
i32.eq
drop
global.get $~lib/builtins/i16.MAX_VALUE
Expand Down
20 changes: 4 additions & 16 deletions tests/compiler/features/simd.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1817,10 +1817,7 @@
end
local.get $2
i8x16.extract_lane_s 0
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
i32.const 2
i32.eq
i32.eqz
Expand All @@ -1834,10 +1831,7 @@
end
local.get $2
i8x16.extract_lane_s 15
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
i32.const -128
i32.eq
i32.eqz
Expand Down Expand Up @@ -2416,10 +2410,7 @@
end
local.get $2
i16x8.extract_lane_s 0
i32.const 16
i32.shl
i32.const 16
i32.shr_s
i32.extend16_s
i32.const 2
i32.eq
i32.eqz
Expand All @@ -2433,10 +2424,7 @@
end
local.get $2
i16x8.extract_lane_s 7
i32.const 16
i32.shl
i32.const 16
i32.shr_s
i32.extend16_s
i32.const -32768
i32.eq
i32.eqz
Expand Down
5 changes: 1 addition & 4 deletions tests/compiler/many-locals.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
)
(func $many-locals/testI8 (param $0 i32) (result i32)
local.get $0
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
)
)
6 changes: 2 additions & 4 deletions tests/compiler/many-locals.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,7 @@
local.get $127
local.set $128
local.get $128
i32.const 24
i32.shl
i32.const 24
i32.shr_s
i32.extend8_s
)
(func $start:many-locals
i32.const 42
Expand All @@ -808,6 +805,7 @@
end
i32.const 42
call $many-locals/testI8
i32.extend8_s
i32.const 42
i32.eq
i32.eqz
Expand Down
Loading

0 comments on commit f67e61a

Please sign in to comment.