Commit 9e5bf00
Scala.js: Emit
Although there is a *correct* implementation of `sr.Arrays.newArray`,
it is not efficient when creating 1-dimensional arrays. The JVM
backend special-cases it to emit `newarray` bytecode instructions.
We now also special-case it in the JS backend. In the Scala.js IR
however, `js.NewArray` only accepts a single dimension. For multiple
dimensions, the right thing to do is to emit a direct call to
`jlr.Array.newInstance`.
[Cherry-picked 2852168]js.NewArray IR nodes when possible.1 parent bcc96b3 commit 9e5bf00
File tree
2 files changed
+28
-3
lines changed- compiler/src/dotty/tools/backend/sjs
2 files changed
+28
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2550 | 2550 | | |
2551 | 2551 | | |
2552 | 2552 | | |
| 2553 | + | |
| 2554 | + | |
2553 | 2555 | | |
2554 | 2556 | | |
2555 | 2557 | | |
| |||
3019 | 3021 | | |
3020 | 3022 | | |
3021 | 3023 | | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
3022 | 3042 | | |
3023 | 3043 | | |
3024 | 3044 | | |
| |||
4831 | 4851 | | |
4832 | 4852 | | |
4833 | 4853 | | |
4834 | | - | |
| 4854 | + | |
4835 | 4855 | | |
4836 | 4856 | | |
4837 | 4857 | | |
| |||
4841 | 4861 | | |
4842 | 4862 | | |
4843 | 4863 | | |
| 4864 | + | |
| 4865 | + | |
| 4866 | + | |
4844 | 4867 | | |
4845 | 4868 | | |
4846 | 4869 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
52 | 53 | | |
53 | | - | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
| 141 | + | |
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
| |||
0 commit comments