Skip to content

synchronized blocks no longer JITtable #233

@retronym

Description

@retronym
class T {
  def test = {
    object ScalaModule {
      toString
    }
    ScalaModule
  }
}

object Test {
  @volatile var t = new T {}
  def main(args: Array[String]) {
    var i = 0
    while (i < 10000000) {
      t.test
      i += 1
    }
  }
}
   1753  514   !   2       T::ScalaModule$lzycompute$1 (35 bytes)
   1753  514   !   2       T::ScalaModule$lzycompute$1 (35 bytes)   COMPILE SKIPPED: invalid parsing (retry at different tier)
                   T.ScalaModule$lzycompute$1(Lscala/runtime/VolatileObjectRef;)V
                   T.ScalaModule$lzycompute$1(Lscala/runtime/VolatileObjectRef;)V
                   T.ScalaModule$lzycompute$1(Lscala/runtime/VolatileObjectRef;)V
                   T.ScalaModule$lzycompute$1(Lscala/runtime/VolatileObjectRef;)V
   1804  532   !   4       T::ScalaModule$lzycompute$1 (35 bytes)
   1804  532   !   4       T::ScalaModule$lzycompute$1 (35 bytes)   COMPILE SKIPPED: cannot parse method (retry at different tier)
--- sandbox/2.11.javap  2016-09-26 09:30:55.000000000 +1000
+++ sandbox/2.12.javap  2016-09-26 09:30:40.000000000 +1000

+  private final void ScalaModule$lzycompute$1(scala.runtime.VolatileObjectRef);
+    descriptor: (Lscala/runtime/VolatileObjectRef;)V
+    flags: ACC_PRIVATE, ACC_FINAL
     Code:
       stack=4, locals=3, args_size=2
          0: aload_0
          1: dup
          2: astore_2
          3: monitorenter
          4: aload_1
-         5: getfield      #16                 // Field scala/runtime/VolatileObjectRef.elem:Ljava/lang/Object;
-         8: ifnonnull     23
-        11: aload_1
-        12: new           #18                 // class T$ScalaModule$2$
-        15: dup
-        16: aload_0
-        17: invokespecial #22                 // Method T$ScalaModule$2$."<init>":(LT;)V
-        20: putfield      #16                 // Field scala/runtime/VolatileObjectRef.elem:Ljava/lang/Object;
-        23: getstatic     #28                 // Field scala/runtime/BoxedUnit.UNIT:Lscala/runtime/BoxedUnit;
-        26: pop
-        27: aload_2
-        28: monitorexit
-        29: aconst_null
-        30: pop
-        31: aload_1
-        32: getfield      #16                 // Field scala/runtime/VolatileObjectRef.elem:Ljava/lang/Object;
-        35: checkcast     #18                 // class T$ScalaModule$2$
-        38: areturn
-        39: aload_2
-        40: monitorexit
-        41: athrow
+         5: getfield      #36                 // Field scala/runtime/VolatileObjectRef.elem:Ljava/lang/Object;
+         8: checkcast     #10                 // class T$ScalaModule$2$
+        11: ifnonnull     26
+        14: aload_1
+        15: new           #10                 // class T$ScalaModule$2$
+        18: dup
+        19: aconst_null
+        20: invokespecial #40                 // Method T$ScalaModule$2$."<init>":(LT;)V
+        23: putfield      #36                 // Field scala/runtime/VolatileObjectRef.elem:Ljava/lang/Object;
+        26: aload_2
+        27: monitorexit
+        28: goto          34
+        31: aload_2
+        32: monitorexit
+        33: athrow
+        34: return
       Exception table:
          from    to  target type
-             4    29    39   any
+             4    26    31   Class java/lang/Throwable
       LocalVariableTable:
         Start  Length  Slot  Name   Signature
-            0      42     0  this   LT;
-            0      42     1   x$1   Lscala/runtime/VolatileObjectRef;
+            0      35     0  this   LT;
+            0      35     1 ScalaModule$module$1   Lscala/runtime/VolatileObjectRef;
       LineNumberTable:
         line 3: 0
-      StackMapTable: number_of_entries = 2
+      StackMapTable: number_of_entries = 3
         frame_type = 252 /* append */
-          offset_delta = 23
+          offset_delta = 26
           locals = [ class T ]
-        frame_type = 79 /* same_locals_1_stack_item */
+        frame_type = 68 /* same_locals_1_stack_item */
           stack = [ class java/lang/Throwable ]

I think it is a general problem with our codegen synchronized blocks, as I'm also seeing this problem for newTermName.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions