4 - use short names for primitives
5 - share string constants
6 =====> generic mechanism for sharing constants?
8 - optimize pattern (new Mlstring("foo").toString())
9 ===> "foo" converted to UTF-8
10 - new MlString(x) replaced by primitive
12 - unhoist functions when possible
16 - stopPropagation: function(){
17 if (this.event.stopPropagation) this.event.stopPropagation();
18 else this.event.cancelBubble = true;
20 - check canvas availability in examples
21 - website: menus + doc
22 - finish planet (no cpu when not moving / not visible)
31 {:m = 1; n = "abcd":} : [> `m of int; `n of string] Js.record Js.t
32 ==> usual rule for mapping field names; check for no duplicate.
34 in particular, heterogeneous arrays...
40 val a : 'a tuple -> 'b -> ('a * 'b) tuple
43 val first : ('a * 'b, 'b) acc
44 val next : ('a, 'b) acc -> ('c * 'a, 'b) acc
45 val get : 'a tuple -> ('a, 'b) acc -> 'b
46 val set : 'a tuple -> ('a, 'b) acc -> 'b -> unit
53 <_0: t0; _1: t1; _n: tn> t
57 - DOMContentLoaded (+workarounds for legacy browsers)
60 ===> log(1+x) == (log(1+x) * x) / ((1-x) - 1)
61 (may be misoptimized...)
65 - take examples from http://shootout.alioth.debian.org/?
66 - planets (+satellites?) ===> Runge-Kutta
67 - 3D effects: http://gyu.que.jp/jscloth/
68 http://stackoverflow.com/questions/1584854/how-to-draw-3d-sphere
72 - mutually recursive functions in a loop are not correctly compiled:
73 should build a shared closure
75 Compiler optimizations
76 ======================
77 - "unsafe" option: no check for division by zero / array access
78 - per module options: we could apply "unsafe" and "inline" options
83 - detect caml_format_int("%d", x) and generate ""+x
85 - syntactic sugar for Javascript literal strings
86 + optimization to avoid going through Caml strings
88 - turn partial applications into closures?
90 x = fun(x1,...,xn) {return f(x, x1, ...,xn);}
92 - Can we avoid spurious conversions from boolean to integers???
93 ===> explicit conversion to boolean; specialized "if" that operates
96 - inlining (especially of functions that are used only once!)
97 - constant hoisting (including functions, out of loops and functions)
98 - inline also partially applied functions
100 - implement variable coalescing (in code generation, reuse the same
101 name for several variables when they have a disting lifetime)
103 - we should check stack compatibility when parsing:
104 when jumping somewhere, the stack should keep the same shape
106 - Improved optimizations
107 ==> cross-function optimizations
108 ==> deadcode elimination inside blocks
109 (for instance, elimination of function which are defined in a
110 functor but are not used)
112 ==========================
113 ==========================
115 Special case for shortcut boolean operations...
124 ==========================
128 http://www.myersdaily.org/joseph/javascript/md5-speed-test.html
129 http://code.google.com/p/crypto-js/source/browse/trunk/src/Crypto.js
130 http://bitwiseshiftleft.github.com/sjcl/
134 http://babbage.cs.qc.edu/IEEE-754/js/IEEE-754.js
135 http://snippets.dzone.com/posts/show/685
136 http://jsfromhell.com/classes/binary-parser
140 function stringFill3(x, n) {
151 Conversion string <-> array
152 ===========================
153 http://code.google.com/p/crypto-js/source/browse/trunk/src/Crypto.js
156 Byte array ==> string
157 =====================
158 int array --map--> string array --join--> string
159 b[i] = toString[a[i]] where toString is a precomputed array of strings
163 http://www.leemon.com/crypto/BigInt.js
165 ==========================
169 - ISINT is compiled to "not a block"; document this deviation
170 (or document that we should not rely on the Obj module)
172 - fix definitions of max_int and min_int in pervasive...
177 - should we rebind variables from a deeper level ?
178 (only if used more than once...)
183 ... y .... y ... y ....
188 - We need to insert newlines from time to time to avoid problems with
190 - Code for variable renaming in Javascript code
191 ==> also eliminate redundant "var"?
192 - Start with function parameters. Then, variables that are used most.
193 - Use interference mechanism...
198 - be more cautious regarding how we print floats...
201 http://caml.inria.fr/pub/ml-archives/caml-list/2002/12/2813f8e8be115b0bad1bc16b1e41b744.en.html
203 - We only have to make sure we do not use a
204 reserved word nor a function used outside for naming variables
206 - explicit conversion from int to boolean
208 - simplify conditional definition
210 Cond of Var.t * cont * cont
211 (we need to eliminate unnecessary conversions from bool to integer
217 - Map Caml objects to Javascript objects
218 ==> remap CamlinternalOO module
220 - dynamic linking? (code generation from cmo files)
222 - Can we use the debugger information to generate specialized code?
223 (Use objects rather than arrays for tuples, ...)
227 - should wrap Ocaml exceptions (more robust code)...
228 ==> use Error object as base object, special "message" method
232 - interprocedural analysis
234 COMPRESSION OPTIMIZATION
235 ========================
236 - http://timepedia.blogspot.com/2009/08/on-reducing-size-of-compressed.html
237 http://timepedia.blogspot.com/2009/11/traveling-salesman-problem-and.html
238 ==> order functions by similarity
239 ==> try to always use the same arguments for functions
240 ==> 7-zip is better at compressing than gzip, with the same algorithm...
241 - we can remove some whitespaces but we have to look at the context...
245 document as much as we can:
246 * the representation of datas, closures, ...
247 * the assumption we make regarding the bytecode
250 ================================
255 http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/
257 http://code.google.com/closure/compiler/
259 http://code.google.com/p/ocamljs/source/browse/#svn/trunk/src
261 Inlining: see Manuel Serrano's paper
263 Resolving and Exploiting the k-CFA Paradox
264 Illuminating Functional vs. Object-Oriented Program Analysis
265 Matthew Might Yannis Smaragdakis David Van Horn
267 ==================================
269 Use window.postMessage instead of setTimeout for yield (setTimeout
271 ==> but window.postMessage is synchronous in IE8
272 + does not cooperate well with other users of message events
274 ==================================
276 Could we generate ocaml bytecode as well? (bytecode optimizer)
279 Targeting JAVA / .net seem harder: not type information...
281 ==================================
283 http://www.pps.jussieu.fr/~montela/ocamil/
284 Note that the OCamIL compilers and tools are currently based on OCaml
285 v3.06. An upgrade to the latest OCaml version is scheduled for the
289 ocamldefun (on ocaml_beginners)
290 I'd really like to play around ocamldefun, but it seems to only work
291 with ocaml 3.06. Has anyone had luck setting this up in more recent
294 OCamlexc (on caml list)
295 So I was wondering if there is any current or recent projects (or interests)
296 to resume OCamlExc development and complete the set of handled constructs,
297 as I'm afraid I'll have neither the time nor the skills to do the job.