mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 01:35:35 +00:00
Bug 1626297 - Part 6: Check for string indices in MacroAssembler::convertValueToInt. r=jandem
Ion doesn't use ICs for bit-not `~` with String inputs, which resulted in `+int32AsString` being noticeably faster than `~~int32AsString`. Handling string indices makes `~~int32AsString` faster than the IC code, which is what we'd normally expect. Drive-by change: - Reuse `SimpleBitOpOperand()` for `bitnotTrySpecialized()`. Differential Revision: https://phabricator.services.mozilla.com/D69519 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
2d35373468
commit
1c9bdaae93
@ -3406,6 +3406,11 @@ AbortReasonOr<Ok> IonBuilder::visitTableSwitch() {
|
||||
|
||||
void IonBuilder::pushConstant(const Value& v) { current->push(constant(v)); }
|
||||
|
||||
static inline bool SimpleBitOpOperand(MDefinition* op) {
|
||||
return !op->mightBeType(MIRType::Object) &&
|
||||
!op->mightBeType(MIRType::Symbol) && !op->mightBeType(MIRType::BigInt);
|
||||
}
|
||||
|
||||
AbortReasonOr<Ok> IonBuilder::bitnotTrySpecialized(bool* emitted,
|
||||
MDefinition* input) {
|
||||
MOZ_ASSERT(*emitted == false);
|
||||
@ -3413,9 +3418,7 @@ AbortReasonOr<Ok> IonBuilder::bitnotTrySpecialized(bool* emitted,
|
||||
// Try to emit a specialized bitnot instruction based on the input type
|
||||
// of the operand.
|
||||
|
||||
if (input->mightBeType(MIRType::Object) ||
|
||||
input->mightBeType(MIRType::Symbol) ||
|
||||
input->mightBeType(MIRType::BigInt)) {
|
||||
if (!SimpleBitOpOperand(input)) {
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@ -3498,11 +3501,6 @@ AbortReasonOr<MBinaryBitwiseInstruction*> IonBuilder::binaryBitOpEmit(
|
||||
return ins;
|
||||
}
|
||||
|
||||
static inline bool SimpleBitOpOperand(MDefinition* op) {
|
||||
return !op->mightBeType(MIRType::Object) &&
|
||||
!op->mightBeType(MIRType::Symbol) && !op->mightBeType(MIRType::BigInt);
|
||||
}
|
||||
|
||||
AbortReasonOr<Ok> IonBuilder::binaryBitOpTrySpecialized(bool* emitted, JSOp op,
|
||||
MDefinition* left,
|
||||
MDefinition* right) {
|
||||
|
@ -2273,11 +2273,21 @@ void MacroAssembler::convertValueToInt(
|
||||
mov(ImmWord(0), output);
|
||||
jump(&done);
|
||||
|
||||
// Try converting a string into a double, then jump to the double case.
|
||||
// |output| needs to be different from |stringReg| to load string indices.
|
||||
bool handleStringIndices = handleStrings && output != stringReg;
|
||||
|
||||
// First try loading a string index. If that fails, try converting a string
|
||||
// into a double, then jump to the double case.
|
||||
Label handleStringIndex;
|
||||
if (handleStrings) {
|
||||
bind(&isString);
|
||||
unboxString(value, stringReg);
|
||||
jump(handleStringEntry);
|
||||
if (handleStringIndices) {
|
||||
loadStringIndexValue(stringReg, output, handleStringEntry);
|
||||
jump(&handleStringIndex);
|
||||
} else {
|
||||
jump(handleStringEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// Try converting double into integer.
|
||||
@ -2303,9 +2313,16 @@ void MacroAssembler::convertValueToInt(
|
||||
}
|
||||
|
||||
// Integers can be unboxed.
|
||||
if (isInt32.used()) {
|
||||
bind(&isInt32);
|
||||
unboxInt32(value, output);
|
||||
if (isInt32.used() || handleStringIndices) {
|
||||
if (isInt32.used()) {
|
||||
bind(&isInt32);
|
||||
unboxInt32(value, output);
|
||||
}
|
||||
|
||||
if (handleStringIndices) {
|
||||
bind(&handleStringIndex);
|
||||
}
|
||||
|
||||
if (behavior == IntConversionBehavior::ClampToUint8) {
|
||||
clampIntToUint8(output);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user