Skip to content

Commit

Permalink
support inlining definline via the core erlang inliner
Browse files Browse the repository at this point in the history
This takes things defined by definline and adds explicit inline
directives for those functions to the core erlang compiler.
  • Loading branch information
ericbmerritt committed Jun 2, 2012
1 parent c66e5d8 commit 132043b
Show file tree
Hide file tree
Showing 2 changed files with 5,447 additions and 5,122 deletions.
35 changes: 26 additions & 9 deletions src/joxa/compiler.jxa
Original file line number Diff line number Diff line change
Expand Up @@ -3556,7 +3556,7 @@
(let (inline-annots (:inline . annots))
(case (make-function (incr-path path0) ctx details)
({name arg-list body}
(add-def-ctx path0 ctx annots name arg-list body)))))
(add-def-ctx path0 ctx inline-annots name arg-list body)))))
((:defmacro+ . details)
(case (make-function (incr-path path0) ctx details)
({name arg-list body}
Expand Down Expand Up @@ -3677,9 +3677,33 @@
(:false
:ok)))

(defn get-definitions (ctx)
(lists/map (fn (el)
(case el
({_ value}
value)))
(definitions-ctx ctx)))

(defn gather-inline-funs (ctx)
(let (defs (definitions-ctx ctx)
inlinables
(lists/foldl (fn (cvar acc)
(case cvar
({name-arity {_ body _}}
(case (lists/member :inline (cerl/get_ann body))
(:true
(name-arity . acc))
(:false acc)))))
[]
defs))
(case inlinables
([] [])
(_
{:inline inlinables}))))

(definline compile-options (ctx type)
(let (additional-opts (case type
(:final [:inline])
(:final [:inline (gather-inline-funs ctx)])
(_ [])))
(lists/flatten [(options-ctx ctx)
additional-opts
Expand Down Expand Up @@ -3731,13 +3755,6 @@
(cerl/ann_c_fname annots fun arity))))
(sets/to_list (exports-ctx ctx))))

(defn get-definitions (ctx)
(lists/map (fn (el)
(case el
({_ value}
value)))
(definitions-ctx ctx)))

;; ### make-joxa-info-1 Function Set
;;
;; The make-joxa-info-1 set of functions creates a module level
Expand Down
Loading

0 comments on commit 132043b

Please sign in to comment.