diff options
Diffstat (limited to 'js/src/vm')
-rw-r--r-- | js/src/vm/AsyncFunction.cpp | 5 | ||||
-rw-r--r-- | js/src/vm/Debugger.cpp | 2 | ||||
-rw-r--r-- | js/src/vm/GlobalObject.cpp | 4 | ||||
-rw-r--r-- | js/src/vm/Interpreter.cpp | 24 | ||||
-rw-r--r-- | js/src/vm/Opcodes.h | 11 | ||||
-rw-r--r-- | js/src/vm/SelfHosting.cpp | 10 | ||||
-rw-r--r-- | js/src/vm/Stack.cpp | 2 | ||||
-rw-r--r-- | js/src/vm/TypeInference.cpp | 2 | ||||
-rw-r--r-- | js/src/vm/TypedArrayObject.cpp | 2 |
9 files changed, 42 insertions, 20 deletions
diff --git a/js/src/vm/AsyncFunction.cpp b/js/src/vm/AsyncFunction.cpp index 1e0c7d7c2..f50c87114 100644 --- a/js/src/vm/AsyncFunction.cpp +++ b/js/src/vm/AsyncFunction.cpp @@ -116,7 +116,7 @@ js::WrapAsyncFunctionWithProto(JSContext* cx, HandleFunction unwrapped, HandleOb // Create a new function with AsyncFunctionPrototype, reusing the name and // the length of `unwrapped`. - RootedAtom funName(cx, unwrapped->name()); + RootedAtom funName(cx, unwrapped->explicitName()); uint16_t length; if (!unwrapped->getLength(cx, &length)) return nullptr; @@ -130,6 +130,9 @@ js::WrapAsyncFunctionWithProto(JSContext* cx, HandleFunction unwrapped, HandleOb if (!wrapped) return nullptr; + if (unwrapped->hasCompileTimeName()) + wrapped->setCompileTimeName(unwrapped->compileTimeName()); + // Link them to each other to make GetWrappedAsyncFunction and // GetUnwrappedAsyncFunction work. unwrapped->setExtendedSlot(UNWRAPPED_ASYNC_WRAPPED_SLOT, ObjectValue(*wrapped)); diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 4d181545f..d16781326 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -9509,7 +9509,7 @@ DebuggerObject::name() const { MOZ_ASSERT(isFunction()); - return referent()->as<JSFunction>().name(); + return referent()->as<JSFunction>().explicitName(); } JSAtom* diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp index 039be2e32..280548cd6 100644 --- a/js/src/vm/GlobalObject.cpp +++ b/js/src/vm/GlobalObject.cpp @@ -802,10 +802,10 @@ GlobalObject::getSelfHostedFunction(JSContext* cx, Handle<GlobalObject*> global, return false; if (exists) { RootedFunction fun(cx, &funVal.toObject().as<JSFunction>()); - if (fun->name() == name) + if (fun->explicitName() == name) return true; - if (fun->name() == selfHostedName) { + if (fun->explicitName() == selfHostedName) { // This function was initially cloned because it was called by // other self-hosted code, so the clone kept its self-hosted name, // instead of getting the name it's intended to have in content diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index fbf526ae5..9cba1f4dc 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -282,8 +282,6 @@ MakeDefaultConstructor(JSContext* cx, JSOp op, JSAtom* atom, HandleObject proto) ctor->setIsConstructor(); ctor->setIsClassConstructor(); - if (derived) - ctor->setHasRest(); MOZ_ASSERT(ctor->infallibleIsDefaultClassConstructor(cx)); @@ -1862,7 +1860,6 @@ CASE(EnableInterruptsPseudoOpcode) /* Various 1-byte no-ops. */ CASE(JSOP_NOP) CASE(JSOP_NOP_DESTRUCTURING) -CASE(JSOP_UNUSED182) CASE(JSOP_UNUSED183) CASE(JSOP_UNUSED187) CASE(JSOP_UNUSED192) @@ -3484,6 +3481,19 @@ CASE(JSOP_TOASYNC) } END_CASE(JSOP_TOASYNC) +CASE(JSOP_SETFUNNAME) +{ + MOZ_ASSERT(REGS.stackDepth() >= 2); + FunctionPrefixKind prefixKind = FunctionPrefixKind(GET_UINT8(REGS.pc)); + ReservedRooted<Value> name(&rootValue0, REGS.sp[-1]); + ReservedRooted<JSFunction*> fun(&rootFunction0, ®S.sp[-2].toObject().as<JSFunction>()); + if (!SetFunctionNameIfNoOwnName(cx, fun, name, prefixKind)) + goto error; + + REGS.sp--; +} +END_CASE(JSOP_SETFUNNAME) + CASE(JSOP_CALLEE) MOZ_ASSERT(REGS.fp()->isFunctionFrame()); PUSH_COPY(REGS.fp()->calleev()); @@ -4345,7 +4355,7 @@ js::DefFunOperation(JSContext* cx, HandleScript script, HandleObject envChain, parent = parent->enclosingEnvironment(); /* ES5 10.5 (NB: with subsequent errata). */ - RootedPropertyName name(cx, fun->name()->asPropertyName()); + RootedPropertyName name(cx, fun->explicitName()->asPropertyName()); RootedShape shape(cx); RootedObject pobj(cx); @@ -4993,7 +5003,7 @@ js::ReportRuntimeLexicalError(JSContext* cx, unsigned errorNumber, RootedPropertyName name(cx); if (op == JSOP_THROWSETCALLEE) { - name = script->functionNonDelazifying()->name()->asPropertyName(); + name = script->functionNonDelazifying()->explicitName()->asPropertyName(); } else if (IsLocalOp(op)) { name = FrameSlotName(script, pc)->asPropertyName(); } else if (IsAtomOp(op)) { @@ -5061,8 +5071,8 @@ js::ThrowUninitializedThis(JSContext* cx, AbstractFramePtr frame) if (fun->isDerivedClassConstructor()) { const char* name = "anonymous"; JSAutoByteString str; - if (fun->name()) { - if (!AtomToPrintableString(cx, fun->name(), &str)) + if (fun->explicitName()) { + if (!AtomToPrintableString(cx, fun->explicitName(), &str)) return false; name = str.ptr(); } diff --git a/js/src/vm/Opcodes.h b/js/src/vm/Opcodes.h index 18ae6f073..f6636004d 100644 --- a/js/src/vm/Opcodes.h +++ b/js/src/vm/Opcodes.h @@ -1870,7 +1870,16 @@ * Stack: => */ \ macro(JSOP_POPVARENV, 181, "popvarenv", NULL, 1, 0, 0, JOF_BYTE) \ - macro(JSOP_UNUSED182, 182,"unused182", NULL, 1, 0, 0, JOF_BYTE) \ + /* + * Pops the top two values on the stack as 'name' and 'fun', defines the + * name of 'fun' to 'name' with prefix if any, and pushes 'fun' back onto + * the stack. + * Category: Statements + * Type: Function + * Operands: uint8_t prefixKind + * Stack: fun, name => fun + */ \ + macro(JSOP_SETFUNNAME, 182,"setfunname", NULL, 2, 2, 1, JOF_UINT8) \ macro(JSOP_UNUSED183, 183,"unused183", NULL, 1, 0, 0, JOF_BYTE) \ \ /* diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index 6737e774c..bf49f2268 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -2878,7 +2878,7 @@ CloneObject(JSContext* cx, HandleNativeObject selfHostedObject) RootedObject clone(cx); if (selfHostedObject->is<JSFunction>()) { RootedFunction selfHostedFunction(cx, &selfHostedObject->as<JSFunction>()); - bool hasName = selfHostedFunction->name() != nullptr; + bool hasName = selfHostedFunction->explicitName() != nullptr; // Arrow functions use the first extended slot for their lexical |this| value. MOZ_ASSERT(!selfHostedFunction->isArrow()); @@ -2894,7 +2894,7 @@ CloneObject(JSContext* cx, HandleNativeObject selfHostedObject) // self-hosting compartment has to be stored on the clone. if (clone && hasName) { clone->as<JSFunction>().setExtendedSlot(LAZY_FUNCTION_NAME_SLOT, - StringValue(selfHostedFunction->name())); + StringValue(selfHostedFunction->explicitName())); } } else if (selfHostedObject->is<RegExpObject>()) { RegExpObject& reobj = selfHostedObject->as<RegExpObject>(); @@ -2977,10 +2977,10 @@ JSRuntime::createLazySelfHostedFunctionClone(JSContext* cx, HandlePropertyName s return false; if (!selfHostedFun->isClassConstructor() && !selfHostedFun->hasGuessedAtom() && - selfHostedFun->name() != selfHostedName) + selfHostedFun->explicitName() != selfHostedName) { MOZ_ASSERT(selfHostedFun->getExtendedSlot(HAS_SELFHOSTED_CANONICAL_NAME_SLOT).toBoolean()); - funName = selfHostedFun->name(); + funName = selfHostedFun->explicitName(); } fun.set(NewScriptedFunction(cx, nargs, JSFunction::INTERPRETED_LAZY, @@ -3022,7 +3022,7 @@ JSRuntime::cloneSelfHostedFunctionScript(JSContext* cx, HandlePropertyName name, MOZ_ASSERT(!targetFun->isInterpretedLazy()); MOZ_ASSERT(sourceFun->nargs() == targetFun->nargs()); - MOZ_ASSERT(sourceFun->hasRest() == targetFun->hasRest()); + MOZ_ASSERT(sourceScript->hasRest() == targetFun->nonLazyScript()->hasRest()); // The target function might have been relazified after its flags changed. targetFun->setFlags(targetFun->flags() | sourceFun->flags()); diff --git a/js/src/vm/Stack.cpp b/js/src/vm/Stack.cpp index 439bb1ed4..87e95c893 100644 --- a/js/src/vm/Stack.cpp +++ b/js/src/vm/Stack.cpp @@ -85,7 +85,7 @@ InterpreterFrame::isNonGlobalEvalFrame() const JSObject* InterpreterFrame::createRestParameter(JSContext* cx) { - MOZ_ASSERT(callee().hasRest()); + MOZ_ASSERT(script()->hasRest()); unsigned nformal = callee().nargs() - 1, nactual = numActualArgs(); unsigned nrest = (nactual > nformal) ? nactual - nformal : 0; Value* restvp = argv() + nformal; diff --git a/js/src/vm/TypeInference.cpp b/js/src/vm/TypeInference.cpp index 2a7762e4f..3d09c7464 100644 --- a/js/src/vm/TypeInference.cpp +++ b/js/src/vm/TypeInference.cpp @@ -4541,7 +4541,7 @@ TypeScript::printTypes(JSContext* cx, HandleScript script) const uintptr_t(script.get()), script->filename(), script->lineno()); if (script->functionNonDelazifying()) { - if (JSAtom* name = script->functionNonDelazifying()->name()) + if (JSAtom* name = script->functionNonDelazifying()->explicitName()) name->dumpCharsNoNewline(); } diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index 9d4ee94c6..ae97be0de 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -2870,7 +2870,7 @@ bool DataViewObject::defineGetter(JSContext* cx, PropertyName* name, HandleNativeObject proto) { RootedId id(cx, NameToId(name)); - RootedAtom atom(cx, IdToFunctionName(cx, id, "get")); + RootedAtom atom(cx, IdToFunctionName(cx, id, FunctionPrefixKind::Get)); if (!atom) return false; unsigned attrs = JSPROP_SHARED | JSPROP_GETTER; |