OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 10133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10144 | 10144 |
10145 // Abstract base class for visiting, and optionally modifying, the | 10145 // Abstract base class for visiting, and optionally modifying, the |
10146 // pointers contained in Objects. Used in GC and serialization/deserialization. | 10146 // pointers contained in Objects. Used in GC and serialization/deserialization. |
10147 // TODO(ulan): move to src/visitors.h | 10147 // TODO(ulan): move to src/visitors.h |
10148 class ObjectVisitor BASE_EMBEDDED { | 10148 class ObjectVisitor BASE_EMBEDDED { |
10149 public: | 10149 public: |
10150 virtual ~ObjectVisitor() {} | 10150 virtual ~ObjectVisitor() {} |
10151 | 10151 |
10152 // Visits a contiguous arrays of pointers in the half-open range | 10152 // Visits a contiguous arrays of pointers in the half-open range |
10153 // [start, end). Any or all of the values may be modified on return. | 10153 // [start, end). Any or all of the values may be modified on return. |
10154 virtual void VisitPointers(Object** start, Object** end) = 0; | 10154 virtual void VisitPointers(HeapObject* host, Object** start, |
| 10155 Object** end) = 0; |
10155 | 10156 |
10156 // Handy shorthand for visiting a single pointer. | 10157 // Handy shorthand for visiting a single pointer. |
10157 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } | 10158 virtual void VisitPointer(HeapObject* host, Object** p) { |
| 10159 VisitPointers(host, p, p + 1); |
| 10160 } |
10158 | 10161 |
10159 // Visit weak next_code_link in Code object. | 10162 // Visit weak next_code_link in Code object. |
10160 virtual void VisitNextCodeLink(Object** p) { VisitPointers(p, p + 1); } | 10163 virtual void VisitNextCodeLink(Code* host, Object** p) { |
| 10164 VisitPointers(host, p, p + 1); |
| 10165 } |
10161 | 10166 |
10162 // To allow lazy clearing of inline caches the visitor has | 10167 // To allow lazy clearing of inline caches the visitor has |
10163 // a rich interface for iterating over Code objects.. | 10168 // a rich interface for iterating over Code objects.. |
10164 | 10169 |
10165 // Visits a code target in the instruction stream. | 10170 // Visits a code target in the instruction stream. |
10166 virtual void VisitCodeTarget(RelocInfo* rinfo); | 10171 virtual void VisitCodeTarget(Code* host, RelocInfo* rinfo); |
10167 | 10172 |
10168 // Visits a code entry in a JS function. | 10173 // Visits a code entry in a JS function. |
10169 virtual void VisitCodeEntry(Address entry_address); | 10174 virtual void VisitCodeEntry(JSFunction* host, Address entry_address); |
10170 | 10175 |
10171 // Visits a global property cell reference in the instruction stream. | 10176 // Visits a global property cell reference in the instruction stream. |
10172 virtual void VisitCell(RelocInfo* rinfo); | 10177 virtual void VisitCell(Code* host, RelocInfo* rinfo); |
10173 | 10178 |
10174 // Visits a runtime entry in the instruction stream. | 10179 // Visits a runtime entry in the instruction stream. |
10175 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {} | 10180 virtual void VisitRuntimeEntry(Code* host, RelocInfo* rinfo) {} |
10176 | 10181 |
10177 // Visits a debug call target in the instruction stream. | 10182 // Visits a debug call target in the instruction stream. |
10178 virtual void VisitDebugTarget(RelocInfo* rinfo); | 10183 virtual void VisitDebugTarget(Code* host, RelocInfo* rinfo); |
10179 | 10184 |
10180 // Visits the byte sequence in a function's prologue that contains information | 10185 // Visits the byte sequence in a function's prologue that contains information |
10181 // about the code's age. | 10186 // about the code's age. |
10182 virtual void VisitCodeAgeSequence(RelocInfo* rinfo); | 10187 virtual void VisitCodeAgeSequence(Code* host, RelocInfo* rinfo); |
10183 | 10188 |
10184 // Visit pointer embedded into a code object. | 10189 // Visit pointer embedded into a code object. |
10185 virtual void VisitEmbeddedPointer(RelocInfo* rinfo); | 10190 virtual void VisitEmbeddedPointer(Code* host, RelocInfo* rinfo); |
10186 | 10191 |
10187 // Visits an external reference embedded into a code object. | 10192 // Visits an external reference embedded into a code object. |
10188 virtual void VisitExternalReference(RelocInfo* rinfo); | 10193 virtual void VisitExternalReference(Code* host, RelocInfo* rinfo) {} |
10189 | 10194 |
10190 // Visits an external reference. | 10195 // Visits an external reference. |
10191 virtual void VisitExternalReference(Address* p) {} | 10196 virtual void VisitExternalReference(Foreign* host, Address* p) {} |
10192 | 10197 |
10193 // Visits an (encoded) internal reference. | 10198 // Visits an (encoded) internal reference. |
10194 virtual void VisitInternalReference(RelocInfo* rinfo) {} | 10199 virtual void VisitInternalReference(Code* host, RelocInfo* rinfo) {} |
10195 }; | 10200 }; |
10196 | 10201 |
10197 | 10202 |
10198 // BooleanBit is a helper class for setting and getting a bit in an integer. | 10203 // BooleanBit is a helper class for setting and getting a bit in an integer. |
10199 class BooleanBit : public AllStatic { | 10204 class BooleanBit : public AllStatic { |
10200 public: | 10205 public: |
10201 static inline bool get(int value, int bit_position) { | 10206 static inline bool get(int value, int bit_position) { |
10202 return (value & (1 << bit_position)) != 0; | 10207 return (value & (1 << bit_position)) != 0; |
10203 } | 10208 } |
10204 | 10209 |
10205 static inline int set(int value, int bit_position, bool v) { | 10210 static inline int set(int value, int bit_position, bool v) { |
10206 if (v) { | 10211 if (v) { |
10207 value |= (1 << bit_position); | 10212 value |= (1 << bit_position); |
10208 } else { | 10213 } else { |
10209 value &= ~(1 << bit_position); | 10214 value &= ~(1 << bit_position); |
10210 } | 10215 } |
10211 return value; | 10216 return value; |
10212 } | 10217 } |
10213 }; | 10218 }; |
10214 | 10219 |
10215 | 10220 |
10216 } // NOLINT, false-positive due to second-order macros. | 10221 } // NOLINT, false-positive due to second-order macros. |
10217 } // NOLINT, false-positive due to second-order macros. | 10222 } // NOLINT, false-positive due to second-order macros. |
10218 | 10223 |
10219 #include "src/objects/object-macros-undef.h" | 10224 #include "src/objects/object-macros-undef.h" |
10220 | 10225 |
10221 #endif // V8_OBJECTS_H_ | 10226 #endif // V8_OBJECTS_H_ |
OLD | NEW |