Bug 1618198 part 18 - Implement assorted JSOps. r=iain

Differential Revision: https://phabricator.services.mozilla.com/D67124
This commit is contained in:
Jan de Mooij committed 2020-03-18 16:28:13 +00:00
1 parent 8a3c00f099
commit 1173378479
5 files changed
+268 -1

No files matched your search

+3
View File
@@ -11222,6 +11222,9 @@ static GetPropertyResultFlags IonGetPropertyICFlags(
GetPropertyResultFlags::AllowDouble;
}
// If WarpBuilder is enabled the IC should support all possible results.
MOZ_ASSERT_IF(JitOptions.warpBuilder, flags == GetPropertyResultFlags::All);
return flags;
}
+218 -1
View File
@@ -389,7 +389,6 @@ bool WarpBuilder::build_Lineno(BytecodeLocation) { return true; }
bool WarpBuilder::build_DebugLeaveLexicalEnv(BytecodeLocation) { return true; }
bool WarpBuilder::build_Undefined(BytecodeLocation) {
// If this ever changes, change what JSOp::GImplicitThis does too.
pushConstant(UndefinedValue());
return true;
}
@@ -1543,3 +1542,221 @@ bool WarpBuilder::build_BindGName(BytecodeLocation loc) {
return buildBindNameOp(loc, globalLexicalEnvConstant());
}
bool WarpBuilder::buildGetPropOp(BytecodeLocation loc, MDefinition* val,
MDefinition* id) {
// For now pass monitoredResult = true to get the behavior we want (no
// TI-related restrictions apply, similar to the Baseline IC).
// See also IonGetPropertyICFlags.
bool monitoredResult = true;
auto* ins = MGetPropertyCache::New(alloc(), val, id, monitoredResult);
current->add(ins);
current->push(ins);
return resumeAfter(ins, loc);
}
bool WarpBuilder::build_GetProp(BytecodeLocation loc) {
PropertyName* name = loc.getPropertyName(script_);
MDefinition* val = current->pop();
MConstant* id = constant(StringValue(name));
return buildGetPropOp(loc, val, id);
}
bool WarpBuilder::build_CallProp(BytecodeLocation loc) {
return build_GetProp(loc);
}
bool WarpBuilder::build_Length(BytecodeLocation loc) {
return build_GetProp(loc);
}
bool WarpBuilder::build_GetElem(BytecodeLocation loc) {
MDefinition* id = current->pop();
MDefinition* val = current->pop();
return buildGetPropOp(loc, val, id);
}
bool WarpBuilder::build_CallElem(BytecodeLocation loc) {
return build_GetElem(loc);
}
bool WarpBuilder::buildSetPropOp(BytecodeLocation loc, MDefinition* obj,
MDefinition* id, MDefinition* val) {
// We need a GC post barrier and we don't know whether the prototype has
// indexed properties so we need to check for holes. We don't need a TI
// barrier.
bool strict = loc.isStrictSetOp();
bool needsPostBarrier = true;
bool needsTypeBarrier = false;
bool guardHoles = true;
auto* ins =
MSetPropertyCache::New(alloc(), obj, id, val, strict, needsPostBarrier,
needsTypeBarrier, guardHoles);
current->add(ins);
current->push(val);
return resumeAfter(ins, loc);
}
bool WarpBuilder::build_SetProp(BytecodeLocation loc) {
PropertyName* name = loc.getPropertyName(script_);
MDefinition* val = current->pop();
MDefinition* obj = current->pop();
MConstant* id = constant(StringValue(name));
return buildSetPropOp(loc, obj, id, val);
}
bool WarpBuilder::build_StrictSetProp(BytecodeLocation loc) {
return build_SetProp(loc);
}
bool WarpBuilder::build_SetName(BytecodeLocation loc) {
return build_SetProp(loc);
}
bool WarpBuilder::build_StrictSetName(BytecodeLocation loc) {
return build_SetProp(loc);
}
bool WarpBuilder::build_SetElem(BytecodeLocation loc) {
MDefinition* val = current->pop();
MDefinition* id = current->pop();
MDefinition* obj = current->pop();
return buildSetPropOp(loc, obj, id, val);
}
bool WarpBuilder::build_StrictSetElem(BytecodeLocation loc) {
return build_SetElem(loc);
}
bool WarpBuilder::build_DelProp(BytecodeLocation loc) {
PropertyName* name = loc.getPropertyName(script_);
MDefinition* obj = current->pop();
bool strict = loc.getOp() == JSOp::StrictDelProp;
MInstruction* ins = MDeleteProperty::New(alloc(), obj, name, strict);
current->add(ins);
current->push(ins);
return resumeAfter(ins, loc);
}
bool WarpBuilder::build_StrictDelProp(BytecodeLocation loc) {
return build_DelProp(loc);
}
bool WarpBuilder::build_DelElem(BytecodeLocation loc) {
MDefinition* id = current->pop();
MDefinition* obj = current->pop();
bool strict = loc.getOp() == JSOp::StrictDelElem;
MInstruction* ins = MDeleteElement::New(alloc(), obj, id, strict);
current->add(ins);
current->push(ins);
return resumeAfter(ins, loc);
}
bool WarpBuilder::build_StrictDelElem(BytecodeLocation loc) {
return build_DelElem(loc);
}
bool WarpBuilder::build_SetFunName(BytecodeLocation loc) {
FunctionPrefixKind prefixKind = loc.getFunctionPrefixKind();
MDefinition* name = current->pop();
MDefinition* fun = current->pop();
MSetFunName* ins = MSetFunName::New(alloc(), fun, name, uint8_t(prefixKind));
current->add(ins);
current->push(fun);
return resumeAfter(ins, loc);
}
bool WarpBuilder::build_PushLexicalEnv(BytecodeLocation loc) {
MOZ_ASSERT(usesEnvironmentChain());
LexicalScope* scope = &loc.getScope(script_)->as<LexicalScope>();
MDefinition* env = current->environmentChain();
auto* ins = MNewLexicalEnvironmentObject::New(alloc(), env, scope);
current->add(ins);
current->setEnvironmentChain(ins);
return true;
}
bool WarpBuilder::build_PopLexicalEnv(BytecodeLocation) {
MDefinition* enclosingEnv = walkEnvironmentChain(1);
current->setEnvironmentChain(enclosingEnv);
return true;
}
void WarpBuilder::buildCopyLexicalEnvOp(bool copySlots) {
MOZ_ASSERT(usesEnvironmentChain());
MDefinition* env = current->environmentChain();
auto* ins = MCopyLexicalEnvironmentObject::New(alloc(), env, copySlots);
current->add(ins);
current->setEnvironmentChain(ins);
}
bool WarpBuilder::build_FreshenLexicalEnv(BytecodeLocation) {
buildCopyLexicalEnvOp(/* copySlots = */ true);
return true;
}
bool WarpBuilder::build_RecreateLexicalEnv(BytecodeLocation) {
buildCopyLexicalEnvOp(/* copySlots = */ false);
return true;
}
bool WarpBuilder::build_ImplicitThis(BytecodeLocation loc) {
MOZ_ASSERT(usesEnvironmentChain());
PropertyName* name = loc.getPropertyName(script_);
MDefinition* env = current->environmentChain();
auto* ins = MImplicitThis::New(alloc(), env, name);
current->add(ins);
current->push(ins);
return resumeAfter(ins, loc);
}
bool WarpBuilder::build_GImplicitThis(BytecodeLocation loc) {
if (script_->hasNonSyntacticScope()) {
return build_ImplicitThis(loc);
}
return build_Undefined(loc);
}
bool WarpBuilder::build_CheckClassHeritage(BytecodeLocation loc) {
MDefinition* def = current->pop();
auto* ins = MCheckClassHeritage::New(alloc(), def);
current->add(ins);
current->push(ins);
return resumeAfter(ins, loc);
}
bool WarpBuilder::build_CheckThis(BytecodeLocation) {
MDefinition* def = current->pop();
auto* ins = MCheckThis::New(alloc(), def);
current->add(ins);
current->push(ins);
return true;
}
bool WarpBuilder::build_CheckThisReinit(BytecodeLocation) {
MDefinition* def = current->pop();
auto* ins = MCheckThisReinit::New(alloc(), def);
current->add(ins);
current->push(ins);
return true;
}
bool WarpBuilder::build_CheckReturn(BytecodeLocation) {
MOZ_ASSERT(!script_->noScriptRval());
MDefinition* returnValue = current->getSlot(info().returnValueSlot());
MDefinition* thisValue = current->pop();
auto* ins = MCheckReturn::New(alloc(), returnValue, thisValue);
current->add(ins);
current->setSlot(info().returnValueSlot(), ins);
return true;
}
+32
View File
@@ -129,6 +129,32 @@ namespace jit {
_(GetGName) \
_(BindName) \
_(BindGName) \
_(GetProp) \
_(CallProp) \
_(Length) \
_(GetElem) \
_(CallElem) \
_(SetProp) \
_(StrictSetProp) \
_(SetName) \
_(StrictSetName) \
_(SetElem) \
_(StrictSetElem) \
_(DelProp) \
_(StrictDelProp) \
_(DelElem) \
_(StrictDelElem) \
_(SetFunName) \
_(PushLexicalEnv) \
_(PopLexicalEnv) \
_(FreshenLexicalEnv) \
_(RecreateLexicalEnv) \
_(ImplicitThis) \
_(GImplicitThis) \
_(CheckClassHeritage) \
_(CheckThis) \
_(CheckThisReinit) \
_(CheckReturn) \
_(SetRval) \
_(Return) \
_(RetRval)
@@ -218,6 +244,12 @@ class MOZ_STACK_CLASS WarpBuilder {
MOZ_MUST_USE bool buildGetNameOp(BytecodeLocation loc, MDefinition* env);
MOZ_MUST_USE bool buildBindNameOp(BytecodeLocation loc, MDefinition* env);
MOZ_MUST_USE bool buildGetPropOp(BytecodeLocation loc, MDefinition* val,
MDefinition* id);
MOZ_MUST_USE bool buildSetPropOp(BytecodeLocation loc, MDefinition* obj,
MDefinition* id, MDefinition* val);
void buildCopyLexicalEnvOp(bool copySlots);
bool usesEnvironmentChain() const;
MDefinition* walkEnvironmentChain(uint32_t numHops);
+5
View File
@@ -56,6 +56,11 @@ inline js::RegExpObject* BytecodeLocation::getRegExp(
return script->getRegExp(this->rawBytecode_);
}
inline js::Scope* BytecodeLocation::getScope(const JSScript* script) const {
MOZ_ASSERT(this->isValid());
return script->getScope(this->rawBytecode_);
}
inline Scope* BytecodeLocation::innermostScope(const JSScript* script) const {
MOZ_ASSERT(this->isValid());
return script->innermostScope(this->rawBytecode_);
+10
View File
@@ -12,6 +12,8 @@
#include "vm/BytecodeUtil.h"
#include "vm/StringType.h"
enum class FunctionPrefixKind;
namespace js {
using RawBytecodeLocationOffset = uint32_t;
@@ -95,6 +97,7 @@ class BytecodeLocation {
inline PropertyName* getPropertyName(const JSScript* script) const;
inline JS::BigInt* getBigInt(const JSScript* script) const;
inline js::RegExpObject* getRegExp(const JSScript* script) const;
inline js::Scope* getScope(const JSScript* script) const;
uint32_t getSymbolIndex() const {
MOZ_ASSERT(is(JSOp::Symbol));
@@ -182,6 +185,8 @@ class BytecodeLocation {
bool isStrictEqualityOp() const { return IsStrictEqualityOp(getOp()); }
bool isStrictSetOp() const { return IsStrictSetPC(rawBytecode_); }
bool isNameOp() const { return IsNameOp(getOp()); }
// Accessors:
@@ -240,6 +245,11 @@ class BytecodeLocation {
return GET_ARGC(rawBytecode_);
}
FunctionPrefixKind getFunctionPrefixKind() const {
MOZ_ASSERT(is(JSOp::SetFunName));
return FunctionPrefixKind(GET_UINT8(rawBytecode_));
}
int8_t getInt8() const {
MOZ_ASSERT(is(JSOp::Int8));
return GET_INT8(rawBytecode_);