Created
August 15, 2020 14:49
-
-
Save jgpc42/37583f0126a5ed0235541a366570e117 to your computer and use it in GitHub Desktop.
direct linking in a REPL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(prn *compiler-options*) | |
; => {:direct-linking true, :disable-locals-clearing true} | |
(require '[no.disassemble :as dis]) | |
(defn reset-atom [a] | |
(swap! a (fnil inc 0))) | |
(defn xxx [a] | |
(reset-atom a)) | |
(print (dis/disassemble xxx)) | |
;; public final class user$xxx extends clojure.lang.AFunction { | |
;; | |
;; // Method descriptor #7 ()V | |
;; // Stack: 1, Locals: 1 | |
;; public user$xxx(); | |
;; 0 aload_0 [this] | |
;; 1 invokespecial clojure.lang.AFunction() [9] | |
;; 4 return | |
;; Line numbers: | |
;; [pc: 0, line: 1] | |
;; | |
;; // Method descriptor #11 (Ljava/lang/Object;)Ljava/lang/Object; | |
;; // Stack: 1, Locals: 1 | |
;; public static java.lang.Object invokeStatic(java.lang.Object a); | |
;; 0 aload_0 [a] | |
;; 1 invokestatic user$reset_atom.invokeStatic(java.lang.Object) : java.lang.Object [15] | |
;; 4 areturn | |
;; Line numbers: | |
;; [pc: 0, line: 1] | |
;; Local variable table: | |
;; [pc: 0, pc: 4] local: a index: 0 type: java.lang.Object | |
;; | |
;; // Method descriptor #11 (Ljava/lang/Object;)Ljava/lang/Object; | |
;; // Stack: 2, Locals: 2 | |
;; public java.lang.Object invoke(java.lang.Object arg0); | |
;; 0 aload_1 [arg0] | |
;; 1 aconst_null | |
;; 2 astore_1 [arg0] | |
;; 3 invokestatic user$xxx.invokeStatic(java.lang.Object) : java.lang.Object [19] | |
;; 6 areturn | |
;; Line numbers: | |
;; [pc: 3, line: 1] | |
;; | |
;; // Method descriptor #7 ()V | |
;; // Stack: 0, Locals: 0 | |
;; public static {}; | |
;; 0 return | |
;; Line numbers: | |
;; [pc: 0, line: 1] | |
;; | |
;; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(prn *compiler-options*) | |
; => {:direct-linking false, :disable-locals-clearing true} | |
(require '[no.disassemble :as dis]) | |
(defn reset-atom [a] | |
(swap! a (fnil inc 0))) | |
(defn xxx [a] | |
(reset-atom a)) | |
(print (dis/disassemble xxx)) | |
;; public final class user$xxx extends clojure.lang.AFunction { | |
;; | |
;; // Field descriptor #13 Lclojure/lang/Var; | |
;; public static final clojure.lang.Var const__0; | |
;; | |
;; // Method descriptor #7 ()V | |
;; // Stack: 1, Locals: 1 | |
;; public user$xxx(); | |
;; 0 aload_0 [this] | |
;; 1 invokespecial clojure.lang.AFunction() [9] | |
;; 4 return | |
;; Line numbers: | |
;; [pc: 0, line: 1] | |
;; | |
;; // Method descriptor #11 (Ljava/lang/Object;)Ljava/lang/Object; | |
;; // Stack: 2, Locals: 1 | |
;; public static java.lang.Object invokeStatic(java.lang.Object a); | |
;; 0 getstatic user$xxx.const__0 : clojure.lang.Var [15] | |
;; 3 invokevirtual clojure.lang.Var.getRawRoot() : java.lang.Object [21] | |
;; 6 checkcast clojure.lang.IFn [23] | |
;; 9 aload_0 [a] | |
;; 10 invokeinterface clojure.lang.IFn.invoke(java.lang.Object) : java.lang.Object [26] [nargs: 2] | |
;; 15 areturn | |
;; Line numbers: | |
;; [pc: 0, line: 1] | |
;; [pc: 6, line: 1] | |
;; [pc: 10, line: 1] | |
;; Local variable table: | |
;; [pc: 0, pc: 15] local: a index: 0 type: java.lang.Object | |
;; | |
;; // Method descriptor #11 (Ljava/lang/Object;)Ljava/lang/Object; | |
;; // Stack: 2, Locals: 2 | |
;; public java.lang.Object invoke(java.lang.Object arg0); | |
;; 0 aload_1 [arg0] | |
;; 1 aconst_null | |
;; 2 astore_1 [arg0] | |
;; 3 invokestatic user$xxx.invokeStatic(java.lang.Object) : java.lang.Object [30] | |
;; 6 areturn | |
;; Line numbers: | |
;; [pc: 3, line: 1] | |
;; | |
;; // Method descriptor #7 ()V | |
;; // Stack: 2, Locals: 0 | |
;; public static {}; | |
;; 0 ldc <String "user"> [33] | |
;; 2 ldc <String "reset-atom"> [35] | |
;; 4 invokestatic clojure.lang.RT.var(java.lang.String, java.lang.String) : clojure.lang.Var [41] | |
;; 7 checkcast clojure.lang.Var [17] | |
;; 10 putstatic user$xxx.const__0 : clojure.lang.Var [15] | |
;; 13 return | |
;; Line numbers: | |
;; [pc: 0, line: 1] | |
;; | |
;; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment