summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-06-08 18:45:53 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-07-18 22:38:21 -0400
commite5019fd4cf2142b7fe2cbfedaefcea300390393e (patch)
treed1c7aa013442c768b425f058e4a88b10b1418a0c /js
parent9476f2e018856139f92e96e8e738bbbab615e67d (diff)
downloaduxp-e5019fd4cf2142b7fe2cbfedaefcea300390393e.tar.gz
1320408 - Part 1: Change JSFunction::getLength and JSFunction::getUnresolvedLength to static method.
Diffstat (limited to 'js')
-rw-r--r--js/src/jsfun.cpp29
-rw-r--r--js/src/jsfun.h5
-rw-r--r--js/src/vm/AsyncFunction.cpp2
-rw-r--r--js/src/vm/SelfHosting.cpp2
4 files changed, 19 insertions, 19 deletions
diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp
index 06d5cced72..18ff875da6 100644
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -476,7 +476,7 @@ fun_resolve(JSContext* cx, HandleObject obj, HandleId id, bool* resolvedp)
if (fun->hasResolvedLength())
return true;
- if (!fun->getUnresolvedLength(cx, &v))
+ if (!JSFunction::getUnresolvedLength(cx, fun, &v))
return false;
} else {
if (fun->hasResolvedName())
@@ -1242,34 +1242,33 @@ JSFunction::isDerivedClassConstructor()
return derived;
}
-bool
-JSFunction::getLength(JSContext* cx, uint16_t* length)
+/* static */ bool
+JSFunction::getLength(JSContext* cx, HandleFunction fun, uint16_t* length)
{
- JS::RootedFunction self(cx, this);
- MOZ_ASSERT(!self->isBoundFunction());
- if (self->isInterpretedLazy() && !self->getOrCreateScript(cx))
+ MOZ_ASSERT(!fun->isBoundFunction());
+ if (fun->isInterpretedLazy() && !fun->getOrCreateScript(cx))
return false;
- *length = self->isNative() ? self->nargs() : self->nonLazyScript()->funLength();
+ *length = fun->isNative() ? fun->nargs() : fun->nonLazyScript()->funLength();
return true;
}
-bool
-JSFunction::getUnresolvedLength(JSContext* cx, MutableHandleValue v)
+/* static */ bool
+JSFunction::getUnresolvedLength(JSContext* cx, HandleFunction fun, MutableHandleValue v)
{
- MOZ_ASSERT(!IsInternalFunctionObject(*this));
- MOZ_ASSERT(!hasResolvedLength());
+ MOZ_ASSERT(!IsInternalFunctionObject(*fun));
+ MOZ_ASSERT(!fun->hasResolvedLength());
// Bound functions' length can have values up to MAX_SAFE_INTEGER, so
// they're handled differently from other functions.
- if (isBoundFunction()) {
- MOZ_ASSERT(getExtendedSlot(BOUND_FUN_LENGTH_SLOT).isNumber());
- v.set(getExtendedSlot(BOUND_FUN_LENGTH_SLOT));
+ if (fun->isBoundFunction()) {
+ MOZ_ASSERT(fun->getExtendedSlot(BOUND_FUN_LENGTH_SLOT).isNumber());
+ v.set(fun->getExtendedSlot(BOUND_FUN_LENGTH_SLOT));
return true;
}
uint16_t length;
- if (!getLength(cx, &length))
+ if (!JSFunction::getLength(cx, fun, &length))
return false;
v.setInt32(length);
diff --git a/js/src/jsfun.h b/js/src/jsfun.h
index b91c69d335..65fe542c49 100644
--- a/js/src/jsfun.h
+++ b/js/src/jsfun.h
@@ -306,7 +306,8 @@ class JSFunction : public js::NativeObject
nonLazyScript()->setAsyncKind(asyncKind);
}
- bool getUnresolvedLength(JSContext* cx, js::MutableHandleValue v);
+ static bool getUnresolvedLength(JSContext* cx, js::HandleFunction fun,
+ js::MutableHandleValue v);
JSAtom* getUnresolvedName(JSContext* cx);
@@ -478,7 +479,7 @@ class JSFunction : public js::NativeObject
return u.i.s.script_;
}
- bool getLength(JSContext* cx, uint16_t* length);
+ static bool getLength(JSContext* cx, js::HandleFunction fun, uint16_t* length);
js::LazyScript* lazyScript() const {
MOZ_ASSERT(isInterpretedLazy() && u.i.s.lazy_);
diff --git a/js/src/vm/AsyncFunction.cpp b/js/src/vm/AsyncFunction.cpp
index f50c871141..e14b77424a 100644
--- a/js/src/vm/AsyncFunction.cpp
+++ b/js/src/vm/AsyncFunction.cpp
@@ -118,7 +118,7 @@ js::WrapAsyncFunctionWithProto(JSContext* cx, HandleFunction unwrapped, HandleOb
RootedAtom funName(cx, unwrapped->explicitName());
uint16_t length;
- if (!unwrapped->getLength(cx, &length))
+ if (!JSFunction::getLength(cx, unwrapped, &length))
return nullptr;
// Steps 3 (partially).
diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp
index ccd4cc8d7b..dfec47cf26 100644
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -477,7 +477,7 @@ intrinsic_FinishBoundFunctionInit(JSContext* cx, unsigned argc, Value* vp)
// Try to avoid invoking the resolve hook.
if (targetObj->is<JSFunction>() && !targetObj->as<JSFunction>().hasResolvedLength()) {
RootedValue targetLength(cx);
- if (!targetObj->as<JSFunction>().getUnresolvedLength(cx, &targetLength))
+ if (!JSFunction::getUnresolvedLength(cx, targetObj.as<JSFunction>(), &targetLength))
return false;
length = Max(0.0, targetLength.toNumber() - argCount);