Commit 082bc3d
[dart2wasm] Improve -O0 code gen for inline unary ops
When inlining an unary operator, evaluate the the operator in compile
time when the arugment is a literal or constant.
This helps with debug mode code size, especially with large literals.
The test `co19/LibTest/core/List/sort_A01_t06.test.dart` becomes 492,496
lines of .wat, from 558,080.
Also removes the intrinsic `_toInt`, which is no longer used.
Example:
void main() {
print(~123);
print(123.toDouble());
print(12.34.floorToDouble());
print(12.34.ceilToDouble());
print(12.34.truncateToDouble());
}
Diff of wat:
--- before 2024-10-28 12:21:08.537971233 +0100
+++ after 2024-10-28 12:17:01.965688861 +0100
@@ -4,41 +4,35 @@
(local $var2 f64)
(local $var3 f64)
(local $var4 f64)
- i64.const 123
- i64.const -1
- i64.xor
+ i64.const -124
local.set $var0
i32.const 5
local.get $var0
struct.new $BoxedInt
call $print
drop
- i64.const 123
- f64.convert_i64_s
+ f64.const 123
local.set $var1
i32.const 4
local.get $var1
struct.new $BoxedDouble
call $print
drop
- f64.const 12.34
- f64.floor
+ f64.const 12
local.set $var2
i32.const 4
local.get $var2
struct.new $BoxedDouble
call $print
drop
- f64.const 12.34
- f64.ceil
+ f64.const 13
local.set $var3
i32.const 4
local.get $var3
struct.new $BoxedDouble
call $print
drop
- f64.const 12.34
- f64.trunc
+ f64.const 12
local.set $var4
i32.const 4
local.get $var4
Change-Id: I318d977b6a54c4028668c3626121e3cd26a7eddc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392122
Reviewed-by: Slava Egorov <[email protected]>
Commit-Queue: Ömer Ağacan <[email protected]>1 parent 933d630 commit 082bc3d
1 file changed
+109
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
94 | | - | |
95 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
96 | 169 | | |
97 | 170 | | |
98 | 171 | | |
| |||
102 | 175 | | |
103 | 176 | | |
104 | 177 | | |
105 | | - | |
106 | 178 | | |
107 | 179 | | |
108 | 180 | | |
| |||
430 | 502 | | |
431 | 503 | | |
432 | 504 | | |
433 | | - | |
434 | | - | |
| 505 | + | |
| 506 | + | |
435 | 507 | | |
436 | | - | |
437 | | - | |
438 | | - | |
| 508 | + | |
| 509 | + | |
439 | 510 | | |
440 | 511 | | |
441 | 512 | | |
| |||
1762 | 1833 | | |
1763 | 1834 | | |
1764 | 1835 | | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
0 commit comments