Closed Bug 1783703 Opened 3 years ago Closed 3 years ago

Fix various issues in the Change-Array-By-Copy functions

Categories

(Core :: JavaScript: Standard Library, defect, P1)

defect

Tracking

()

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: anba, Assigned: anba)

References

Details

Attachments

(15 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Fix various issues in the Change-Array-By-Copy functions and add some optimisations for the C++ code.

There's already a realm creation option for this feature.

Depends on D153981

Built-ins are created when the realm is created (at least according to the spec),
so it should be a RealmCreationOptions.

Depends on D153982

This function has been removed from the proposal.

Depends on D153984

Changes:

  • Don't enter the compartment of the TypedArray to match TypedArraySort. This
    is done to avoid having to switch the compartment when the comparator function
    is in the current compartment.
  • Add missing check for detached buffers.
  • Use single line comments, because we prefer them for new code.
  • Avoid unnecessary indirection through CallTypedArrayMethodIfWrapped.

Depends on D153985

Drive-by change:

  • Replace DefineDataProperty with assignment to better match spec.

Depends on D153986

Changes:

  • Correctly check for detached buffers.
  • Consistently use var.
  • Coerce value before the range check.
  • Reload length before range check.
  • Replace DefineDataProperty with assignment to match spec.
  • Remove unused function isValidIntegerIndex

Depends on D153987

Changes:

  • GetPrototypeFromBuiltinConstructor is unnecessary.
  • Use NewDensePartlyAllocatedArray to better describe how the array is allocated.
  • IsIntegralNumber is unused.
  • More comment changes.
  • JSMSG_BAD_INDEX doesn't have an argument string.
  • int64_t(len + actualIndex) is UB when the result is outside the int64_t range.
  • Add missing CheckForInterrupt.
  • Use DefineArrayElement instead of SetArrayElement.
  • Prefer variable name arr over A to match other functions here and elsewhere in C++.

Depends on D153989

  • Use correct types.
  • Use single line comments, because we prefer them in new code.
  • Add extra assertions.

Depends on D153990

Changes:

  • array_toSpliced instead of array_to_spliced to match naming conventions.
  • More comment changes.
  • More assertions.
  • Use more narrow types where possible.
  • Add missing CheckForInterrupt.
  • Use DefineArrayElement instead of SetArrayElement to match spec.

Depends on D153991

We should provide an optimisation for dense elements when the code is already
in C++.

Depends on D153993

We should provide an optimisation for dense elements when the code is already
in C++.

Depends on D153994

Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/20bab21cb2f9 Part 1: Remove ContextOptions::arrayGrouping(). r=mgaudet https://hg.mozilla.org/integration/autoland/rev/51f5e08c0910 Part 2: Change-Array-By-Copy flag should be a RealmCreationOptions. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/756492ddc26e Part 3: Remove TypedArrayProtoFinish. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/cc68008df183 Part 4: Remove TypedArray.prototype.toSpliced(). r=mgaudet https://hg.mozilla.org/integration/autoland/rev/bf33097e583a Part 5: Align TypedArrayToSorted with TypedArraySort. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/10e2bccd526b Part 6: Handle detached buffers in TypedArrayToReversed. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/a8624e35aca9 Part 7: Synchronise and fix some issues in TypedArrayWith. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/94f2ccf5ad44 Part 8: Remove incorrect comment in TypedArrayAt. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/62d7d9d37022 Part 9: Fix various issues in array_with. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/dd1820cfa903 Part 10: Clean-up Array.prototype.splice helpers. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/b39a39e874ef Part 11: Fix various issues in array_toSpliced. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/ede9a0e515ad Part 12: Inline NewDensePartlyAllocatedArray with uint64_t length argument. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/d3bb893d3ebe Part 13: Add an optimised code path for dense elements to Array.prototype.with. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/c65668216e4e Part 14: Add an optimised code path for dense elements to Array.prototype.toSpliced. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/e54f9ca5cb57 Part 15: Avoid calling IsArraySpecies twice in array_splice. r=mgaudet
Severity: -- → S4
Priority: -- → P1
Depends on: 1784454
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: