зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1833484 - Optimize bytecode emission for Infinity, NaN and undefined where possible. r=arai
This is possible because once we are looking at the global we know that these values aren't configurable and therefore have well known values. Differential Revision: https://phabricator.services.mozilla.com/D178243
This commit is contained in:
Родитель
ba1d4a0dfc
Коммит
f0828bc714
|
@ -463,6 +463,11 @@ static MOZ_ALWAYS_INLINE double GenericNaN() {
|
||||||
return mozilla::BitwiseCast<double>(detail::CanonicalizedNaNBits);
|
return mozilla::BitwiseCast<double>(detail::CanonicalizedNaNBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the infinity the engine uses
|
||||||
|
static MOZ_ALWAYS_INLINE double Infinity() {
|
||||||
|
return mozilla::BitwiseCast<double>(detail::InfinityBits);
|
||||||
|
}
|
||||||
|
|
||||||
// Convert an arbitrary double to one compatible with JS::Value representation
|
// Convert an arbitrary double to one compatible with JS::Value representation
|
||||||
// by replacing any NaN value with a canonical one.
|
// by replacing any NaN value with a canonical one.
|
||||||
static MOZ_ALWAYS_INLINE double CanonicalizeNaN(double d) {
|
static MOZ_ALWAYS_INLINE double CanonicalizeNaN(double d) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "frontend/SharedContext.h"
|
#include "frontend/SharedContext.h"
|
||||||
#include "frontend/TDZCheckCache.h"
|
#include "frontend/TDZCheckCache.h"
|
||||||
#include "frontend/ValueUsage.h"
|
#include "frontend/ValueUsage.h"
|
||||||
|
#include "js/Value.h"
|
||||||
#include "vm/Opcodes.h"
|
#include "vm/Opcodes.h"
|
||||||
|
|
||||||
using namespace js;
|
using namespace js;
|
||||||
|
@ -43,12 +44,28 @@ bool NameOpEmitter::emitGet() {
|
||||||
// [stack] VAL
|
// [stack] VAL
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Some names on the global are not configurable and have fixed values
|
||||||
|
// which we can emit instead.
|
||||||
|
if (name_ == TaggedParserAtomIndex::WellKnown::undefined()) {
|
||||||
|
if (!bce_->emit1(JSOp::Undefined)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (name_ == TaggedParserAtomIndex::WellKnown::NaN()) {
|
||||||
|
if (!bce_->emitDouble(JS::GenericNaN())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (name_ == TaggedParserAtomIndex::WellKnown::Infinity()) {
|
||||||
|
if (!bce_->emitDouble(JS::Infinity())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!bce_->emitAtomOp(JSOp::GetGName, name_)) {
|
if (!bce_->emitAtomOp(JSOp::GetGName, name_)) {
|
||||||
// [stack] VAL
|
// [stack] VAL
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NameLocation::Kind::Intrinsic:
|
case NameLocation::Kind::Intrinsic:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче