Commit Graph

107 Commits

Author SHA1 Message Date
73417a9a06 Move 'abort' out of builtins and make it overridable
Now defaults to 'env.abort' as imported in lib/env.ts, but can be overridden through '--use abort=someThingElseOrNothingAtAll'
2018-05-21 18:48:29 +02:00
e415377cda Avoid trampolines where optional arguments are constant literals, see #102; Fix temporary local flags not being cleared; Fix inlined temporary locals not being free'd; Fix inlined flows not breaking after returns; Allow changetype of u32s, i.e. function pointers 2018-05-11 16:31:56 +02:00
1bf0ca6525 Add a mechanism to enable additional (experimental) features and start with sign extension operations; Hashing experimentation 2018-05-08 00:36:19 +02:00
25a1f6230a Suppress some unnecessary blocks and nops; Fix compilation of always 'break'ing 'do's 2018-05-06 05:46:35 +02:00
50f6c1c460 Update internal ABI to zero/sign-extend where necessary only (#87) 2018-05-06 00:00:54 +02:00
99bde3a5fa Use insertion sort for references in Array#sort (#90)
This fixes that Weak Heap Sort isn't stable and thus might swap equal values, which sometimes results in not deep equal arrays of strings, for example. Insertion sort is stable, so it is used for references instead.
2018-05-02 19:33:17 +02:00
2aea14b518 Add more inline-assembler-ish builtins; Update Binaryen 2018-04-27 19:12:25 +02:00
06f99406be Experimenting with inline-assembler-ish explicit builtins
Starting with explicit loads and stores as part of the respective type namespaces. Might become handy for use with portable code, because these can be polyfilled, while load<T> and store<T> can't.
2018-04-27 00:08:41 +02:00
6d6d1dddcf Improve inlining where locals can be aliased; Add a crude mechanism for explicit unchecked array accesses
The `unchecked` builtin should be handled with ultimate care and it would be a lot better if there'd be a mechanism doing this automatically.
2018-04-25 05:04:35 +02:00
391db28fe2 Always try to eliminate branches if tree-shaking is enabled 2018-04-24 23:11:11 +02:00
8465776a1d Use 'super' in Uint8ClampedArray#__set 2018-04-24 00:42:17 +02:00
ddde13a648 Implement Uint8ClampedArray (#82) 2018-04-24 00:33:21 +02:00
63aa648ace Slim down indexed access as far as currently possible
Interestingly, the same code written as statements is significantly slower. See notes.
2018-04-23 23:57:15 +02:00
fac0fc59b5 Implement Array#map, Array#forEach, Array#filter, Array#reduceRight (#81) 2018-04-22 22:15:38 +02:00
9579086699 Add what we have for GC so far
Not functional yet, but might be good to have for discussing it.
2018-04-18 16:32:07 +02:00
a15457d8b9 Simplify isFinite & isNaN (#78) 2018-04-18 15:14:24 +02:00
4929fca363 Move some numeric builtins to stdlib; Minor refactoring 2018-04-17 02:50:38 +02:00
6d0b5d92c2 Minor string comparision optimizations (#77) 2018-04-16 23:02:55 +02:00
ee73a4d28f Initial type parameter inference, see #61
This catches the most common cases but doesn't yet implement inference involving the return type because some prequesites are not yet in place (see test case).
2018-04-13 12:25:27 +02:00
1cea3c6f08 Improve Math#sign (#72) 2018-04-12 19:26:50 +02:00
2002e32c9c Inline small stdlib functions (#71) 2018-04-12 14:17:29 +02:00
623597c23a Make the transition to ArrayBuffer backed Arrays (#70)
* Traverse base classes when resolving overloads
* Implement preliminary TypedArray accessors
* Extract decorator flags from common flags to make space
* Add '**' overload
* Implement basic explicit inlining
* Support inlining of instance methods
* Reduce number of required locals when inlining
* Implement inlining of operator overloads
* Fix issues when inlining generic functions
2018-04-11 23:35:19 +02:00
0f49e054d2 Minor optimizations to array sorting
...to get a handle on the code
2018-04-08 01:53:22 +02:00
ac2281b14b Improve memory usage for weakHeap sorting (#68) 2018-04-08 01:03:26 +02:00
9731958738 Implement a mechanism to realloc array buffers; Trap when trying to allocate more than max size; Test allocators in CI 2018-04-08 00:52:19 +02:00
dcc0e284fb Make type checking builtins also accept just a type argument 2018-04-07 23:31:36 +02:00
b7ef21950b Add String#repeat method (#67) 2018-04-07 18:59:26 +02:00
8770f7b548 New ArrayBuffer/TypedArray; Stdlib restructure; Fix importing stdlib in stdlib; Traverse constructors; Allow initialization of readonly instance fields in constructors 2018-04-07 03:27:22 +02:00
6268b92eba Resolve string instances to the program's string class 2018-04-06 00:19:45 +02:00
70a0123554 Fix some cases in string comparision (#66) 2018-04-05 17:44:17 +02:00
26601dcfb1 Make '===' and '!==' ignore operator overloads
While not semantically equivalent with JS semantics, this appears to be the right thing to do in AS. Also avoids using changetype just for this purpose, which will eventually become considered unsafe.
2018-04-05 02:42:12 +02:00
e790eb757f Add string comparison operator overloads (#64) 2018-04-04 21:50:40 +02:00
5e20bed09a Unify / simplify asc API (in browsers) 2018-04-04 14:39:40 +02:00
acfef646ef Update dist files; Also parse name and source mapping sections in lib/parse 2018-04-04 03:41:04 +02:00
c45a35b1c1 Implement Array#sort (#57) 2018-04-04 00:42:23 +02:00
5823e35f37 Progress and a tiny WASM binary parser 2018-04-03 23:56:48 +02:00
06198a3723 Rename lib prefix to '~lib' (parens aren't valid); Add built-in alignof<T>; Prepare for ArrayBufferView 2018-04-02 19:05:26 +02:00
59a22c1842 A little 'asinit' CLI tool for quickly setting up a project; Minor refactoring 2018-04-01 23:46:41 +02:00
164f134053 Even more math (#56)
Remaining implementations of JavaScript's Math functions (except sin/cos/tan), both double (Math) and single (Mathf) precision, ported from musl incl. tests from libc-test, plus some changes to match JS semantics. Also binds fmod to `%` and pow to `**`.
2018-03-30 17:25:54 +02:00
e47a130771 More math 2018-03-26 23:46:41 +02:00
792202ac5a Add an option to alias global objects
This for example allows to switch the default 'Math' implementation a program will use. Uses 'NativeMath' by default.
2018-03-26 16:54:25 +02:00
e75d006d26 Implement Math/Mathf.pow 2018-03-26 03:50:06 +02:00
e26734ef90 Implement Math/Mathf.exp; Initial math test suite 2018-03-25 17:42:56 +02:00
710fcefd72 Add array methods: findIndex, reduce, some, every (#49) 2018-03-25 13:13:53 +02:00
38a025950e Support parameter properties; Minor formatting 2018-03-25 00:21:58 +01:00
c80bf35747 Move fmod/fmodf to builtins and bind them to the '%' operator 2018-03-24 18:39:20 +01:00
721d77012b Math scaffolding 2018-03-24 17:18:15 +01:00
664f2a1c0d Add offsetof<T> builtin; Put a function's trampoline into the function table if a it has optional parameters; TypedArray scaffolding 2018-03-24 00:38:49 +01:00
4adb69f73a Binary expression operator overloads for +/==; Check allocation flow in ternary expressions; Cache empty array buffers; Sealed decorator for non-derivable internals 2018-03-23 12:45:29 +01:00
9cc0fcd611 Initial ArrayBuffer implementation; Conditional allocation within constructors; Explicit constructor return values 2018-03-23 01:47:01 +01:00