Bug 1636942 part 1 - Rename JSOp::ToId to JSOp::ToPropertyKey. r=evilpie

Doesn't rename the MToId instruction because the next patch will make changes to
that anyway.

The comment in Interpreter.cpp was removed because this op is already (and better)
documented in vm/Opcodes.h

Differential Revision: https://phabricator.services.mozilla.com/D78039
This commit is contained in:
Jan de Mooij 2020-06-05 07:14:22 +00:00
parent 2517967e0e
commit 1d34735dbc
15 changed files with 27 additions and 31 deletions

View File

@ -1585,7 +1585,7 @@ static bool BytecodeIsEffectful(JSOp op) {
case JSOp::Typeof:
case JSOp::TypeofExpr:
case JSOp::ToAsyncIter:
case JSOp::ToId:
case JSOp::ToPropertyKey:
case JSOp::IterNext:
case JSOp::Lambda:
case JSOp::LambdaArrow:

View File

@ -3534,7 +3534,7 @@ bool BytecodeEmitter::emitDestructuringOpsArray(ListNode* pattern,
bool BytecodeEmitter::emitComputedPropertyName(UnaryNode* computedPropName) {
MOZ_ASSERT(computedPropName->isKind(ParseNodeKind::ComputedName));
return emitTree(computedPropName->kid()) && emit1(JSOp::ToId);
return emitTree(computedPropName->kid()) && emit1(JSOp::ToPropertyKey);
}
bool BytecodeEmitter::emitDestructuringOpsObject(ListNode* pattern,
@ -8352,7 +8352,7 @@ bool BytecodeEmitter::emitPropertyList(ListNode* obj, PropertyEmitter& pe,
return false;
}
if (!emit1(JSOp::ToId)) {
if (!emit1(JSOp::ToPropertyKey)) {
// [stack] CTOR? OBJ ARRAY KEY
return false;
}

View File

@ -55,7 +55,7 @@ bool ElemOpEmitter::emitGet() {
MOZ_ASSERT(state_ == State::Key);
if (isIncDec() || isCompoundAssignment()) {
if (!bce_->emit1(JSOp::ToId)) {
if (!bce_->emit1(JSOp::ToPropertyKey)) {
// [stack] # if Super
// [stack] THIS KEY
// [stack] # otherwise
@ -151,7 +151,7 @@ bool ElemOpEmitter::emitDelete() {
MOZ_ASSERT(isDelete());
if (isSuper()) {
if (!bce_->emit1(JSOp::ToId)) {
if (!bce_->emit1(JSOp::ToPropertyKey)) {
// [stack] THIS KEY
return false;
}

View File

@ -209,7 +209,7 @@ bool PropertyEmitter::prepareForComputedPropValue() {
// [stack] CTOR? OBJ CTOR? KEY
if (!bce_->emit1(JSOp::ToId)) {
if (!bce_->emit1(JSOp::ToPropertyKey)) {
// [stack] CTOR? OBJ CTOR? KEY
return false;
}

View File

@ -5090,7 +5090,7 @@ bool BaselineCodeGen<Handler>::emit_RetRval() {
}
template <typename Handler>
bool BaselineCodeGen<Handler>::emit_ToId() {
bool BaselineCodeGen<Handler>::emit_ToPropertyKey() {
// Load index in R0, but keep values on the stack for the decompiler.
frame.syncStack(0);
masm.loadValue(frame.addressOfStackValue(-1), R0);
@ -5106,7 +5106,7 @@ bool BaselineCodeGen<Handler>::emit_ToId() {
pushArg(R0);
using Fn = bool (*)(JSContext*, HandleValue, MutableHandleValue);
if (!callVM<Fn, js::ToIdOperation>()) {
if (!callVM<Fn, js::ToPropertyKeyOperation>()) {
return false;
}

View File

@ -11849,7 +11849,7 @@ void CodeGenerator::visitToIdV(LToIdV* lir) {
ValueOperand input = ToValue(lir, LToIdV::Input);
using Fn = bool (*)(JSContext*, HandleValue, MutableHandleValue);
OutOfLineCode* ool = oolCallVM<Fn, ToIdOperation>(
OutOfLineCode* ool = oolCallVM<Fn, ToPropertyKeyOperation>(
lir, ArgList(ToValue(lir, LToIdV::Input)), StoreValueTo(out));
Register tag = masm.extractTag(input, out.scratchReg());

View File

@ -1534,7 +1534,7 @@ class MOZ_RAII PoppedValueUseChecker {
switch (op) {
case JSOp::Pos:
case JSOp::ToNumeric:
case JSOp::ToId:
case JSOp::ToPropertyKey:
case JSOp::ToString:
// These ops may leave their input on the stack without setting
// the ImplicitlyUsed flag. If this value will be popped immediately,
@ -2277,8 +2277,8 @@ AbortReasonOr<Ok> IonBuilder::inspectOpcode(JSOp op, bool* restarted) {
case JSOp::ToAsyncIter:
return jsop_toasynciter();
case JSOp::ToId:
return jsop_toid();
case JSOp::ToPropertyKey:
return jsop_topropertykey();
case JSOp::IterNext:
return jsop_iternext();
@ -12132,8 +12132,8 @@ AbortReasonOr<Ok> IonBuilder::jsop_toasynciter() {
return resumeAfter(ins);
}
AbortReasonOr<Ok> IonBuilder::jsop_toid() {
// No-op if the index is trivally convertable to an id.
AbortReasonOr<Ok> IonBuilder::jsop_topropertykey() {
// No-op if the index is trivally convertable to a PropertyKey.
MIRType type = current->peek(-1)->type();
if (type == MIRType::Int32 || type == MIRType::String ||
type == MIRType::Symbol) {

View File

@ -644,7 +644,7 @@ class MOZ_STACK_CLASS IonBuilder {
AbortReasonOr<Ok> jsop_typeof();
AbortReasonOr<Ok> jsop_toasync();
AbortReasonOr<Ok> jsop_toasynciter();
AbortReasonOr<Ok> jsop_toid();
AbortReasonOr<Ok> jsop_topropertykey();
AbortReasonOr<Ok> jsop_iter();
AbortReasonOr<Ok> jsop_itermore();
AbortReasonOr<Ok> jsop_isnoiter();

View File

@ -269,8 +269,8 @@ namespace jit {
_(ThrowRuntimeLexicalError, js::jit::ThrowRuntimeLexicalError) \
_(ThrowUninitializedThis, js::ThrowUninitializedThis) \
_(ToBigInt, js::ToBigInt) \
_(ToIdOperation, js::ToIdOperation) \
_(ToObjectSlow, js::ToObjectSlow) \
_(ToPropertyKeyOperation, js::ToPropertyKeyOperation) \
_(ToStringSlow, js::ToStringSlow<CanGC>) \
_(TrySkipAwait, js::jit::TrySkipAwait)

View File

@ -1519,7 +1519,7 @@ bool WarpBuilder::build_ToAsyncIter(BytecodeLocation loc) {
return resumeAfter(ins, loc);
}
bool WarpBuilder::build_ToId(BytecodeLocation loc) {
bool WarpBuilder::build_ToPropertyKey(BytecodeLocation loc) {
MDefinition* index = current->pop();
MToId* ins = MToId::New(alloc(), index);
current->add(ins);

View File

@ -549,7 +549,7 @@ AbortReasonOr<WarpScriptSnapshot*> WarpOracle::createScriptSnapshot(
case JSOp::ClassConstructor:
case JSOp::DerivedConstructor:
case JSOp::ToAsyncIter:
case JSOp::ToId:
case JSOp::ToPropertyKey:
case JSOp::Typeof:
case JSOp::TypeofExpr:
case JSOp::ObjWithProto:

View File

@ -2114,8 +2114,8 @@ bool ExpressionDecompiler::decompilePC(jsbytecode* pc, uint8_t defIndex) {
case JSOp::SuperBase:
return write("HOMEOBJECTPROTO");
case JSOp::ToId:
return write("TOID(") && decompilePCForStackOperand(pc, -1) &&
case JSOp::ToPropertyKey:
return write("TOPROPERTYKEY(") && decompilePCForStackOperand(pc, -1) &&
write(")");
case JSOp::ToString:
return write("TOSTRING(") && decompilePCForStackOperand(pc, -1) &&

View File

@ -388,8 +388,9 @@ static MOZ_ALWAYS_INLINE bool DecOperation(JSContext* cx, HandleValue val,
return BigInt::decValue(cx, val, res);
}
static MOZ_ALWAYS_INLINE bool ToIdOperation(JSContext* cx, HandleValue idval,
MutableHandleValue res) {
static MOZ_ALWAYS_INLINE bool ToPropertyKeyOperation(JSContext* cx,
HandleValue idval,
MutableHandleValue res) {
if (idval.isInt32()) {
res.set(idval);
return true;

View File

@ -2910,19 +2910,14 @@ static MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_CALLER bool Interpret(JSContext* cx,
}
END_CASE(DelElem)
CASE(ToId) {
/*
* Increment or decrement requires use to lookup the same property twice,
* but we need to avoid the observable stringification the second time.
* There must be an object value below the id, which will not be popped.
*/
CASE(ToPropertyKey) {
ReservedRooted<Value> idval(&rootValue1, REGS.sp[-1]);
MutableHandleValue res = REGS.stackHandleAt(-1);
if (!ToIdOperation(cx, idval, res)) {
if (!ToPropertyKeyOperation(cx, idval, res)) {
goto error;
}
}
END_CASE(ToId)
END_CASE(ToPropertyKey)
CASE(TypeofExpr)
CASE(Typeof) {

View File

@ -705,7 +705,7 @@
* Operands:
* Stack: propertyNameValue => propertyKey
*/ \
MACRO(ToId, to_id, NULL, 1, 1, 1, JOF_BYTE) \
MACRO(ToPropertyKey, to_property_key, NULL, 1, 1, 1, JOF_BYTE) \
/*
* Convert a value to a numeric value (a Number or BigInt).
*