|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef jit_Safepoints_h |
|
8 #define jit_Safepoints_h |
|
9 |
|
10 #include "jit/CompactBuffer.h" |
|
11 #include "jit/shared/Assembler-shared.h" |
|
12 |
|
13 namespace js { |
|
14 namespace jit { |
|
15 |
|
16 class BitSet; |
|
17 struct SafepointNunboxEntry; |
|
18 class LAllocation; |
|
19 class LSafepoint; |
|
20 |
|
21 static const uint32_t INVALID_SAFEPOINT_OFFSET = uint32_t(-1); |
|
22 |
|
23 class SafepointWriter |
|
24 { |
|
25 CompactBufferWriter stream_; |
|
26 BitSet *frameSlots_; |
|
27 |
|
28 public: |
|
29 bool init(TempAllocator &alloc, uint32_t slotCount); |
|
30 |
|
31 private: |
|
32 // A safepoint entry is written in the order these functions appear. |
|
33 uint32_t startEntry(); |
|
34 |
|
35 void writeOsiCallPointOffset(uint32_t osiPointOffset); |
|
36 void writeGcRegs(LSafepoint *safepoint); |
|
37 void writeGcSlots(LSafepoint *safepoint); |
|
38 void writeValueSlots(LSafepoint *safepoint); |
|
39 |
|
40 void writeSlotsOrElementsSlots(LSafepoint *safepoint); |
|
41 |
|
42 #ifdef JS_NUNBOX32 |
|
43 void writeNunboxParts(LSafepoint *safepoint); |
|
44 #endif |
|
45 |
|
46 void endEntry(); |
|
47 |
|
48 public: |
|
49 void encode(LSafepoint *safepoint); |
|
50 |
|
51 size_t size() const { |
|
52 return stream_.length(); |
|
53 } |
|
54 const uint8_t *buffer() const { |
|
55 return stream_.buffer(); |
|
56 } |
|
57 }; |
|
58 |
|
59 class SafepointReader |
|
60 { |
|
61 CompactBufferReader stream_; |
|
62 uint32_t frameSlots_; |
|
63 uint32_t currentSlotChunk_; |
|
64 uint32_t nextSlotChunkNumber_; |
|
65 uint32_t osiCallPointOffset_; |
|
66 GeneralRegisterSet gcSpills_; |
|
67 GeneralRegisterSet valueSpills_; |
|
68 GeneralRegisterSet slotsOrElementsSpills_; |
|
69 GeneralRegisterSet allGprSpills_; |
|
70 FloatRegisterSet allFloatSpills_; |
|
71 uint32_t nunboxSlotsRemaining_; |
|
72 uint32_t slotsOrElementsSlotsRemaining_; |
|
73 |
|
74 private: |
|
75 void advanceFromGcRegs(); |
|
76 void advanceFromGcSlots(); |
|
77 void advanceFromValueSlots(); |
|
78 void advanceFromNunboxSlots(); |
|
79 bool getSlotFromBitmap(uint32_t *slot); |
|
80 |
|
81 public: |
|
82 SafepointReader(IonScript *script, const SafepointIndex *si); |
|
83 |
|
84 static CodeLocationLabel InvalidationPatchPoint(IonScript *script, const SafepointIndex *si); |
|
85 |
|
86 uint32_t osiCallPointOffset() const { |
|
87 return osiCallPointOffset_; |
|
88 } |
|
89 GeneralRegisterSet gcSpills() const { |
|
90 return gcSpills_; |
|
91 } |
|
92 GeneralRegisterSet slotsOrElementsSpills() const { |
|
93 return slotsOrElementsSpills_; |
|
94 } |
|
95 GeneralRegisterSet valueSpills() const { |
|
96 return valueSpills_; |
|
97 } |
|
98 GeneralRegisterSet allGprSpills() const { |
|
99 return allGprSpills_; |
|
100 } |
|
101 FloatRegisterSet allFloatSpills() const { |
|
102 return allFloatSpills_; |
|
103 } |
|
104 uint32_t osiReturnPointOffset() const; |
|
105 |
|
106 // Returns true if a slot was read, false if there are no more slots. |
|
107 bool getGcSlot(uint32_t *slot); |
|
108 |
|
109 // Returns true if a slot was read, false if there are no more value slots. |
|
110 bool getValueSlot(uint32_t *slot); |
|
111 |
|
112 // Returns true if a nunbox slot was read, false if there are no more |
|
113 // nunbox slots. |
|
114 bool getNunboxSlot(LAllocation *type, LAllocation *payload); |
|
115 |
|
116 // Returns true if a slot was read, false if there are no more slots. |
|
117 bool getSlotsOrElementsSlot(uint32_t *slot); |
|
118 }; |
|
119 |
|
120 } // namespace jit |
|
121 } // namespace js |
|
122 |
|
123 #endif /* jit_Safepoints_h */ |