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_BaselineDebugModeOSR_h michael@0: #define jit_BaselineDebugModeOSR_h michael@0: michael@0: #ifdef JS_ION michael@0: michael@0: #include "jit/BaselineFrame.h" michael@0: #include "jit/BaselineIC.h" michael@0: #include "jit/BaselineJIT.h" michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: // Note that this file and the corresponding .cpp implement debug mode michael@0: // on-stack recompilation. This is to be distinguished from ordinary michael@0: // Baseline->Ion OSR, which is used to jump into compiled loops. michael@0: michael@0: // michael@0: // A volatile location due to recompilation of an on-stack baseline script michael@0: // (e.g., for debug mode toggling). michael@0: // michael@0: // It is usually used in fallback stubs which may trigger on-stack michael@0: // recompilation by calling out into the VM. Example use: michael@0: // michael@0: // DebugModeOSRVolatileStub stub(frame, stub_) michael@0: // michael@0: // // Call out to the VM michael@0: // // Other effectful operations like TypeScript::Monitor michael@0: // michael@0: // if (stub.invalid()) michael@0: // return true; michael@0: // michael@0: // // First use of stub after VM call. michael@0: // michael@0: template michael@0: class DebugModeOSRVolatileStub michael@0: { michael@0: T stub_; michael@0: BaselineFrame *frame_; michael@0: uint32_t pcOffset_; michael@0: michael@0: public: michael@0: DebugModeOSRVolatileStub(BaselineFrame *frame, ICFallbackStub *stub) michael@0: : stub_(static_cast(stub)), michael@0: frame_(frame), michael@0: pcOffset_(stub->icEntry()->pcOffset()) michael@0: { } michael@0: michael@0: bool invalid() const { michael@0: ICEntry &entry = frame_->script()->baselineScript()->icEntryFromPCOffset(pcOffset_); michael@0: return stub_ != entry.fallbackStub(); michael@0: } michael@0: michael@0: operator const T&() const { MOZ_ASSERT(!invalid()); return stub_; } michael@0: T operator->() const { MOZ_ASSERT(!invalid()); return stub_; } michael@0: T *address() { MOZ_ASSERT(!invalid()); return &stub_; } michael@0: const T *address() const { MOZ_ASSERT(!invalid()); return &stub_; } michael@0: T &get() { MOZ_ASSERT(!invalid()); return stub_; } michael@0: const T &get() const { MOZ_ASSERT(!invalid()); return stub_; } michael@0: michael@0: bool operator!=(const T &other) const { MOZ_ASSERT(!invalid()); return stub_ != other; } michael@0: bool operator==(const T &other) const { MOZ_ASSERT(!invalid()); return stub_ == other; } michael@0: }; michael@0: michael@0: // michael@0: // Auxiliary info to help the DebugModeOSRHandler fix up state. michael@0: // michael@0: struct BaselineDebugModeOSRInfo michael@0: { michael@0: uint8_t *resumeAddr; michael@0: jsbytecode *pc; michael@0: PCMappingSlotInfo slotInfo; michael@0: ICEntry::Kind frameKind; michael@0: michael@0: // Filled in by SyncBaselineDebugModeOSRInfo. michael@0: uintptr_t stackAdjust; michael@0: Value valueR0; michael@0: Value valueR1; michael@0: michael@0: BaselineDebugModeOSRInfo(jsbytecode *pc, ICEntry::Kind kind) michael@0: : resumeAddr(nullptr), michael@0: pc(pc), michael@0: slotInfo(0), michael@0: frameKind(kind), michael@0: stackAdjust(0), michael@0: valueR0(UndefinedValue()), michael@0: valueR1(UndefinedValue()) michael@0: { } michael@0: michael@0: void popValueInto(PCMappingSlotInfo::SlotLocation loc, Value *vp); michael@0: }; michael@0: michael@0: bool michael@0: RecompileOnStackBaselineScriptsForDebugMode(JSContext *cx, JSCompartment *comp); michael@0: michael@0: } // namespace jit michael@0: } // namespace js michael@0: michael@0: #endif // JS_ION michael@0: michael@0: #endif // jit_BaselineDebugModeOSR_h