From ca27c14869010744ed1a7fb7c4b643da61063032 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Fri, 6 Jan 2012 11:06:48 -0800 Subject: [PATCH] Bug 715667: Remove some unnecessary toFunction() calls applied to JSFunction values. r=luke --- js/src/jsfun.h | 7 +++++++ js/src/vm/Stack-inl.h | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/js/src/jsfun.h b/js/src/jsfun.h index 35c219202938..6e25b126a4a3 100644 --- a/js/src/jsfun.h +++ b/js/src/jsfun.h @@ -289,6 +289,13 @@ struct JSFunction : public JSObject */ inline JSAtom *methodAtom() const; inline void setMethodAtom(JSAtom *atom); + + /* + * These member functions are inherited from JSObject, but should never be applied to + * a value statically known to be a JSFunction. + */ + inline JSFunction *toFunction() MOZ_DELETE; + inline const JSFunction *toFunction() const MOZ_DELETE; }; inline JSFunction * diff --git a/js/src/vm/Stack-inl.h b/js/src/vm/Stack-inl.h index e4d199e116e3..283906a151d7 100644 --- a/js/src/vm/Stack-inl.h +++ b/js/src/vm/Stack-inl.h @@ -152,13 +152,13 @@ StackFrame::initCallFrame(JSContext *cx, JSFunction &callee, LOWERED_CALL_APPLY | OVERFLOW_ARGS | UNDERFLOW_ARGS)) == 0); - JS_ASSERT(script == callee.toFunction()->script()); + JS_ASSERT(script == callee.script()); /* Initialize stack frame members. */ flags_ = FUNCTION | HAS_PREVPC | HAS_SCOPECHAIN | HAS_BLOCKCHAIN | flagsArg; exec.fun = &callee; args.nactual = nactual; - scopeChain_ = callee.toFunction()->environment(); + scopeChain_ = callee.environment(); ncode_ = NULL; initPrev(cx); blockChain_= NULL; @@ -569,7 +569,7 @@ ContextStack::pushInlineFrame(JSContext *cx, FrameRegs ®s, const CallArgs &ar JS_ASSERT(onTop()); JS_ASSERT(regs.sp == args.end()); /* Cannot assert callee == args.callee() since this is called from LeaveTree. */ - JS_ASSERT(script == callee.toFunction()->script()); + JS_ASSERT(script == callee.script()); /*StackFrame::Flags*/ uint32_t flags = ToFrameFlags(initial); StackFrame *fp = getCallFrame(cx, REPORT_ERROR, args, &callee, script, &flags);