Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make default bridge generation smarter #2520

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

Closed
sjrd opened this issue Jul 11, 2016 · 0 comments · Fixed by #4893
Closed

Make default bridge generation smarter #2520

sjrd opened this issue Jul 11, 2016 · 0 comments · Fixed by #4893
Assignees
Labels
optimization Optimization only. Does not affect semantics or correctness.
Milestone

Comments

@sjrd
Copy link
Member

sjrd commented Jul 11, 2016

Since 2.12.0-M5 does not generate explicit bridges to default methods in classes anymore, the linker has more responsibility in creating default method bridges. But the way it does this is suboptimal. Consider:

trait Foo {
  def foo(): Int = 5
}
class A extends Foo
class B extends A
class C extends A

An ideal solution (and what happened when scalac generated the bridges) is to create the bridge in A:

class A extends Foo {
  def foo(): Int = this.Foo::foo()
}
class B extends A
class C extends A

But the way the linker works for now is a bit stupid, and it will generate bridges in all the instantiated subclasses of A. So if A, B and C are all instantiated, we end up with

class A extends Foo {
  def foo(): Int = this.Foo::foo()
}
class B extends A {
  def foo(): Int = this.Foo::foo()
}
class C extends A {
  def foo(): Int = this.Foo::foo()
}

We should make the default bridge generation smarter so that it generates a bridge in the most appropriate place in the parent chain of a class.

@sjrd sjrd added the enhancement Feature request (that does not concern language semantics, see "language") label Jul 11, 2016
@sjrd sjrd self-assigned this Jul 11, 2016
@sjrd sjrd added optimization Optimization only. Does not affect semantics or correctness. and removed enhancement Feature request (that does not concern language semantics, see "language") labels Jul 22, 2016
@sjrd sjrd added this to the Post-v1.0.0 milestone Oct 11, 2017
@gzm0 gzm0 removed this from the Post-v1.0.0 milestone Apr 8, 2020
gzm0 added a commit to gzm0/scala-js that referenced this issue Aug 6, 2023
- Fixes scala-js#2520 (make default bridge generation smarter)
- Avoids traversal order dependent behavior.

Since we potentially need to do a default target check on every method
lookup, we memoize calculated default targets.
gzm0 added a commit to gzm0/scala-js that referenced this issue Aug 6, 2023
- Fixes scala-js#2520 (make default bridge generation smarter)
- Avoids traversal order dependent behavior.

Since we potentially need to do a default target check on every method
lookup, we memoize calculated default targets.
gzm0 added a commit to gzm0/scala-js that referenced this issue Aug 6, 2023
- Fixes scala-js#2520 (make default bridge generation smarter)
- Avoids traversal order dependent behavior.

Since we potentially need to do a default target check on every method
lookup, we memoize calculated default targets.

Note that this might generate more default bridges than actually
necessary. However, since they will not be marked as reachable, they
will not even be synthesized.
gzm0 added a commit to gzm0/scala-js that referenced this issue Aug 6, 2023
- Fixes scala-js#2520 (make default bridge generation smarter)
- Avoids traversal order dependent behavior.

Since we potentially need to do a default target check on every method
lookup, we memoize calculated default targets.

Note that this might generate more default bridges than actually
necessary. However, since they will not be marked as reachable, they
will not even be synthesized.
@gzm0 gzm0 added this to the v1.14.0 milestone Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization Optimization only. Does not affect semantics or correctness.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants