1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
|
Libraries
=========
- object literals
{:m = 1; n = "abcd":} : [> `m of int; `n of string] Js.record Js.t
==> usual rule for mapping field names; check for no duplicate.
- array literals
in particular, heterogeneous arrays...
('a, 'b, 'c) t ???
module Tuple : sig
type 'a tuple
val e : unit tuple
val a : 'a tuple -> 'b -> ('a * 'b) tuple
type ('a, 'b) acc
val first : ('a * 'b, 'b) acc
val next : ('a, 'b) acc -> ('c * 'a, 'b) acc
val get : 'a tuple -> ('a, 'b) acc -> 'b
val set : 'a tuple -> ('a, 'b) acc -> 'b -> unit
end = struct
type 'a tuple = 'a
let e = ()
let a x y = (x, y)
end
<_0: t0; _1: t1; _n: tn> t
- DOMContentLoaded (+workarounds for legacy browsers)
===> see jquery
Benchmarks/examples
===================
- polishing
- check canvas availability in examples
- finish planet (no cpu when not moving / not visible)
- take examples from http://shootout.alioth.debian.org/?
- planets (+satellites?) ===> Runge-Kutta
- 3D effects: http://gyu.que.jp/jscloth/
http://stackoverflow.com/questions/1584854/how-to-draw-3d-sphere
Compiler optimizations
======================
- "unsafe" option: no check for division by zero / array access
- per module options: we could apply "unsafe" and "inline" options
selectively
- fix control.ml
- syntactic sugar for Javascript literal strings
+ optimization to avoid going through Caml strings
- Can we avoid spurious conversions from boolean to integers???
===> explicit conversion to boolean; specialized "if" that operates
on booleans directly
- constant hoisting (including functions, out of loops and functions)
- inline also partially applied functions
- we should check stack compatibility when parsing:
when jumping somewhere, the stack should keep the same shape
- Improved optimizations
==> cross-function optimizations
==> deadcode elimination inside blocks
(for instance, elimination of function which are defined in a
functor but are not used)
==========================
==========================
Special case for shortcut boolean operations...
1
|\
| \2
| /\
|/ \
3 4
==========================
MD5
===
http://www.myersdaily.org/joseph/javascript/md5-speed-test.html
http://code.google.com/p/crypto-js/source/browse/trunk/src/Crypto.js
http://bitwiseshiftleft.github.com/sjcl/
Float <-> hex
=============
http://babbage.cs.qc.edu/IEEE-754/js/IEEE-754.js
http://snippets.dzone.com/posts/show/685
http://jsfromhell.com/classes/binary-parser
Filling a string
================
function stringFill3(x, n) {
var s = '';
for (;;) {
if (n & 1) s += x;
n >>= 1;
if (n) x += x;
else break;
}
return s;
}
Conversion string <-> array
===========================
http://code.google.com/p/crypto-js/source/browse/trunk/src/Crypto.js
Byte array ==> string
=====================
int array --map--> string array --join--> string
b[i] = toString[a[i]] where toString is a precomputed array of strings
Bigint
======
http://www.leemon.com/crypto/BigInt.js
==========================
BUGS
====
- ISINT is compiled to "not a block"; document this deviation
(or document that we should not rely on the Obj module)
PERFORMANCE
===========
- should we rebind variables from a deeper level ?
(only if used more than once...)
var x = ...
function () {
var y = x;
... y .... y ... y ....
}
IMPROVEMENTS
============
- be more cautious regarding how we print floats...
(is it accurate?)
==> gdtoa
http://caml.inria.fr/pub/ml-archives/caml-list/2002/12/2813f8e8be115b0bad1bc16b1e41b744.en.html
- explicit conversion from int to boolean
- simplify conditional definition
should be:
Cond of Var.t * cont * cont
(we need to eliminate unnecessary conversions from bool to integer
for that)
NEW FEATURES
============
- dynamic linking? (code generation from cmo files)
- Can we use the debugger information to generate specialized code?
(Use objects rather than arrays for tuples, ...)
DATA REPRESENTATION
===================
- should wrap Ocaml exceptions (more robust code)...
==> use Error object as base object, special "message" method
DATA ANALYSIS
=============
- interprocedural analysis
COMPRESSION OPTIMIZATION
========================
- http://timepedia.blogspot.com/2009/08/on-reducing-size-of-compressed.html
http://timepedia.blogspot.com/2009/11/traveling-salesman-problem-and.html
==> order functions by similarity
==> 7-zip is better at compressing than gzip, with the same algorithm...
DOCUMENTATION
=============
document as much as we can:
* the representation of datas, closures, ...
* the assumption we make regarding the bytecode
==> ISINT
================================
REFERENCES
==========
http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/
http://code.google.com/closure/compiler/
http://code.google.com/p/ocamljs/source/browse/#svn/trunk/src
Inlining: see Manuel Serrano's paper
Resolving and Exploiting the k-CFA Paradox
Illuminating Functional vs. Object-Oriented Program Analysis
Matthew Might Yannis Smaragdakis David Van Horn
==================================
Use window.postMessage instead of setTimeout for yield (setTimeout
always waits a bit!)
==> but window.postMessage is synchronous in IE8
+ does not cooperate well with other users of message events
==================================
Could we generate ocaml bytecode as well? (bytecode optimizer)
LLVM code?
Targeting JAVA / .net seem harder: not type information...
==================================
http://www.pps.jussieu.fr/~montela/ocamil/
Note that the OCamIL compilers and tools are currently based on OCaml
v3.06. An upgrade to the latest OCaml version is scheduled for the
next release.
[Never happened...]
ocamldefun (on ocaml_beginners)
I'd really like to play around ocamldefun, but it seems to only work
with ocaml 3.06. Has anyone had luck setting this up in more recent
versions of ocaml?
OCamlexc (on caml list)
So I was wondering if there is any current or recent projects (or interests)
to resume OCamlExc development and complete the set of handled constructs,
as I'm afraid I'll have neither the time nor the skills to do the job.
|