Bug 1530937 part 12 - Convert remaining inline callVMs in CodeGenerator.cpp. r=tcampbell

* Moves NewArrayWithGroup from CodeGenerator.cpp to builtin/Array.cpp

* GetProperty has various overloads so I added GetValueProperty. I considered
  *renaming* that GetProperty overload to GetValueProperty but there are quite
  a lot of callers in VM code where GetProperty is probably closer to the spec
  language.

* Ion called js::GetElement and js::CallElement which forwarded to GetElementOperation.
  This was changed to call GetElementOperation directly (eliminates a VM wrapper).

Depends on D22677

Differential Revision: https://phabricator.services.mozilla.com/D22678

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan de Mooij 2019-03-08 14:56:38 +00:00
Родитель 6f558829a7
Коммит 94d1ed4cac
6 изменённых файлов: 41 добавлений и 60 удалений

Просмотреть файл

@ -4325,6 +4325,19 @@ ArrayObject* js::NewCopiedArrayForCallingAllocationSite(
return NewCopiedArrayTryUseGroup(cx, group, vp, length);
}
ArrayObject* js::NewArrayWithGroup(JSContext* cx, uint32_t length,
HandleObjectGroup group,
bool convertDoubleElements) {
ArrayObject* res = NewFullyAllocatedArrayTryUseGroup(cx, group, length);
if (!res) {
return nullptr;
}
if (convertDoubleElements) {
res->setShouldConvertDoubleElements();
}
return res;
}
#ifdef DEBUG
bool js::ArrayInfo(JSContext* cx, unsigned argc, Value* vp) {
CallArgs args = CallArgsFromVp(argc, vp);

Просмотреть файл

@ -112,6 +112,10 @@ extern ArrayObject* NewCopiedArrayForCallingAllocationSite(
JSContext* cx, const Value* vp, size_t length,
HandleObject proto = nullptr);
extern ArrayObject* NewArrayWithGroup(JSContext* cx, uint32_t length,
HandleObjectGroup group,
bool convertDoubleElements);
extern bool GetLengthProperty(JSContext* cx, HandleObject obj,
uint32_t* lengthp);

Просмотреть файл

@ -6427,24 +6427,6 @@ class OutOfLineNewArray : public OutOfLineCodeBase<CodeGenerator> {
LNewArray* lir() const { return lir_; }
};
static JSObject* NewArrayWithGroup(JSContext* cx, uint32_t length,
HandleObjectGroup group,
bool convertDoubleElements) {
ArrayObject* res = NewFullyAllocatedArrayTryUseGroup(cx, group, length);
if (!res) {
return nullptr;
}
if (convertDoubleElements) {
res->setShouldConvertDoubleElements();
}
return res;
}
typedef JSObject* (*NewArrayWithGroupFn)(JSContext*, uint32_t,
HandleObjectGroup, bool);
static const VMFunction NewArrayWithGroupInfo =
FunctionInfo<NewArrayWithGroupFn>(NewArrayWithGroup, "NewArrayWithGroup");
void CodeGenerator::visitNewArrayCallVM(LNewArray* lir) {
Register objReg = ToRegister(lir->output());
@ -6458,7 +6440,8 @@ void CodeGenerator::visitNewArrayCallVM(LNewArray* lir) {
pushArg(ImmGCPtr(templateObject->group()));
pushArg(Imm32(lir->mir()->length()));
callVM(NewArrayWithGroupInfo, lir);
using Fn = ArrayObject* (*)(JSContext*, uint32_t, HandleObjectGroup, bool);
callVM<Fn, NewArrayWithGroup>(lir);
} else {
pushArg(Imm32(GenericObject));
pushArg(Imm32(lir->mir()->length()));
@ -11311,37 +11294,25 @@ void CodeGenerator::visitCallBindVar(LCallBindVar* lir) {
callVM<Fn, BindVarOperation>(lir);
}
typedef bool (*GetPropertyFn)(JSContext*, HandleValue, HandlePropertyName,
MutableHandleValue);
static const VMFunction GetPropertyInfo =
FunctionInfo<GetPropertyFn>(GetProperty, "GetProperty");
void CodeGenerator::visitCallGetProperty(LCallGetProperty* lir) {
pushArg(ImmGCPtr(lir->mir()->name()));
pushArg(ToValue(lir, LCallGetProperty::Value));
callVM(GetPropertyInfo, lir);
using Fn =
bool (*)(JSContext*, HandleValue, HandlePropertyName, MutableHandleValue);
callVM<Fn, GetValueProperty>(lir);
}
typedef bool (*GetOrCallElementFn)(JSContext*, MutableHandleValue, HandleValue,
MutableHandleValue);
static const VMFunction GetElementInfo =
FunctionInfo<GetOrCallElementFn>(js::GetElement, "GetElement");
static const VMFunction CallElementInfo =
FunctionInfo<GetOrCallElementFn>(js::CallElement, "CallElement");
void CodeGenerator::visitCallGetElement(LCallGetElement* lir) {
pushArg(ToValue(lir, LCallGetElement::RhsInput));
pushArg(ToValue(lir, LCallGetElement::LhsInput));
JSOp op = JSOp(*lir->mir()->resumePoint()->pc());
pushArg(Imm32(op));
if (op == JSOP_GETELEM) {
callVM(GetElementInfo, lir);
} else {
MOZ_ASSERT(op == JSOP_CALLELEM);
callVM(CallElementInfo, lir);
}
using Fn =
bool (*)(JSContext*, JSOp, HandleValue, HandleValue, MutableHandleValue);
callVM<Fn, GetElementOperation>(lir);
}
void CodeGenerator::visitCallSetElement(LCallSetElement* lir) {
@ -11635,11 +11606,6 @@ void CodeGenerator::visitHasOwnCache(LHasOwnCache* ins) {
addIC(ins, allocateIC(cache));
}
typedef bool (*SetPropertyFn)(JSContext*, HandleObject, HandlePropertyName,
const HandleValue, bool, jsbytecode*);
static const VMFunction SetPropertyInfo =
FunctionInfo<SetPropertyFn>(SetProperty, "SetProperty");
void CodeGenerator::visitCallSetProperty(LCallSetProperty* ins) {
ConstantOrRegister value =
TypedOrValueRegister(ToValue(ins, LCallSetProperty::Value));
@ -11653,7 +11619,9 @@ void CodeGenerator::visitCallSetProperty(LCallSetProperty* ins) {
pushArg(ImmGCPtr(ins->mir()->name()));
pushArg(objReg);
callVM(SetPropertyInfo, ins);
using Fn = bool (*)(JSContext*, HandleObject, HandlePropertyName,
const HandleValue, bool, jsbytecode*);
callVM<Fn, jit::SetProperty>(ins);
}
void CodeGenerator::visitCallDeleteProperty(LCallDeleteProperty* lir) {

Просмотреть файл

@ -83,10 +83,12 @@ namespace jit {
_(FreshenLexicalEnv, js::jit::FreshenLexicalEnv) \
_(FunWithProtoOperation, js::FunWithProtoOperation) \
_(GetAndClearException, js::GetAndClearException) \
_(GetElementOperation, js::GetElementOperation) \
_(GetImportOperation, js::GetImportOperation) \
_(GetIntrinsicValue, js::jit::GetIntrinsicValue) \
_(GetNonSyntacticGlobalThis, js::GetNonSyntacticGlobalThis) \
_(GetOrCreateModuleMetaObject, js::GetOrCreateModuleMetaObject) \
_(GetValueProperty, js::GetValueProperty) \
_(GlobalNameConflictsCheckFromIon, js::jit::GlobalNameConflictsCheckFromIon) \
_(GreaterThan, js::jit::GreaterThan) \
_(GreaterThanOrEqual, js::jit::GreaterThanOrEqual) \
@ -131,6 +133,7 @@ namespace jit {
_(NewArgumentsObject, js::jit::NewArgumentsObject) \
_(NewArrayCopyOnWriteOperation, js::NewArrayCopyOnWriteOperation) \
_(NewArrayOperation, js::NewArrayOperation) \
_(NewArrayWithGroup, js::NewArrayWithGroup) \
_(NewDenseCopyOnWriteArray, js::NewDenseCopyOnWriteArray) \
_(NewObjectOperation, js::NewObjectOperation) \
_(NewObjectOperationWithTemplate, js::NewObjectOperationWithTemplate) \
@ -158,6 +161,7 @@ namespace jit {
_(SetFunctionName, js::SetFunctionName) \
_(SetIntrinsicOperation, js::SetIntrinsicOperation) \
_(SetObjectElementWithReceiver, js::SetObjectElementWithReceiver) \
_(SetProperty, js::jit::SetProperty) \
_(SetPropertySuper, js::SetPropertySuper) \
_(SingletonObjectLiteralOperation, js::SingletonObjectLiteralOperation) \
_(StartDynamicModuleImport, js::StartDynamicModuleImport) \

Просмотреть файл

@ -4469,6 +4469,11 @@ bool js::GetProperty(JSContext* cx, HandleValue v, HandlePropertyName name,
return GetProperty(cx, obj, receiver, name, vp);
}
bool js::GetValueProperty(JSContext* cx, HandleValue value,
HandlePropertyName name, MutableHandleValue vp) {
return GetProperty(cx, value, name, vp);
}
JSObject* js::Lambda(JSContext* cx, HandleFunction fun, HandleObject parent) {
MOZ_ASSERT(!fun->isArrow());
@ -4784,16 +4789,6 @@ template bool js::DeleteElementJit<true>(JSContext*, HandleValue, HandleValue,
template bool js::DeleteElementJit<false>(JSContext*, HandleValue, HandleValue,
bool* succeeded);
bool js::GetElement(JSContext* cx, MutableHandleValue lref, HandleValue rref,
MutableHandleValue vp) {
return GetElementOperation(cx, JSOP_GETELEM, lref, rref, vp);
}
bool js::CallElement(JSContext* cx, MutableHandleValue lref, HandleValue rref,
MutableHandleValue res) {
return GetElementOperation(cx, JSOP_CALLELEM, lref, rref, res);
}
bool js::SetObjectElement(JSContext* cx, HandleObject obj, HandleValue index,
HandleValue value, bool strict) {
RootedId id(cx);

Просмотреть файл

@ -430,17 +430,14 @@ bool ThrowOperation(JSContext* cx, HandleValue v);
bool GetProperty(JSContext* cx, HandleValue value, HandlePropertyName name,
MutableHandleValue vp);
bool GetValueProperty(JSContext* cx, HandleValue value, HandlePropertyName name,
MutableHandleValue vp);
JSObject* Lambda(JSContext* cx, HandleFunction fun, HandleObject parent);
JSObject* LambdaArrow(JSContext* cx, HandleFunction fun, HandleObject parent,
HandleValue newTargetv);
bool GetElement(JSContext* cx, MutableHandleValue lref, HandleValue rref,
MutableHandleValue res);
bool CallElement(JSContext* cx, MutableHandleValue lref, HandleValue rref,
MutableHandleValue res);
bool SetObjectElement(JSContext* cx, HandleObject obj, HandleValue index,
HandleValue value, bool strict);
bool SetObjectElement(JSContext* cx, HandleObject obj, HandleValue index,