Compound assignment calls ToPropertyKey before RequireObjectCoercible
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
People
(Reporter: bakkot, Assigned: yulia)
References
(Blocks 1 open bug)
Details
(Keywords: triage-deferred)
Attachments
(3 files, 7 obsolete files)
Comment 1•8 years ago
|
||
Updated•7 years ago
|
Assignee | ||
Comment 2•4 years ago
|
||
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Comment 3•4 years ago
|
||
There's an open spec issue about this type of bugs: https://github.com/tc39/ecma262/issues/467
Basically we never invested time to implement the exact spec algorithms, because it leads to regressions (bloats byte code; worse error messages). And the spec was never changed to follow the implementations, because it requires reworking the Reference type (and some folks still prefer strict left-to-right evaluation).
Assignee | ||
Comment 4•4 years ago
|
||
Those two reasons: bloats byte code and worse error messages, sounds like a good reason to change the spec. I understand that this might take some spec work, but since this is part of the stream this might be interesting for people to see. Is it worth the time investment to change the spec?
Comment 5•4 years ago
|
||
It'd be easier to convince TC39 to change the spec if implementations all had the exact same semantics, but they're also all slightly different. :-/
Just to expand on "bloats byte code and worse error messages", for dis(function(o, p, v){ o[p] = v })
, we're currently emitting
GetArg 0 # o
GetArg 1 # o p
GetArg 2 # o p v
SetElem # o[p]
which has the minimum number of operations.
Per spec and with our current set of byte code operations, we'd need to emit:
GetArg 0 # o
GetArg 1 # o p
Swap # p o
CheckObjCoercible # p o
Swap # o p
ToPropertyKey # o p
GetArg 2 # o p v
SetElem # o[p]
which doubles the amount of byte code operations, so that's not really acceptable. Furthermore CheckObjCoercible
will report TypeError: null has no properties
when o == null
, whereas we're currently reporting TypeError: can't access property 0, o is null
. The less informative error message is already today visible:
js> null[0]++
typein:1:1 TypeError: null has no properties
Stack:
@typein:1:1
js> null[0]+=1
typein:2:1 TypeError: can't access property 0 of null
Stack:
@typein:2:1
To reduce the byte code bloat and also still report a proper error message, we'd need to add a new operation which combines CheckObjCoercible
and ToPropertyKey
:
GetArg 0 # o
GetArg 1 # o p
PrepareSetElem # o p
GetArg 2 # o p v
SetElem # o[p]
But that's still a 25% increase in the number of byte code operations.
Assignee | ||
Comment 6•4 years ago
|
||
Depends on D78905
Assignee | ||
Comment 7•4 years ago
|
||
Depends on D86231
Assignee | ||
Comment 8•4 years ago
|
||
I have the worst ideas for optimization
Depends on D86232
Assignee | ||
Comment 9•4 years ago
|
||
Depends on D86233
Assignee | ||
Comment 10•4 years ago
|
||
Depends on D86234
Assignee | ||
Comment 11•4 years ago
|
||
Depends on D86235
Assignee | ||
Comment 12•4 years ago
|
||
Depends on D86236
Assignee | ||
Comment 13•4 years ago
|
||
Depends on D86234
Assignee | ||
Comment 14•4 years ago
|
||
Depends on D90695
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Comment 15•3 years ago
|
||
The leave-open keyword is there and there is no activity for 6 months.
:ystartsev, maybe it's time to close this bug?
Assignee | ||
Comment 16•3 years ago
|
||
This has been addressed within the spec iirc (https://github.com/tc39/ecma262/pull/2267), so we can close this.
Updated•3 years ago
|
Description
•