Bug 1688794 - Cleanup self-hosting helpers for later use by stencil methods. r=jandem

Make these few functions accessible to Stencil.cpp and clean up function signatures.

Differential Revision: https://phabricator.services.mozilla.com/D120538
This commit is contained in:
Ted Campbell 2021-07-28 14:09:58 +00:00
Родитель f86787ec41
Коммит 0c5eb67302
3 изменённых файлов: 13 добавлений и 7 удалений

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

@ -672,7 +672,7 @@ struct JSRuntime {
bool isSelfHostingGlobal(JSObject* global) {
return global == selfHostingGlobal_;
}
js::GeneratorKind getSelfHostedFunctionGeneratorKind(JSAtom* name);
js::GeneratorKind getSelfHostedFunctionGeneratorKind(js::PropertyName* name);
bool createLazySelfHostedFunctionClone(JSContext* cx,
js::HandlePropertyName selfHostedName,
js::HandleAtom name, unsigned nargs,

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

@ -935,7 +935,8 @@ void js::SetUnclonedSelfHostedCanonicalName(JSFunction* fun, JSAtom* name) {
fun->setExtendedSlot(CANONICAL_FUNCTION_NAME_SLOT, StringValue(name));
}
static void SetClonedSelfHostedFunctionName(JSFunction* fun, JSAtom* name) {
void js::SetClonedSelfHostedFunctionName(JSFunction* fun,
js::PropertyName* name) {
fun->setExtendedSlot(LAZY_FUNCTION_NAME_SLOT, StringValue(name));
}
@ -2797,8 +2798,9 @@ void JSRuntime::traceSelfHostingGlobal(JSTracer* trc) {
}
}
GeneratorKind JSRuntime::getSelfHostedFunctionGeneratorKind(JSAtom* name) {
JSFunction* fun = getUnclonedSelfHostedFunction(name->asPropertyName());
GeneratorKind JSRuntime::getSelfHostedFunctionGeneratorKind(
js::PropertyName* name) {
JSFunction* fun = getUnclonedSelfHostedFunction(name);
return fun->generatorKind();
}
@ -2922,7 +2924,7 @@ static JSString* CloneString(JSContext* cx, JSLinearString* selfHostedString) {
// Returns the ScriptSourceObject to use for cloned self-hosted scripts in the
// current realm.
static ScriptSourceObject* SelfHostingScriptSourceObject(JSContext* cx) {
ScriptSourceObject* js::SelfHostingScriptSourceObject(JSContext* cx) {
if (ScriptSourceObject* sso = cx->realm()->selfHostingScriptSource) {
return sso;
}
@ -3002,8 +3004,9 @@ static JSObject* CloneObject(JSContext* cx,
// Save the original function name that we are cloning from. This allows
// the function to potentially be relazified in the future.
SetClonedSelfHostedFunctionName(&clone->as<JSFunction>(),
selfHostedFunction->explicitName());
SetClonedSelfHostedFunctionName(
&clone->as<JSFunction>(),
selfHostedFunction->explicitName()->asPropertyName());
// If |_SetCanonicalName| was called on the function, the function name to
// use is stored in the extended slot.

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

@ -14,6 +14,8 @@
namespace js {
ScriptSourceObject* SelfHostingScriptSourceObject(JSContext* cx);
/*
* Check whether the given JSFunction is a self-hosted function whose
* self-hosted name is the given name.
@ -27,6 +29,7 @@ bool IsSelfHostedFunctionWithName(JSFunction* fun, JSAtom* name);
* declaration in the self-hosted global.
*/
PropertyName* GetClonedSelfHostedFunctionName(const JSFunction* fun);
void SetClonedSelfHostedFunctionName(JSFunction* fun, PropertyName* name);
/*
* Same as GetClonedSelfHostedFunctionName, but `fun` is guaranteed to be an