js/src/jit/BaselineInspector.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit/BaselineInspector.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,129 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef jit_BaselineInspector_h
    1.11 +#define jit_BaselineInspector_h
    1.12 +
    1.13 +#ifdef JS_ION
    1.14 +
    1.15 +#include "jit/BaselineIC.h"
    1.16 +#include "jit/BaselineJIT.h"
    1.17 +#include "jit/MIR.h"
    1.18 +
    1.19 +namespace js {
    1.20 +namespace jit {
    1.21 +
    1.22 +class BaselineInspector;
    1.23 +
    1.24 +class ICInspector
    1.25 +{
    1.26 +  protected:
    1.27 +    BaselineInspector *inspector_;
    1.28 +    jsbytecode *pc_;
    1.29 +    ICEntry *icEntry_;
    1.30 +
    1.31 +    ICInspector(BaselineInspector *inspector, jsbytecode *pc, ICEntry *icEntry)
    1.32 +      : inspector_(inspector), pc_(pc), icEntry_(icEntry)
    1.33 +    { }
    1.34 +};
    1.35 +
    1.36 +class SetElemICInspector : public ICInspector
    1.37 +{
    1.38 +  public:
    1.39 +    SetElemICInspector(BaselineInspector *inspector, jsbytecode *pc, ICEntry *icEntry)
    1.40 +      : ICInspector(inspector, pc, icEntry)
    1.41 +    { }
    1.42 +
    1.43 +    bool sawOOBDenseWrite() const;
    1.44 +    bool sawOOBTypedArrayWrite() const;
    1.45 +    bool sawDenseWrite() const;
    1.46 +    bool sawTypedArrayWrite() const;
    1.47 +};
    1.48 +
    1.49 +class BaselineInspector
    1.50 +{
    1.51 +  private:
    1.52 +    JSScript *script;
    1.53 +    ICEntry *prevLookedUpEntry;
    1.54 +
    1.55 +  public:
    1.56 +    BaselineInspector(JSScript *script)
    1.57 +      : script(script), prevLookedUpEntry(nullptr)
    1.58 +    {
    1.59 +        JS_ASSERT(script);
    1.60 +    }
    1.61 +
    1.62 +    bool hasBaselineScript() const {
    1.63 +        return script->hasBaselineScript();
    1.64 +    }
    1.65 +
    1.66 +    BaselineScript *baselineScript() const {
    1.67 +        return script->baselineScript();
    1.68 +    }
    1.69 +
    1.70 +  private:
    1.71 +#ifdef DEBUG
    1.72 +    bool isValidPC(jsbytecode *pc) {
    1.73 +        return script->containsPC(pc);
    1.74 +    }
    1.75 +#endif
    1.76 +
    1.77 +    ICEntry &icEntryFromPC(jsbytecode *pc) {
    1.78 +        JS_ASSERT(hasBaselineScript());
    1.79 +        JS_ASSERT(isValidPC(pc));
    1.80 +        ICEntry &ent = baselineScript()->icEntryFromPCOffset(script->pcToOffset(pc), prevLookedUpEntry);
    1.81 +        JS_ASSERT(ent.isForOp());
    1.82 +        prevLookedUpEntry = &ent;
    1.83 +        return ent;
    1.84 +    }
    1.85 +
    1.86 +    template <typename ICInspectorType>
    1.87 +    ICInspectorType makeICInspector(jsbytecode *pc, ICStub::Kind expectedFallbackKind) {
    1.88 +        ICEntry *ent = nullptr;
    1.89 +        if (hasBaselineScript()) {
    1.90 +            ent = &icEntryFromPC(pc);
    1.91 +            JS_ASSERT(ent->fallbackStub()->kind() == expectedFallbackKind);
    1.92 +        }
    1.93 +        return ICInspectorType(this, pc, ent);
    1.94 +    }
    1.95 +
    1.96 +    ICStub *monomorphicStub(jsbytecode *pc);
    1.97 +    bool dimorphicStub(jsbytecode *pc, ICStub **pfirst, ICStub **psecond);
    1.98 +
    1.99 +  public:
   1.100 +    typedef Vector<Shape *, 4, IonAllocPolicy> ShapeVector;
   1.101 +    bool maybeShapesForPropertyOp(jsbytecode *pc, ShapeVector &shapes);
   1.102 +
   1.103 +    SetElemICInspector setElemICInspector(jsbytecode *pc) {
   1.104 +        return makeICInspector<SetElemICInspector>(pc, ICStub::SetElem_Fallback);
   1.105 +    }
   1.106 +
   1.107 +    MIRType expectedResultType(jsbytecode *pc);
   1.108 +    MCompare::CompareType expectedCompareType(jsbytecode *pc);
   1.109 +    MIRType expectedBinaryArithSpecialization(jsbytecode *pc);
   1.110 +
   1.111 +    bool hasSeenNonNativeGetElement(jsbytecode *pc);
   1.112 +    bool hasSeenNegativeIndexGetElement(jsbytecode *pc);
   1.113 +    bool hasSeenAccessedGetter(jsbytecode *pc);
   1.114 +    bool hasSeenDoubleResult(jsbytecode *pc);
   1.115 +    bool hasSeenNonStringIterNext(jsbytecode *pc);
   1.116 +
   1.117 +    JSObject *getTemplateObject(jsbytecode *pc);
   1.118 +    JSObject *getTemplateObjectForNative(jsbytecode *pc, Native native);
   1.119 +
   1.120 +    DeclEnvObject *templateDeclEnvObject();
   1.121 +    CallObject *templateCallObject();
   1.122 +
   1.123 +    JSObject *commonGetPropFunction(jsbytecode *pc, Shape **lastProperty, JSFunction **commonGetter);
   1.124 +    JSObject *commonSetPropFunction(jsbytecode *pc, Shape **lastProperty, JSFunction **commonSetter);
   1.125 +};
   1.126 +
   1.127 +} // namespace jit
   1.128 +} // namespace js
   1.129 +
   1.130 +#endif // JS_ION
   1.131 +
   1.132 +#endif /* jit_BaselineInspector_h */

mercurial