LCOV - code coverage report
Current view: top level - js/src - jsscriptinlines.h (source / functions) Hit Total Coverage
Test: output.info Lines: 58 89 65.2 %
Date: 2017-07-14 16:53:18 Functions: 13 19 68.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  * vim: set ts=8 sts=4 et sw=4 tw=99:
       3             :  * This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef jsscriptinlines_h
       8             : #define jsscriptinlines_h
       9             : 
      10             : #include "jsscript.h"
      11             : 
      12             : #include "jit/BaselineJIT.h"
      13             : #include "jit/IonAnalysis.h"
      14             : #include "vm/EnvironmentObject.h"
      15             : #include "vm/RegExpObject.h"
      16             : #include "wasm/AsmJS.h"
      17             : 
      18             : #include "jscompartmentinlines.h"
      19             : 
      20             : #include "vm/Shape-inl.h"
      21             : 
      22             : namespace js {
      23             : 
      24           0 : ScriptCounts::ScriptCounts()
      25             :   : pcCounts_(),
      26             :     throwCounts_(),
      27           0 :     ionCounts_(nullptr)
      28             : {
      29           0 : }
      30             : 
      31         613 : ScriptCounts::ScriptCounts(PCCountsVector&& jumpTargets)
      32         613 :   : pcCounts_(Move(jumpTargets)),
      33             :     throwCounts_(),
      34         613 :     ionCounts_(nullptr)
      35             : {
      36         613 : }
      37             : 
      38           0 : ScriptCounts::ScriptCounts(ScriptCounts&& src)
      39           0 :   : pcCounts_(Move(src.pcCounts_)),
      40           0 :     throwCounts_(Move(src.throwCounts_)),
      41           0 :     ionCounts_(Move(src.ionCounts_))
      42             : {
      43           0 :     src.ionCounts_ = nullptr;
      44           0 : }
      45             : 
      46             : ScriptCounts&
      47           0 : ScriptCounts::operator=(ScriptCounts&& src)
      48             : {
      49           0 :     pcCounts_ = Move(src.pcCounts_);
      50           0 :     throwCounts_ = Move(src.throwCounts_);
      51           0 :     ionCounts_ = Move(src.ionCounts_);
      52           0 :     src.ionCounts_ = nullptr;
      53           0 :     return *this;
      54             : }
      55             : 
      56           0 : ScriptCounts::~ScriptCounts()
      57             : {
      58           0 :     js_delete(ionCounts_);
      59           0 : }
      60             : 
      61           0 : ScriptAndCounts::ScriptAndCounts(JSScript* script)
      62             :   : script(script),
      63           0 :     scriptCounts()
      64             : {
      65           0 :     script->releaseScriptCounts(&scriptCounts);
      66           0 : }
      67             : 
      68           0 : ScriptAndCounts::ScriptAndCounts(ScriptAndCounts&& sac)
      69           0 :   : script(Move(sac.script)),
      70           0 :     scriptCounts(Move(sac.scriptCounts))
      71             : {
      72           0 : }
      73             : 
      74             : void
      75             : SetFrameArgumentsObject(JSContext* cx, AbstractFramePtr frame,
      76             :                         HandleScript script, JSObject* argsobj);
      77             : 
      78             : /* static */ inline JSFunction*
      79         256 : LazyScript::functionDelazifying(JSContext* cx, Handle<LazyScript*> script)
      80             : {
      81         512 :     RootedFunction fun(cx, script->function_);
      82         256 :     if (script->function_ && !JSFunction::getOrCreateScript(cx, fun))
      83           0 :         return nullptr;
      84         256 :     return script->function_;
      85             : }
      86             : 
      87             : } // namespace js
      88             : 
      89             : inline JSFunction*
      90        2378 : JSScript::functionDelazifying() const
      91             : {
      92        2378 :     JSFunction* fun = function();
      93        2378 :     if (fun && fun->isInterpretedLazy()) {
      94           0 :         fun->setUnlazifiedScript(const_cast<JSScript*>(this));
      95             :         // If this script has a LazyScript, make sure the LazyScript has a
      96             :         // reference to the script when delazifying its canonical function.
      97           0 :         if (lazyScript && !lazyScript->maybeScript())
      98           0 :             lazyScript->initScript(const_cast<JSScript*>(this));
      99             :     }
     100        2378 :     return fun;
     101             : }
     102             : 
     103             : inline void
     104       19897 : JSScript::ensureNonLazyCanonicalFunction()
     105             : {
     106             :     // Infallibly delazify the canonical script.
     107       19897 :     JSFunction* fun = function();
     108       19897 :     if (fun && fun->isInterpretedLazy())
     109           0 :         functionDelazifying();
     110       19897 : }
     111             : 
     112             : inline JSFunction*
     113       12377 : JSScript::getFunction(size_t index)
     114             : {
     115       12377 :     JSFunction* fun = &getObject(index)->as<JSFunction>();
     116       12377 :     MOZ_ASSERT_IF(fun->isNative(), IsAsmJSModuleNative(fun->native()));
     117       12377 :     return fun;
     118             : }
     119             : 
     120             : inline js::RegExpObject*
     121             : JSScript::getRegExp(size_t index)
     122             : {
     123             :     return &getObject(index)->as<js::RegExpObject>();
     124             : }
     125             : 
     126             : inline js::RegExpObject*
     127         153 : JSScript::getRegExp(jsbytecode* pc)
     128             : {
     129         153 :     return &getObject(pc)->as<js::RegExpObject>();
     130             : }
     131             : 
     132             : inline js::GlobalObject&
     133       15127 : JSScript::global() const
     134             : {
     135             :     /*
     136             :      * A JSScript always marks its compartment's global (via bindings) so we
     137             :      * can assert that maybeGlobal is non-null here.
     138             :      */
     139       15127 :     return *compartment()->maybeGlobal();
     140             : }
     141             : 
     142             : inline js::LexicalScope*
     143       38327 : JSScript::maybeNamedLambdaScope() const
     144             : {
     145             :     // Dynamically created Functions via the 'new Function' are considered
     146             :     // named lambdas but they do not have the named lambda scope of
     147             :     // textually-created named lambdas.
     148       38327 :     js::Scope* scope = outermostScope();
     149       71920 :     if (scope->kind() == js::ScopeKind::NamedLambda ||
     150       33593 :         scope->kind() == js::ScopeKind::StrictNamedLambda)
     151             :     {
     152        6474 :         MOZ_ASSERT_IF(!strict(), scope->kind() == js::ScopeKind::NamedLambda);
     153        6474 :         MOZ_ASSERT_IF(strict(), scope->kind() == js::ScopeKind::StrictNamedLambda);
     154        6474 :         return &scope->as<js::LexicalScope>();
     155             :     }
     156       31853 :     return nullptr;
     157             : }
     158             : 
     159             : inline js::Shape*
     160       46597 : JSScript::initialEnvironmentShape() const
     161             : {
     162       46597 :     js::Scope* scope = bodyScope();
     163       46597 :     if (scope->is<js::FunctionScope>()) {
     164       43714 :         if (js::Shape* envShape = scope->environmentShape())
     165        8675 :             return envShape;
     166       35039 :         if (js::Scope* namedLambdaScope = maybeNamedLambdaScope())
     167        3188 :             return namedLambdaScope->environmentShape();
     168        2883 :     } else if (scope->is<js::EvalScope>()) {
     169          12 :         return scope->environmentShape();
     170             :     }
     171       34722 :     return nullptr;
     172             : }
     173             : 
     174             : inline JSPrincipals*
     175          64 : JSScript::principals()
     176             : {
     177          64 :     return compartment()->principals();
     178             : }
     179             : 
     180             : inline void
     181        1174 : JSScript::setBaselineScript(JSRuntime* maybeRuntime, js::jit::BaselineScript* baselineScript)
     182             : {
     183        1174 :     if (hasBaselineScript())
     184         546 :         js::jit::BaselineScript::writeBarrierPre(zone(), baseline);
     185        1174 :     MOZ_ASSERT(!hasIonScript());
     186        1174 :     baseline = baselineScript;
     187        1174 :     resetWarmUpResetCounter();
     188        1174 :     updateBaselineOrIonRaw(maybeRuntime);
     189        1174 : }
     190             : 
     191             : inline bool
     192         972 : JSScript::ensureHasAnalyzedArgsUsage(JSContext* cx)
     193             : {
     194         972 :     if (analyzedArgsUsage())
     195         837 :         return true;
     196         135 :     return js::jit::AnalyzeArgumentsUsage(cx, this);
     197             : }
     198             : 
     199             : inline bool
     200       45234 : JSScript::isDebuggee() const
     201             : {
     202       45234 :     return compartment_->debuggerObservesAllExecution() || hasDebugScript_;
     203             : }
     204             : 
     205             : #endif /* jsscriptinlines_h */

Generated by: LCOV version 1.13