JavaScript:SpiderMonkey:Arena Allocation

Revision as of 22:32, 27 April 2010 by Cdleary (talk | contribs) (Arena allocation info and plans.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The SpiderMonkey arena allocation API is used for:

  • Stack space in the JSContext (to be removed by bug 540706)
  • Temp space in the JSContext
  • Bytecodes/source notes in the js::Compiler for expanding compilation storage
  • JSScopeProperties in the JSPropertyTree objects
  • Temp space for regular expression matching, stored in the JSContext
  • Decompiler printer objects

Plans

Time-deferred "soft" release — it was observed in the execution of imacro_asm.js that the regexp pool thrashes quite a bit: a recurring free/alloc of a single arena occurs with each simple regular expression match. By sticking a timestamp on the arena pool and having the garbage collector release the outstanding arenas at a later time we can avoid this overhead in the common case.

Determine optimal arena chunk policy — the arena chunk sizes should mesh with the virtual memory subsystem as nicely as possible. For example, mallocing PAGE_SIZE + 1 byte is probably not ideal. It appears that OS X and Linux follow the same allocation patterns with their malloc implementations WRT their page sizes from these experiments. Further investigation would probably be helpful in determining an overall policy. References: 421435, 561286