[webkit-changes] [WebKit/WebKit] 78ca85: WasmSectionParser should use tryReserveInitialCapa...

Commit Queue noreply at github.com
Wed Aug 30 16:07:07 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 78ca85d1db78101d75e8500282808226b695a1e7
      https://github.com/WebKit/WebKit/commit/78ca85d1db78101d75e8500282808226b695a1e7
  Author: Mark Lam <mark.lam at apple.com>
  Date:   2023-08-30 (Wed, 30 Aug 2023)

  Changed paths:
    M Source/JavaScriptCore/wasm/WasmSectionParser.cpp
    M Source/WTF/wtf/Vector.h

  Log Message:
  -----------
  WasmSectionParser should use tryReserveInitialCapacity instead of tryReserveCapacity.
https://bugs.webkit.org/show_bug.cgi?id=260913
rdar://114175821

Reviewed by Justin Michaud.

We already enforced ordered section parsing, which also enforces that a section type can only
be parsed once (with CustomSection being the only exception).  For each of these sections, there
are many cases where capacity for their vector stores can be allocated with
Vector::tryReserveInitialCapacity instead of Vector::tryReserveCapacity.
Vector::tryReserveInitialCapacity will be more efficient.

Added some RELEASE_ASSERTs to enforce the invariant that these section types are only parsed once.
Added Vector::growCapacityBy and Vector::tryGrowCapacityBy to more concisely express the idea
that we're growing the capacity by some increment.

Also fixed an under-allocation of m_info->typeSignatures and m_info->rtts in SectionParser::parseRecursionGroup.
This code is still under development and is not yet deployed on any platforms.

* Source/JavaScriptCore/wasm/WasmSectionParser.cpp:
(JSC::Wasm::SectionParser::parseType):
(JSC::Wasm::SectionParser::parseImport):
(JSC::Wasm::SectionParser::parseFunction):
(JSC::Wasm::SectionParser::parseGlobal):
(JSC::Wasm::SectionParser::parseExport):
(JSC::Wasm::SectionParser::parseElement):
(JSC::Wasm::SectionParser::parseFunctionType):
(JSC::Wasm::SectionParser::parseStructType):
(JSC::Wasm::SectionParser::parseRecursionGroup):
(JSC::Wasm::SectionParser::parseData):
(JSC::Wasm::SectionParser::parseException):
(JSC::Wasm::SectionParser::parseCustom):
* Source/WTF/wtf/Vector.h:
(WTF::Vector::growCapacityBy):
(WTF::Vector::tryGrowCapacityBy):
(WTF::Malloc>::growCapacityBy):

Canonical link: https://commits.webkit.org/267469@main




More information about the webkit-changes mailing list