Status: Untriaged
Owner: ----
Type: Bug
New issue 12242 by
ro...@foxglove.dev: Slow class initialization with class members
https://bugs.chromium.org/p/v8/issues/detail?id=12242Version: 93.0.4577.82 (Official Build) (arm64)
OS: macOS 11.5.2
Architecture: arm64
JavaScript: V8 9.3.345.19
What steps will reproduce the problem?
I created the following code in a <script> tag on an otherwise empty page:
```
class WithMember {
x;
}
class WithConstructor {
constructor() {
this.x = undefined;
}
}
new WithMember();
new WithConstructor();
function runWithMember() {
for (let i=0; i<1000000 ; ++i) {
new WithMember();
}
}
function runWithConstructor() {
for (let i=0; i<1000000 ; ++i) {
new WithConstructor();
}
}
runWithMember();
runWithConstructor();
```
When I run the above and capture the performance with the "performance" tab in Devtools - I see that the "runWithMember" version runs significantly slower (close to 100x slower) due to "<instance_members_initializer>"
What is the expected output?
I would expect both versions to have the same runtime.
I've attached a screenshot of the performance tab showing the discrepancy in runtime.
Should I be doing something differently in the `WithMember` version?
P.S. - I've also tried `#x;` and `#x = undefined`; in the `WithMember` class both leading to the same runtime result as just `x;`
Attachments:
Screen Shot 2021-09-18 at 9.03.08 AM.png 228 KB
--
You received this message because:
1. The project was configured to send all issue notifications to this address
You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings