Commit Graph

37 Commits

Author SHA1 Message Date
Avi Halachmi (:avih)
c4c1524e97 gc: don't ignore property allocations count
They're not negligible in the overall count.

This decreases the performance of scripts which use objects with many
properties because the GC threshold remains the same (10K) but it's
reached quicker due to counting more allocations, so GC is more
frequent and wastes more overall time.

Good example of the performance impact is the splay.js v8 bench test,
where this commit reduces its score by a factor of 5.

We're not changing the threshold because it's arbitrary anyway, but the
next commit will change it in a way which allows more proportional
control of the GC overhead.
2020-07-23 12:40:09 +02:00
Tor Andersson
bd9920c571 Handle null/undefined in OP_NEXTITER rather than creating empty iterator.
Only create an iterator for coercible types in OP_ITERATOR, and then
detect the lack of a real iterator in OP_NEXTITER.
Thus we don't need to allocate and push an empty iterator object for
these cases.
2019-01-07 13:28:22 +01:00
Tor Andersson
7be32a0f5f Bug 700441: Handle null and undefined expressions in for-in statement. 2019-01-04 10:58:30 +01:00
Tor Andersson
2b4d05a575 Revert 'Maintain order of property enumeration by keeping a linked list.'
Reduce memory use per property by not keeping the properties in two
parallel data structures. Maintaining the order of insertion is not
required by the spec, and is not a very useful feature.
2017-05-09 13:52:11 +02:00
Tor Andersson
805e0f0f59 Add js_newobjectx to create an object with a specific prototype object. 2016-09-09 19:56:35 +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
543115ba39 strict mode: Errors when extending non-extensible objects. 2015-01-14 13:05:12 +01:00
Tor Andersson
6538308087 Add short strings (with data embedded in js_Value).
Allows js_tostring to avoid either interning strings converted from
numbers or creating lots of garbage collected strings.
2014-11-29 16:01:36 +01:00
Tor Andersson
7bb55ad356 Add js_itoa for faster conversion of unsigned int to string. 2014-11-29 12:39:57 +01: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
9f181651fb Track array sparseness to be smarter in jsV_resizearray. 2014-11-07 16:00:45 +01:00
Tor Andersson
a9e6b4cd01 Fix bug in maintaining property enumeration list.
The tail pointer in the linked list head was mismanaged, leading
to using free memory when properties are inserted after deleting
a property such that the tail points to the deleted node.
2014-11-01 13:03:40 +01:00
Tor Andersson
67b33c5a86 Handle malloc failure by throwing exceptions. 2014-02-28 14:24:13 +01:00
Tor Andersson
45e3a31950 Some -pedantic warning fixes.
Drop the use of 'inline' in most places... place some trust in the
compiler.
2014-02-25 01:23:52 +01:00
Tor Andersson
a98748a0ce Use clang by default and enable more warnings. 2014-02-25 01:01:20 +01:00
Tor Andersson
588fdd18d6 Small cleanups. 2014-02-18 14:38:50 +01:00
Tor Andersson
b219aef882 Add virtual string array index properties for characters. 2014-02-07 16:40:22 +01:00
Tor Andersson
979c7bc1bd Implement extensible object attribute. 2014-02-07 10:57:52 +01:00
Tor Andersson
d35cef7df9 Implement getters and setters.
Does not work properly for setters on inherited properties.
2014-02-06 16:03:44 +01:00
Tor Andersson
e4ab13f855 Fix clang scan-build warning. 2014-01-28 23:42:16 +01:00
Tor Andersson
8ade82bdfa Maintain order of property enumeration by keeping a linked list.
Match behaviour with other JS implementations.
2014-01-28 13:58:19 +01:00
Tor Andersson
9103b4f4de Add 'own' argument to iterator.
If set, it will only create an iterator for own properties.
If unset, it will iterate over all properties in the prototype
chain.
2014-01-25 17:46:43 +01:00
Tor Andersson
f66986d3d8 Implement a smarter deletion of properties when resizing an array. 2014-01-25 17:40:37 +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
ac6cc9f7b7 Automagically update Array length property. 2014-01-24 22:33:07 +01:00
Tor Andersson
7a45bb4363 Free iterator nodes as they are being iterated over. 2014-01-23 23:04:59 +01:00
Tor Andersson
195816c208 Set property attributes on built-in objects and respect DontEnum. 2014-01-23 17:53:22 +01:00
Tor Andersson
0fd3f364ec Add iterator object class for internal use in for-in loops.
Flatten all enumerable properties in object prototype chain
into a linked list to enumerate.
2014-01-23 10:07:22 +01:00
Tor Andersson
b262cc3673 Rename many jsR functions to jsV.
Danger! jsV work on values internally without the stack.

Also rearrange how C-constructors are created.
2014-01-20 17:44:56 +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
95ac24c7cf Put js_Object contents in a union. 2014-01-19 13:29:38 +01:00
Tor Andersson
ffc82eabd7 Add allocation counter to trigger garbage collector during interpretation.
Only trigger between function calls, during bytecode interpretation,
to allow for intra-function race conditions where an object has been
created but not yet inserted into the stack or environment scope chain.
2014-01-18 00:57:18 +01:00
Tor Andersson
96ca91ec7c Garbage collector lists. 2014-01-17 23:02:14 +01:00
Tor Andersson
299dbda156 Move stack into state. 2014-01-17 22:42:15 +01:00
Tor Andersson
f487a7db10 Set prototype internal property when creating objects. 2014-01-17 19:41:41 +01:00
Tor Andersson
b595422da9 Add object property accessor functions to public API. 2014-01-17 03:03:10 +01:00
Tor Andersson
288eef80e1 Clean up. Rearrange files. Rename functions. 2014-01-16 20:48:43 +01:00