1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit/Safepoints.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,123 @@ 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_Safepoints_h 1.11 +#define jit_Safepoints_h 1.12 + 1.13 +#include "jit/CompactBuffer.h" 1.14 +#include "jit/shared/Assembler-shared.h" 1.15 + 1.16 +namespace js { 1.17 +namespace jit { 1.18 + 1.19 +class BitSet; 1.20 +struct SafepointNunboxEntry; 1.21 +class LAllocation; 1.22 +class LSafepoint; 1.23 + 1.24 +static const uint32_t INVALID_SAFEPOINT_OFFSET = uint32_t(-1); 1.25 + 1.26 +class SafepointWriter 1.27 +{ 1.28 + CompactBufferWriter stream_; 1.29 + BitSet *frameSlots_; 1.30 + 1.31 + public: 1.32 + bool init(TempAllocator &alloc, uint32_t slotCount); 1.33 + 1.34 + private: 1.35 + // A safepoint entry is written in the order these functions appear. 1.36 + uint32_t startEntry(); 1.37 + 1.38 + void writeOsiCallPointOffset(uint32_t osiPointOffset); 1.39 + void writeGcRegs(LSafepoint *safepoint); 1.40 + void writeGcSlots(LSafepoint *safepoint); 1.41 + void writeValueSlots(LSafepoint *safepoint); 1.42 + 1.43 + void writeSlotsOrElementsSlots(LSafepoint *safepoint); 1.44 + 1.45 +#ifdef JS_NUNBOX32 1.46 + void writeNunboxParts(LSafepoint *safepoint); 1.47 +#endif 1.48 + 1.49 + void endEntry(); 1.50 + 1.51 + public: 1.52 + void encode(LSafepoint *safepoint); 1.53 + 1.54 + size_t size() const { 1.55 + return stream_.length(); 1.56 + } 1.57 + const uint8_t *buffer() const { 1.58 + return stream_.buffer(); 1.59 + } 1.60 +}; 1.61 + 1.62 +class SafepointReader 1.63 +{ 1.64 + CompactBufferReader stream_; 1.65 + uint32_t frameSlots_; 1.66 + uint32_t currentSlotChunk_; 1.67 + uint32_t nextSlotChunkNumber_; 1.68 + uint32_t osiCallPointOffset_; 1.69 + GeneralRegisterSet gcSpills_; 1.70 + GeneralRegisterSet valueSpills_; 1.71 + GeneralRegisterSet slotsOrElementsSpills_; 1.72 + GeneralRegisterSet allGprSpills_; 1.73 + FloatRegisterSet allFloatSpills_; 1.74 + uint32_t nunboxSlotsRemaining_; 1.75 + uint32_t slotsOrElementsSlotsRemaining_; 1.76 + 1.77 + private: 1.78 + void advanceFromGcRegs(); 1.79 + void advanceFromGcSlots(); 1.80 + void advanceFromValueSlots(); 1.81 + void advanceFromNunboxSlots(); 1.82 + bool getSlotFromBitmap(uint32_t *slot); 1.83 + 1.84 + public: 1.85 + SafepointReader(IonScript *script, const SafepointIndex *si); 1.86 + 1.87 + static CodeLocationLabel InvalidationPatchPoint(IonScript *script, const SafepointIndex *si); 1.88 + 1.89 + uint32_t osiCallPointOffset() const { 1.90 + return osiCallPointOffset_; 1.91 + } 1.92 + GeneralRegisterSet gcSpills() const { 1.93 + return gcSpills_; 1.94 + } 1.95 + GeneralRegisterSet slotsOrElementsSpills() const { 1.96 + return slotsOrElementsSpills_; 1.97 + } 1.98 + GeneralRegisterSet valueSpills() const { 1.99 + return valueSpills_; 1.100 + } 1.101 + GeneralRegisterSet allGprSpills() const { 1.102 + return allGprSpills_; 1.103 + } 1.104 + FloatRegisterSet allFloatSpills() const { 1.105 + return allFloatSpills_; 1.106 + } 1.107 + uint32_t osiReturnPointOffset() const; 1.108 + 1.109 + // Returns true if a slot was read, false if there are no more slots. 1.110 + bool getGcSlot(uint32_t *slot); 1.111 + 1.112 + // Returns true if a slot was read, false if there are no more value slots. 1.113 + bool getValueSlot(uint32_t *slot); 1.114 + 1.115 + // Returns true if a nunbox slot was read, false if there are no more 1.116 + // nunbox slots. 1.117 + bool getNunboxSlot(LAllocation *type, LAllocation *payload); 1.118 + 1.119 + // Returns true if a slot was read, false if there are no more slots. 1.120 + bool getSlotsOrElementsSlot(uint32_t *slot); 1.121 +}; 1.122 + 1.123 +} // namespace jit 1.124 +} // namespace js 1.125 + 1.126 +#endif /* jit_Safepoints_h */