tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 8da206a49a226da313113fadb1cf83339a885eb1
parent 4b1c8f3a56479eef14df1230cf2e386255cb1afe
Author: André Bargull <andre.bargull@gmail.com>
Date:   Mon,  3 Nov 2025 13:43:29 +0000

Bug 1997885: Avoid function definitions in global namespace in JSFunction.cpp. r=spidermonkey-reviewers,jandem

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

Diffstat:
Mjs/src/vm/JSFunction.cpp | 13+++++++------
Mjs/src/vm/JSFunction.h | 6+++---
2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/js/src/vm/JSFunction.cpp b/js/src/vm/JSFunction.cpp @@ -102,7 +102,7 @@ static bool fun_enumerate(JSContext* cx, HandleObject obj) { return true; } -bool IsFunction(HandleValue v) { +static bool IsFunction(HandleValue v) { return v.isObject() && v.toObject().is<JSFunction>(); } @@ -168,7 +168,7 @@ static bool ArgumentsRestrictions(JSContext* cx, HandleFunction fun) { return true; } -bool ArgumentsGetterImpl(JSContext* cx, const CallArgs& args) { +static bool ArgumentsGetterImpl(JSContext* cx, const CallArgs& args) { MOZ_ASSERT(IsFunction(args.thisv())); RootedFunction fun(cx, &args.thisv().toObject().as<JSFunction>()); @@ -214,7 +214,7 @@ static bool ArgumentsGetter(JSContext* cx, unsigned argc, Value* vp) { return CallNonGenericMethod<IsFunction, ArgumentsGetterImpl>(cx, args); } -bool ArgumentsSetterImpl(JSContext* cx, const CallArgs& args) { +static bool ArgumentsSetterImpl(JSContext* cx, const CallArgs& args) { MOZ_ASSERT(IsFunction(args.thisv())); RootedFunction fun(cx, &args.thisv().toObject().as<JSFunction>()); @@ -250,7 +250,7 @@ static bool CallerRestrictions(JSContext* cx, HandleFunction fun) { return true; } -bool CallerGetterImpl(JSContext* cx, const CallArgs& args) { +static bool CallerGetterImpl(JSContext* cx, const CallArgs& args) { MOZ_ASSERT(IsFunction(args.thisv())); // Beware! This function can be invoked on *any* function! It can't @@ -320,7 +320,7 @@ static bool CallerGetter(JSContext* cx, unsigned argc, Value* vp) { return CallNonGenericMethod<IsFunction, CallerGetterImpl>(cx, args); } -bool CallerSetterImpl(JSContext* cx, const CallArgs& args) { +static bool CallerSetterImpl(JSContext* cx, const CallArgs& args) { MOZ_ASSERT(IsFunction(args.thisv())); // We just have to return |undefined|, but first we call CallerGetterImpl @@ -1014,7 +1014,8 @@ JSString* js::FunctionToString(JSContext* cx, HandleFunction fun, return out.finishString(); } -JSString* fun_toStringHelper(JSContext* cx, HandleObject obj, bool isToSource) { +JSString* js::fun_toStringHelper(JSContext* cx, HandleObject obj, + bool isToSource) { if (!obj->is<JSFunction>()) { if (JSFunToStringOp op = obj->getOpsFunToString()) { return op(cx, obj, isToSource); diff --git a/js/src/vm/JSFunction.h b/js/src/vm/JSFunction.h @@ -769,11 +769,11 @@ static_assert( static_assert(unsigned(JSFunction::AtomSlot) == unsigned(JS::shadow::Function::AtomSlot)); -extern JSString* fun_toStringHelper(JSContext* cx, js::HandleObject obj, - bool isToSource); - namespace js { +extern JSString* fun_toStringHelper(JSContext* cx, HandleObject obj, + bool isToSource); + extern bool Function(JSContext* cx, unsigned argc, Value* vp); extern bool Generator(JSContext* cx, unsigned argc, Value* vp);