Fix incorrect argument loading in upcall stubs
This commit is contained in:
parent
14d38e3b8a
commit
a1ad988aad
2 changed files with 17 additions and 5 deletions
|
|
@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This change
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Long and double arguments to upcalls failed to compile in some cases
|
||||||
- Void return types on upcalls would crash on serialization
|
- Void return types on upcalls would crash on serialization
|
||||||
|
|
||||||
## [0.1.251] - 2021-10-14
|
## [0.1.251] - 2021-10-14
|
||||||
|
|
|
||||||
|
|
@ -459,6 +459,10 @@
|
||||||
::mem/double :dreturn
|
::mem/double :dreturn
|
||||||
::mem/void :return})
|
::mem/void :return})
|
||||||
|
|
||||||
|
(def ^:private double-sized?
|
||||||
|
"Set of primitive types which require 2 indices in the constant pool."
|
||||||
|
#{::mem/double ::mem/long ::mem/long-long})
|
||||||
|
|
||||||
(defn- upcall-class
|
(defn- upcall-class
|
||||||
"Constructs a class definition for a class with a single method, `upcall`, which
|
"Constructs a class definition for a class with a single method, `upcall`, which
|
||||||
boxes any primitives passed to it and calls a closed over [[IFn]]."
|
boxes any primitives passed to it and calls a closed over [[IFn]]."
|
||||||
|
|
@ -482,11 +486,18 @@
|
||||||
(insn-layout ret-type))
|
(insn-layout ret-type))
|
||||||
:emit [[:aload 0]
|
:emit [[:aload 0]
|
||||||
[:getfield :this "upcall_ifn" IFn]
|
[:getfield :this "upcall_ifn" IFn]
|
||||||
(map-indexed
|
(loop [types arg-types
|
||||||
(fn [idx arg]
|
acc []
|
||||||
[[(load-instructions (mem/primitive-type arg) :aload) (inc idx)]
|
idx 1]
|
||||||
(to-object-asm arg)])
|
(if (seq types)
|
||||||
arg-types)
|
(let [prim (mem/primitive-type (first types))]
|
||||||
|
(recur (rest types)
|
||||||
|
(conj acc [[(load-instructions prim) idx]
|
||||||
|
(to-object-asm (first types))])
|
||||||
|
(cond-> (inc idx)
|
||||||
|
(double-sized? prim)
|
||||||
|
inc)))
|
||||||
|
acc))
|
||||||
[:invokeinterface IFn "invoke" (repeat (inc (count arg-types)) Object)]
|
[:invokeinterface IFn "invoke" (repeat (inc (count arg-types)) Object)]
|
||||||
(to-prim-asm ret-type)
|
(to-prim-asm ret-type)
|
||||||
[(return-for-type ret-type :areturn)]]}]})
|
[(return-for-type ret-type :areturn)]]}]})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue