Open Bug 1787350 Opened 2 years ago Updated 6 months ago

Spec compliance and implementation simplifications for Record and Tuple properties and prototypes

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

People

(Reporter: tjc, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(5 files)

A change introduced in https://phabricator.services.mozilla.com/D131124 added special handling for record and tuple wrappers to allow them to be both non-extensible and lazily resolved. (That is, properties were copied from the underlying primitive record or tuple into the wrapper only when accessed.) This follows the treatment of string wrappers, but string wrappers are extensible.

I discussed this with Nicolò and we agreed that we don't think this is necessary. Record and tuple wrappers are usually optimized away. The potential performance cost of copying all properties eagerly on wrapper creation has to be weighed with the benefits of eliminating record-and-tuple-specific changes from the code paths for Objects.

I'm about to submit a patch for this.

Blocks: 1658309

Previously, Object wrappers for records and tuples had lazily resolved
properties, similarly to string properties. This is an optimization that saves
time and space by only copying properties from the primitive into the wrapper
as needed.

However, this creates complications for records and tuples, since unlike
strings, their wrappers are frozen. This commit eliminates several special
cases from object operations by eliminating lazy resolution for record and
tuple wrapper objects. Instead, constructing a RecordObject or
TupleObject eagerly copies the properties. We don't expect this to cause
a performance issue since record and tuple wrappers can usually be optimized
away, but time will tell.

Assignee: nobody → tjc
Status: NEW → ASSIGNED
Severity: -- → N/A
Priority: -- → P2
Summary: Record and Tuple wrapper properties can be eagerly resolved → Spec compliance and implementation simplifications for Record and Tuple properties and prototypes

I renamed the bug so that a few other fixes can be included in the same patch stack:

As per section 14.2.3 of the Record and Tuple proposal -
https://tc39.es/proposal-record-tuple/#sec-properties-of-the-tuple-prototype-object

  • the Tuple prototype object has its prototype set to null. Previously,
    it inherited from Object.prototype.

Depends on D155642

As per step 3.b.ii of [[Get]] for tuple wrappers given in section
10.4.9.5 of the Record and Tuple proposal:
https://tc39.es/proposal-record-tuple/#sec-tuple-exotic-objects-get-p-receiver

when a numeric property key P is outside the valid range of indices for a
given tuple wrapper, Get(P) should immediately return undefined rather
than searching the prototype change.

This patch extends the existing special case for TypedArray to
partially apply to TupleObject as well.

Depends on D156135

Adds conformance tests for section 10.4.9 of the Record and Tuple proposal -
https://tc39.es/proposal-record-tuple/#sec-tuple-exotic-objects

as well as tests reflecting that length is an own property as per
section 10.4.9.2,
https://tc39.es/proposal-record-tuple/#sec-tuple-exotic-objects-getownproperty-p

Depends on D156136

Adding one more spec compliance bug: Record.prototype should be null (proposal section 14.1.2.3: https://tc39.es/proposal-record-tuple/#sec-record.prototype ).

As per section 14.1.2.3 of the Record and Tuple proposal -
https://tc39.es/proposal-record-tuple/#sec-record.prototype - set
Record.prototype to null and initialize RecordObjects with a null
prototype

Attachment #9292567 - Attachment description: Bug 1787350: Skip proto chain lookups for out-of-range tuple elements r?jandem → Bug 1787350: Skip proto chain lookups for out-of-range tuple elements r?anba
Blocks: 1765477
No longer blocks: 1765477

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: tjc → nobody
Status: ASSIGNED → NEW
Assignee: nobody → tjc
Status: NEW → ASSIGNED
Assignee: tjc → nobody
Status: ASSIGNED → NEW
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: