InstanceMethodExpr.emit emits rendudant method calls which slow application down

Description

Because of the current implementation of InstanceMethodExpr.emit, if the invoked Java method returns a primitive value, the compiler will always produce a "boxing" method call, even if the value is to be discarded right away. Case in point, the following function:

produces this bytecode:

See 7: invokestatic clojure/lang/Numbers.num and 10: pop right after.

I found this because e.g. such Numbers.num calls overhead is observable in our production applications that work with AtomicIntegers and the like.

The attached patch ensures that such values are just discarded in statement context. Judging from the commented form and the commit message for it, this is something that was already done before 2008, but was disabled.

Environment

None

Assignee

Unassigned

Reporter

Alexander Yakushev

Patch

Code

Priority

Major

Affects versions