Closed Bug 1919204 Opened 11 months ago Closed 10 months ago

Remove some global constructors

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
133 Branch
Tracking Status
firefox133 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 2 open bugs)

Details

Attachments

(4 files, 2 obsolete files)

Remove some global constructors according to -Wglobal-constructors. Not necessarily still global constructors after compiler optimisations, see bug 74803, comment #99. But no harm also removing global constructors from -Wglobal-constructors, too. The proposed patches do remove the effective number of global constructors per nm libmozjs-132a1.so | grep -c _GLOBAL__sub_, but I haven't spent time investigating which patch removed which constructor.

Add more constexpr in preparation for part 2.

Part 2 only requires constexpr operator+, but there shouldn't be harm
adding constexpr to the other methods, too.

Required for the next part.

PackedTypeCode:

  • Add separate PackedTypeCode::pack() for non-ref type case, because
    reinterpret_cast isn't allowed in constexpr functions. (There's an
    implicit reinterpret_cast in (uint64_t)(uintptr_t)typeDef.)
  • Add private constructors to PackedTypeCode to fully initialise all parts of
    the union. constexpr functions can't change the active member of an union
    and the initialisation through PackedTypeCode ptc = {}; activates the
    PackedTypeCode::bits_ member.
  • The default constructor is needed for the std::is_pod_v<LitValPOD> static
    assertion in "js/src/wasm/AsmJS.cpp".

The preprocessor generated SymbolicAddressSignature SASig##sa_name globals needed
global constructors, because when calling ValType::toMIRType(), cf. specTypeToMIRType
in "GenerateBuiltinModules.py".

The previous part made ValType::toMIRType() constexpr, also add constexpr here to
avoid regressions. Also add constexpr to all other SymbolicAddressSignature globals
for consistency.

TypedArrayObject::{fixedLength,resizable}Classes were defined out-of-line,
which caused protoTable to generate a global constructor. Change the
definition to be inline and then make protoTable constexpr to ensure we
don't regress this.

Blocks: sm-runtime
Severity: -- → N/A
Priority: -- → P2
Attachment #9425200 - Attachment description: Bug 1919204 - Part 6: Avoid global constructor for protoTable. r=#spidermonkey-reviewers! → Bug 1919204 - Part 4: Avoid global constructor for protoTable. r=#spidermonkey-reviewers!
Attachment #9425198 - Attachment description: Bug 1919204 - Part 4: Make PackedTypeCode and PackedType constructors constexpr. r=#spidermonkey-reviewers! → Bug 1919204 - Part 5: Make PackedTypeCode and PackedType constructors constexpr. r=#spidermonkey-reviewers!
Attachment #9425199 - Attachment description: Bug 1919204 - Part 5: Make SymbolicAddressSignature globals constexpr. r=#spidermonkey-reviewers! → Bug 1919204 - Part 6: Make SymbolicAddressSignature globals constexpr. r=#spidermonkey-reviewers!
Attachment #9425195 - Attachment is obsolete: true
Attachment #9425196 - Attachment is obsolete: true
Attachment #9425197 - Attachment description: Bug 1919204 - Part 3: Avoid global constructors for ModuleNamespaceObject::ProxyHandler. r=#spidermonkey-reviewers! → Bug 1919204 - Part 1: Avoid global constructors for ModuleNamespaceObject::ProxyHandler. r=#spidermonkey-reviewers!
Attachment #9425200 - Attachment description: Bug 1919204 - Part 4: Avoid global constructor for protoTable. r=#spidermonkey-reviewers! → Bug 1919204 - Part 2: Avoid global constructor for protoTable. r=#spidermonkey-reviewers!
Attachment #9425198 - Attachment description: Bug 1919204 - Part 5: Make PackedTypeCode and PackedType constructors constexpr. r=#spidermonkey-reviewers! → Bug 1919204 - Part 3: Make PackedTypeCode and PackedType constructors constexpr. r=#spidermonkey-reviewers!
Attachment #9425199 - Attachment description: Bug 1919204 - Part 6: Make SymbolicAddressSignature globals constexpr. r=#spidermonkey-reviewers! → Bug 1919204 - Part 4: Make SymbolicAddressSignature globals constexpr. r=#spidermonkey-reviewers!
Keywords: leave-open
Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/9cda912ff9b9 Part 1: Avoid global constructors for ModuleNamespaceObject::ProxyHandler. r=spidermonkey-reviewers,mgaudet https://hg.mozilla.org/integration/autoland/rev/973011a914fc Part 2: Avoid global constructor for protoTable. r=spidermonkey-reviewers,mgaudet
Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/378c7b45cb5d Part 3: Make PackedTypeCode and PackedType constructors constexpr. r=yury https://hg.mozilla.org/integration/autoland/rev/75900af5f9c7 Part 4: Make SymbolicAddressSignature globals constexpr. r=yury
Keywords: leave-open
Status: ASSIGNED → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 133 Branch
Duplicate of this bug: 1921343
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: