Commit Graph

12 Commits

Author SHA1 Message Date
Tor Andersson
ae54eaa652 Move js_Buffer to jsi.h and fix some potential leaks. 2017-07-05 13:31:12 +02:00
Tor Andersson
3e3c382a0c Avoid using 'unsigned int'.
Mixing signed and unsigned ints is just a plain headache.
2016-04-27 16:26:00 +02:00
Tor Andersson
0cbd5326f2 Garbage collect (some) strings.
Separate literal/interned and garbage collected string types in js_Value.

js_pushintern/js_tointern are convenience functions to push/pop strings and
automatically intern them (so that the string pointers are guaranteed to be
stable).

js_pushliteral should push stable strings (either interned or actual literals).

js_pushstring will copy the string into garbage collected memory.

The pointer returned by js_tostring is guaranteed to be stable only for as long as
the stack slot it came from remains untouched.

Some uses will always cause a string to be interned:

 * Using it as a property name.
 * Wrapping it in a new String() object.
 * Strings returned by toString().
	ToPrimitive must not clobber the stack, so the result has to be unrooted.
 * Numbers converted to strings (by js_tostring)
	Likewise, we have nowhere to store the temporary string here.
	Passing in a scratch buffer to js_tostring could help this problem.
	Mostly an issue with array accesses (OP_GETPROP, etc) so an auxiliary
	function and we don't have to clutter the API needlessly.
2014-11-28 17:10:08 +01:00
Tor Andersson
67b33c5a86 Handle malloc failure by throwing exceptions. 2014-02-28 14:24:13 +01:00
Tor Andersson
ff6f942365 Add AA-tree node removal.
Simplify string interning AA-tree skew and split operations.

Remove the recursion which is not needed.
2014-01-25 00:45:28 +01:00
Tor Andersson
a6a5bd7994 Add prefixes and remove duplicate functions.
Allows compiling all sources as one big blob.
2014-01-22 03:14:37 +01:00
Tor Andersson
40a12fba0d Split header into js.h public and jsi.h private. Start cleaning up
private function prefixes.
2014-01-20 16:13:09 +01:00
Tor Andersson
48e3fdb718 Alloc interned strings at the end of the string nodes.
Only use one malloc rather than two for each interned string.
2014-01-19 13:33:29 +01:00
Tor Andersson
96ca91ec7c Garbage collector lists. 2014-01-17 23:02:14 +01:00
Tor Andersson
18b192b8aa Minor cleanups. 2014-01-16 02:14:07 +01:00
Tor Andersson
89310461e8 Optimise string interning. 2014-01-13 17:21:38 +01:00
Tor Andersson
8342452b13 Rename files and put stuff in the correct headers. 2014-01-10 14:37:57 +01:00