Skip to content

Commit 64ec8b9

Browse files
authored
Disable aggressive ARC optimizations (#1323)
1 parent acfb1b8 commit 64ec8b9

17 files changed

+24732
-20486
lines changed

src/module.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,12 +1488,13 @@ export class Module {
14881488
passes.push("rse");
14891489
passes.push("vacuum");
14901490
}
1491-
if (usesARC) {
1492-
if (optimizeLevel < 3) {
1493-
passes.push("flatten");
1494-
}
1495-
passes.push("post-assemblyscript");
1496-
}
1491+
// FIXME: see issue #1288
1492+
// if (usesARC) {
1493+
// if (optimizeLevel < 3) {
1494+
// passes.push("flatten");
1495+
// }
1496+
// passes.push("post-assemblyscript");
1497+
// }
14971498
passes.push("optimize-instructions");
14981499
passes.push("inlining");
14991500
passes.push("dce");

tests/compiler/extends-baseaggregate.optimized.wat

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(module
2-
(type $i32_i32_=>_none (func (param i32 i32)))
32
(type $i32_=>_none (func (param i32)))
3+
(type $i32_i32_=>_none (func (param i32 i32)))
44
(type $i32_i32_i32_=>_none (func (param i32 i32 i32)))
55
(type $i32_=>_i32 (func (param i32) (result i32)))
66
(type $none_=>_none (func))
@@ -1580,20 +1580,34 @@
15801580
end
15811581
end
15821582
)
1583+
(func $~lib/rt/pure/__release (param $0 i32)
1584+
local.get $0
1585+
i32.const 1564
1586+
i32.gt_u
1587+
if
1588+
local.get $0
1589+
i32.const 16
1590+
i32.sub
1591+
call $~lib/rt/pure/decrement
1592+
end
1593+
)
15831594
(func $~lib/array/Array<extends-baseaggregate/A2>#push (param $0 i32)
15841595
(local $1 i32)
15851596
(local $2 i32)
15861597
(local $3 i32)
15871598
(local $4 i32)
15881599
(local $5 i32)
15891600
(local $6 i32)
1601+
local.get $0
1602+
call $~lib/rt/pure/__retain
1603+
local.set $1
15901604
i32.const 1116
15911605
i32.load
15921606
local.tee $6
15931607
i32.const 1
15941608
i32.add
15951609
local.tee $2
1596-
local.set $1
1610+
local.set $0
15971611
local.get $2
15981612
i32.const 1112
15991613
i32.load
@@ -1602,7 +1616,7 @@
16021616
i32.shr_u
16031617
i32.gt_u
16041618
if
1605-
local.get $1
1619+
local.get $0
16061620
i32.const 268435452
16071621
i32.gt_u
16081622
if
@@ -1620,28 +1634,28 @@
16201634
call $~lib/rt/tlsf/maybeInitialize
16211635
local.get $4
16221636
call $~lib/rt/tlsf/checkUsedBlock
1623-
local.get $1
1637+
local.get $0
16241638
i32.const 2
16251639
i32.shl
16261640
local.tee $5
16271641
call $~lib/rt/tlsf/reallocateBlock
16281642
i32.const 16
16291643
i32.add
1630-
local.tee $1
1644+
local.tee $0
16311645
i32.add
16321646
local.get $5
16331647
local.get $3
16341648
i32.sub
16351649
call $~lib/memory/memory.fill
1636-
local.get $1
1650+
local.get $0
16371651
local.get $4
16381652
i32.ne
16391653
if
16401654
i32.const 1104
1641-
local.get $1
1655+
local.get $0
16421656
i32.store
16431657
i32.const 1108
1644-
local.get $1
1658+
local.get $0
16451659
i32.store
16461660
end
16471661
i32.const 1112
@@ -1654,12 +1668,14 @@
16541668
i32.const 2
16551669
i32.shl
16561670
i32.add
1657-
local.get $0
1671+
local.get $1
16581672
call $~lib/rt/pure/__retain
16591673
i32.store
16601674
i32.const 1116
16611675
local.get $2
16621676
i32.store
1677+
local.get $1
1678+
call $~lib/rt/pure/__release
16631679
)
16641680
(func $~start
16651681
(local $0 i32)
@@ -1688,14 +1704,7 @@
16881704
local.get $0
16891705
call $~lib/array/Array<extends-baseaggregate/A2>#push
16901706
local.get $0
1691-
i32.const 1564
1692-
i32.gt_u
1693-
if
1694-
local.get $0
1695-
i32.const 16
1696-
i32.sub
1697-
call $~lib/rt/pure/decrement
1698-
end
1707+
call $~lib/rt/pure/__release
16991708
)
17001709
(func $~lib/rt/pure/markGray (param $0 i32)
17011710
(local $1 i32)

tests/compiler/issues/1095.optimized.wat

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -958,18 +958,22 @@
958958
(local $0 i32)
959959
(local $1 i32)
960960
(local $2 i32)
961+
(local $3 i32)
961962
call $~lib/rt/tlsf/maybeInitialize
962963
call $~lib/rt/tlsf/allocateBlock
963964
i32.const 16
964965
i32.add
965966
call $~lib/rt/pure/__retain
966-
local.tee $1
967+
local.tee $3
967968
i32.const 1200
968969
i32.store
970+
local.get $3
971+
call $~lib/rt/pure/__retain
972+
local.tee $1
973+
local.set $2
969974
local.get $1
970-
local.tee $0
971975
i32.load
972-
local.tee $2
976+
local.tee $0
973977
i32.eqz
974978
if
975979
i32.const 0
@@ -979,22 +983,24 @@
979983
call $~lib/builtins/abort
980984
unreachable
981985
end
982-
local.get $2
983986
local.get $0
987+
local.get $2
984988
i32.load
985-
local.tee $1
989+
local.tee $2
986990
i32.ne
987991
if
988-
local.get $2
992+
local.get $0
989993
call $~lib/rt/pure/__retain
990-
local.set $2
991-
local.get $1
994+
local.set $0
995+
local.get $2
992996
call $~lib/rt/pure/__release
993997
end
998+
local.get $1
994999
local.get $0
995-
local.get $2
9961000
i32.store
997-
local.get $0
1001+
local.get $1
1002+
call $~lib/rt/pure/__release
1003+
local.get $3
9981004
call $~lib/rt/pure/__release
9991005
)
10001006
(func $~lib/rt/pure/decrement (param $0 i32)

tests/compiler/logical.optimized.wat

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(module
22
(type $i32_=>_none (func (param i32)))
3-
(type $i32_i32_=>_none (func (param i32 i32)))
4-
(type $none_=>_i32 (func (result i32)))
53
(type $i32_=>_i32 (func (param i32) (result i32)))
64
(type $none_=>_none (func))
5+
(type $i32_i32_=>_none (func (param i32 i32)))
6+
(type $none_=>_i32 (func (result i32)))
77
(type $i32_i32_i32_=>_none (func (param i32 i32 i32)))
88
(type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32)))
99
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
@@ -891,22 +891,17 @@
891891
call $~lib/rt/rtrace/onalloc
892892
local.get $1
893893
)
894-
(func $logical/Obj#constructor (result i32)
895-
(local $0 i32)
894+
(func $~lib/rt/pure/__retain (param $0 i32) (result i32)
896895
(local $1 i32)
897896
(local $2 i32)
898-
call $~lib/rt/tlsf/maybeInitialize
899-
call $~lib/rt/tlsf/allocateBlock
900-
i32.const 16
901-
i32.add
902-
local.tee $1
897+
local.get $0
903898
i32.const 1232
904899
i32.gt_u
905900
if
906-
local.get $1
901+
local.get $0
907902
i32.const 16
908903
i32.sub
909-
local.tee $0
904+
local.tee $1
910905
i32.load offset=4
911906
local.tee $2
912907
i32.const -268435456
@@ -925,14 +920,14 @@
925920
call $~lib/builtins/abort
926921
unreachable
927922
end
928-
local.get $0
923+
local.get $1
929924
local.get $2
930925
i32.const 1
931926
i32.add
932927
i32.store offset=4
933-
local.get $0
928+
local.get $1
934929
call $~lib/rt/rtrace/onincrement
935-
local.get $0
930+
local.get $1
936931
i32.load
937932
i32.const 1
938933
i32.and
@@ -945,7 +940,14 @@
945940
unreachable
946941
end
947942
end
948-
local.get $1
943+
local.get $0
944+
)
945+
(func $logical/Obj#constructor (result i32)
946+
call $~lib/rt/tlsf/maybeInitialize
947+
call $~lib/rt/tlsf/allocateBlock
948+
i32.const 16
949+
i32.add
950+
call $~lib/rt/pure/__retain
949951
)
950952
(func $~lib/rt/pure/__release (param $0 i32)
951953
local.get $0
@@ -958,16 +960,24 @@
958960
call $~lib/rt/pure/decrement
959961
end
960962
)
961-
(func $~start
962-
(local $0 i32)
963+
(func $start:logical
964+
(local $0 f64)
963965
(local $1 i32)
966+
(local $2 i32)
967+
(local $3 f32)
968+
(local $4 i32)
969+
(local $5 i32)
964970
call $logical/Obj#constructor
965-
local.tee $0
966-
if (result i32)
971+
local.tee $4
972+
call $~lib/rt/pure/__retain
973+
local.tee $2
974+
if
967975
i32.const 1
968-
else
969-
i32.const 0
976+
local.set $1
970977
end
978+
local.get $2
979+
call $~lib/rt/pure/__release
980+
local.get $1
971981
i32.eqz
972982
if
973983
i32.const 0
@@ -978,12 +988,16 @@
978988
unreachable
979989
end
980990
call $logical/Obj#constructor
981-
local.tee $1
991+
local.tee $2
992+
call $~lib/rt/pure/__retain
993+
local.tee $5
982994
if (result i32)
983995
i32.const 1
984996
else
985997
i32.const 0
986998
end
999+
local.get $5
1000+
call $~lib/rt/pure/__release
9871001
i32.eqz
9881002
if
9891003
i32.const 0
@@ -993,11 +1007,14 @@
9931007
call $~lib/builtins/abort
9941008
unreachable
9951009
end
996-
local.get $0
1010+
local.get $4
9971011
call $~lib/rt/pure/__release
998-
local.get $1
1012+
local.get $2
9991013
call $~lib/rt/pure/__release
10001014
)
1015+
(func $~start
1016+
call $start:logical
1017+
)
10011018
(func $~lib/rt/pure/decrement (param $0 i32)
10021019
(local $1 i32)
10031020
(local $2 i32)

0 commit comments

Comments
 (0)