aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lux.clj5
-rw-r--r--src/lux/compiler.clj3
-rw-r--r--src/lux/compiler/lux.clj31
-rw-r--r--src/lux/optimizer.clj10
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)