Skip to content

Instantly share code, notes, and snippets.

@reborg
Created April 9, 2018 09:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save reborg/2e60268d87c12e73e9460593f6440276 to your computer and use it in GitHub Desktop.
/* The following are decompiled classes for the snippet (fn [b x] (chunk-append b (f x)) b)
In the the first case, the snippet was part of AOT+directlinking compilation. The second evaluated at the REPL
as lambda function inside a (reduce) operation. All as expected, but benchmarks for the non-AOT non-directlinked are
faster and can't explain why it should be. Faster as in 30-40% faster (criterium-bench). */
// 1. AOT compiled + direct linking
public final class clojure.core$map$fn__5678$fn__5679 extends clojure.lang.AFunction {
// Field descriptor #7 Ljava/lang/Object;
java.lang.Object f;
// Method descriptor #9 (Ljava/lang/Object;)V
// Stack: 2, Locals: 2
public core$map$fn__5678$fn__5679(java.lang.Object arg0);
0 aload_0 [this]
1 invokespecial clojure.lang.AFunction() [12]
4 aload_0 [this]
5 aload_1 [arg0]
6 putfield clojure.core$map$fn__5678$fn__5679.f : java.lang.Object [14]
9 return
Line numbers:
[pc: 0, line: 2743]
// Method descriptor #16 (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
// Stack: 4, Locals: 3
public java.lang.Object invoke(java.lang.Object b, java.lang.Object x);
0 aload_1 [b]
1 aload_0 [this]
2 getfield clojure.core$map$fn__5678$fn__5679.f : java.lang.Object [14]
5 checkcast clojure.lang.IFn [18]
8 aload_2 [x]
9 aconst_null
10 astore_2 [x]
11 invokeinterface clojure.lang.IFn.invoke(java.lang.Object) : java.lang.Object [21] [nargs: 2]
16 invokestatic clojure.core$chunk_append.invokeStatic(java.lang.Object, java.lang.Object) : java.lang.Object [26]
19 pop
20 aload_1 [b]
21 aconst_null
22 astore_1 [b]
23 areturn
Line numbers:
[pc: 0, line: 2743]
[pc: 5, line: 2743]
[pc: 11, line: 2743]
Local variable table:
[pc: 0, pc: 23] local: this index: 0 type: java.lang.Object
[pc: 0, pc: 23] local: b index: 1 type: java.lang.Object
[pc: 0, pc: 23] local: x index: 2 type: java.lang.Object
// Method descriptor #10 ()V
// Stack: 0, Locals: 0
public static {};
0 return
Line numbers:
[pc: 0, line: 2743]
}
// 2. Same code, evaluated at the REPL (no AOT no direct linking)
public final class user$cmap$fn__27424$fn__27425 extends clojure.lang.AFunction {
// Field descriptor #7 Ljava/lang/Object;
java.lang.Object f;
// Field descriptor #18 Lclojure/lang/Var;
public static final clojure.lang.Var const__0;
// Method descriptor #9 (Ljava/lang/Object;)V
// Stack: 2, Locals: 2
public user$cmap$fn__27424$fn__27425(java.lang.Object arg0);
0 aload_0 [this]
1 invokespecial clojure.lang.AFunction() [12]
4 aload_0 [this]
5 aload_1 [arg0]
6 putfield user$cmap$fn__27424$fn__27425.f : java.lang.Object [14]
9 return
Line numbers:
[pc: 0, line: 7]
// Method descriptor #16 (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
// Stack: 5, Locals: 3
public java.lang.Object invoke(java.lang.Object b, java.lang.Object x);
0 getstatic user$cmap$fn__27424$fn__27425.const__0 : clojure.lang.Var [20]
3 invokevirtual clojure.lang.Var.getRawRoot() : java.lang.Object [26]
6 checkcast clojure.lang.IFn [28]
9 aload_1 [b]
10 aload_0 [this]
11 getfield user$cmap$fn__27424$fn__27425.f : java.lang.Object [14]
14 checkcast clojure.lang.IFn [28]
17 aload_2 [x]
18 aconst_null
19 astore_2 [x]
20 invokeinterface clojure.lang.IFn.invoke(java.lang.Object) : java.lang.Object [31] [nargs: 2]
25 invokeinterface clojure.lang.IFn.invoke(java.lang.Object, java.lang.Object) : java.lang.Object [33] [nargs: 3]
30 pop
31 aload_1 [b]
32 aconst_null
33 astore_1 [b]
34 areturn
Line numbers:
[pc: 0, line: 7]
[pc: 6, line: 7]
[pc: 14, line: 7]
[pc: 20, line: 7]
[pc: 25, line: 7]
Local variable table:
[pc: 0, pc: 34] local: this index: 0 type: java.lang.Object
[pc: 0, pc: 34] local: b index: 1 type: java.lang.Object
[pc: 0, pc: 34] local: x index: 2 type: java.lang.Object
// Method descriptor #10 ()V
// Stack: 2, Locals: 0
public static {};
0 ldc <String "clojure.core"> [39]
2 ldc <String "chunk-append"> [41]
4 invokestatic clojure.lang.RT.var(java.lang.String, java.lang.String) : clojure.lang.Var [47]
7 checkcast clojure.lang.Var [22]
10 putstatic user$cmap$fn__27424$fn__27425.const__0 : clojure.lang.Var [20]
13 return
Line numbers:
[pc: 0, line: 7]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment