michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef jit_BaselineInspector_h michael@0: #define jit_BaselineInspector_h michael@0: michael@0: #ifdef JS_ION michael@0: michael@0: #include "jit/BaselineIC.h" michael@0: #include "jit/BaselineJIT.h" michael@0: #include "jit/MIR.h" michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: class BaselineInspector; michael@0: michael@0: class ICInspector michael@0: { michael@0: protected: michael@0: BaselineInspector *inspector_; michael@0: jsbytecode *pc_; michael@0: ICEntry *icEntry_; michael@0: michael@0: ICInspector(BaselineInspector *inspector, jsbytecode *pc, ICEntry *icEntry) michael@0: : inspector_(inspector), pc_(pc), icEntry_(icEntry) michael@0: { } michael@0: }; michael@0: michael@0: class SetElemICInspector : public ICInspector michael@0: { michael@0: public: michael@0: SetElemICInspector(BaselineInspector *inspector, jsbytecode *pc, ICEntry *icEntry) michael@0: : ICInspector(inspector, pc, icEntry) michael@0: { } michael@0: michael@0: bool sawOOBDenseWrite() const; michael@0: bool sawOOBTypedArrayWrite() const; michael@0: bool sawDenseWrite() const; michael@0: bool sawTypedArrayWrite() const; michael@0: }; michael@0: michael@0: class BaselineInspector michael@0: { michael@0: private: michael@0: JSScript *script; michael@0: ICEntry *prevLookedUpEntry; michael@0: michael@0: public: michael@0: BaselineInspector(JSScript *script) michael@0: : script(script), prevLookedUpEntry(nullptr) michael@0: { michael@0: JS_ASSERT(script); michael@0: } michael@0: michael@0: bool hasBaselineScript() const { michael@0: return script->hasBaselineScript(); michael@0: } michael@0: michael@0: BaselineScript *baselineScript() const { michael@0: return script->baselineScript(); michael@0: } michael@0: michael@0: private: michael@0: #ifdef DEBUG michael@0: bool isValidPC(jsbytecode *pc) { michael@0: return script->containsPC(pc); michael@0: } michael@0: #endif michael@0: michael@0: ICEntry &icEntryFromPC(jsbytecode *pc) { michael@0: JS_ASSERT(hasBaselineScript()); michael@0: JS_ASSERT(isValidPC(pc)); michael@0: ICEntry &ent = baselineScript()->icEntryFromPCOffset(script->pcToOffset(pc), prevLookedUpEntry); michael@0: JS_ASSERT(ent.isForOp()); michael@0: prevLookedUpEntry = &ent; michael@0: return ent; michael@0: } michael@0: michael@0: template michael@0: ICInspectorType makeICInspector(jsbytecode *pc, ICStub::Kind expectedFallbackKind) { michael@0: ICEntry *ent = nullptr; michael@0: if (hasBaselineScript()) { michael@0: ent = &icEntryFromPC(pc); michael@0: JS_ASSERT(ent->fallbackStub()->kind() == expectedFallbackKind); michael@0: } michael@0: return ICInspectorType(this, pc, ent); michael@0: } michael@0: michael@0: ICStub *monomorphicStub(jsbytecode *pc); michael@0: bool dimorphicStub(jsbytecode *pc, ICStub **pfirst, ICStub **psecond); michael@0: michael@0: public: michael@0: typedef Vector ShapeVector; michael@0: bool maybeShapesForPropertyOp(jsbytecode *pc, ShapeVector &shapes); michael@0: michael@0: SetElemICInspector setElemICInspector(jsbytecode *pc) { michael@0: return makeICInspector(pc, ICStub::SetElem_Fallback); michael@0: } michael@0: michael@0: MIRType expectedResultType(jsbytecode *pc); michael@0: MCompare::CompareType expectedCompareType(jsbytecode *pc); michael@0: MIRType expectedBinaryArithSpecialization(jsbytecode *pc); michael@0: michael@0: bool hasSeenNonNativeGetElement(jsbytecode *pc); michael@0: bool hasSeenNegativeIndexGetElement(jsbytecode *pc); michael@0: bool hasSeenAccessedGetter(jsbytecode *pc); michael@0: bool hasSeenDoubleResult(jsbytecode *pc); michael@0: bool hasSeenNonStringIterNext(jsbytecode *pc); michael@0: michael@0: JSObject *getTemplateObject(jsbytecode *pc); michael@0: JSObject *getTemplateObjectForNative(jsbytecode *pc, Native native); michael@0: michael@0: DeclEnvObject *templateDeclEnvObject(); michael@0: CallObject *templateCallObject(); michael@0: michael@0: JSObject *commonGetPropFunction(jsbytecode *pc, Shape **lastProperty, JSFunction **commonGetter); michael@0: JSObject *commonSetPropFunction(jsbytecode *pc, Shape **lastProperty, JSFunction **commonSetter); michael@0: }; michael@0: michael@0: } // namespace jit michael@0: } // namespace js michael@0: michael@0: #endif // JS_ION michael@0: michael@0: #endif /* jit_BaselineInspector_h */