Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

The docstring for {{clojure.core/not=}} states "Same as (not (= obj1 obj2))". But since {{clojure.core/=}} has inline arities the emitted code can differ:

`
user=> (defn v1 [] (not= (bit-and 0 0) 0))

'user/v1

user=> (println (disassemble v1))
...
public static java.lang.Object invokeStatic();

 0  getstatic indy_type_hint.core$v1.const__0 : clojure.lang.Var [15]
 3  invokevirtual clojure.lang.Var.getRawRoot() : java.lang.Object [20]
 6  checkcast clojure.lang.IFn [22]
 9  lconst_0
10  lconst_0
11  invokestatic clojure.lang.Numbers.and(long, long) : long [28]       <<<<<<< doesn't use land intrinsic
14  invokestatic clojure.lang.Numbers.num(long) : java.lang.Number [32]
17  getstatic indy_type_hint.core$v1.const__2 : java.lang.Object [36]
20  invokeinterface clojure.lang.IFn.invoke(java.lang.Object, java.lang.Object) : java.lang.Object [40] [nargs: 3]
25  areturn

...

user=> (defn v2 [] (not (= (bit-and 0 0) 0)))

'user/v1

user=> (println (disassemble v2))
...
public static java.lang.Object invokeStatic();

 0  getstatic indy_type_hint.core$v2.const__0 : clojure.lang.Var [15]
 3  invokevirtual clojure.lang.Var.getRawRoot() : java.lang.Object [20]
 6  checkcast clojure.lang.IFn [22]
 9  lconst_0
10  lconst_0
11  land               <<<<<<< uses land intrinsic
12  lconst_0
13  invokestatic clojure.lang.Util.equiv(long, long) : boolean [28]
16  ifeq 25
19  getstatic java.lang.Boolean.TRUE : java.lang.Boolean [34]
22  goto 28
25  getstatic java.lang.Boolean.FALSE : java.lang.Boolean [37]
28  invokeinterface clojure.lang.IFn.invoke(java.lang.Object) : java.lang.Object [41] [nargs: 2]
33  areturn

...
`

The patch adds the same inline arities to {{clojure.core/not=}} as {{clojure.core/=}}. With the patch applied the compiler emits the {{v2}} bytecode for both {{v1}} and {{v2}}.

2 Answers

0 votes
by

Comment made by: schmee

This is the first time I've submitted a patch, please let me know if I did something incorrectly. Also, I haven't signed the CLA yet, but I will be able to do so in the next few weeks.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-2340 (reported by schmee)
Welcome to Clojure Q&A, where you can ask questions and receive answers from members of the Clojure community.
...