Skip to content

Experimental Lite Mode #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
eb7d048
ugh, bring it back
swannodette Jul 29, 2025
3105284
- remove old ObjMap
swannodette Jul 29, 2025
dba928b
fix all the ObjMap ctor sites
swannodette Jul 30, 2025
db62937
check for :lite-mode? - emit Vector if set
swannodette Jul 30, 2025
85a3620
:lite-mode? -> :lite-mode
swannodette Jul 30, 2025
930fbef
update HashMap and Set
swannodette Jul 30, 2025
71b1e99
no .toString for :lite-mode, pay for what you use
swannodette Jul 30, 2025
90945e6
- something weird about simple-hash-map, leave a note
swannodette Jul 30, 2025
d3beffe
:lite-mode path for maps
swannodette Jul 30, 2025
4e3f244
always elide toString Object methods in :lite-mode
swannodette Jul 30, 2025
ac11735
assoc directly reference array-map, replace w/ literal
swannodette Jul 30, 2025
42bb870
add simple-vector for now, might need to compiler support soon, but c…
swannodette Jul 30, 2025
ac61da8
- formatting
swannodette Jul 30, 2025
e0fb270
- formatting
swannodette Jul 30, 2025
ae604a4
- formatting
swannodette Jul 30, 2025
f329097
- modernize HashMap
swannodette Jul 30, 2025
de3b500
- fix bootstrapped
swannodette Jul 30, 2025
2940738
LITE_MODE goog-define so we can elide chunked logic from std lib
swannodette Jul 30, 2025
d1a6b1d
fix MapEntry construction
swannodette Jul 30, 2025
fa643f1
->> to core/->>
swannodette Jul 30, 2025
d975d25
remove call to vec from simple-vector
swannodette Jul 30, 2025
614d180
add simple-vec
swannodette Jul 31, 2025
2d34791
implement the transient protocols as identity and the standard ops. i…
swannodette Jul 31, 2025
f67fb7b
sketch for vector and vec replace compiler passes
swannodette Jul 31, 2025
d9eb63e
move lite-mode? predicate into the analyzer
swannodette Jul 31, 2025
23492ae
fix pass, add lite-mode tests
swannodette Jul 31, 2025
94c1886
for fn invokes to be replace we also need to update :info
swannodette Jul 31, 2025
c31e77c
`vector` is an inlining macro, so can't handle it only as a pass - ne…
swannodette Aug 1, 2025
4f4842a
handle sets
swannodette Aug 1, 2025
5873009
avoid lazyseq stuff in HashMap impl
swannodette Aug 1, 2025
9a2c2e8
typos
swannodette Aug 1, 2025
c81817a
avoid full blown map entry
swannodette Aug 1, 2025
6ce216c
- more std-lib avoidance, micro sizing opts
swannodette Aug 1, 2025
a2373cb
- use kv-reduce to save some more space
swannodette Aug 1, 2025
1967067
- formatting
swannodette Aug 1, 2025
67ee02b
- before core fns knew about the ObjMap key rep - now it needs to be …
swannodette Aug 3, 2025
28f5133
- lite testing wip
swannodette Aug 3, 2025
c447abb
- cannot pass arrays to ci-reduce, use array-reduce
swannodette Aug 3, 2025
8246266
- fix simple-map-entryff call
swannodette Aug 3, 2025
73c5b89
- missing declare
swannodette Aug 3, 2025
393a594
- simple-map-entry needs to satisfy IVector and IIndexed
swannodette Aug 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"-e" "(cljs.test-runner/-main)"]}
:runtime.test.build {:extra-paths ["src/test/cljs"]
:main-opts ["-m" "cljs.main" "-co" "resources/test.edn" "-c"]}
:lite.test.build {:extra-paths ["src/test/cljs"]
:main-opts ["-m" "cljs.main" "-co" "resources/lite_test.edn" "-c"]}
:selfhost.test.build {:extra-paths ["src/test/self"]
:main-opts ["-m" "cljs.main" "-co" "resources/self_host_test.edn" "-c"]}
:selfparity.test.build {:extra-paths ["src/test/self"]
Expand Down
13 changes: 13 additions & 0 deletions resources/lite_test.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{:optimizations :advanced
:main lite-test-runner
:lite-mode true
:output-to "builds/out-lite/lite-test.js"
:output-dir "builds/out-lite"
:output-wrapper true
:verbose true
:compiler-stats true
:parallel-build true
:closure-warnings {:non-standard-jsdoc :off :global-this :off}
:language-out :es5
:pseudo-names true
:pretty-print true}
32 changes: 32 additions & 0 deletions src/main/cljs/cljs/analyzer/passes/lite.cljc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
;; Copyright (c) Rich Hickey. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.

(ns cljs.analyzer.passes.lite
(:refer-clojure :exclude [var?]))

(defn var? [ast]
(= :var (:op ast)))

(def ctor->simple-ctor
'{cljs.core/vector cljs.core/simple-vector
cljs.core/vec cljs.core/simple-vec})

(defn update-var [{:keys [name] :as ast}]
(let [replacement (get ctor->simple-ctor name)]
(-> ast
(assoc :name replacement)
(assoc-in [:info :name] replacement))))

(defn replace-var? [ast]
(and (var? ast)
(contains? ctor->simple-ctor (:name ast))))

(defn use-lite-types
[env ast _]
(cond-> ast
(replace-var? ast) update-var))
Loading