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 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 private: | 1392 private: |
1393 // HeapObject calls the private constructor and directly reads the value. | 1393 // HeapObject calls the private constructor and directly reads the value. |
1394 friend class HeapObject; | 1394 friend class HeapObject; |
1395 | 1395 |
1396 explicit MapWord(uintptr_t value) : value_(value) {} | 1396 explicit MapWord(uintptr_t value) : value_(value) {} |
1397 | 1397 |
1398 uintptr_t value_; | 1398 uintptr_t value_; |
1399 }; | 1399 }; |
1400 | 1400 |
1401 | 1401 |
| 1402 // The content of an heap object (except for the map pointer). kTaggedValues |
| 1403 // objects can contain both heap pointers and Smis, kMixedValues can contain |
| 1404 // heap pointers, Smis, and raw values (e.g. doubles or strings), and kRawValues |
| 1405 // objects can contain raw values and Smis. |
| 1406 enum class HeapObjectContents { kTaggedValues, kMixedValues, kRawValues }; |
| 1407 |
| 1408 |
1402 // HeapObject is the superclass for all classes describing heap allocated | 1409 // HeapObject is the superclass for all classes describing heap allocated |
1403 // objects. | 1410 // objects. |
1404 class HeapObject: public Object { | 1411 class HeapObject: public Object { |
1405 public: | 1412 public: |
1406 // [map]: Contains a map which contains the object's reflective | 1413 // [map]: Contains a map which contains the object's reflective |
1407 // information. | 1414 // information. |
1408 inline Map* map() const; | 1415 inline Map* map() const; |
1409 inline void set_map(Map* value); | 1416 inline void set_map(Map* value); |
1410 // The no-write-barrier version. This is OK if the object is white and in | 1417 // The no-write-barrier version. This is OK if the object is white and in |
1411 // new space, or if the value is an immortal immutable object, like the maps | 1418 // new space, or if the value is an immortal immutable object, like the maps |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 | 1450 |
1444 // Iterates over all pointers contained in the object except the | 1451 // Iterates over all pointers contained in the object except the |
1445 // first map pointer. The object type is given in the first | 1452 // first map pointer. The object type is given in the first |
1446 // parameter. This function does not access the map pointer in the | 1453 // parameter. This function does not access the map pointer in the |
1447 // object, and so is safe to call while the map pointer is modified. | 1454 // object, and so is safe to call while the map pointer is modified. |
1448 void IterateBody(InstanceType type, int object_size, ObjectVisitor* v); | 1455 void IterateBody(InstanceType type, int object_size, ObjectVisitor* v); |
1449 | 1456 |
1450 // Returns the heap object's size in bytes | 1457 // Returns the heap object's size in bytes |
1451 inline int Size(); | 1458 inline int Size(); |
1452 | 1459 |
1453 // Returns true if this heap object may contain raw values, i.e., values that | 1460 // Indicates what type of values this heap object may contain. |
1454 // look like pointers to heap objects. | 1461 inline HeapObjectContents ContentType(); |
1455 inline bool MayContainRawValues(); | |
1456 | 1462 |
1457 // Given a heap object's map pointer, returns the heap size in bytes | 1463 // Given a heap object's map pointer, returns the heap size in bytes |
1458 // Useful when the map pointer field is used for other purposes. | 1464 // Useful when the map pointer field is used for other purposes. |
1459 // GC internal. | 1465 // GC internal. |
1460 inline int SizeFromMap(Map* map); | 1466 inline int SizeFromMap(Map* map); |
1461 | 1467 |
1462 // Returns the field at offset in obj, as a read/write Object* reference. | 1468 // Returns the field at offset in obj, as a read/write Object* reference. |
1463 // Does no checking, and is safe to use during GC, while maps are invalid. | 1469 // Does no checking, and is safe to use during GC, while maps are invalid. |
1464 // Does not invoke write barrier, so should only be assigned to | 1470 // Does not invoke write barrier, so should only be assigned to |
1465 // during marking GC. | 1471 // during marking GC. |
(...skipping 9407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10873 } else { | 10879 } else { |
10874 value &= ~(1 << bit_position); | 10880 value &= ~(1 << bit_position); |
10875 } | 10881 } |
10876 return value; | 10882 return value; |
10877 } | 10883 } |
10878 }; | 10884 }; |
10879 | 10885 |
10880 } } // namespace v8::internal | 10886 } } // namespace v8::internal |
10881 | 10887 |
10882 #endif // V8_OBJECTS_H_ | 10888 #endif // V8_OBJECTS_H_ |
OLD | NEW |