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 10187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10198 | 10198 |
10199 // Abstract base class for visiting, and optionally modifying, the | 10199 // Abstract base class for visiting, and optionally modifying, the |
10200 // pointers contained in Objects. Used in GC and serialization/deserialization. | 10200 // pointers contained in Objects. Used in GC and serialization/deserialization. |
10201 // TODO(ulan): move to src/visitors.h | 10201 // TODO(ulan): move to src/visitors.h |
10202 class ObjectVisitor BASE_EMBEDDED { | 10202 class ObjectVisitor BASE_EMBEDDED { |
10203 public: | 10203 public: |
10204 virtual ~ObjectVisitor() {} | 10204 virtual ~ObjectVisitor() {} |
10205 | 10205 |
10206 // Visits a contiguous arrays of pointers in the half-open range | 10206 // Visits a contiguous arrays of pointers in the half-open range |
10207 // [start, end). Any or all of the values may be modified on return. | 10207 // [start, end). Any or all of the values may be modified on return. |
10208 virtual void VisitPointers(Object** start, Object** end) = 0; | 10208 virtual void VisitPointers(HeapObject* host, Object** start, |
| 10209 Object** end) = 0; |
10209 | 10210 |
10210 // Handy shorthand for visiting a single pointer. | 10211 // Handy shorthand for visiting a single pointer. |
10211 virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); } | 10212 virtual void VisitPointer(HeapObject* host, Object** p) { |
| 10213 VisitPointers(host, p, p + 1); |
| 10214 } |
10212 | 10215 |
10213 // Visit weak next_code_link in Code object. | 10216 // Visit weak next_code_link in Code object. |
10214 virtual void VisitNextCodeLink(Object** p) { VisitPointers(p, p + 1); } | 10217 virtual void VisitNextCodeLink(Code* host, Object** p) { |
| 10218 VisitPointers(host, p, p + 1); |
| 10219 } |
10215 | 10220 |
10216 // To allow lazy clearing of inline caches the visitor has | 10221 // To allow lazy clearing of inline caches the visitor has |
10217 // a rich interface for iterating over Code objects.. | 10222 // a rich interface for iterating over Code objects.. |
10218 | 10223 |
10219 // Visits a code target in the instruction stream. | 10224 // Visits a code target in the instruction stream. |
10220 virtual void VisitCodeTarget(RelocInfo* rinfo); | 10225 virtual void VisitCodeTarget(Code* host, RelocInfo* rinfo); |
10221 | 10226 |
10222 // Visits a code entry in a JS function. | 10227 // Visits a code entry in a JS function. |
10223 virtual void VisitCodeEntry(Address entry_address); | 10228 virtual void VisitCodeEntry(JSFunction* host, Address entry_address); |
10224 | 10229 |
10225 // Visits a global property cell reference in the instruction stream. | 10230 // Visits a global property cell reference in the instruction stream. |
10226 virtual void VisitCell(RelocInfo* rinfo); | 10231 virtual void VisitCellPointer(Code* host, RelocInfo* rinfo); |
10227 | 10232 |
10228 // Visits a runtime entry in the instruction stream. | 10233 // Visits a runtime entry in the instruction stream. |
10229 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {} | 10234 virtual void VisitRuntimeEntry(Code* host, RelocInfo* rinfo) {} |
10230 | 10235 |
10231 // Visits a debug call target in the instruction stream. | 10236 // Visits a debug call target in the instruction stream. |
10232 virtual void VisitDebugTarget(RelocInfo* rinfo); | 10237 virtual void VisitDebugTarget(Code* host, RelocInfo* rinfo); |
10233 | 10238 |
10234 // Visits the byte sequence in a function's prologue that contains information | 10239 // Visits the byte sequence in a function's prologue that contains information |
10235 // about the code's age. | 10240 // about the code's age. |
10236 virtual void VisitCodeAgeSequence(RelocInfo* rinfo); | 10241 virtual void VisitCodeAgeSequence(Code* host, RelocInfo* rinfo); |
10237 | 10242 |
10238 // Visit pointer embedded into a code object. | 10243 // Visit pointer embedded into a code object. |
10239 virtual void VisitEmbeddedPointer(RelocInfo* rinfo); | 10244 virtual void VisitEmbeddedPointer(Code* host, RelocInfo* rinfo); |
10240 | 10245 |
10241 // Visits an external reference embedded into a code object. | 10246 // Visits an external reference embedded into a code object. |
10242 virtual void VisitExternalReference(RelocInfo* rinfo); | 10247 virtual void VisitExternalReference(Code* host, RelocInfo* rinfo) {} |
10243 | 10248 |
10244 // Visits an external reference. | 10249 // Visits an external reference. |
10245 virtual void VisitExternalReference(Address* p) {} | 10250 virtual void VisitExternalReference(Foreign* host, Address* p) {} |
10246 | 10251 |
10247 // Visits an (encoded) internal reference. | 10252 // Visits an (encoded) internal reference. |
10248 virtual void VisitInternalReference(RelocInfo* rinfo) {} | 10253 virtual void VisitInternalReference(Code* host, RelocInfo* rinfo) {} |
10249 }; | 10254 }; |
10250 | 10255 |
10251 | 10256 |
10252 // BooleanBit is a helper class for setting and getting a bit in an integer. | 10257 // BooleanBit is a helper class for setting and getting a bit in an integer. |
10253 class BooleanBit : public AllStatic { | 10258 class BooleanBit : public AllStatic { |
10254 public: | 10259 public: |
10255 static inline bool get(int value, int bit_position) { | 10260 static inline bool get(int value, int bit_position) { |
10256 return (value & (1 << bit_position)) != 0; | 10261 return (value & (1 << bit_position)) != 0; |
10257 } | 10262 } |
10258 | 10263 |
10259 static inline int set(int value, int bit_position, bool v) { | 10264 static inline int set(int value, int bit_position, bool v) { |
10260 if (v) { | 10265 if (v) { |
10261 value |= (1 << bit_position); | 10266 value |= (1 << bit_position); |
10262 } else { | 10267 } else { |
10263 value &= ~(1 << bit_position); | 10268 value &= ~(1 << bit_position); |
10264 } | 10269 } |
10265 return value; | 10270 return value; |
10266 } | 10271 } |
10267 }; | 10272 }; |
10268 | 10273 |
10269 | 10274 |
10270 } // NOLINT, false-positive due to second-order macros. | 10275 } // NOLINT, false-positive due to second-order macros. |
10271 } // NOLINT, false-positive due to second-order macros. | 10276 } // NOLINT, false-positive due to second-order macros. |
10272 | 10277 |
10273 #include "src/objects/object-macros-undef.h" | 10278 #include "src/objects/object-macros-undef.h" |
10274 | 10279 |
10275 #endif // V8_OBJECTS_H_ | 10280 #endif // V8_OBJECTS_H_ |
OLD | NEW |