Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc improvements to internal data structures #1196

Open
2 of 20 tasks
svaarala opened this issue Dec 18, 2016 · 0 comments
Open
2 of 20 tasks

Misc improvements to internal data structures #1196

svaarala opened this issue Dec 18, 2016 · 0 comments

Comments

@svaarala
Copy link
Owner

svaarala commented Dec 18, 2016

The current data structures for string table, object property tables, etc are for the most part unchanged from the initial 1.0 release. They're functional but are in some need of improvement as they're starting to limit performance and footprint improvements, at least compared to for example bytecode dispatch. This is a high level issue to track the overall changes in the medium term for all changes planned but not yet finished. All changes are prototyped and measured before being actually merged of course.

String handling: #1363

Object property table handling: #1364

Miscellaneous:

  • Separate duk_hproxy sub-struct. Add internal duk_hproxy struct #1500
  • Separate duk_hboundfunc sub-struct. Add internal duk_hboundfunc type and collapse bound function chains #1503
  • Revisit the duk_tval format. It's gone through several iterations between NaN aliasing, explicit union (portability), and tagged pointers. Tagged pointers were rejected for 1.0 release because there was no fastint support which makes IEEE double representation (and without fastints, all integer representation) very awkward. Now with fastint support most common values would be representable as tagged pointers, and Float64Array allows IEEE double heavy arithmetic relatively efficiently and compactly. Tagged pointers have several downsides, but also upsides: for one they can be represented as void * which is convenient to pass around by value. They are also more compact than NaN aliasing.
  • To simplify buffer handling, it may be cleaner to separate ArrayBuffer from duk_hbufobj (as it's not a view), and maybe merge plain buffers and ArrayBuffers conceptually, so that a duk_hbufobj could back directly to an ArrayBuffer rather than going through an ArrayBuffer which then is backed by a plain buffer.
  • Similar reconsideration for the lightfunc type might make sense. One approach for the C API would be to hide the difference between a function and a lightfunc from C code (same is done for numbers and fastints for example).
  • Symbol support currently has no explicit C API type. Consider adding that to simplify C code. It may then need a type tag in the internal representation.
  • duk_hobject subtype detection relies on specific flags rather than some kind of enumeration field (class number or similar). Sometimes bit flags are good for fast checking, but when switching over the subtypes a sequence of bit flag tests is not ideal.
  • Boxed values (String object, Number object, etc) now use a _Value internal property. Maybe add a duk_hboxed subtype which can hold a duk_tval. This can then be uniformly unboxed for example. Ability to store a "user value" would be useful in general.

Individual backlog issues to consider when touching the internal typing:

@svaarala svaarala changed the title Round of improvements to internal data structures Misc improvements to internal data structures Feb 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant