From 2267287530c40836f10c9c8ba0c80e840d968e78 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Thu, 7 Mar 2019 17:49:04 +0000 Subject: [PATCH] Bug 1530937 part 10 - Convert more callVMs in CodeGenerator.cpp. r=nbp Differential Revision: https://phabricator.services.mozilla.com/D22523 --HG-- extra : moz-landing-system : lando --- js/src/builtin/String.cpp | 2 +- js/src/builtin/String.h | 2 +- js/src/jit/BaselineFrame-inl.h | 2 +- js/src/jit/CodeGenerator.cpp | 264 +++++++++++--------------------- js/src/jit/Recover.cpp | 4 +- js/src/jit/VMFunctionList-inl.h | 29 ++++ js/src/jit/VMFunctions.h | 5 + js/src/vm/EnvironmentObject.cpp | 2 +- js/src/vm/EnvironmentObject.h | 6 +- js/src/vm/Stack.cpp | 2 +- js/src/vm/TypedArrayObject.cpp | 18 +-- js/src/vm/TypedArrayObject.h | 18 +-- 12 files changed, 146 insertions(+), 208 deletions(-) diff --git a/js/src/builtin/String.cpp b/js/src/builtin/String.cpp index 10f538ef4ad7..3ecea79685e5 100644 --- a/js/src/builtin/String.cpp +++ b/js/src/builtin/String.cpp @@ -2910,7 +2910,7 @@ static bool StrFlatReplaceGlobal(JSContext* cx, JSLinearString* str, // This is identical to "str.split(pattern).join(replacement)" except that we // do some deforestation optimization in Ion. -JSString* js::str_flat_replace_string(JSContext* cx, HandleString string, +JSString* js::StringFlatReplaceString(JSContext* cx, HandleString string, HandleString pattern, HandleString replacement) { MOZ_ASSERT(string); diff --git a/js/src/builtin/String.h b/js/src/builtin/String.h index 821e55302911..a2a1531126b2 100644 --- a/js/src/builtin/String.h +++ b/js/src/builtin/String.h @@ -141,7 +141,7 @@ ArrayObject* str_split_string(JSContext* cx, HandleObjectGroup group, HandleString str, HandleString sep, uint32_t limit); -JSString* str_flat_replace_string(JSContext* cx, HandleString string, +JSString* StringFlatReplaceString(JSContext* cx, HandleString string, HandleString pattern, HandleString replacement); diff --git a/js/src/jit/BaselineFrame-inl.h b/js/src/jit/BaselineFrame-inl.h index 883a5ede8f0d..50fd60f54529 100644 --- a/js/src/jit/BaselineFrame-inl.h +++ b/js/src/jit/BaselineFrame-inl.h @@ -43,7 +43,7 @@ inline void BaselineFrame::replaceInnermostEnvironment(EnvironmentObject& env) { inline bool BaselineFrame::pushLexicalEnvironment(JSContext* cx, Handle scope) { LexicalEnvironmentObject* env = - LexicalEnvironmentObject::create(cx, scope, this); + LexicalEnvironmentObject::createForFrame(cx, scope, this); if (!env) { return false; } diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index fcf3f6f52879..bf3f7316f5ca 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -2749,13 +2749,6 @@ class OutOfLineRegExpMatcher : public OutOfLineCodeBase { LRegExpMatcher* lir() const { return lir_; } }; -typedef bool (*RegExpMatcherRawFn)(JSContext* cx, HandleObject regexp, - HandleString input, int32_t lastIndex, - MatchPairs* pairs, - MutableHandleValue output); -static const VMFunction RegExpMatcherRawInfo = - FunctionInfo(RegExpMatcherRaw, "RegExpMatcherRaw"); - void CodeGenerator::visitOutOfLineRegExpMatcher(OutOfLineRegExpMatcher* ool) { LRegExpMatcher* lir = ool->lir(); Register lastIndex = ToRegister(lir->lastIndex()); @@ -2778,7 +2771,10 @@ void CodeGenerator::visitOutOfLineRegExpMatcher(OutOfLineRegExpMatcher* ool) { // We are not using oolCallVM because we are in a Call, and that live // registers are already saved by the the register allocator. - callVM(RegExpMatcherRawInfo, lir); + using Fn = bool (*)(JSContext * cx, HandleObject regexp, HandleString input, + int32_t lastIndex, MatchPairs * pairs, + MutableHandleValue output); + callVM(lir); masm.jump(ool->rejoin()); } @@ -2934,12 +2930,6 @@ class OutOfLineRegExpSearcher : public OutOfLineCodeBase { LRegExpSearcher* lir() const { return lir_; } }; -typedef bool (*RegExpSearcherRawFn)(JSContext* cx, HandleObject regexp, - HandleString input, int32_t lastIndex, - MatchPairs* pairs, int32_t* result); -static const VMFunction RegExpSearcherRawInfo = - FunctionInfo(RegExpSearcherRaw, "RegExpSearcherRaw"); - void CodeGenerator::visitOutOfLineRegExpSearcher(OutOfLineRegExpSearcher* ool) { LRegExpSearcher* lir = ool->lir(); Register lastIndex = ToRegister(lir->lastIndex()); @@ -2962,7 +2952,9 @@ void CodeGenerator::visitOutOfLineRegExpSearcher(OutOfLineRegExpSearcher* ool) { // We are not using oolCallVM because we are in a Call, and that live // registers are already saved by the the register allocator. - callVM(RegExpSearcherRawInfo, lir); + using Fn = bool (*)(JSContext * cx, HandleObject regexp, HandleString input, + int32_t lastIndex, MatchPairs * pairs, int32_t * result); + callVM(lir); masm.jump(ool->rejoin()); } @@ -3076,12 +3068,6 @@ class OutOfLineRegExpTester : public OutOfLineCodeBase { LRegExpTester* lir() const { return lir_; } }; -typedef bool (*RegExpTesterRawFn)(JSContext* cx, HandleObject regexp, - HandleString input, int32_t lastIndex, - int32_t* result); -static const VMFunction RegExpTesterRawInfo = - FunctionInfo(RegExpTesterRaw, "RegExpTesterRaw"); - void CodeGenerator::visitOutOfLineRegExpTester(OutOfLineRegExpTester* ool) { LRegExpTester* lir = ool->lir(); Register lastIndex = ToRegister(lir->lastIndex()); @@ -3094,7 +3080,9 @@ void CodeGenerator::visitOutOfLineRegExpTester(OutOfLineRegExpTester* ool) { // We are not using oolCallVM because we are in a Call, and that live // registers are already saved by the the register allocator. - callVM(RegExpTesterRawInfo, lir); + using Fn = bool (*)(JSContext * cx, HandleObject regexp, HandleString input, + int32_t lastIndex, int32_t * result); + callVM(lir); masm.jump(ool->rejoin()); } @@ -3302,13 +3290,6 @@ void CodeGenerator::visitGetFirstDollarIndex(LGetFirstDollarIndex* ins) { masm.bind(ool->rejoin()); } -typedef JSString* (*StringReplaceFn)(JSContext*, HandleString, HandleString, - HandleString); -static const VMFunction StringFlatReplaceInfo = FunctionInfo( - js::str_flat_replace_string, "str_flat_replace_string"); -static const VMFunction StringReplaceInfo = - FunctionInfo(StringReplace, "StringReplace"); - void CodeGenerator::visitStringReplace(LStringReplace* lir) { if (lir->replacement()->isConstant()) { pushArg(ImmGCPtr(lir->replacement()->toConstant()->toString())); @@ -3328,10 +3309,12 @@ void CodeGenerator::visitStringReplace(LStringReplace* lir) { pushArg(ToRegister(lir->string())); } + using Fn = + JSString* (*)(JSContext*, HandleString, HandleString, HandleString); if (lir->mir()->isFlatReplacement()) { - callVM(StringFlatReplaceInfo, lir); + callVM(lir); } else { - callVM(StringReplaceInfo, lir); + callVM(lir); } } @@ -3480,11 +3463,6 @@ class OutOfLineLambdaArrow : public OutOfLineCodeBase { Label* entryNoPop() { return &entryNoPop_; } }; -typedef JSObject* (*LambdaArrowFn)(JSContext*, HandleFunction, HandleObject, - HandleValue); -static const VMFunction LambdaArrowInfo = - FunctionInfo(js::LambdaArrow, "LambdaArrow"); - void CodeGenerator::visitOutOfLineLambdaArrow(OutOfLineLambdaArrow* ool) { Register envChain = ToRegister(ool->lir->environmentChain()); ValueOperand newTarget = ToValue(ool->lir, LLambdaArrow::NewTargetValue); @@ -3503,7 +3481,9 @@ void CodeGenerator::visitOutOfLineLambdaArrow(OutOfLineLambdaArrow* ool) { pushArg(envChain); pushArg(ImmGCPtr(info.funUnsafe())); - callVM(LambdaArrowInfo, ool->lir); + using Fn = + JSObject* (*)(JSContext*, HandleFunction, HandleObject, HandleValue); + callVM(ool->lir); StoreRegisterTo(output).generate(this); restoreLiveIgnore(ool->lir, StoreRegisterTo(output).clobbered()); @@ -3684,16 +3664,12 @@ void CodeGenerator::visitTableSwitchV(LTableSwitchV* ins) { emitTableSwitchDispatch(mir, index, ToRegisterOrInvalid(ins->tempPointer())); } -typedef JSObject* (*DeepCloneObjectLiteralFn)(JSContext*, HandleObject, - NewObjectKind); -static const VMFunction DeepCloneObjectLiteralInfo = - FunctionInfo(DeepCloneObjectLiteral, - "DeepCloneObjectLiteral"); - void CodeGenerator::visitCloneLiteral(LCloneLiteral* lir) { pushArg(ImmWord(TenuredObject)); pushArg(ToRegister(lir->getObjectLiteral())); - callVM(DeepCloneObjectLiteralInfo, lir); + + using Fn = JSObject* (*)(JSContext*, HandleObject, NewObjectKind); + callVM(lir); } void CodeGenerator::visitParameter(LParameter* lir) {} @@ -4301,32 +4277,24 @@ void CodeGenerator::visitHomeObjectSuperBase(LHomeObjectSuperBase* lir) { masm.bind(ool->rejoin()); } -typedef LexicalEnvironmentObject* (*NewLexicalEnvironmentObjectFn)( - JSContext*, Handle, HandleObject, gc::InitialHeap); -static const VMFunction NewLexicalEnvironmentObjectInfo = - FunctionInfo( - LexicalEnvironmentObject::create, "LexicalEnvironmentObject::create"); - void CodeGenerator::visitNewLexicalEnvironmentObject( LNewLexicalEnvironmentObject* lir) { pushArg(Imm32(gc::DefaultHeap)); pushArg(ToRegister(lir->enclosing())); pushArg(ImmGCPtr(lir->mir()->scope())); - callVM(NewLexicalEnvironmentObjectInfo, lir); -} -typedef JSObject* (*CopyLexicalEnvironmentObjectFn)(JSContext*, HandleObject, - bool); -static const VMFunction CopyLexicalEnvironmentObjectInfo = - FunctionInfo( - js::jit::CopyLexicalEnvironmentObject, - "js::jit::CopyLexicalEnvironmentObject"); + using Fn = LexicalEnvironmentObject* (*)(JSContext*, Handle, + HandleObject, gc::InitialHeap); + callVM(lir); +} void CodeGenerator::visitCopyLexicalEnvironmentObject( LCopyLexicalEnvironmentObject* lir) { pushArg(Imm32(lir->mir()->copySlots())); pushArg(ToRegister(lir->env())); - callVM(CopyLexicalEnvironmentObjectInfo, lir); + + using Fn = JSObject* (*)(JSContext*, HandleObject, bool); + callVM(lir); } void CodeGenerator::visitGuardShape(LGuardShape* guard) { @@ -5054,20 +5022,12 @@ void CodeGenerator::visitCallDOMNative(LCallDOMNative* call) { MOZ_ASSERT(masm.framePushed() == initialStack); } -typedef bool (*GetIntrinsicValueFn)(JSContext* cx, HandlePropertyName, - MutableHandleValue); -static const VMFunction GetIntrinsicValueInfo = - FunctionInfo(GetIntrinsicValue, "GetIntrinsicValue"); - void CodeGenerator::visitCallGetIntrinsicValue(LCallGetIntrinsicValue* lir) { pushArg(ImmGCPtr(lir->mir()->name())); - callVM(GetIntrinsicValueInfo, lir); -} -typedef bool (*InvokeFunctionFn)(JSContext*, HandleObject, bool, bool, uint32_t, - Value*, MutableHandleValue); -static const VMFunction InvokeFunctionInfo = - FunctionInfo(InvokeFunction, "InvokeFunction"); + using Fn = bool (*)(JSContext * cx, HandlePropertyName, MutableHandleValue); + callVM(lir); +} void CodeGenerator::emitCallInvokeFunction( LInstruction* call, Register calleereg, bool constructing, @@ -5082,7 +5042,9 @@ void CodeGenerator::emitCallInvokeFunction( pushArg(Imm32(constructing)); // constructing. pushArg(calleereg); // JSFunction*. - callVM(InvokeFunctionInfo, call); + using Fn = bool (*)(JSContext*, HandleObject, bool, bool, uint32_t, Value*, + MutableHandleValue); + callVM(call); // Un-nestle %esp from the argument vector. No prefix was pushed. masm.reserveStack(unusedStack); @@ -5196,11 +5158,6 @@ void CodeGenerator::visitCallGeneric(LCallGeneric* call) { } } -typedef bool (*InvokeFunctionShuffleFn)(JSContext*, HandleObject, uint32_t, - uint32_t, Value*, MutableHandleValue); -static const VMFunction InvokeFunctionShuffleInfo = - FunctionInfo(InvokeFunctionShuffleNewTarget, - "InvokeFunctionShuffleNewTarget"); void CodeGenerator::emitCallInvokeFunctionShuffleNewTarget( LCallKnown* call, Register calleeReg, uint32_t numFormals, uint32_t unusedStack) { @@ -5211,7 +5168,9 @@ void CodeGenerator::emitCallInvokeFunctionShuffleNewTarget( pushArg(Imm32(call->numActualArgs())); pushArg(calleeReg); - callVM(InvokeFunctionShuffleInfo, call); + using Fn = bool (*)(JSContext*, HandleObject, uint32_t, uint32_t, Value*, + MutableHandleValue); + callVM(call); masm.reserveStack(unusedStack); } @@ -5331,7 +5290,9 @@ void CodeGenerator::emitCallInvokeFunction(T* apply, Register extraStackSize) { pushArg(ToRegister(apply->getFunction())); // JSFunction*. // This specialization og callVM restore the extraStackSize after the call. - callVM(InvokeFunctionInfo, apply, &extraStackSize); + using Fn = bool (*)(JSContext*, HandleObject, bool, bool, uint32_t, Value*, + MutableHandleValue); + callVM(apply, &extraStackSize); masm.Pop(extraStackSize); } @@ -5733,12 +5694,6 @@ void CodeGenerator::visitGetDynamicName(LGetDynamicName* lir) { bailoutIfFalseBool(ReturnReg, lir->snapshot()); } -typedef bool (*DirectEvalSFn)(JSContext*, HandleObject, HandleScript, - HandleValue, HandleString, jsbytecode*, - MutableHandleValue); -static const VMFunction DirectEvalStringInfo = FunctionInfo( - DirectEvalStringFromIon, "DirectEvalStringFromIon"); - void CodeGenerator::visitCallDirectEval(LCallDirectEval* lir) { Register envChain = ToRegister(lir->getEnvironmentChain()); Register string = ToRegister(lir->getString()); @@ -5749,7 +5704,9 @@ void CodeGenerator::visitCallDirectEval(LCallDirectEval* lir) { pushArg(ImmGCPtr(current->mir()->info().script())); pushArg(envChain); - callVM(DirectEvalStringInfo, lir); + using Fn = bool (*)(JSContext*, HandleObject, HandleScript, HandleValue, + HandleString, jsbytecode*, MutableHandleValue); + callVM(lir); } void CodeGenerator::generateArgumentsChecks(bool assert) { @@ -5913,10 +5870,6 @@ void CodeGenerator::visitDefFun(LDefFun* lir) { callVM(lir); } -typedef bool (*CheckOverRecursedFn)(JSContext*); -static const VMFunction CheckOverRecursedInfo = - FunctionInfo(CheckOverRecursed, "CheckOverRecursed"); - void CodeGenerator::visitCheckOverRecursedFailure( CheckOverRecursedFailure* ool) { // The OOL path is hit if the recursion depth has been exceeded. @@ -5927,7 +5880,8 @@ void CodeGenerator::visitCheckOverRecursedFailure( // a GC. saveLive(ool->lir()); - callVM(CheckOverRecursedInfo, ool->lir()); + using Fn = bool (*)(JSContext*); + callVM(ool->lir()); restoreLive(ool->lir()); masm.jump(ool->rejoin()); @@ -6473,11 +6427,6 @@ class OutOfLineNewArray : public OutOfLineCodeBase { LNewArray* lir() const { return lir_; } }; -typedef JSObject* (*NewArrayOperationFn)(JSContext*, HandleScript, jsbytecode*, - uint32_t, NewObjectKind); -static const VMFunction NewArrayOperationInfo = - FunctionInfo(NewArrayOperation, "NewArrayOperation"); - static JSObject* NewArrayWithGroup(JSContext* cx, uint32_t length, HandleObjectGroup group, bool convertDoubleElements) { @@ -6516,7 +6465,9 @@ void CodeGenerator::visitNewArrayCallVM(LNewArray* lir) { pushArg(ImmPtr(lir->mir()->pc())); pushArg(ImmGCPtr(lir->mir()->block()->info().script())); - callVM(NewArrayOperationInfo, lir); + using Fn = JSObject* (*)(JSContext*, HandleScript, jsbytecode*, uint32_t, + NewObjectKind); + callVM(lir); } if (ReturnReg != objReg) { @@ -6526,18 +6477,14 @@ void CodeGenerator::visitNewArrayCallVM(LNewArray* lir) { restoreLive(lir); } -typedef JSObject* (*NewDerivedTypedObjectFn)(JSContext*, HandleObject type, - HandleObject owner, - int32_t offset); -static const VMFunction CreateDerivedTypedObjInfo = - FunctionInfo(CreateDerivedTypedObj, - "CreateDerivedTypedObj"); - void CodeGenerator::visitNewDerivedTypedObject(LNewDerivedTypedObject* lir) { pushArg(ToRegister(lir->offset())); pushArg(ToRegister(lir->owner())); pushArg(ToRegister(lir->type())); - callVM(CreateDerivedTypedObjInfo, lir); + + using Fn = JSObject* (*)(JSContext*, HandleObject type, HandleObject owner, + int32_t offset); + callVM(lir); } void CodeGenerator::visitAtan2D(LAtan2D* lir) { @@ -6736,8 +6683,9 @@ typedef TypedArrayObject* (*TypedArrayConstructorOneArgFn)(JSContext*, HandleObject, int32_t length); static const VMFunction TypedArrayConstructorOneArgInfo = - FunctionInfo(TypedArrayCreateWithTemplate, - "TypedArrayCreateWithTemplate"); + FunctionInfo( + NewTypedArrayWithTemplateAndLength, + "NewTypedArrayWithTemplateAndLength"); void CodeGenerator::visitNewTypedArray(LNewTypedArray* lir) { Register objReg = ToRegister(lir->output()); @@ -6790,24 +6738,13 @@ void CodeGenerator::visitNewTypedArrayDynamicLength( masm.bind(ool->rejoin()); } -typedef TypedArrayObject* (*TypedArrayCreateWithTemplateFn)(JSContext*, - HandleObject, - HandleObject); -static const VMFunction TypedArrayCreateWithTemplateInfo = - FunctionInfo( - js::TypedArrayCreateWithTemplate, "TypedArrayCreateWithTemplate"); - void CodeGenerator::visitNewTypedArrayFromArray(LNewTypedArrayFromArray* lir) { pushArg(ToRegister(lir->array())); pushArg(ImmGCPtr(lir->mir()->templateObject())); - callVM(TypedArrayCreateWithTemplateInfo, lir); -} -typedef TypedArrayObject* (*TypedArrayCreateFromArrayBufferWithTemplateFn)( - JSContext*, HandleObject, HandleObject, HandleValue, HandleValue); -static const VMFunction TypedArrayCreateFromArrayBufferWithTemplateInfo = - FunctionInfo( - js::TypedArrayCreateWithTemplate, "TypedArrayCreateWithTemplate"); + using Fn = TypedArrayObject* (*)(JSContext*, HandleObject, HandleObject); + callVM(lir); +} void CodeGenerator::visitNewTypedArrayFromArrayBuffer( LNewTypedArrayFromArrayBuffer* lir) { @@ -6815,7 +6752,10 @@ void CodeGenerator::visitNewTypedArrayFromArrayBuffer( pushArg(ToValue(lir, LNewTypedArrayFromArrayBuffer::ByteOffsetIndex)); pushArg(ToRegister(lir->arrayBuffer())); pushArg(ImmGCPtr(lir->mir()->templateObject())); - callVM(TypedArrayCreateFromArrayBufferWithTemplateInfo, lir); + + using Fn = TypedArrayObject* (*)(JSContext*, HandleObject, HandleObject, + HandleValue, HandleValue); + callVM(lir); } // Out-of-line object allocation for JSOP_NEWOBJECT. @@ -6832,22 +6772,6 @@ class OutOfLineNewObject : public OutOfLineCodeBase { LNewObject* lir() const { return lir_; } }; -typedef JSObject* (*NewInitObjectWithTemplateFn)(JSContext*, HandleObject); -static const VMFunction NewInitObjectWithTemplateInfo = - FunctionInfo(NewObjectOperationWithTemplate, - "NewObjectOperationWithTemplate"); - -typedef JSObject* (*NewInitObjectFn)(JSContext*, HandleScript, jsbytecode* pc, - NewObjectKind); -static const VMFunction NewInitObjectInfo = - FunctionInfo(NewObjectOperation, "NewObjectOperation"); - -typedef PlainObject* (*ObjectCreateWithTemplateFn)(JSContext*, - HandlePlainObject); -static const VMFunction ObjectCreateWithTemplateInfo = - FunctionInfo(ObjectCreateWithTemplate, - "ObjectCreateWithTemplate"); - void CodeGenerator::visitNewObjectVMCall(LNewObject* lir) { Register objReg = ToRegister(lir->output()); @@ -6864,17 +6788,24 @@ void CodeGenerator::visitNewObjectVMCall(LNewObject* lir) { case MNewObject::ObjectLiteral: if (templateObject) { pushArg(ImmGCPtr(templateObject)); - callVM(NewInitObjectWithTemplateInfo, lir); + + using Fn = JSObject* (*)(JSContext*, HandleObject); + callVM(lir); } else { pushArg(Imm32(GenericObject)); pushArg(ImmPtr(lir->mir()->resumePoint()->pc())); pushArg(ImmGCPtr(lir->mir()->block()->info().script())); - callVM(NewInitObjectInfo, lir); + + using Fn = JSObject* (*)(JSContext*, HandleScript, jsbytecode * pc, + NewObjectKind); + callVM(lir); } break; case MNewObject::ObjectCreate: pushArg(ImmGCPtr(templateObject)); - callVM(ObjectCreateWithTemplateInfo, lir); + + using Fn = PlainObject* (*)(JSContext*, HandlePlainObject); + callVM(lir); break; } @@ -7107,11 +7038,6 @@ void CodeGenerator::visitNewStringObject(LNewStringObject* lir) { masm.bind(ool->rejoin()); } -typedef bool (*InitElemFn)(JSContext* cx, jsbytecode* pc, HandleObject obj, - HandleValue id, HandleValue value); -static const VMFunction InitElemInfo = - FunctionInfo(InitElemOperation, "InitElemOperation"); - void CodeGenerator::visitInitElem(LInitElem* lir) { Register objReg = ToRegister(lir->getObject()); @@ -7120,7 +7046,9 @@ void CodeGenerator::visitInitElem(LInitElem* lir) { pushArg(objReg); pushArg(ImmPtr(lir->mir()->resumePoint()->pc())); - callVM(InitElemInfo, lir); + using Fn = bool (*)(JSContext * cx, jsbytecode * pc, HandleObject obj, + HandleValue id, HandleValue value); + callVM(lir); } void CodeGenerator::visitInitElemGetterSetter(LInitElemGetterSetter* lir) { @@ -7161,11 +7089,6 @@ void CodeGenerator::visitInitPropGetterSetter(LInitPropGetterSetter* lir) { callVM(lir); } -typedef bool (*CreateThisFn)(JSContext* cx, HandleObject callee, - HandleObject newTarget, MutableHandleValue rval); -static const VMFunction CreateThisInfoCodeGen = - FunctionInfo(CreateThis, "CreateThis"); - void CodeGenerator::visitCreateThis(LCreateThis* lir) { const LAllocation* callee = lir->getCallee(); const LAllocation* newTarget = lir->getNewTarget(); @@ -7182,17 +7105,11 @@ void CodeGenerator::visitCreateThis(LCreateThis* lir) { pushArg(ToRegister(callee)); } - callVM(CreateThisInfoCodeGen, lir); + using Fn = bool (*)(JSContext * cx, HandleObject callee, + HandleObject newTarget, MutableHandleValue rval); + callVM(lir); } -typedef JSObject* (*CreateThisWithProtoFn)(JSContext* cx, HandleFunction callee, - HandleObject newTarget, - HandleObject proto, - NewObjectKind newKind); -static const VMFunction CreateThisWithProtoInfo = - FunctionInfo(CreateThisForFunctionWithProto, - "CreateThisForFunctionWithProto"); - void CodeGenerator::visitCreateThisWithProto(LCreateThisWithProto* lir) { const LAllocation* callee = lir->getCallee(); const LAllocation* newTarget = lir->getNewTarget(); @@ -7218,7 +7135,10 @@ void CodeGenerator::visitCreateThisWithProto(LCreateThisWithProto* lir) { pushArg(ToRegister(callee)); } - callVM(CreateThisWithProtoInfo, lir); + using Fn = JSObject* (*)(JSContext * cx, HandleFunction callee, + HandleObject newTarget, HandleObject proto, + NewObjectKind newKind); + callVM(lir); } typedef JSObject* (*CreateThisWithTemplateFn)(JSContext*, HandleObject); @@ -7245,14 +7165,6 @@ void CodeGenerator::visitCreateThisWithTemplate(LCreateThisWithTemplate* lir) { masm.bind(ool->rejoin()); } -typedef JSObject* (*NewIonArgumentsObjectFn)(JSContext* cx, - JitFrameLayout* frame, - HandleObject); -static const VMFunction NewIonArgumentsObjectInfo = - FunctionInfo( - (NewIonArgumentsObjectFn)ArgumentsObject::createForIon, - "ArgumentsObject::createForIon"); - void CodeGenerator::visitCreateArgumentsObject(LCreateArgumentsObject* lir) { // This should be getting constructed in the first block only, and not any OSR // entry blocks. @@ -7304,7 +7216,9 @@ void CodeGenerator::visitCreateArgumentsObject(LCreateArgumentsObject* lir) { pushArg(callObj); pushArg(temp); - callVM(NewIonArgumentsObjectInfo, lir); + + using Fn = ArgumentsObject* (*)(JSContext*, JitFrameLayout*, HandleObject); + callVM(lir); masm.bind(&done); } @@ -8052,15 +7966,13 @@ void CodeGenerator::visitPowD(LPowD* ins) { MOZ_ASSERT(ToFloatRegister(ins->output()) == ReturnDoubleReg); } -using PowFn = bool (*)(JSContext*, MutableHandleValue, MutableHandleValue, - MutableHandleValue); -static const VMFunction PowInfo = - FunctionInfo(js::PowValues, "PowValues"); - void CodeGenerator::visitPowV(LPowV* ins) { pushArg(ToValue(ins, LPowV::PowerInput)); pushArg(ToValue(ins, LPowV::ValueInput)); - callVM(PowInfo, ins); + + using Fn = bool (*)(JSContext*, MutableHandleValue, MutableHandleValue, + MutableHandleValue); + callVM(ins); } void CodeGenerator::visitSignI(LSignI* ins) { diff --git a/js/src/jit/Recover.cpp b/js/src/jit/Recover.cpp index cdd71b7a88f9..cb3abc10fb72 100644 --- a/js/src/jit/Recover.cpp +++ b/js/src/jit/Recover.cpp @@ -1214,7 +1214,7 @@ bool RNewTypedArray::recover(JSContext* cx, SnapshotIterator& iter) const { uint32_t length = templateObject.as()->length(); JSObject* resultObject = - TypedArrayCreateWithTemplate(cx, templateObject, length); + NewTypedArrayWithTemplateAndLength(cx, templateObject, length); if (!resultObject) { return false; } @@ -1610,7 +1610,7 @@ bool RStringReplace::recover(JSContext* cx, SnapshotIterator& iter) const { JSString* result = isFlatReplacement_ - ? js::str_flat_replace_string(cx, string, pattern, replace) + ? js::StringFlatReplaceString(cx, string, pattern, replace) : js::str_replace_string_raw(cx, string, pattern, replace); if (!result) { diff --git a/js/src/jit/VMFunctionList-inl.h b/js/src/jit/VMFunctionList-inl.h index f7e0593b6261..c456972c7be5 100644 --- a/js/src/jit/VMFunctionList-inl.h +++ b/js/src/jit/VMFunctionList-inl.h @@ -4,6 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "builtin/Eval.h" +#include "builtin/RegExp.h" #include "jit/BaselineIC.h" #include "jit/IonIC.h" #include "jit/JitRealm.h" @@ -11,6 +13,7 @@ #include "vm/AsyncFunction.h" #include "vm/AsyncIteration.h" #include "vm/Interpreter.h" +#include "vm/TypedArrayObject.h" #include "jit/BaselineFrame-inl.h" #include "vm/Interpreter-inl.h" @@ -22,6 +25,7 @@ namespace jit { // (must be unique, used for the VMFunctionId enum and profiling) and the C++ // function to be called. This list must be sorted on the name field. #define VMFUNCTION_LIST(_) \ + _(ArgumentsObjectCreateForIon, js::ArgumentsObject::createForIon) \ _(AsyncFunctionAwait, js::AsyncFunctionAwait) \ _(AsyncFunctionResolve, js::AsyncFunctionResolve) \ _(BaselineDebugPrologue, js::jit::DebugPrologue) \ @@ -34,10 +38,15 @@ namespace jit { _(CheckGlobalOrEvalDeclarationConflicts, \ js::CheckGlobalOrEvalDeclarationConflicts) \ _(CheckIsCallable, js::jit::CheckIsCallable) \ + _(CheckOverRecursed, js::jit::CheckOverRecursed) \ _(CheckOverRecursedBaseline, js::jit::CheckOverRecursedBaseline) \ _(CloneRegExpObject, js::CloneRegExpObject) \ + _(CopyLexicalEnvironmentObject, js::jit::CopyLexicalEnvironmentObject) \ _(CreateAsyncFromSyncIterator, js::CreateAsyncFromSyncIterator) \ + _(CreateDerivedTypedObj, js::jit::CreateDerivedTypedObj) \ _(CreateGenerator, js::jit::CreateGenerator) \ + _(CreateThis, js::jit::CreateThis) \ + _(CreateThisForFunctionWithProto, js::CreateThisForFunctionWithProto) \ _(DebugAfterYield, js::jit::DebugAfterYield) \ _(DebugEpilogueOnBaselineReturn, js::jit::DebugEpilogueOnBaselineReturn) \ _(DebugLeaveLexicalEnv, js::jit::DebugLeaveLexicalEnv) \ @@ -46,6 +55,7 @@ namespace jit { _(DebugLeaveThenRecreateLexicalEnv, \ js::jit::DebugLeaveThenRecreateLexicalEnv) \ _(Debug_CheckSelfHosted, js::Debug_CheckSelfHosted) \ + _(DeepCloneObjectLiteral, js::DeepCloneObjectLiteral) \ _(DefFunOperation, js::DefFunOperation) \ _(DefLexicalOperation, js::DefLexicalOperation) \ _(DefVarOperation, js::DefVarOperation) \ @@ -54,6 +64,7 @@ namespace jit { _(DeleteNameOperation, js::DeleteNameOperation) \ _(DeletePropertyNonStrict, js::DeletePropertyJit) \ _(DeletePropertyStrict, js::DeletePropertyJit) \ + _(DirectEvalStringFromIon, js::DirectEvalStringFromIon) \ _(DoToNumber, js::jit::DoToNumber) \ _(DoToNumeric, js::jit::DoToNumeric) \ _(EnterWith, js::jit::EnterWith) \ @@ -62,16 +73,20 @@ namespace jit { _(FunWithProtoOperation, js::FunWithProtoOperation) \ _(GetAndClearException, js::GetAndClearException) \ _(GetImportOperation, js::GetImportOperation) \ + _(GetIntrinsicValue, js::jit::GetIntrinsicValue) \ _(GetNonSyntacticGlobalThis, js::GetNonSyntacticGlobalThis) \ _(GetOrCreateModuleMetaObject, js::GetOrCreateModuleMetaObject) \ _(HomeObjectSuperBase, js::HomeObjectSuperBase) \ _(ImplicitThisOperation, js::ImplicitThisOperation) \ _(ImportMetaOperation, js::ImportMetaOperation) \ _(InitElemGetterSetterOperation, js::InitElemGetterSetterOperation) \ + _(InitElemOperation, js::InitElemOperation) \ _(InitFunctionEnvironmentObjects, js::jit::InitFunctionEnvironmentObjects) \ _(InitPropGetterSetterOperation, js::InitPropGetterSetterOperation) \ _(InterpretResume, js::jit::InterpretResume) \ _(InterruptCheck, js::jit::InterruptCheck) \ + _(InvokeFunction, js::jit::InvokeFunction) \ + _(InvokeFunctionShuffleNewTarget, js::jit::InvokeFunctionShuffleNewTarget) \ _(IonBinaryArithICUpdate, js::jit::IonBinaryArithIC::update) \ _(IonBindNameICUpdate, js::jit::IonBindNameIC::update) \ _(IonCompareICUpdate, js::jit::IonCompareIC::update) \ @@ -88,27 +103,41 @@ namespace jit { _(Lambda, js::Lambda) \ _(LambdaArrow, js::LambdaArrow) \ _(LeaveWith, js::jit::LeaveWith) \ + _(LexicalEnvironmentObjectCreate, js::LexicalEnvironmentObject::create) \ _(MakeDefaultConstructor, js::MakeDefaultConstructor) \ _(MutatePrototype, js::jit::MutatePrototype) \ _(NewArgumentsObject, js::jit::NewArgumentsObject) \ _(NewArrayCopyOnWriteOperation, js::NewArrayCopyOnWriteOperation) \ + _(NewArrayOperation, js::NewArrayOperation) \ _(NewDenseCopyOnWriteArray, js::NewDenseCopyOnWriteArray) \ + _(NewObjectOperation, js::NewObjectOperation) \ + _(NewObjectOperationWithTemplate, js::NewObjectOperationWithTemplate) \ + _(NewTypedArrayWithTemplateAndArray, js::NewTypedArrayWithTemplateAndArray) \ + _(NewTypedArrayWithTemplateAndBuffer, \ + js::NewTypedArrayWithTemplateAndBuffer) \ _(NormalSuspend, js::jit::NormalSuspend) \ + _(ObjectCreateWithTemplate, js::ObjectCreateWithTemplate) \ _(ObjectWithProtoOperation, js::ObjectWithProtoOperation) \ _(OnDebuggerStatement, js::jit::OnDebuggerStatement) \ _(OptimizeSpreadCall, js::OptimizeSpreadCall) \ _(PopLexicalEnv, js::jit::PopLexicalEnv) \ _(PopVarEnv, js::jit::PopVarEnv) \ + _(PowValues, js::PowValues) \ _(ProcessCallSiteObjOperation, js::ProcessCallSiteObjOperation) \ _(PushLexicalEnv, js::jit::PushLexicalEnv) \ _(PushVarEnv, js::jit::PushVarEnv) \ _(RecreateLexicalEnv, js::jit::RecreateLexicalEnv) \ + _(RegExpMatcherRaw, js::RegExpMatcherRaw) \ + _(RegExpSearcherRaw, js::RegExpSearcherRaw) \ + _(RegExpTesterRaw, js::RegExpTesterRaw) \ _(SetFunctionName, js::SetFunctionName) \ _(SetIntrinsicOperation, js::SetIntrinsicOperation) \ _(SetObjectElementWithReceiver, js::SetObjectElementWithReceiver) \ _(SetPropertySuper, js::SetPropertySuper) \ _(SingletonObjectLiteralOperation, js::SingletonObjectLiteralOperation) \ _(StartDynamicModuleImport, js::StartDynamicModuleImport) \ + _(StringFlatReplaceString, js::StringFlatReplaceString) \ + _(StringReplace, js::jit::StringReplace) \ _(SuperFunOperation, js::SuperFunOperation) \ _(ThrowBadDerivedReturn, js::jit::ThrowBadDerivedReturn) \ _(ThrowCheckIsObject, js::ThrowCheckIsObject) \ diff --git a/js/src/jit/VMFunctions.h b/js/src/jit/VMFunctions.h index c69cf91b9ad1..cdb7b8c9816d 100644 --- a/js/src/jit/VMFunctions.h +++ b/js/src/jit/VMFunctions.h @@ -18,6 +18,7 @@ namespace js { +class ArgumentsObject; class NamedLambdaObject; class WithScope; class InlineTypedObject; @@ -439,6 +440,10 @@ struct TypeToDataType { static const DataType result = Type_Object; }; template <> +struct TypeToDataType { + static const DataType result = Type_Object; +}; +template <> struct TypeToDataType { static const DataType result = Type_Object; }; diff --git a/js/src/vm/EnvironmentObject.cpp b/js/src/vm/EnvironmentObject.cpp index d54e6e4c1aaa..a6db401e3962 100644 --- a/js/src/vm/EnvironmentObject.cpp +++ b/js/src/vm/EnvironmentObject.cpp @@ -943,7 +943,7 @@ LexicalEnvironmentObject* LexicalEnvironmentObject::create( } /* static */ -LexicalEnvironmentObject* LexicalEnvironmentObject::create( +LexicalEnvironmentObject* LexicalEnvironmentObject::createForFrame( JSContext* cx, Handle scope, AbstractFramePtr frame) { RootedObject enclosing(cx, frame.environmentChain()); return create(cx, scope, enclosing, gc::DefaultHeap); diff --git a/js/src/vm/EnvironmentObject.h b/js/src/vm/EnvironmentObject.h index 443440627919..c9f106c200e1 100644 --- a/js/src/vm/EnvironmentObject.h +++ b/js/src/vm/EnvironmentObject.h @@ -527,9 +527,9 @@ class LexicalEnvironmentObject : public EnvironmentObject { Handle scope, HandleObject enclosing, gc::InitialHeap heap); - static LexicalEnvironmentObject* create(JSContext* cx, - Handle scope, - AbstractFramePtr frame); + static LexicalEnvironmentObject* createForFrame(JSContext* cx, + Handle scope, + AbstractFramePtr frame); static LexicalEnvironmentObject* createGlobal(JSContext* cx, Handle global); static LexicalEnvironmentObject* createNonSyntactic(JSContext* cx, diff --git a/js/src/vm/Stack.cpp b/js/src/vm/Stack.cpp index 94b2b09d3b34..1e2421e15e35 100644 --- a/js/src/vm/Stack.cpp +++ b/js/src/vm/Stack.cpp @@ -289,7 +289,7 @@ bool InterpreterFrame::pushVarEnvironment(JSContext* cx, HandleScope scope) { bool InterpreterFrame::pushLexicalEnvironment(JSContext* cx, Handle scope) { LexicalEnvironmentObject* env = - LexicalEnvironmentObject::create(cx, scope, this); + LexicalEnvironmentObject::createForFrame(cx, scope, this); if (!env) { return false; } diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index 4afd8b6cd878..887d83092236 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -980,9 +980,8 @@ JS_FOR_EACH_TYPED_ARRAY(CREATE_TYPE_FOR_TYPED_ARRAY) } /* anonymous namespace */ -TypedArrayObject* js::TypedArrayCreateWithTemplate(JSContext* cx, - HandleObject templateObj, - int32_t len) { +TypedArrayObject* js::NewTypedArrayWithTemplateAndLength( + JSContext* cx, HandleObject templateObj, int32_t len) { MOZ_ASSERT(templateObj->is()); TypedArrayObject* tobj = &templateObj->as(); @@ -998,9 +997,8 @@ TypedArrayObject* js::TypedArrayCreateWithTemplate(JSContext* cx, } } -TypedArrayObject* js::TypedArrayCreateWithTemplate(JSContext* cx, - HandleObject templateObj, - HandleObject array) { +TypedArrayObject* js::NewTypedArrayWithTemplateAndArray( + JSContext* cx, HandleObject templateObj, HandleObject array) { MOZ_ASSERT(templateObj->is()); TypedArrayObject* tobj = &templateObj->as(); @@ -1016,11 +1014,9 @@ TypedArrayObject* js::TypedArrayCreateWithTemplate(JSContext* cx, } } -TypedArrayObject* js::TypedArrayCreateWithTemplate(JSContext* cx, - HandleObject templateObj, - HandleObject arrayBuffer, - HandleValue byteOffset, - HandleValue length) { +TypedArrayObject* js::NewTypedArrayWithTemplateAndBuffer( + JSContext* cx, HandleObject templateObj, HandleObject arrayBuffer, + HandleValue byteOffset, HandleValue length) { MOZ_ASSERT(templateObj->is()); TypedArrayObject* tobj = &templateObj->as(); diff --git a/js/src/vm/TypedArrayObject.h b/js/src/vm/TypedArrayObject.h index abf79fefb2bd..b61a9cdb5639 100644 --- a/js/src/vm/TypedArrayObject.h +++ b/js/src/vm/TypedArrayObject.h @@ -193,19 +193,15 @@ class TypedArrayObject : public ArrayBufferViewObject { MOZ_MUST_USE bool TypedArray_bufferGetter(JSContext* cx, unsigned argc, Value* vp); -extern TypedArrayObject* TypedArrayCreateWithTemplate(JSContext* cx, - HandleObject templateObj, - int32_t len); +extern TypedArrayObject* NewTypedArrayWithTemplateAndLength( + JSContext* cx, HandleObject templateObj, int32_t len); -extern TypedArrayObject* TypedArrayCreateWithTemplate(JSContext* cx, - HandleObject templateObj, - HandleObject array); +extern TypedArrayObject* NewTypedArrayWithTemplateAndArray( + JSContext* cx, HandleObject templateObj, HandleObject array); -extern TypedArrayObject* TypedArrayCreateWithTemplate(JSContext* cx, - HandleObject templateObj, - HandleObject arrayBuffer, - HandleValue byteOffset, - HandleValue length); +extern TypedArrayObject* NewTypedArrayWithTemplateAndBuffer( + JSContext* cx, HandleObject templateObj, HandleObject arrayBuffer, + HandleValue byteOffset, HandleValue length); inline bool IsTypedArrayClass(const Class* clasp) { return &TypedArrayObject::classes[0] <= clasp &&