From 1190d0cad6ed554128a88329a56320cfc6457407 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Mon, 18 Jan 2016 10:23:50 +0100 Subject: [PATCH] Bug 1234845 part 7 - Simplify isGlobalFrame and isModuleFrame. r=jonco --- js/src/jit/BaselineFrame.h | 8 +++++--- js/src/jit/RematerializedFrame.h | 7 +++++-- js/src/jsscript.h | 11 +++++++---- js/src/vm/Stack-inl.h | 22 ++++++++++------------ js/src/vm/Stack.cpp | 19 ------------------- js/src/vm/Stack.h | 11 ++--------- 6 files changed, 29 insertions(+), 49 deletions(-) diff --git a/js/src/jit/BaselineFrame.h b/js/src/jit/BaselineFrame.h index 9195f2bf4faa..ff5378a7b7ec 100644 --- a/js/src/jit/BaselineFrame.h +++ b/js/src/jit/BaselineFrame.h @@ -372,9 +372,11 @@ class BaselineFrame void trace(JSTracer* trc, JitFrameIterator& frame); - bool isGlobalOrModuleFrame() const { - MOZ_ASSERT(!isEvalFrame()); - return !CalleeTokenIsFunction(calleeToken()); + bool isGlobalFrame() const { + return script()->isGlobalCode(); + } + bool isModuleFrame() const { + return script()->module(); } bool isEvalFrame() const { return script()->isForEval(); diff --git a/js/src/jit/RematerializedFrame.h b/js/src/jit/RematerializedFrame.h index 67115039969b..4d3cce19cfa4 100644 --- a/js/src/jit/RematerializedFrame.h +++ b/js/src/jit/RematerializedFrame.h @@ -141,8 +141,11 @@ class RematerializedFrame bool isFunctionFrame() const { return !!script_->functionNonDelazifying(); } - bool isGlobalOrModuleFrame() const { - return !isFunctionFrame(); + bool isGlobalFrame() const { + return script_->isGlobalCode(); + } + bool isModuleFrame() const { + return script_->module(); } JSScript* script() const { diff --git a/js/src/jsscript.h b/js/src/jsscript.h index 040684914e31..22581a43579d 100644 --- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -1294,20 +1294,20 @@ class JSScript : public js::gc::TenuredCell // The fixed part of a stack frame is comprised of vars (in function and // module code) and block-scoped locals (in all kinds of code). size_t nfixed() const { - return isGlobalCode() ? bindings.numBlockScoped() : bindings.numFixedLocals(); + return isGlobalOrEvalCode() ? bindings.numBlockScoped() : bindings.numFixedLocals(); } // Number of fixed slots reserved for vars. Only nonzero for function // or module code. size_t nfixedvars() const { - return isGlobalCode() ? 0 : bindings.numUnaliasedVars(); + return isGlobalOrEvalCode() ? 0 : bindings.numUnaliasedVars(); } // Number of fixed slots reserved for body-level lexicals and vars. This // value minus nfixedvars() is the number of body-level lexicals. Only // nonzero for function or module code. size_t nbodyfixed() const { - return isGlobalCode() ? 0 : bindings.numUnaliasedBodyLevelLocals(); + return isGlobalOrEvalCode() ? 0 : bindings.numUnaliasedBodyLevelLocals(); } // Calculate the number of fixed slots that are live at a particular bytecode. @@ -1642,9 +1642,12 @@ class JSScript : public js::gc::TenuredCell } inline void setModule(js::ModuleObject* module); - bool isGlobalCode() const { + bool isGlobalOrEvalCode() const { return !function_ && !module_; } + bool isGlobalCode() const { + return isGlobalOrEvalCode() && !isForEval(); + } // Returns true if the script may read formal arguments on the stack // directly, via lazy arguments or a rest parameter. diff --git a/js/src/vm/Stack-inl.h b/js/src/vm/Stack-inl.h index 460a447564f2..a29165bfeb8b 100644 --- a/js/src/vm/Stack-inl.h +++ b/js/src/vm/Stack-inl.h @@ -563,26 +563,24 @@ AbstractFramePtr::createSingleton() const return false; } -inline bool -AbstractFramePtr::isGlobalOrModuleFrame() const -{ - if (isInterpreterFrame()) - return asInterpreterFrame()->isGlobalOrModuleFrame(); - if (isBaselineFrame()) - return asBaselineFrame()->isGlobalOrModuleFrame(); - return asRematerializedFrame()->isGlobalOrModuleFrame(); -} - inline bool AbstractFramePtr::isGlobalFrame() const { - return isGlobalOrModuleFrame() && !script()->module(); + if (isInterpreterFrame()) + return asInterpreterFrame()->isGlobalFrame(); + if (isBaselineFrame()) + return asBaselineFrame()->isGlobalFrame(); + return asRematerializedFrame()->isGlobalFrame(); } inline bool AbstractFramePtr::isModuleFrame() const { - return isGlobalOrModuleFrame() && script()->module(); + if (isInterpreterFrame()) + return asInterpreterFrame()->isModuleFrame(); + if (isBaselineFrame()) + return asBaselineFrame()->isModuleFrame(); + return asRematerializedFrame()->isModuleFrame(); } inline bool diff --git a/js/src/vm/Stack.cpp b/js/src/vm/Stack.cpp index 746685212cc1..fe2f65aa9a21 100644 --- a/js/src/vm/Stack.cpp +++ b/js/src/vm/Stack.cpp @@ -840,25 +840,6 @@ FrameIter::compartment() const MOZ_CRASH("Unexpected state"); } -bool -FrameIter::isGlobalOrModuleFrame() const -{ - switch (data_.state_) { - case DONE: - break; - case INTERP: - return interpFrame()->isGlobalOrModuleFrame(); - case JIT: - if (data_.jitFrames_.isBaselineJS()) - return data_.jitFrames_.baselineFrame()->isGlobalOrModuleFrame(); - MOZ_ASSERT(!script()->isForEval()); - return script()->isGlobalCode(); - case WASM: - return false; - } - MOZ_CRASH("Unexpected state"); -} - bool FrameIter::isEvalFrame() const { diff --git a/js/src/vm/Stack.h b/js/src/vm/Stack.h index 0e631d6101e0..63ca8a2fdecf 100644 --- a/js/src/vm/Stack.h +++ b/js/src/vm/Stack.h @@ -202,7 +202,6 @@ class AbstractFramePtr inline JSCompartment* compartment() const; inline bool hasCallObj() const; - inline bool isGlobalOrModuleFrame() const; inline bool isGlobalFrame() const; inline bool isModuleFrame() const; inline bool isEvalFrame() const; @@ -459,17 +458,12 @@ class InterpreterFrame * eval frame: execution of eval code */ - bool isGlobalOrModuleFrame() const { - MOZ_ASSERT(!isEvalFrame()); - return !!(flags_ & GLOBAL_OR_MODULE); - } - bool isGlobalFrame() const { - return isGlobalOrModuleFrame() && !script()->module(); + return script_->isGlobalCode(); } bool isModuleFrame() const { - return isGlobalOrModuleFrame() && script()->module(); + return script_->module(); } bool isEvalFrame() const { @@ -1826,7 +1820,6 @@ class FrameIter inline bool isBaseline() const; inline bool isPhysicalIonFrame() const; - bool isGlobalOrModuleFrame() const; bool isEvalFrame() const; bool isFunctionFrame() const; bool hasArgs() const { return isFunctionFrame(); }