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_Safepoints_h michael@0: #define jit_Safepoints_h michael@0: michael@0: #include "jit/CompactBuffer.h" michael@0: #include "jit/shared/Assembler-shared.h" michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: class BitSet; michael@0: struct SafepointNunboxEntry; michael@0: class LAllocation; michael@0: class LSafepoint; michael@0: michael@0: static const uint32_t INVALID_SAFEPOINT_OFFSET = uint32_t(-1); michael@0: michael@0: class SafepointWriter michael@0: { michael@0: CompactBufferWriter stream_; michael@0: BitSet *frameSlots_; michael@0: michael@0: public: michael@0: bool init(TempAllocator &alloc, uint32_t slotCount); michael@0: michael@0: private: michael@0: // A safepoint entry is written in the order these functions appear. michael@0: uint32_t startEntry(); michael@0: michael@0: void writeOsiCallPointOffset(uint32_t osiPointOffset); michael@0: void writeGcRegs(LSafepoint *safepoint); michael@0: void writeGcSlots(LSafepoint *safepoint); michael@0: void writeValueSlots(LSafepoint *safepoint); michael@0: michael@0: void writeSlotsOrElementsSlots(LSafepoint *safepoint); michael@0: michael@0: #ifdef JS_NUNBOX32 michael@0: void writeNunboxParts(LSafepoint *safepoint); michael@0: #endif michael@0: michael@0: void endEntry(); michael@0: michael@0: public: michael@0: void encode(LSafepoint *safepoint); michael@0: michael@0: size_t size() const { michael@0: return stream_.length(); michael@0: } michael@0: const uint8_t *buffer() const { michael@0: return stream_.buffer(); michael@0: } michael@0: }; michael@0: michael@0: class SafepointReader michael@0: { michael@0: CompactBufferReader stream_; michael@0: uint32_t frameSlots_; michael@0: uint32_t currentSlotChunk_; michael@0: uint32_t nextSlotChunkNumber_; michael@0: uint32_t osiCallPointOffset_; michael@0: GeneralRegisterSet gcSpills_; michael@0: GeneralRegisterSet valueSpills_; michael@0: GeneralRegisterSet slotsOrElementsSpills_; michael@0: GeneralRegisterSet allGprSpills_; michael@0: FloatRegisterSet allFloatSpills_; michael@0: uint32_t nunboxSlotsRemaining_; michael@0: uint32_t slotsOrElementsSlotsRemaining_; michael@0: michael@0: private: michael@0: void advanceFromGcRegs(); michael@0: void advanceFromGcSlots(); michael@0: void advanceFromValueSlots(); michael@0: void advanceFromNunboxSlots(); michael@0: bool getSlotFromBitmap(uint32_t *slot); michael@0: michael@0: public: michael@0: SafepointReader(IonScript *script, const SafepointIndex *si); michael@0: michael@0: static CodeLocationLabel InvalidationPatchPoint(IonScript *script, const SafepointIndex *si); michael@0: michael@0: uint32_t osiCallPointOffset() const { michael@0: return osiCallPointOffset_; michael@0: } michael@0: GeneralRegisterSet gcSpills() const { michael@0: return gcSpills_; michael@0: } michael@0: GeneralRegisterSet slotsOrElementsSpills() const { michael@0: return slotsOrElementsSpills_; michael@0: } michael@0: GeneralRegisterSet valueSpills() const { michael@0: return valueSpills_; michael@0: } michael@0: GeneralRegisterSet allGprSpills() const { michael@0: return allGprSpills_; michael@0: } michael@0: FloatRegisterSet allFloatSpills() const { michael@0: return allFloatSpills_; michael@0: } michael@0: uint32_t osiReturnPointOffset() const; michael@0: michael@0: // Returns true if a slot was read, false if there are no more slots. michael@0: bool getGcSlot(uint32_t *slot); michael@0: michael@0: // Returns true if a slot was read, false if there are no more value slots. michael@0: bool getValueSlot(uint32_t *slot); michael@0: michael@0: // Returns true if a nunbox slot was read, false if there are no more michael@0: // nunbox slots. michael@0: bool getNunboxSlot(LAllocation *type, LAllocation *payload); michael@0: michael@0: // Returns true if a slot was read, false if there are no more slots. michael@0: bool getSlotsOrElementsSlot(uint32_t *slot); michael@0: }; michael@0: michael@0: } // namespace jit michael@0: } // namespace js michael@0: michael@0: #endif /* jit_Safepoints_h */