Commit 6c5d3fb
[dart2wasm] Pass arg counts from JS to Dart as i32
The JS code we generate for converting a Dart function to a function
callable from JS currently looks like this:
_194: f => finalizeWrapper(f, function(x0,x1) {
return dartInstance.exports._194(f,arguments.length,x0,x1)
}),
`_194` called by this JS code is an export:
(func $_194 (;296;) (export "_194")
(param $callback (;0;) anyref)
(param $argumentsLength (;1;) f64)
(param $x1 (;2;) externref)
(param $x2 (;3;) externref)
(result externref)
...)
Here the `double` parameter current causing redundant boxing and slow
`BoxedDouble` operations, because it's compared against an `int` values
when checking whether the right number of arguments is passed to the
Dart function: (in the body of `$_194`, unoptimized)
local.get $argumentsLength
local.set $var5
i32.const 75
local.get $var5
struct.new $BoxedDouble
global.get $global664
call $BoxedDouble.>=
...
We could compare it against double values instead of int to improve
this, but a better way is to make `argumentsLength` an `i32`, as the
argument will always be a small integer (smi), which can be passed
without allocation, so that's what we do in this CL.
The same code with this CL: (unoptimized)
(func $_194 (;294;) (export "_194")
(param $callback (;0;) anyref)
(param $argumentsLengthWasmI32 (;1;) i32)
(param $x1 (;2;) externref)
(param $x2 (;3;) externref)
(result externref)
...
local.get $argumentsLengthWasmI32
i64.extend_i32_s
local.set $argumentsLength
local.get $argumentsLength
i64.const 2
i64.ge_s
...)
Change-Id: Ib9d4d625bea896e8b680e7e5bffc02c19db0d3cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423740
Reviewed-by: Srujan Gaddam <[email protected]>
Commit-Queue: Ömer Ağacan <[email protected]>1 parent 2d588d0 commit 6c5d3fb
2 files changed
+30
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
107 | 126 | | |
108 | 127 | | |
109 | 128 | | |
| |||
133 | 152 | | |
134 | 153 | | |
135 | 154 | | |
136 | | - | |
137 | | - | |
| 155 | + | |
138 | 156 | | |
139 | 157 | | |
140 | 158 | | |
| |||
151 | 169 | | |
152 | 170 | | |
153 | 171 | | |
154 | | - | |
| 172 | + | |
155 | 173 | | |
156 | 174 | | |
157 | 175 | | |
| |||
167 | 185 | | |
168 | 186 | | |
169 | 187 | | |
170 | | - | |
| 188 | + | |
171 | 189 | | |
172 | 190 | | |
173 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
127 | 132 | | |
128 | 133 | | |
129 | 134 | | |
| |||
0 commit comments