Skip to content

Commit

Permalink
Bug 1832582 part 4 - Add JOF_USES_ENV to JSOp::Arguments and JSOp::Ge…
Browse files Browse the repository at this point in the history
…nerator. r=iain a=pascalc

This shouldn't affect behavior because for `JSOp::Arguments` this replaces a similar check
in `WarpOracle`, and generators have their own environment object causing us to return
true from `ScriptUsesEnvironmentChain`.

Differential Revision: https://phabricator.services.mozilla.com/D178653
  • Loading branch information
jandem committed May 30, 2023
1 parent bd81d5f commit 94b5fa3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 7 additions & 0 deletions js/src/jit/WarpBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,7 @@ bool WarpBuilder::build_Arguments(BytecodeLocation loc) {
auto* snapshot = getOpSnapshot<WarpArguments>(loc);
MOZ_ASSERT(info().needsArgsObj());
MOZ_ASSERT(snapshot);
MOZ_ASSERT(usesEnvironmentChain());

ArgumentsObject* templateObj = snapshot->templateObj();
MDefinition* env = current->environmentChain();
Expand Down Expand Up @@ -1836,6 +1837,8 @@ MConstant* WarpBuilder::globalLexicalEnvConstant() {
}

bool WarpBuilder::build_GetName(BytecodeLocation loc) {
MOZ_ASSERT(usesEnvironmentChain());

MDefinition* env = current->environmentChain();
return buildIC(loc, CacheKind::GetName, {env});
}
Expand Down Expand Up @@ -1865,6 +1868,8 @@ bool WarpBuilder::build_GetGName(BytecodeLocation loc) {
}

bool WarpBuilder::build_BindName(BytecodeLocation loc) {
MOZ_ASSERT(usesEnvironmentChain());

MDefinition* env = current->environmentChain();
return buildIC(loc, CacheKind::BindName, {env});
}
Expand Down Expand Up @@ -2226,6 +2231,8 @@ bool WarpBuilder::build_CheckThisReinit(BytecodeLocation loc) {
}

bool WarpBuilder::build_Generator(BytecodeLocation loc) {
MOZ_ASSERT(usesEnvironmentChain());

MDefinition* callee = getCallee();
MDefinition* environmentChain = current->environmentChain();
MDefinition* argsObj = info().needsArgsObj() ? current->argumentsObject()
Expand Down
6 changes: 1 addition & 5 deletions js/src/jit/WarpOracle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,7 @@ ICEntry& WarpScriptOracle::getICEntryAndFallback(BytecodeLocation loc,

WarpEnvironment WarpScriptOracle::createEnvironment() {
// Don't do anything if the script doesn't use the environment chain.
// Always make an environment chain if the script needs an arguments object
// because ArgumentsObject construction requires the environment chain to be
// passed in.
if (!script_->jitScript()->usesEnvironmentChain() &&
!script_->needsArgsObj()) {
if (!script_->jitScript()->usesEnvironmentChain()) {
return WarpEnvironment(NoEnvironment());
}

Expand Down
4 changes: 2 additions & 2 deletions js/src/vm/Opcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2005,7 +2005,7 @@
* Operands:
* Stack: => gen
*/ \
MACRO(Generator, generator, NULL, 1, 0, 1, JOF_BYTE) \
MACRO(Generator, generator, NULL, 1, 0, 1, JOF_BYTE|JOF_USES_ENV) \
/*
* Suspend the current generator and return to the caller.
*
Expand Down Expand Up @@ -3378,7 +3378,7 @@
* Operands:
* Stack: => arguments
*/ \
MACRO(Arguments, arguments, NULL, 1, 0, 1, JOF_BYTE) \
MACRO(Arguments, arguments, NULL, 1, 0, 1, JOF_BYTE|JOF_USES_ENV) \
/*
* Create and push the rest parameter array for current function call.
*
Expand Down

0 comments on commit 94b5fa3

Please sign in to comment.