Skip to content

Compiler improvement #22

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

Merged
merged 62 commits into from
Oct 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e6c3b75
COMPILER: delay var assignement
hhugo Aug 24, 2013
0add49f
COMPILER: cleanning
hhugo Aug 24, 2013
41480f9
COMPILER: Reserved var module
hhugo Sep 9, 2013
3538d29
COMPILER: clean Var module
hhugo Sep 9, 2013
93d4bff
COMPILER: compute free variables
hhugo Sep 11, 2013
074ee23
COMPILER: variable graph coloring
hhugo Sep 11, 2013
460ec00
OPAM: add ocamlgraph deps
hhugo Sep 11, 2013
e2dcb09
COMPILER: refactoring
hhugo Sep 12, 2013
f599901
COMPILER: clean -> no need for Var.stream
hhugo Sep 12, 2013
63cec75
COMPILER : Refactoring
hhugo Sep 12, 2013
72dcc20
COMPILER: cleanup debugs
hhugo Sep 12, 2013
0eb908e
COMPILER: use colored graph to generate short var names
hhugo Sep 12, 2013
008c8b0
EXAMPLES: rm warning
hhugo Sep 12, 2013
4a7e3c3
COMPILER: delete jsfile in case of error
hhugo Sep 12, 2013
205248b
COMPILER: static evaluation
hhugo Sep 12, 2013
24df695
COMPILER: better variables queue with dep tracking (// renaming)
hhugo Sep 12, 2013
b1dadc6
COMPILER: depend
hhugo Sep 12, 2013
d23bd51
COMPILER: utils
hhugo Sep 12, 2013
20f266a
COMPILER: typo
hhugo Sep 12, 2013
df0ac0d
LIB: restore depend
hhugo Sep 13, 2013
bc5648d
COMPILER: fix scope of try_statement
hhugo Sep 13, 2013
cb17587
COMPILER: make it compile
hhugo Sep 13, 2013
252d268
COMPILER: Js optim
hhugo Sep 12, 2013
25c2b1d
COMPILER: refactoring options
hhugo Sep 14, 2013
f87716f
COMPILER: some cleanning
hhugo Sep 14, 2013
4362f98
COMPILER: mv specialize
hhugo Sep 14, 2013
5c39ab1
COMPILER: split specialize
hhugo Sep 14, 2013
05920c3
COMPILER: plugback specialize
hhugo Sep 15, 2013
ec9a51d
COMPILER: add IString
hhugo Sep 15, 2013
28166be
COMPILER: propagate constant string
hhugo Sep 15, 2013
6a1c9e7
COMPILER: add static eval
hhugo Sep 15, 2013
17ecae0
COMPILER: remove previous attempt
hhugo Sep 15, 2013
b665c0f
COMPILER: share string constant
hhugo Jun 10, 2013
9de7047
COMPILER: detect caml_format_int %d
hhugo Sep 15, 2013
9c44e5e
COMPILER: Sharing
hhugo Sep 16, 2013
62e0f98
COMPILER: more sharing
hhugo Sep 16, 2013
007abb1
COMPILER: more sharing (hack)
hhugo Sep 16, 2013
a919904
COMPILER: fix
hhugo Sep 16, 2013
114079a
COMPILER: missing cleaning
hhugo Sep 16, 2013
14bd57f
TODO: update
hhugo Sep 16, 2013
b236fa9
COMPILER: restore some js_simpl
hhugo Sep 16, 2013
f962906
COMPILER: mv VarPrinter
hhugo Sep 16, 2013
ddb7964
COMPILER: catch only NoColoring exc
hhugo Sep 16, 2013
21bf133
COMPILER: use temp file
hhugo Sep 16, 2013
b863412
COMPILER: use real temp file
hhugo Sep 17, 2013
fb1a023
COMPILER: remove some try-catch
hhugo Sep 24, 2013
61f0ab6
COMPILER: more of js ast
hhugo Sep 21, 2013
d7db7f7
COMPILER: js parser (imported from pfff)
hhugo Sep 21, 2013
9654f94
PARSER: handle regexp properly
hhugo Sep 23, 2013
2195855
Merge remote-tracking branch 'up/master' into compiler
hhugo Sep 24, 2013
47e304e
PARSERJS: typo
hhugo Sep 24, 2013
2123858
COMPILER: compact mode for regexp
hhugo Sep 24, 2013
17c097a
restore pretty var
hhugo Oct 1, 2013
b7c670b
Merge remote-tracking branch 'up/master'
hhugo Oct 3, 2013
f527773
COMPILER: disable short var optim
hhugo Oct 3, 2013
ff33da6
RUNTIME: fix typo
hhugo Oct 3, 2013
8ce6afb
COMPILER: fix static eval of shift functions
hhugo Oct 3, 2013
e2e5287
COMPILER: missing provided symbol
hhugo Oct 3, 2013
3fcc4c9
COMPILER: cleaning js_simpl
hhugo Oct 3, 2013
180b451
COMPILER: use InrA
hhugo Oct 3, 2013
93a99c1
CHANGES: update
hhugo Oct 3, 2013
b6fdf6b
COMPILER: fix move_file
hhugo Oct 3, 2013
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
35 changes: 35 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,41 @@

* Features/Changes
** Add -linkall option to keep all provided primitives
** Compiler: Add javascript file lookup using findlib
(+mypkg/myfile.js will read myfile.js from mypkg findlib directory)
(by Hugo Heuzard)
** Compiler: Add compilation profiles -opt 1 (2 or 3)
(1 -> as before ; 2 -> loop until fixpoint ; 3 -> enable experimental optim
(by Hugo Heuzard)
** Compiler: Improve missing primitives & reserved name detection
(by Hugo Heuzard)
** Compiler: Add variable renaming (Based on graph coloring)
can be enable with -enable shortvar
(by Hugo Heuzard)
** Compiler: static evaluation of constant ("staticeval" optimisation)
(by Hugo Heuzard)
** Compiler: Share string constant (by Hugo Heuzard)
** Compiler: Alias primitives (by Hugo Heuzard)
** Compiler: Complete javacript ast (by Hugo Heuzard)
** Compiler: 'caml_format_int %d x' compiles to ""+x (by Hugo Heuzard)
** add javascript file in META (to be used with ocamlfind)
(by Hugo Heuzard)
** add Ocamlbuild plugin js_of_ocaml.ocamlbuild
(by Jacques-Pascal Deplaix)
** Add/Install unix.js, classlist.js, weak.js
** Add Url.Current.protocol (by Vicent Balat)
** Dependency: deriving instead of deriving-ocsigen
** Log in case of wrong string encoding (by Hugo Heuzard)
** Add compiler_libs (by Pierre Chambart)
** Add Application Cache (by Marc Simon)
** Compile native syntax extension (by Hugo Heuzard)
** Add a javascript parser (extracted from facebook/pfff)
(to be use later)

* BugFixes
** Compiler: js file is not create in case of error (by Hugo Heuzard)
** Fix compatibility when using type conv (by Hugo Heuzard)
** Fix setTimeout overflow (by Hugo Heuzard)

===== 1.3 (2012-11-28) =====

Expand Down
22 changes: 1 addition & 21 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
Priorities
==========

- use short names for primitives
- share string constants
=====> generic mechanism for sharing constants?

- optimize pattern (new Mlstring("foo").toString())
===> "foo" converted to UTF-8
- new MlString(x) replaced by primitive

- unhoist functions when possible

---------
Expand Down Expand Up @@ -80,8 +72,6 @@ Compiler optimizations

- fix control.ml

- detect caml_format_int("%d", x) and generate ""+x

- syntactic sugar for Javascript literal strings
+ optimization to avoid going through Caml strings

Expand All @@ -93,13 +83,9 @@ Compiler optimizations
===> explicit conversion to boolean; specialized "if" that operates
on booleans directly

- inlining (especially of functions that are used only once!)
- constant hoisting (including functions, out of loops and functions)
- inline also partially applied functions

- implement variable coalescing (in code generation, reuse the same
name for several variables when they have a disting lifetime)

- we should check stack compatibility when parsing:
when jumping somewhere, the stack should keep the same shape

Expand Down Expand Up @@ -184,10 +170,7 @@ COMPACT MODE
============
- We need to insert newlines from time to time to avoid problems with
some routers...
- Code for variable renaming in Javascript code
==> also eliminate redundant "var"?
- Start with function parameters. Then, variables that are used most.
- Use interference mechanism...
- eliminate redundant "var"?

IMPROVEMENTS
============
Expand All @@ -197,9 +180,6 @@ IMPROVEMENTS
==> gdtoa
http://caml.inria.fr/pub/ml-archives/caml-list/2002/12/2813f8e8be115b0bad1bc16b1e41b744.en.html

- We only have to make sure we do not use a
reserved word nor a function used outside for naming variables

- explicit conversion from int to boolean

- simplify conditional definition
Expand Down
111 changes: 65 additions & 46 deletions compiler/.depend
Original file line number Diff line number Diff line change
@@ -1,61 +1,79 @@
code.cmo : util.cmi code.cmi
code.cmx : util.cmx code.cmi
code.cmo : util.cmi reserved.cmo option.cmo code.cmi
code.cmx : util.cmx reserved.cmx option.cmx code.cmi
control.cmo : subst.cmi code.cmi control.cmi
control.cmx : subst.cmx code.cmx control.cmi
deadcode.cmo : util.cmi pure_fun.cmi code.cmi deadcode.cmi
deadcode.cmx : util.cmx pure_fun.cmx code.cmx deadcode.cmi
deadcode.cmo : util.cmi pure_fun.cmi option.cmo code.cmi deadcode.cmi
deadcode.cmx : util.cmx pure_fun.cmx option.cmx code.cmx deadcode.cmi
dgraph.cmo : dgraph.cmi
dgraph.cmx : dgraph.cmi
driver.cmo : util.cmi tailcall.cmi phisimpl.cmi parse_bytecode.cmi \
js_output.cmi inline.cmi generate.cmi flow.cmi deadcode.cmi code.cmi \
driver.cmi
driver.cmx : util.cmx tailcall.cmx phisimpl.cmx parse_bytecode.cmx \
js_output.cmx inline.cmx generate.cmx flow.cmx deadcode.cmx code.cmx \
driver.cmi
flow.cmo : util.cmi subst.cmi dgraph.cmi code.cmi flow.cmi
flow.cmx : util.cmx subst.cmx dgraph.cmx code.cmx flow.cmi
freevars.cmo : util.cmi code.cmi freevars.cmi
freevars.cmx : util.cmx code.cmx freevars.cmi
generate.cmo : util.cmi subst.cmi primitive.cmi pretty_print.cmi linker.cmi \
js_simpl.cmi js_output.cmi javascript.cmi freevars.cmi code.cmi \
generate.cmi
generate.cmx : util.cmx subst.cmx primitive.cmx pretty_print.cmx linker.cmx \
js_simpl.cmx js_output.cmx javascript.cmx freevars.cmx code.cmx \
generate.cmi
inline.cmo : util.cmi deadcode.cmi code.cmi inline.cmi
inline.cmx : util.cmx deadcode.cmx code.cmx inline.cmi
driver.cmo : tailcall.cmi specialize_js.cmo specialize.cmo primitive.cmi \
pretty_print.cmi phisimpl.cmi parse_bytecode.cmi option.cmo linker.cmi \
js_var.cmi js_output.cmi inline.cmi generate.cmi flow.cmi eval.cmo \
deadcode.cmi code.cmi driver.cmi
driver.cmx : tailcall.cmx specialize_js.cmx specialize.cmx primitive.cmx \
pretty_print.cmx phisimpl.cmx parse_bytecode.cmx option.cmx linker.cmx \
js_var.cmx js_output.cmx inline.cmx generate.cmx flow.cmx eval.cmx \
deadcode.cmx code.cmx driver.cmi
eval.cmo : primitive.cmi flow.cmi code.cmi
eval.cmx : primitive.cmx flow.cmx code.cmx
flow.cmo : util.cmi subst.cmi option.cmo dgraph.cmi code.cmi flow.cmi
flow.cmx : util.cmx subst.cmx option.cmx dgraph.cmx code.cmx flow.cmi
freevars.cmo : util.cmi option.cmo code.cmi freevars.cmi
freevars.cmx : util.cmx option.cmx code.cmx freevars.cmi
generate.cmo : util.cmi subst.cmi primitive.cmi option.cmo js_simpl.cmi \
javascript.cmi freevars.cmi code.cmi generate.cmi
generate.cmx : util.cmx subst.cmx primitive.cmx option.cmx js_simpl.cmx \
javascript.cmx freevars.cmx code.cmx generate.cmi
inline.cmo : subst.cmi code.cmi inline.cmi
inline.cmx : subst.cmx code.cmx inline.cmi
instr.cmo : instr.cmi
instr.cmx : instr.cmi
javascript.cmo : javascript.cmi
javascript.cmx : javascript.cmi
js_output.cmo : pretty_print.cmi javascript.cmi js_output.cmi
js_output.cmx : pretty_print.cmx javascript.cmx js_output.cmi
javascript.cmo : code.cmi javascript.cmi
javascript.cmx : code.cmx javascript.cmi
js_output.cmo : pretty_print.cmi parse_bytecode.cmi option.cmo \
javascript.cmi code.cmi js_output.cmi
js_output.cmx : pretty_print.cmx parse_bytecode.cmx option.cmx \
javascript.cmx code.cmx js_output.cmi
js_rename.cmo : util.cmi javascript.cmi
js_rename.cmx : util.cmx javascript.cmx
js_simpl.cmo : javascript.cmi js_simpl.cmi
js_simpl.cmx : javascript.cmx js_simpl.cmi
linker.cmo : util.cmi primitive.cmi pretty_print.cmi code.cmi linker.cmi
linker.cmx : util.cmx primitive.cmx pretty_print.cmx code.cmx linker.cmi
main.cmo : util.cmi pretty_print.cmi parse_bytecode.cmi linker.cmi \
driver.cmi
main.cmx : util.cmx pretty_print.cmx parse_bytecode.cmx linker.cmx \
driver.cmx
parse_bytecode.cmo : util.cmi primitive.cmi instr.cmi code.cmi \
js_simpl.cmo : javascript.cmi code.cmi js_simpl.cmi
js_simpl.cmx : javascript.cmx code.cmx js_simpl.cmi
js_var.cmo : util.cmi reserved.cmo primitive.cmi option.cmo javascript.cmi \
code.cmi js_var.cmi
js_var.cmx : util.cmx reserved.cmx primitive.cmx option.cmx javascript.cmx \
code.cmx js_var.cmi
linker.cmo : util.cmi primitive.cmi pretty_print.cmi linker.cmi
linker.cmx : util.cmx primitive.cmx pretty_print.cmx linker.cmi
main.cmo : util.cmi pretty_print.cmi parse_bytecode.cmi option.cmo \
linker.cmi driver.cmi
main.cmx : util.cmx pretty_print.cmx parse_bytecode.cmx option.cmx \
linker.cmx driver.cmx
option.cmo :
option.cmx :
parse_bytecode.cmo : util.cmi primitive.cmi option.cmo instr.cmi code.cmi \
parse_bytecode.cmi
parse_bytecode.cmx : util.cmx primitive.cmx instr.cmx code.cmx \
parse_bytecode.cmx : util.cmx primitive.cmx option.cmx instr.cmx code.cmx \
parse_bytecode.cmi
phisimpl.cmo : util.cmi subst.cmi dgraph.cmi code.cmi phisimpl.cmi
phisimpl.cmx : util.cmx subst.cmx dgraph.cmx code.cmx phisimpl.cmi
phisimpl.cmo : util.cmi subst.cmi option.cmo dgraph.cmi code.cmi \
phisimpl.cmi
phisimpl.cmx : util.cmx subst.cmx option.cmx dgraph.cmx code.cmx \
phisimpl.cmi
pretty_print.cmo : pretty_print.cmi
pretty_print.cmx : pretty_print.cmi
primitive.cmo : util.cmi primitive.cmi
primitive.cmx : util.cmx primitive.cmi
primitive.cmo : util.cmi reserved.cmo primitive.cmi
primitive.cmx : util.cmx reserved.cmx primitive.cmi
pure_fun.cmo : primitive.cmi code.cmi pure_fun.cmi
pure_fun.cmx : primitive.cmx code.cmx pure_fun.cmi
reserved.cmo :
reserved.cmx :
specialize.cmo : option.cmo flow.cmi code.cmi
specialize.cmx : option.cmx flow.cmx code.cmx
specialize_js.cmo : flow.cmi code.cmi
specialize_js.cmx : flow.cmx code.cmx
subst.cmo : util.cmi code.cmi subst.cmi
subst.cmx : util.cmx code.cmx subst.cmi
tailcall.cmo : util.cmi subst.cmi code.cmi tailcall.cmi
tailcall.cmx : util.cmx subst.cmx code.cmx tailcall.cmi
tailcall.cmo : util.cmi subst.cmi option.cmo code.cmi tailcall.cmi
tailcall.cmx : util.cmx subst.cmx option.cmx code.cmx tailcall.cmi
util.cmo : util.cmi
util.cmx : util.cmi
code.cmi : util.cmi
Expand All @@ -65,12 +83,13 @@ dgraph.cmi :
driver.cmi : pretty_print.cmi parse_bytecode.cmi code.cmi
flow.cmi : code.cmi
freevars.cmi : util.cmi code.cmi
generate.cmi : pretty_print.cmi parse_bytecode.cmi code.cmi
generate.cmi : javascript.cmi code.cmi
inline.cmi : code.cmi
instr.cmi :
javascript.cmi :
js_output.cmi : pretty_print.cmi parse_bytecode.cmi javascript.cmi
js_simpl.cmi : javascript.cmi
javascript.cmi : code.cmi
js_output.cmi : pretty_print.cmi parse_bytecode.cmi javascript.cmi code.cmi
js_simpl.cmi : javascript.cmi code.cmi
js_var.cmi : javascript.cmi code.cmi
linker.cmi : pretty_print.cmi
parse_bytecode.cmi : code.cmi
phisimpl.cmi : code.cmi
Expand Down
17 changes: 9 additions & 8 deletions compiler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ all: $(COMPILER)

lib: compiler.cma compiler.cmxa compiler.cmxs

PACKAGES=findlib,str,unix
PACKAGES=findlib,str,unix,ocamlgraph

OBJS=pretty_print.cmx util.cmx dgraph.cmx \
javascript.cmx js_output.cmx js_simpl.cmx \
instr.cmx code.cmx primitive.cmx subst.cmx pure_fun.cmx deadcode.cmx \
flow.cmx inline.cmx \
OBJS=pretty_print.cmx reserved.cmx util.cmx option.cmx dgraph.cmx \
code.cmx javascript.cmx js_output.cmx js_simpl.cmx \
instr.cmx primitive.cmx subst.cmx pure_fun.cmx deadcode.cmx \
flow.cmx specialize.cmx specialize_js.cmx eval.cmx inline.cmx \
tailcall.cmx freevars.cmx phisimpl.cmx \
js_var.cmx \
linker.cmx generate.cmx parse_bytecode.cmx driver.cmx

COMPOBJS=$(OBJS) main.cmx
Expand Down Expand Up @@ -40,13 +41,13 @@ compiler.cmxs: $(OBJS)
ocamlfind ocamlopt -shared -o $@ $^

%.cmx: %.ml
ocamlfind ocamlopt -package findlib,str -for-pack Compiler -c $<
ocamlfind ocamlopt -package findlib,str,ocamlgraph -for-pack Compiler -c $<

%.cmo: %.ml
ocamlfind ocamlc -package findlib,str -c $<
ocamlfind ocamlc -package findlib,str,ocamlgraph -c $<

%.cmi: %.mli
ocamlfind ocamlc -package findlib,str -c $<
ocamlfind ocamlc -package findlib,str,ocamlgraph -c $<

clean:
rm -f *.cm[aiox] *.cmxa *.cmxs *.o *.a
Expand Down
Loading