Skip to content

Conversation

liufengyun
Copy link
Contributor

WIP - Performance improvement to global initialization checker

@liufengyun liufengyun force-pushed the liufengyun/improve-global-init branch from 41e9816 to fac91e3 Compare September 3, 2024 20:30
See test tests/init-global/warn/return2.scala
Otherwise, the following program causes weird address not found error:

    import scala.collection.immutable.HashSet

    object A:
      val a = HashSet(1, 2, 3)

The error looks like the following:

    -- Warning: out/bootstrap/scala2-library-bootstrapped/scala-3.6.0-RC1-bin-SNAPSHOT-nonbootstrapped/src_managed/main/scala-library-src/scala/collection/immutable/ChampCommon.scala:155:24
    155 |    currentStackLevel = currentStackLevel - 1
        |                        ^^^^^^^^^^^^^^^^^
        |[Internal error] Address not found FieldAddr(List(),val currentStackLevel,module class A$). Trace:
        |Calling trace:
        |├── object A:	[ HashSet.scala:3 ]
        |│   ^
        |├── val a = HashSet(1, 2, 3)	[ HashSet.scala:4 ]
        |│           ^^^^^^^^^^^^^^^^
        |├── def apply[A](elems: A*): CC[A] = from(elems)	[ Factory.scala:103 ]
        |│                                    ^^^^^^^^^^^
        |├── def from[A](source: collection.IterableOnce[A]): HashSet[A] =	[ HashSet.scala:1939 ]
        |│   ^
        |├── case _ => (newBuilder[A] ++= source).result()	[ HashSet.scala:1943 ]
        |│              ^^^^^^^^^^^^^^^^^^^^^^^^
        |├── @inline final def ++= (@deprecatedName("xs") elems: IterableOnce[A]): this.type = addAll(elems)	[ Growable.scala:69 ]
        |│                                                                                     ^^^^^^^^^^^^^
        |├── override def addAll(xs: IterableOnce[A]) = {	[ HashSet.scala:2079 ]
        |│   ^
        |├── }	[ HashSet.scala:2096 ]
        |│    ^
        |├── new ChampBaseIterator[A, SetNode[A]](hm.rootNode) {	[ HashSet.scala:2083 ]
        |│   ^
        |├── while(hasNext) {	[ HashSet.scala:2084 ]
        |│         ^^^^^^^
        |├── final def hasNext = (currentValueCursor < currentValueLength) || searchNextValueNode()	[ ChampCommon.scala:185 ]
        |│                                                                    ^^^^^^^^^^^^^^^^^^^^^
        |├── private final def searchNextValueNode(): Boolean = {	[ ChampCommon.scala:162 ]
        |│   ^
        |├── popNode()	[ ChampCommon.scala:178 ]
        |│   ^^^^^^^^^
        |├── private final def popNode(): Unit = {	[ ChampCommon.scala:154 ]
        |│   ^
        |└── currentStackLevel = currentStackLevel - 1	[ ChampCommon.scala:155 ]
        |                        ^^^^^^^^^^^^^^^^^
@liufengyun liufengyun force-pushed the liufengyun/improve-global-init branch from 575eb0a to 08b4e66 Compare September 16, 2024 17:00
@liufengyun liufengyun force-pushed the liufengyun/improve-global-init branch from 4ae29fb to ce87173 Compare September 29, 2024 20:50
@liufengyun
Copy link
Contributor Author

This is an obsolete experiment.

@liufengyun liufengyun closed this Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant