Hasty Briefsbeta

Bilingual

Fast Properties in V8 (2017)

3 months ago
  • #JavaScript
  • #Performance
  • #V8
  • V8 handles JavaScript properties differently for performance and memory reasons.
  • JavaScript objects behave like dictionaries but treat integer-indexed and named properties differently.
  • V8 uses HiddenClasses to track object shapes and optimize property access.
  • Named properties are stored separately from elements (integer-indexed properties).
  • HiddenClasses change when properties are added, creating a transition tree for similar objects.
  • Named properties can be in-object, fast (stored in properties store), or slow (dictionary-based).
  • Elements (array-indexed properties) can be packed or have holes, and can be fast or dictionary-mode.
  • Elements are specialized (e.g., Smi, Double) to optimize performance and reduce GC overhead.
  • Array functions are implemented via ElementsAccessor to handle different element kinds efficiently.