-
Notifications
You must be signed in to change notification settings - Fork 396
Investigate Fishy Record Names in Optimizer Core #4947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've been playing around with this and so far, I have not actually managed for the optimizer to produce a Record. Either, the local def system already resolved everything before even creating a record (this is what happened here: #4946 (comment)) or the optimizer cancelled the inlining. @sjrd how did you determine the piece of code in question is not dead code? I'm starting to suspect that it only triggers for RuntimeLong (where we have more aggressive class inlining policies). |
Replace it by In order for a record to be reified, I believe we need at least an if/else where both branches return an instance of the inline class. Or any other merge point. So that's maybe what we need to add to #4946 (comment) |
I managed to find a problematic program: class A {
private val x: Int = 1
def foo = x
}
@inline
class B extends A {
private val x: String = "f"
def bar = x
}
object HelloWorld {
@noinline
def p(x: Any) = println(x)
@noinline
def test: Boolean = false
def main(args: Array[String]): Unit = {
val b =
if (test) new B()
else new B()
p(b.foo)
p(b.bar)
}
} The main method links to: $c_Lhelloworld_HelloWorld$.prototype.main__AT__V = (function(args) {
if (this.test__Z()) {
var b__x = 1;
var b__x$1 = "f";
} else {
var b__x = 1;
var b__x$1 = "f";
}
this.p__O__V(b__x);
this.p__O__V(b__x); // should be b__x$1
}); |
Nice catch! |
Instead of only retaining the `RecordType`. The `structure` contains the complete information required to map `FieldName`s to the record's `SimpleFieldName`s.
Instead of only retaining the `RecordType`. The `structure` contains the complete information required to map `FieldName`s to the record's `SimpleFieldName`s.
Fix #4947: Retain the `structure` of `PreTransRecordTree`.
Follow-up form here:
scala-js/linker/shared/src/main/scala/org/scalajs/linker/frontend/optimizer/OptimizerCore.scala
Lines 1236 to 1240 in 244fa53
The text was updated successfully, but these errors were encountered: