Skip to content

Commit

Permalink
Bug 1916260 - Part 9: Resolve binding in destructuring before retriev…
Browse files Browse the repository at this point in the history
…ing destructured element. r=arai

`BytecodeEmitter::emitDestructuringLHSRef` needs to call `NameOpEmitter::prepareForRhs`
to emit the necessary steps to resolve environment bindings. To avoid adding a new
`skipPrepareForRhs` method to `NameOpEmitter`, instead pass `DestructuringLHSRef&`
to `emitDestructuringLHSRef`, where `DestructuringLHSRef` holds the emitter for the
destructuring left-hand side reference.

Tests are in <tc39/test262#4216>.

Differential Revision: https://phabricator.services.mozilla.com/D220828

UltraBlame original commit: 4c26da6ff32617ca7b277a16949419a7ab28ac5b
  • Loading branch information
marco-c committed Sep 6, 2024
1 parent a145e76 commit 16154a6
Show file tree
Hide file tree
Showing 9 changed files with 491 additions and 573 deletions.
812 changes: 418 additions & 394 deletions js/src/frontend/BytecodeEmitter.cpp

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions js/src/frontend/BytecodeEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ class
ClassEmitter
;
class
DestructuringLHSRef
;
class
ElemOpEmitter
;
class
Expand Down Expand Up @@ -3278,9 +3281,11 @@ emitDestructuringLHSRef
ParseNode
*
target
size_t
*
emitted
DestructuringFlavor
flav
DestructuringLHSRef
&
lref
)
;
[
Expand All @@ -3296,6 +3301,9 @@ ParseNode
target
DestructuringFlavor
flav
DestructuringLHSRef
&
lref
)
;
[
Expand Down
47 changes: 0 additions & 47 deletions js/src/frontend/ElemOpEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,53 +558,6 @@ bool
ElemOpEmitter
:
:
skipObjAndKeyAndRhs
(
)
{
MOZ_ASSERT
(
state_
=
=
State
:
:
Start
)
;
MOZ_ASSERT
(
isSimpleAssignment
(
)
|
|
isPropInit
(
)
)
;
#
ifdef
DEBUG
state_
=
State
:
:
Rhs
;
#
endif
return
true
;
}
bool
ElemOpEmitter
:
:
emitDelete
(
)
Expand Down
31 changes: 21 additions & 10 deletions js/src/frontend/ElemOpEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ Attributes
.
h
"
#
include
<
stddef
.
h
>
namespace
js
{
Expand Down Expand Up @@ -396,16 +403,6 @@ nodiscard
]
]
bool
skipObjAndKeyAndRhs
(
)
;
[
[
nodiscard
]
]
bool
emitDelete
(
)
Expand All @@ -432,6 +429,20 @@ ValueUsage
valueUsage
)
;
size_t
numReferenceSlots
(
)
const
{
return
2
+
isSuper
(
)
;
}
}
;
}
Expand Down
19 changes: 19 additions & 0 deletions js/src/frontend/NameOpEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ h
"
#
include
<
stddef
.
h
>
#
include
"
frontend
/
Expand Down Expand Up @@ -423,6 +430,18 @@ ValueUsage
valueUsage
)
;
size_t
numReferenceSlots
(
)
const
{
return
emittedBindOp
(
)
;
}
}
;
}
Expand Down
47 changes: 0 additions & 47 deletions js/src/frontend/PrivateOpEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,53 +425,6 @@ bool
PrivateOpEmitter
:
:
skipReference
(
)
{
MOZ_ASSERT
(
state_
=
=
State
:
:
Start
)
;
if
(
!
init
(
)
)
{
return
false
;
}
#
ifdef
DEBUG
state_
=
State
:
:
Reference
;
#
endif
return
true
;
}
bool
PrivateOpEmitter
:
:
emitGet
(
)
Expand Down
16 changes: 1 addition & 15 deletions js/src/frontend/PrivateOpEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,16 +434,6 @@ nodiscard
]
]
bool
skipReference
(
)
;
[
[
nodiscard
]
]
bool
emitGet
(
)
Expand Down Expand Up @@ -480,15 +470,11 @@ ValueUsage
valueUsage
)
;
[
[
nodiscard
]
]
size_t
numReferenceSlots
(
)
const
{
return
2
Expand Down
47 changes: 0 additions & 47 deletions js/src/frontend/PropOpEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,53 +492,6 @@ bool
PropOpEmitter
:
:
skipObjAndRhs
(
)
{
MOZ_ASSERT
(
state_
=
=
State
:
:
Start
)
;
MOZ_ASSERT
(
isSimpleAssignment
(
)
|
|
isPropInit
(
)
)
;
#
ifdef
DEBUG
state_
=
State
:
:
Rhs
;
#
endif
return
true
;
}
bool
PropOpEmitter
:
:
emitDelete
(
TaggedParserAtomIndex
Expand Down
31 changes: 21 additions & 10 deletions js/src/frontend/PropOpEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ h
"
#
include
<
stddef
.
h
>
#
include
"
vm
/
Expand Down Expand Up @@ -414,16 +421,6 @@ nodiscard
]
]
bool
skipObjAndRhs
(
)
;
[
[
nodiscard
]
]
bool
emitDelete
(
TaggedParserAtomIndex
Expand Down Expand Up @@ -456,6 +453,20 @@ ValueUsage
valueUsage
)
;
size_t
numReferenceSlots
(
)
const
{
return
1
+
isSuper
(
)
;
}
}
;
}
Expand Down

0 comments on commit 16154a6

Please sign in to comment.