diff options
author | Eduardo Julian | 2015-03-02 00:02:56 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-03-02 00:02:56 -0400 |
commit | c7fc7e1ffa91db4a563a48d53743a5e0752779ea (patch) | |
tree | ddd79922f36a7025662df34caee7f0064e27306b /src | |
parent | 4908fef51307348d8469d8e95885fa9a0d8eb821 (diff) |
- Removed the (currently broken) static-call optimization.
- Added a list of optimizations to do in the future (after the language is functionally complete).
Diffstat (limited to 'src')
-rw-r--r-- | src/lux.clj | 5 | ||||
-rw-r--r-- | src/lux/compiler.clj | 3 | ||||
-rw-r--r-- | src/lux/compiler/lux.clj | 31 | ||||
-rw-r--r-- | src/lux/optimizer.clj | 10 |
4 files changed, 11 insertions, 38 deletions
diff --git a/src/lux.clj b/src/lux.clj index 53bc115f8..66cb929a4 100644 --- a/src/lux.clj +++ b/src/lux.clj @@ -6,19 +6,16 @@ ;; TODO: Make macros monadic. ;; TODO: Finish type system. ;; TODO: Re-implement compiler in language. - ;; TODO: Do tail-call optimization. ;; TODO: Adding metadata to global vars. ;; TODO: Add records. ;; TODO: throw, try, catch, finally - ;; TODO: Add extra arities (apply2, apply3, ..., apply16) ;; TODO: Allow setting fields. ;; TODO: monitor enter & monitor exit. - ;; TODO: Remember to optimize calling global functions. ;; TODO: ;; TODO: ;; TODO: ;; TODO: - + (time (&compiler/compile-all ["lux"])) (time (&compiler/compile-all ["lux" "test2"])) diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj index 8681aebe4..afc232843 100644 --- a/src/lux/compiler.clj +++ b/src/lux/compiler.clj @@ -63,9 +63,6 @@ [::&a/call ?fn ?args] (&&lux/compile-call compile-expression ?type ?fn ?args) - [::&a/static-call ?needs-num ?fn ?args] - (&&lux/compile-static-call compile-expression ?type ?needs-num ?fn ?args) - [::&a/variant ?tag ?members] (&&lux/compile-variant compile-expression ?type ?tag ?members) diff --git a/src/lux/compiler/lux.clj b/src/lux/compiler/lux.clj index 60a5dbdc0..72aff9798 100644 --- a/src/lux/compiler/lux.clj +++ b/src/lux/compiler/lux.clj @@ -138,37 +138,6 @@ ?args)] (return nil))) -(defn compile-static-call [compile *type* ?needs-num ?fn ?args] - (assert false (pr-str 'compile-static-call)) - (exec [*writer* &/get-writer - :let [_ (match (:form ?fn) - [::&a/global ?owner-class ?fn-name] - (let [arg-sig (&host/->type-signature "java.lang.Object") - call-class (&host/location (list ?owner-class ?fn-name)) - provides-num (count ?args)] - (if (>= provides-num ?needs-num) - (let [impl-sig (str "(" (reduce str "" (repeat ?needs-num arg-sig)) ")" arg-sig)] - (doto *writer* - (-> (do (compile arg)) - (->> (doseq [arg (take ?needs-num ?args)]))) - (.visitMethodInsn Opcodes/INVOKESTATIC call-class "impl" impl-sig) - (-> (doto (do (compile arg)) - (.visitMethodInsn Opcodes/INVOKEINTERFACE (&host/->class &host/function-class) "apply" &&/apply-signature)) - (->> (doseq [arg (drop ?needs-num ?args)]))))) - (let [counter-sig "I" - init-signature (str "(" (apply str counter-sig (repeat (dec ?needs-num) arg-sig)) ")" "V")] - (doto *writer* - (.visitTypeInsn Opcodes/NEW call-class) - (.visitInsn Opcodes/DUP) - (.visitLdcInsn (int provides-num)) - (-> (do (compile arg)) - (->> (doseq [arg ?args]))) - (&&/add-nulls (dec (- ?needs-num provides-num))) - (.visitMethodInsn Opcodes/INVOKESPECIAL call-class "<init>" init-signature))) - )) - )]] - (return nil))) - (defn compile-def [compile name value] (exec [value-type (&a/expr-type value)] (match value diff --git a/src/lux/optimizer.clj b/src/lux/optimizer.clj index c032bc7fb..be6df920f 100644 --- a/src/lux/optimizer.clj +++ b/src/lux/optimizer.clj @@ -1,5 +1,15 @@ (ns lux.optimizer (:require [lux.analyser :as &analyser])) +;; [List of pending optimizations] +;; Global functions: direct currying or direct invocation when function is known at compile-time +;; Improving function calls: add extra arities (apply2, apply3, ..., apply16) +;; Recursion: tail-call optimization +;; Pattern-matching: decision-trees to avoid unnecessary tests +;; Less classes generated per function: Fold nested function classes into one. +;; Mutability for performance: do escape analysis to know when data-structures can be mutated in-place without anybody noticing. +;; Avoid (un)boxing: Analyser movement of primitive values to/from functions to known when (un)boxing can be avoided. +;; Pre-compute constant expressions: Find function calls for which all arguments are known at compile-time and pre-calculate everything prior to compilation. + ;; [Exports] (def optimize &analyser/analyse) |