Skip to content
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

direct var reference #46

Open
mkeskells opened this issue Jan 30, 2018 · 1 comment
Open

direct var reference #46

mkeskells opened this issue Jan 30, 2018 · 1 comment
Assignees

Comments

@mkeskells
Copy link
Collaborator

mkeskells commented Jan 30, 2018

Nil has multiple levels of methods for var access

tail calls tl, tl accesses the field
and we have an tl$access that isnt needed?

  // access flags 0x1
  // signature ()Lscala/collection/immutable/List<TB;>;
  // declaration: scala.collection.immutable.List<B> tl$access$1()
  public tl$access$1()Lscala/collection/immutable/List;
   L0
    LINENUMBER 451 L0
    ALOAD 0
    GETFIELD scala/collection/immutable/$colon$colon.tl : Lscala/collection/immutable/List;
    ARETURN
   L1
    LOCALVARIABLE this Lscala/collection/immutable/$colon$colon; L0 L1 0
    MAXSTACK = 1
    MAXLOCALS = 1

  // access flags 0x1
  // signature ()Lscala/collection/immutable/List<TB;>;
  // declaration: scala.collection.immutable.List<B> tl()
  public tl()Lscala/collection/immutable/List;
   L0
    LINENUMBER 451 L0
    ALOAD 0
    GETFIELD scala/collection/immutable/$colon$colon.tl : Lscala/collection/immutable/List;
    ARETURN
   L1
    LOCALVARIABLE this Lscala/collection/immutable/$colon$colon; L0 L1 0
    MAXSTACK = 1
    MAXLOCALS = 1

  // access flags 0x1
  // signature (Lscala/collection/immutable/List<TB;>;)V
  // declaration: void tl_$eq(scala.collection.immutable.List<B>)
  public tl_$eq(Lscala/collection/immutable/List;)V
    // parameter final  x$1
   L0
    LINENUMBER 451 L0
    ALOAD 0
    ALOAD 1
    PUTFIELD scala/collection/immutable/$colon$colon.tl : Lscala/collection/immutable/List;
    RETURN
   L1
    LOCALVARIABLE this Lscala/collection/immutable/$colon$colon; L0 L1 0
    LOCALVARIABLE x$1 Lscala/collection/immutable/List; L0 L1 1
    MAXSTACK = 2
    MAXLOCALS = 2

  // access flags 0x1
  // signature ()Lscala/collection/immutable/List<TB;>;
  // declaration: scala.collection.immutable.List<B> tail()
  public tail()Lscala/collection/immutable/List;
   L0
    LINENUMBER 452 L0
    ALOAD 0
    INVOKEVIRTUAL scala/collection/immutable/$colon$colon.tl ()Lscala/collection/immutable/List;
    ARETURN
   L1
    LOCALVARIABLE this Lscala/collection/immutable/$colon$colon; L0 L1 0
    MAXSTACK = 1
    MAXLOCALS = 1

@retronym
Copy link

retronym commented Feb 6, 2018

This is a bit of a corner case because of the accessor created for the non-public case class parameter.

@SerialVersionUID(509929039250432923L) // value computed by serialver for 2.11.2, annotation added in 2.11.4
final case class ::[B](override val head: B, private[scala] var tl: List[B]) extends List[B] {
  override def tail : List[B] = this.tl : @inline
  override def isEmpty: Boolean = false
}

Results in:

  public scala.collection.immutable.List<B> tail();
    Code:
       0: aload_0
       1: getfield      #23                 // Field tl:Lscala/collection/immutable/List;
       4: areturn

Which might help some unlucky code that got caught at the threshhold of -XX:MaxInlineLevel.

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

No branches or pull requests

3 participants