| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 private: | 1497 private: |
| 1498 // HeapObject calls the private constructor and directly reads the value. | 1498 // HeapObject calls the private constructor and directly reads the value. |
| 1499 friend class HeapObject; | 1499 friend class HeapObject; |
| 1500 | 1500 |
| 1501 explicit MapWord(uintptr_t value) : value_(value) {} | 1501 explicit MapWord(uintptr_t value) : value_(value) {} |
| 1502 | 1502 |
| 1503 uintptr_t value_; | 1503 uintptr_t value_; |
| 1504 }; | 1504 }; |
| 1505 | 1505 |
| 1506 | 1506 |
| 1507 // The content of an heap object (except for the map pointer). kTaggedValues | |
| 1508 // objects can contain both heap pointers and Smis, kMixedValues can contain | |
| 1509 // heap pointers, Smis, and raw values (e.g. doubles or strings), and kRawValues | |
| 1510 // objects can contain raw values and Smis. | |
| 1511 enum class HeapObjectContents { kTaggedValues, kMixedValues, kRawValues }; | |
| 1512 | |
| 1513 | |
| 1514 // HeapObject is the superclass for all classes describing heap allocated | 1507 // HeapObject is the superclass for all classes describing heap allocated |
| 1515 // objects. | 1508 // objects. |
| 1516 class HeapObject: public Object { | 1509 class HeapObject: public Object { |
| 1517 public: | 1510 public: |
| 1518 // [map]: Contains a map which contains the object's reflective | 1511 // [map]: Contains a map which contains the object's reflective |
| 1519 // information. | 1512 // information. |
| 1520 inline Map* map() const; | 1513 inline Map* map() const; |
| 1521 inline void set_map(Map* value); | 1514 inline void set_map(Map* value); |
| 1522 // The no-write-barrier version. This is OK if the object is white and in | 1515 // The no-write-barrier version. This is OK if the object is white and in |
| 1523 // new space, or if the value is an immortal immutable object, like the maps | 1516 // new space, or if the value is an immortal immutable object, like the maps |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 ObjectVisitor* v); | 1573 ObjectVisitor* v); |
| 1581 | 1574 |
| 1582 // Returns true if the object contains a tagged value at given offset. | 1575 // Returns true if the object contains a tagged value at given offset. |
| 1583 // It is used for invalid slots filtering. If the offset points outside | 1576 // It is used for invalid slots filtering. If the offset points outside |
| 1584 // of the object or to the map word, the result is UNDEFINED (!!!). | 1577 // of the object or to the map word, the result is UNDEFINED (!!!). |
| 1585 bool IsValidSlot(int offset); | 1578 bool IsValidSlot(int offset); |
| 1586 | 1579 |
| 1587 // Returns the heap object's size in bytes | 1580 // Returns the heap object's size in bytes |
| 1588 inline int Size(); | 1581 inline int Size(); |
| 1589 | 1582 |
| 1590 // Indicates what type of values this heap object may contain. | |
| 1591 inline HeapObjectContents ContentType(); | |
| 1592 | |
| 1593 // Given a heap object's map pointer, returns the heap size in bytes | 1583 // Given a heap object's map pointer, returns the heap size in bytes |
| 1594 // Useful when the map pointer field is used for other purposes. | 1584 // Useful when the map pointer field is used for other purposes. |
| 1595 // GC internal. | 1585 // GC internal. |
| 1596 inline int SizeFromMap(Map* map); | 1586 inline int SizeFromMap(Map* map); |
| 1597 | 1587 |
| 1598 // Returns the field at offset in obj, as a read/write Object* reference. | 1588 // Returns the field at offset in obj, as a read/write Object* reference. |
| 1599 // Does no checking, and is safe to use during GC, while maps are invalid. | 1589 // Does no checking, and is safe to use during GC, while maps are invalid. |
| 1600 // Does not invoke write barrier, so should only be assigned to | 1590 // Does not invoke write barrier, so should only be assigned to |
| 1601 // during marking GC. | 1591 // during marking GC. |
| 1602 static inline Object** RawField(HeapObject* obj, int offset); | 1592 static inline Object** RawField(HeapObject* obj, int offset); |
| (...skipping 9105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10708 } | 10698 } |
| 10709 return value; | 10699 return value; |
| 10710 } | 10700 } |
| 10711 }; | 10701 }; |
| 10712 | 10702 |
| 10713 | 10703 |
| 10714 } // NOLINT, false-positive due to second-order macros. | 10704 } // NOLINT, false-positive due to second-order macros. |
| 10715 } // NOLINT, false-positive due to second-order macros. | 10705 } // NOLINT, false-positive due to second-order macros. |
| 10716 | 10706 |
| 10717 #endif // V8_OBJECTS_H_ | 10707 #endif // V8_OBJECTS_H_ |
| OLD | NEW |