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: 5a9e48dab16e9706ff963d6155df153acb6a0354
  • Loading branch information
marco-c committed Sep 6, 2024
1 parent bfdecdd commit c055299
Show file tree
Hide file tree
Showing 9 changed files with 470 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
24 changes: 14 additions & 10 deletions js/src/frontend/ElemOpEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,16 +396,6 @@ nodiscard
]
]
bool
skipObjAndKeyAndRhs
(
)
;
[
[
nodiscard
]
]
bool
emitDelete
(
)
Expand All @@ -432,6 +422,20 @@ ValueUsage
valueUsage
)
;
size_t
numReferenceSlots
(
)
const
{
return
2
+
isSuper
(
)
;
}
}
;
}
Expand Down
12 changes: 12 additions & 0 deletions js/src/frontend/NameOpEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,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
24 changes: 14 additions & 10 deletions js/src/frontend/PropOpEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,6 @@ nodiscard
]
]
bool
skipObjAndRhs
(
)
;
[
[
nodiscard
]
]
bool
emitDelete
(
TaggedParserAtomIndex
Expand Down Expand Up @@ -456,6 +446,20 @@ ValueUsage
valueUsage
)
;
size_t
numReferenceSlots
(
)
const
{
return
1
+
isSuper
(
)
;
}
}
;
}
Expand Down

0 comments on commit c055299

Please sign in to comment.