dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.09k stars 1.56k forks source link

[vm] Consider creating a specialized allocator for List.filled #44208

Open alexmarkov opened 3 years ago

alexmarkov commented 3 years ago

We can implement List.filled (_List.filled, _GrowableList.filled) more efficiently, without a loop which initializes array elements after creating a list - it can reuse initialization performed during array object allocation. For this purpose, we need the following:

rakudrama commented 3 years ago

You could delete the old instruction afterward. Legacy mode List(n) would then be lowered to _List.filled with an explicit null. Then you should have approximately the same amount of code to maintain.