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" |
11 #include "src/assert-scope.h" | 11 #include "src/assert-scope.h" |
12 #include "src/bailout-reason.h" | 12 #include "src/bailout-reason.h" |
13 #include "src/base/bits.h" | 13 #include "src/base/bits.h" |
14 #include "src/base/smart-pointers.h" | 14 #include "src/base/smart-pointers.h" |
15 #include "src/builtins.h" | 15 #include "src/builtins.h" |
16 #include "src/checks.h" | 16 #include "src/checks.h" |
17 #include "src/elements-kind.h" | 17 #include "src/elements-kind.h" |
18 #include "src/field-index.h" | 18 #include "src/field-index.h" |
19 #include "src/flags.h" | 19 #include "src/flags.h" |
20 #include "src/list.h" | 20 #include "src/list.h" |
| 21 #include "src/objects-body-descriptors-fwd.h" |
21 #include "src/property-details.h" | 22 #include "src/property-details.h" |
22 #include "src/unicode.h" | 23 #include "src/unicode.h" |
23 #include "src/unicode-decoder.h" | 24 #include "src/unicode-decoder.h" |
24 #include "src/zone.h" | 25 #include "src/zone.h" |
25 | 26 |
26 #if V8_TARGET_ARCH_ARM | 27 #if V8_TARGET_ARCH_ARM |
27 #include "src/arm/constants-arm.h" // NOLINT | 28 #include "src/arm/constants-arm.h" // NOLINT |
28 #elif V8_TARGET_ARCH_ARM64 | 29 #elif V8_TARGET_ARCH_ARM64 |
29 #include "src/arm64/constants-arm64.h" // NOLINT | 30 #include "src/arm64/constants-arm64.h" // NOLINT |
30 #elif V8_TARGET_ARCH_MIPS | 31 #elif V8_TARGET_ARCH_MIPS |
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 static inline HeapObject* FromAddress(Address address) { | 1549 static inline HeapObject* FromAddress(Address address) { |
1549 DCHECK_TAG_ALIGNED(address); | 1550 DCHECK_TAG_ALIGNED(address); |
1550 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); | 1551 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); |
1551 } | 1552 } |
1552 | 1553 |
1553 // Returns the address of this HeapObject. | 1554 // Returns the address of this HeapObject. |
1554 inline Address address() { | 1555 inline Address address() { |
1555 return reinterpret_cast<Address>(this) - kHeapObjectTag; | 1556 return reinterpret_cast<Address>(this) - kHeapObjectTag; |
1556 } | 1557 } |
1557 | 1558 |
1558 // Iterates over pointers contained in the object (including the Map) | 1559 // Iterates over pointers contained in the object (including the Map). |
| 1560 // If it's not performance critical iteration use the non-templatized |
| 1561 // version. |
1559 void Iterate(ObjectVisitor* v); | 1562 void Iterate(ObjectVisitor* v); |
1560 | 1563 |
| 1564 template <typename ObjectVisitor> |
| 1565 inline void IterateFast(ObjectVisitor* v); |
| 1566 |
1561 // Iterates over all pointers contained in the object except the | 1567 // Iterates over all pointers contained in the object except the |
1562 // first map pointer. The object type is given in the first | 1568 // first map pointer. The object type is given in the first |
1563 // parameter. This function does not access the map pointer in the | 1569 // parameter. This function does not access the map pointer in the |
1564 // object, and so is safe to call while the map pointer is modified. | 1570 // object, and so is safe to call while the map pointer is modified. |
| 1571 // If it's not performance critical iteration use the non-templatized |
| 1572 // version. |
| 1573 void IterateBody(ObjectVisitor* v); |
1565 void IterateBody(InstanceType type, int object_size, ObjectVisitor* v); | 1574 void IterateBody(InstanceType type, int object_size, ObjectVisitor* v); |
1566 | 1575 |
| 1576 template <typename ObjectVisitor> |
| 1577 inline void IterateBodyFast(ObjectVisitor* v); |
| 1578 |
| 1579 template <typename ObjectVisitor> |
| 1580 inline void IterateBodyFast(InstanceType type, int object_size, |
| 1581 ObjectVisitor* v); |
| 1582 |
| 1583 // Returns true if the object contains a tagged value at given offset. |
| 1584 // It is used for invalid slots filtering. If the offset points outside |
| 1585 // of the object or to the map word, the result is UNDEFINED (!!!). |
| 1586 bool IsValidSlot(int offset); |
| 1587 |
1567 // Returns the heap object's size in bytes | 1588 // Returns the heap object's size in bytes |
1568 inline int Size(); | 1589 inline int Size(); |
1569 | 1590 |
1570 // Indicates what type of values this heap object may contain. | 1591 // Indicates what type of values this heap object may contain. |
1571 inline HeapObjectContents ContentType(); | 1592 inline HeapObjectContents ContentType(); |
1572 | 1593 |
1573 // Given a heap object's map pointer, returns the heap size in bytes | 1594 // Given a heap object's map pointer, returns the heap size in bytes |
1574 // Useful when the map pointer field is used for other purposes. | 1595 // Useful when the map pointer field is used for other purposes. |
1575 // GC internal. | 1596 // GC internal. |
1576 inline int SizeFromMap(Map* map); | 1597 inline int SizeFromMap(Map* map); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 | 1637 |
1617 inline AllocationAlignment RequiredAlignment(); | 1638 inline AllocationAlignment RequiredAlignment(); |
1618 | 1639 |
1619 // Layout description. | 1640 // Layout description. |
1620 // First field in a heap object is map. | 1641 // First field in a heap object is map. |
1621 static const int kMapOffset = Object::kHeaderSize; | 1642 static const int kMapOffset = Object::kHeaderSize; |
1622 static const int kHeaderSize = kMapOffset + kPointerSize; | 1643 static const int kHeaderSize = kMapOffset + kPointerSize; |
1623 | 1644 |
1624 STATIC_ASSERT(kMapOffset == Internals::kHeapObjectMapOffset); | 1645 STATIC_ASSERT(kMapOffset == Internals::kHeapObjectMapOffset); |
1625 | 1646 |
1626 protected: | |
1627 // helpers for calling an ObjectVisitor to iterate over pointers in the | |
1628 // half-open range [start, end) specified as integer offsets | |
1629 inline void IteratePointers(ObjectVisitor* v, int start, int end); | |
1630 // as above, for the single element at "offset" | |
1631 inline void IteratePointer(ObjectVisitor* v, int offset); | |
1632 // as above, for the next code link of a code object. | |
1633 inline void IterateNextCodeLink(ObjectVisitor* v, int offset); | |
1634 | |
1635 private: | 1647 private: |
1636 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject); | 1648 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject); |
1637 }; | 1649 }; |
1638 | 1650 |
1639 | 1651 |
1640 // This is the base class for object's body descriptors. | |
1641 class BodyDescriptorBase { | |
1642 protected: | |
1643 static inline void IterateBodyImpl(HeapObject* obj, int start_offset, | |
1644 int end_offset, ObjectVisitor* v); | |
1645 | |
1646 template <typename StaticVisitor> | |
1647 static inline void IterateBodyImpl(Heap* heap, HeapObject* obj, | |
1648 int start_offset, int end_offset); | |
1649 | |
1650 static inline void IteratePointers(HeapObject* obj, int start_offset, | |
1651 int end_offset, ObjectVisitor* v); | |
1652 | |
1653 template <typename StaticVisitor> | |
1654 static inline void IteratePointers(Heap* heap, HeapObject* obj, | |
1655 int start_offset, int end_offset); | |
1656 }; | |
1657 | |
1658 | |
1659 // This class describes a body of an object of a fixed size | |
1660 // in which all pointer fields are located in the [start_offset, end_offset) | |
1661 // interval. | |
1662 template <int start_offset, int end_offset, int size> | |
1663 class FixedBodyDescriptor : public BodyDescriptorBase { | |
1664 public: | |
1665 static const int kStartOffset = start_offset; | |
1666 static const int kEndOffset = end_offset; | |
1667 static const int kSize = size; | |
1668 | |
1669 static inline void IterateBody(HeapObject* obj, ObjectVisitor* v) { | |
1670 IterateBodyImpl(obj, start_offset, end_offset, v); | |
1671 } | |
1672 | |
1673 template <typename StaticVisitor> | |
1674 static inline void IterateBody(HeapObject* obj) { | |
1675 Heap* heap = obj->GetHeap(); | |
1676 IterateBodyImpl<StaticVisitor>(heap, obj, start_offset, end_offset); | |
1677 } | |
1678 }; | |
1679 | |
1680 | |
1681 // This base class describes a body of an object of a variable size | |
1682 // in which all pointer fields are located in the [start_offset, object_size) | |
1683 // interval. | |
1684 template <int start_offset> | |
1685 class FlexibleBodyDescriptorBase : public BodyDescriptorBase { | |
1686 public: | |
1687 static const int kStartOffset = start_offset; | |
1688 | |
1689 static inline void IterateBody(HeapObject* obj, int object_size, | |
1690 ObjectVisitor* v) { | |
1691 IterateBodyImpl(obj, start_offset, object_size, v); | |
1692 } | |
1693 | |
1694 template <typename StaticVisitor> | |
1695 static inline void IterateBody(HeapObject* obj, int object_size) { | |
1696 Heap* heap = obj->GetHeap(); | |
1697 IterateBodyImpl<StaticVisitor>(heap, obj, start_offset, object_size); | |
1698 } | |
1699 }; | |
1700 | |
1701 | |
1702 // This class describes a body of an object of a variable size | |
1703 // in which all pointer fields are located in the [start_offset, object_size) | |
1704 // interval. The size of the object is taken from the map. | |
1705 template <int start_offset> | |
1706 class FlexibleBodyDescriptor : public FlexibleBodyDescriptorBase<start_offset> { | |
1707 public: | |
1708 static inline int SizeOf(Map* map, HeapObject* object); | |
1709 }; | |
1710 | |
1711 | |
1712 // The HeapNumber class describes heap allocated numbers that cannot be | 1652 // The HeapNumber class describes heap allocated numbers that cannot be |
1713 // represented in a Smi (small integer) | 1653 // represented in a Smi (small integer) |
1714 class HeapNumber: public HeapObject { | 1654 class HeapNumber: public HeapObject { |
1715 public: | 1655 public: |
1716 // [value]: number value. | 1656 // [value]: number value. |
1717 inline double value() const; | 1657 inline double value() const; |
1718 inline void set_value(double value); | 1658 inline void set_value(double value); |
1719 | 1659 |
1720 DECLARE_CAST(HeapNumber) | 1660 DECLARE_CAST(HeapNumber) |
1721 | 1661 |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2681 // Swap two elements in a pair of arrays. If this array and the | 2621 // Swap two elements in a pair of arrays. If this array and the |
2682 // numbers array are the same object, the elements are only swapped | 2622 // numbers array are the same object, the elements are only swapped |
2683 // once. | 2623 // once. |
2684 void SwapPairs(FixedArray* numbers, int i, int j); | 2624 void SwapPairs(FixedArray* numbers, int i, int j); |
2685 | 2625 |
2686 // Sort prefix of this array and the numbers array as pairs wrt. the | 2626 // Sort prefix of this array and the numbers array as pairs wrt. the |
2687 // numbers. If the numbers array and the this array are the same | 2627 // numbers. If the numbers array and the this array are the same |
2688 // object, the prefix of this array is sorted. | 2628 // object, the prefix of this array is sorted. |
2689 void SortPairs(FixedArray* numbers, uint32_t len); | 2629 void SortPairs(FixedArray* numbers, uint32_t len); |
2690 | 2630 |
2691 class BodyDescriptor : public FlexibleBodyDescriptorBase<kHeaderSize> { | 2631 typedef FlexibleBodyDescriptor<kHeaderSize> BodyDescriptor; |
2692 public: | |
2693 static inline int SizeOf(Map* map, HeapObject* object); | |
2694 }; | |
2695 | 2632 |
2696 protected: | 2633 protected: |
2697 // Set operation on FixedArray without using write barriers. Can | 2634 // Set operation on FixedArray without using write barriers. Can |
2698 // only be used for storing old space objects or smis. | 2635 // only be used for storing old space objects or smis. |
2699 static inline void NoWriteBarrierSet(FixedArray* array, | 2636 static inline void NoWriteBarrierSet(FixedArray* array, |
2700 int index, | 2637 int index, |
2701 Object* value); | 2638 Object* value); |
2702 | 2639 |
2703 // Set operation on FixedArray without incremental write barrier. Can | 2640 // Set operation on FixedArray without incremental write barrier. Can |
2704 // only be used if the object is guaranteed to be white (whiteness witness | 2641 // only be used if the object is guaranteed to be white (whiteness witness |
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4416 inline int parameter_count() const; | 4353 inline int parameter_count() const; |
4417 inline void set_parameter_count(int number_of_parameters); | 4354 inline void set_parameter_count(int number_of_parameters); |
4418 | 4355 |
4419 // Accessors for the constant pool. | 4356 // Accessors for the constant pool. |
4420 DECL_ACCESSORS(constant_pool, FixedArray) | 4357 DECL_ACCESSORS(constant_pool, FixedArray) |
4421 | 4358 |
4422 DECLARE_CAST(BytecodeArray) | 4359 DECLARE_CAST(BytecodeArray) |
4423 | 4360 |
4424 // Dispatched behavior. | 4361 // Dispatched behavior. |
4425 inline int BytecodeArraySize(); | 4362 inline int BytecodeArraySize(); |
4426 inline void BytecodeArrayIterateBody(ObjectVisitor* v); | |
4427 | 4363 |
4428 DECLARE_PRINTER(BytecodeArray) | 4364 DECLARE_PRINTER(BytecodeArray) |
4429 DECLARE_VERIFIER(BytecodeArray) | 4365 DECLARE_VERIFIER(BytecodeArray) |
4430 | 4366 |
4431 void Disassemble(std::ostream& os); | 4367 void Disassemble(std::ostream& os); |
4432 | 4368 |
4433 // Layout description. | 4369 // Layout description. |
4434 static const int kFrameSizeOffset = FixedArrayBase::kHeaderSize; | 4370 static const int kFrameSizeOffset = FixedArrayBase::kHeaderSize; |
4435 static const int kParameterSizeOffset = kFrameSizeOffset + kIntSize; | 4371 static const int kParameterSizeOffset = kFrameSizeOffset + kIntSize; |
4436 static const int kConstantPoolOffset = kParameterSizeOffset + kIntSize; | 4372 static const int kConstantPoolOffset = kParameterSizeOffset + kIntSize; |
4437 static const int kHeaderSize = kConstantPoolOffset + kPointerSize; | 4373 static const int kHeaderSize = kConstantPoolOffset + kPointerSize; |
4438 | 4374 |
4439 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); | 4375 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); |
4440 | 4376 |
4441 // Maximal memory consumption for a single BytecodeArray. | 4377 // Maximal memory consumption for a single BytecodeArray. |
4442 static const int kMaxSize = 512 * MB; | 4378 static const int kMaxSize = 512 * MB; |
4443 // Maximal length of a single BytecodeArray. | 4379 // Maximal length of a single BytecodeArray. |
4444 static const int kMaxLength = kMaxSize - kHeaderSize; | 4380 static const int kMaxLength = kMaxSize - kHeaderSize; |
4445 | 4381 |
| 4382 class BodyDescriptor; |
| 4383 |
4446 private: | 4384 private: |
4447 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArray); | 4385 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArray); |
4448 }; | 4386 }; |
4449 | 4387 |
4450 | 4388 |
4451 // FreeSpace are fixed-size free memory blocks used by the heap and GC. | 4389 // FreeSpace are fixed-size free memory blocks used by the heap and GC. |
4452 // They look like heap objects (are heap object tagged and have a map) so that | 4390 // They look like heap objects (are heap object tagged and have a map) so that |
4453 // the heap remains iterable. They have a size and a next pointer. | 4391 // the heap remains iterable. They have a size and a next pointer. |
4454 // The next pointer is the raw address of the next FreeSpace object (or NULL) | 4392 // The next pointer is the raw address of the next FreeSpace object (or NULL) |
4455 // in the free list. | 4393 // in the free list. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4501 public: | 4439 public: |
4502 // [base_pointer]: Either points to the FixedTypedArrayBase itself or nullptr. | 4440 // [base_pointer]: Either points to the FixedTypedArrayBase itself or nullptr. |
4503 DECL_ACCESSORS(base_pointer, Object) | 4441 DECL_ACCESSORS(base_pointer, Object) |
4504 | 4442 |
4505 // [external_pointer]: Contains the offset between base_pointer and the start | 4443 // [external_pointer]: Contains the offset between base_pointer and the start |
4506 // of the data. If the base_pointer is a nullptr, the external_pointer | 4444 // of the data. If the base_pointer is a nullptr, the external_pointer |
4507 // therefore points to the actual backing store. | 4445 // therefore points to the actual backing store. |
4508 DECL_ACCESSORS(external_pointer, void) | 4446 DECL_ACCESSORS(external_pointer, void) |
4509 | 4447 |
4510 // Dispatched behavior. | 4448 // Dispatched behavior. |
4511 inline void FixedTypedArrayBaseIterateBody(ObjectVisitor* v); | |
4512 | |
4513 template <typename StaticVisitor> | |
4514 inline void FixedTypedArrayBaseIterateBody(); | |
4515 | |
4516 DECLARE_CAST(FixedTypedArrayBase) | 4449 DECLARE_CAST(FixedTypedArrayBase) |
4517 | 4450 |
4518 static const int kBasePointerOffset = FixedArrayBase::kHeaderSize; | 4451 static const int kBasePointerOffset = FixedArrayBase::kHeaderSize; |
4519 static const int kExternalPointerOffset = kBasePointerOffset + kPointerSize; | 4452 static const int kExternalPointerOffset = kBasePointerOffset + kPointerSize; |
4520 static const int kHeaderSize = | 4453 static const int kHeaderSize = |
4521 DOUBLE_POINTER_ALIGN(kExternalPointerOffset + kPointerSize); | 4454 DOUBLE_POINTER_ALIGN(kExternalPointerOffset + kPointerSize); |
4522 | 4455 |
4523 static const int kDataOffset = kHeaderSize; | 4456 static const int kDataOffset = kHeaderSize; |
4524 | 4457 |
| 4458 class BodyDescriptor; |
| 4459 |
4525 inline int size(); | 4460 inline int size(); |
4526 | 4461 |
4527 static inline int TypedArraySize(InstanceType type, int length); | 4462 static inline int TypedArraySize(InstanceType type, int length); |
4528 inline int TypedArraySize(InstanceType type); | 4463 inline int TypedArraySize(InstanceType type); |
4529 | 4464 |
4530 // Use with care: returns raw pointer into heap. | 4465 // Use with care: returns raw pointer into heap. |
4531 inline void* DataPtr(); | 4466 inline void* DataPtr(); |
4532 | 4467 |
4533 inline int DataSize(); | 4468 inline int DataSize(); |
4534 | 4469 |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5185 inline int ExecutableSize(); | 5120 inline int ExecutableSize(); |
5186 | 5121 |
5187 // Locating source position. | 5122 // Locating source position. |
5188 int SourcePosition(Address pc); | 5123 int SourcePosition(Address pc); |
5189 int SourceStatementPosition(Address pc); | 5124 int SourceStatementPosition(Address pc); |
5190 | 5125 |
5191 DECLARE_CAST(Code) | 5126 DECLARE_CAST(Code) |
5192 | 5127 |
5193 // Dispatched behavior. | 5128 // Dispatched behavior. |
5194 inline int CodeSize(); | 5129 inline int CodeSize(); |
5195 inline void CodeIterateBody(ObjectVisitor* v); | |
5196 | |
5197 template<typename StaticVisitor> | |
5198 inline void CodeIterateBody(Heap* heap); | |
5199 | 5130 |
5200 DECLARE_PRINTER(Code) | 5131 DECLARE_PRINTER(Code) |
5201 DECLARE_VERIFIER(Code) | 5132 DECLARE_VERIFIER(Code) |
5202 | 5133 |
5203 void ClearInlineCaches(); | 5134 void ClearInlineCaches(); |
5204 void ClearInlineCaches(Kind kind); | 5135 void ClearInlineCaches(Kind kind); |
5205 | 5136 |
5206 BailoutId TranslatePcOffsetToAstId(uint32_t pc_offset); | 5137 BailoutId TranslatePcOffsetToAstId(uint32_t pc_offset); |
5207 uint32_t TranslateAstIdToPcOffset(BailoutId ast_id); | 5138 uint32_t TranslateAstIdToPcOffset(BailoutId ast_id); |
5208 | 5139 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5287 static const int kPrologueOffset = kKindSpecificFlags2Offset + kIntSize; | 5218 static const int kPrologueOffset = kKindSpecificFlags2Offset + kIntSize; |
5288 static const int kConstantPoolOffset = kPrologueOffset + kIntSize; | 5219 static const int kConstantPoolOffset = kPrologueOffset + kIntSize; |
5289 static const int kHeaderPaddingStart = | 5220 static const int kHeaderPaddingStart = |
5290 kConstantPoolOffset + kConstantPoolSize; | 5221 kConstantPoolOffset + kConstantPoolSize; |
5291 | 5222 |
5292 // Add padding to align the instruction start following right after | 5223 // Add padding to align the instruction start following right after |
5293 // the Code object header. | 5224 // the Code object header. |
5294 static const int kHeaderSize = | 5225 static const int kHeaderSize = |
5295 (kHeaderPaddingStart + kCodeAlignmentMask) & ~kCodeAlignmentMask; | 5226 (kHeaderPaddingStart + kCodeAlignmentMask) & ~kCodeAlignmentMask; |
5296 | 5227 |
| 5228 class BodyDescriptor; |
| 5229 |
5297 // Byte offsets within kKindSpecificFlags1Offset. | 5230 // Byte offsets within kKindSpecificFlags1Offset. |
5298 static const int kFullCodeFlags = kKindSpecificFlags1Offset; | 5231 static const int kFullCodeFlags = kKindSpecificFlags1Offset; |
5299 class FullCodeFlagsHasDeoptimizationSupportField: | 5232 class FullCodeFlagsHasDeoptimizationSupportField: |
5300 public BitField<bool, 0, 1> {}; // NOLINT | 5233 public BitField<bool, 0, 1> {}; // NOLINT |
5301 class FullCodeFlagsHasDebugBreakSlotsField: public BitField<bool, 1, 1> {}; | 5234 class FullCodeFlagsHasDebugBreakSlotsField: public BitField<bool, 1, 1> {}; |
5302 class FullCodeFlagsHasRelocInfoForSerialization | 5235 class FullCodeFlagsHasRelocInfoForSerialization |
5303 : public BitField<bool, 2, 1> {}; | 5236 : public BitField<bool, 2, 1> {}; |
5304 // Bit 3 in this bitfield is unused. | 5237 // Bit 3 in this bitfield is unused. |
5305 class ProfilerTicksField : public BitField<int, 4, 28> {}; | 5238 class ProfilerTicksField : public BitField<int, 4, 28> {}; |
5306 | 5239 |
(...skipping 3890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9197 // which the pointer cache has to be refreshed. | 9130 // which the pointer cache has to be refreshed. |
9198 inline void update_data_cache(); | 9131 inline void update_data_cache(); |
9199 | 9132 |
9200 inline const uint8_t* GetChars(); | 9133 inline const uint8_t* GetChars(); |
9201 | 9134 |
9202 // Dispatched behavior. | 9135 // Dispatched behavior. |
9203 inline uint16_t ExternalOneByteStringGet(int index); | 9136 inline uint16_t ExternalOneByteStringGet(int index); |
9204 | 9137 |
9205 DECLARE_CAST(ExternalOneByteString) | 9138 DECLARE_CAST(ExternalOneByteString) |
9206 | 9139 |
9207 // Garbage collection support. | 9140 class BodyDescriptor; |
9208 inline void ExternalOneByteStringIterateBody(ObjectVisitor* v); | |
9209 | |
9210 template <typename StaticVisitor> | |
9211 inline void ExternalOneByteStringIterateBody(); | |
9212 | 9141 |
9213 private: | 9142 private: |
9214 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalOneByteString); | 9143 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalOneByteString); |
9215 }; | 9144 }; |
9216 | 9145 |
9217 | 9146 |
9218 // The ExternalTwoByteString class is an external string backed by a UTF-16 | 9147 // The ExternalTwoByteString class is an external string backed by a UTF-16 |
9219 // encoded string. | 9148 // encoded string. |
9220 class ExternalTwoByteString: public ExternalString { | 9149 class ExternalTwoByteString: public ExternalString { |
9221 public: | 9150 public: |
(...skipping 14 matching lines...) Expand all Loading... |
9236 inline const uint16_t* GetChars(); | 9165 inline const uint16_t* GetChars(); |
9237 | 9166 |
9238 // Dispatched behavior. | 9167 // Dispatched behavior. |
9239 inline uint16_t ExternalTwoByteStringGet(int index); | 9168 inline uint16_t ExternalTwoByteStringGet(int index); |
9240 | 9169 |
9241 // For regexp code. | 9170 // For regexp code. |
9242 inline const uint16_t* ExternalTwoByteStringGetData(unsigned start); | 9171 inline const uint16_t* ExternalTwoByteStringGetData(unsigned start); |
9243 | 9172 |
9244 DECLARE_CAST(ExternalTwoByteString) | 9173 DECLARE_CAST(ExternalTwoByteString) |
9245 | 9174 |
9246 // Garbage collection support. | 9175 class BodyDescriptor; |
9247 inline void ExternalTwoByteStringIterateBody(ObjectVisitor* v); | |
9248 | |
9249 template<typename StaticVisitor> | |
9250 inline void ExternalTwoByteStringIterateBody(); | |
9251 | 9176 |
9252 private: | 9177 private: |
9253 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString); | 9178 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString); |
9254 }; | 9179 }; |
9255 | 9180 |
9256 | 9181 |
9257 // Utility superclass for stack-allocated objects that must be updated | 9182 // Utility superclass for stack-allocated objects that must be updated |
9258 // on gc. It provides two ways for the gc to update instances, either | 9183 // on gc. It provides two ways for the gc to update instances, either |
9259 // iterating or updating after gc. | 9184 // iterating or updating after gc. |
9260 class Relocatable BASE_EMBEDDED { | 9185 class Relocatable BASE_EMBEDDED { |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9879 static void Initialize(Handle<JSWeakCollection> collection, Isolate* isolate); | 9804 static void Initialize(Handle<JSWeakCollection> collection, Isolate* isolate); |
9880 static void Set(Handle<JSWeakCollection> collection, Handle<Object> key, | 9805 static void Set(Handle<JSWeakCollection> collection, Handle<Object> key, |
9881 Handle<Object> value, int32_t hash); | 9806 Handle<Object> value, int32_t hash); |
9882 static bool Delete(Handle<JSWeakCollection> collection, Handle<Object> key, | 9807 static bool Delete(Handle<JSWeakCollection> collection, Handle<Object> key, |
9883 int32_t hash); | 9808 int32_t hash); |
9884 | 9809 |
9885 static const int kTableOffset = JSObject::kHeaderSize; | 9810 static const int kTableOffset = JSObject::kHeaderSize; |
9886 static const int kNextOffset = kTableOffset + kPointerSize; | 9811 static const int kNextOffset = kTableOffset + kPointerSize; |
9887 static const int kSize = kNextOffset + kPointerSize; | 9812 static const int kSize = kNextOffset + kPointerSize; |
9888 | 9813 |
| 9814 class BodyDescriptor; |
| 9815 |
9889 private: | 9816 private: |
9890 DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakCollection); | 9817 DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakCollection); |
9891 }; | 9818 }; |
9892 | 9819 |
9893 | 9820 |
9894 // The JSWeakMap describes EcmaScript Harmony weak maps | 9821 // The JSWeakMap describes EcmaScript Harmony weak maps |
9895 class JSWeakMap: public JSWeakCollection { | 9822 class JSWeakMap: public JSWeakCollection { |
9896 public: | 9823 public: |
9897 DECLARE_CAST(JSWeakMap) | 9824 DECLARE_CAST(JSWeakMap) |
9898 | 9825 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9957 static bool SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, | 9884 static bool SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, |
9958 Isolate* isolate, size_t allocated_length, | 9885 Isolate* isolate, size_t allocated_length, |
9959 bool initialize = true, | 9886 bool initialize = true, |
9960 SharedFlag shared = SharedFlag::kNotShared); | 9887 SharedFlag shared = SharedFlag::kNotShared); |
9961 | 9888 |
9962 // Dispatched behavior. | 9889 // Dispatched behavior. |
9963 DECLARE_PRINTER(JSArrayBuffer) | 9890 DECLARE_PRINTER(JSArrayBuffer) |
9964 DECLARE_VERIFIER(JSArrayBuffer) | 9891 DECLARE_VERIFIER(JSArrayBuffer) |
9965 | 9892 |
9966 static const int kByteLengthOffset = JSObject::kHeaderSize; | 9893 static const int kByteLengthOffset = JSObject::kHeaderSize; |
9967 | |
9968 // NOTE: GC will visit objects fields: | |
9969 // 1. From JSObject::BodyDescriptor::kStartOffset to kByteLengthOffset + | |
9970 // kPointerSize | |
9971 // 2. From start of the internal fields and up to the end of them | |
9972 static const int kBackingStoreOffset = kByteLengthOffset + kPointerSize; | 9894 static const int kBackingStoreOffset = kByteLengthOffset + kPointerSize; |
9973 static const int kBitFieldSlot = kBackingStoreOffset + kPointerSize; | 9895 static const int kBitFieldSlot = kBackingStoreOffset + kPointerSize; |
9974 #if V8_TARGET_LITTLE_ENDIAN || !V8_HOST_ARCH_64_BIT | 9896 #if V8_TARGET_LITTLE_ENDIAN || !V8_HOST_ARCH_64_BIT |
9975 static const int kBitFieldOffset = kBitFieldSlot; | 9897 static const int kBitFieldOffset = kBitFieldSlot; |
9976 #else | 9898 #else |
9977 static const int kBitFieldOffset = kBitFieldSlot + kIntSize; | 9899 static const int kBitFieldOffset = kBitFieldSlot + kIntSize; |
9978 #endif | 9900 #endif |
9979 static const int kSize = kBitFieldSlot + kPointerSize; | 9901 static const int kSize = kBitFieldSlot + kPointerSize; |
9980 | 9902 |
9981 static const int kSizeWithInternalFields = | 9903 static const int kSizeWithInternalFields = |
9982 kSize + v8::ArrayBuffer::kInternalFieldCount * kPointerSize; | 9904 kSize + v8::ArrayBuffer::kInternalFieldCount * kPointerSize; |
9983 | 9905 |
9984 template <typename StaticVisitor> | 9906 // Iterates all fields in the object including internal ones except |
9985 static inline void JSArrayBufferIterateBody(Heap* heap, HeapObject* obj); | 9907 // kBackingStoreOffset and kBitFieldSlot. |
9986 | 9908 class BodyDescriptor; |
9987 static inline void JSArrayBufferIterateBody(HeapObject* obj, | |
9988 ObjectVisitor* v); | |
9989 | 9909 |
9990 class IsExternal : public BitField<bool, 1, 1> {}; | 9910 class IsExternal : public BitField<bool, 1, 1> {}; |
9991 class IsNeuterable : public BitField<bool, 2, 1> {}; | 9911 class IsNeuterable : public BitField<bool, 2, 1> {}; |
9992 class WasNeutered : public BitField<bool, 3, 1> {}; | 9912 class WasNeutered : public BitField<bool, 3, 1> {}; |
9993 class IsShared : public BitField<bool, 4, 1> {}; | 9913 class IsShared : public BitField<bool, 4, 1> {}; |
9994 | 9914 |
9995 private: | 9915 private: |
9996 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBuffer); | 9916 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBuffer); |
9997 }; | 9917 }; |
9998 | 9918 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10084 // Foreign describes objects pointing from JavaScript to C structures. | 10004 // Foreign describes objects pointing from JavaScript to C structures. |
10085 class Foreign: public HeapObject { | 10005 class Foreign: public HeapObject { |
10086 public: | 10006 public: |
10087 // [address]: field containing the address. | 10007 // [address]: field containing the address. |
10088 inline Address foreign_address(); | 10008 inline Address foreign_address(); |
10089 inline void set_foreign_address(Address value); | 10009 inline void set_foreign_address(Address value); |
10090 | 10010 |
10091 DECLARE_CAST(Foreign) | 10011 DECLARE_CAST(Foreign) |
10092 | 10012 |
10093 // Dispatched behavior. | 10013 // Dispatched behavior. |
10094 inline void ForeignIterateBody(ObjectVisitor* v); | |
10095 | |
10096 template<typename StaticVisitor> | |
10097 inline void ForeignIterateBody(); | |
10098 | |
10099 // Dispatched behavior. | |
10100 DECLARE_PRINTER(Foreign) | 10014 DECLARE_PRINTER(Foreign) |
10101 DECLARE_VERIFIER(Foreign) | 10015 DECLARE_VERIFIER(Foreign) |
10102 | 10016 |
10103 // Layout description. | 10017 // Layout description. |
10104 | 10018 |
10105 static const int kForeignAddressOffset = HeapObject::kHeaderSize; | 10019 static const int kForeignAddressOffset = HeapObject::kHeaderSize; |
10106 static const int kSize = kForeignAddressOffset + kPointerSize; | 10020 static const int kSize = kForeignAddressOffset + kPointerSize; |
10107 | 10021 |
10108 STATIC_ASSERT(kForeignAddressOffset == Internals::kForeignAddressOffset); | 10022 STATIC_ASSERT(kForeignAddressOffset == Internals::kForeignAddressOffset); |
10109 | 10023 |
| 10024 class BodyDescriptor; |
| 10025 |
10110 private: | 10026 private: |
10111 DISALLOW_IMPLICIT_CONSTRUCTORS(Foreign); | 10027 DISALLOW_IMPLICIT_CONSTRUCTORS(Foreign); |
10112 }; | 10028 }; |
10113 | 10029 |
10114 | 10030 |
10115 // The JSArray describes JavaScript Arrays | 10031 // The JSArray describes JavaScript Arrays |
10116 // Such an array can be in one of two modes: | 10032 // Such an array can be in one of two modes: |
10117 // - fast, backing storage is a FixedArray and length <= elements.length(); | 10033 // - fast, backing storage is a FixedArray and length <= elements.length(); |
10118 // Please note: push and pop can be used to grow and shrink the array. | 10034 // Please note: push and pop can be used to grow and shrink the array. |
10119 // - slow, backing storage is a HashTable with numbers as keys. | 10035 // - slow, backing storage is a HashTable with numbers as keys. |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10763 // Visits a handle that has an embedder-assigned class ID. | 10679 // Visits a handle that has an embedder-assigned class ID. |
10764 virtual void VisitEmbedderReference(Object** p, uint16_t class_id) {} | 10680 virtual void VisitEmbedderReference(Object** p, uint16_t class_id) {} |
10765 | 10681 |
10766 // Intended for serialization/deserialization checking: insert, or | 10682 // Intended for serialization/deserialization checking: insert, or |
10767 // check for the presence of, a tag at this position in the stream. | 10683 // check for the presence of, a tag at this position in the stream. |
10768 // Also used for marking up GC roots in heap snapshots. | 10684 // Also used for marking up GC roots in heap snapshots. |
10769 virtual void Synchronize(VisitorSynchronization::SyncTag tag) {} | 10685 virtual void Synchronize(VisitorSynchronization::SyncTag tag) {} |
10770 }; | 10686 }; |
10771 | 10687 |
10772 | 10688 |
10773 typedef FlexibleBodyDescriptor<HeapObject::kHeaderSize> StructBodyDescriptor; | |
10774 | |
10775 | |
10776 // BooleanBit is a helper class for setting and getting a bit in an integer. | 10689 // BooleanBit is a helper class for setting and getting a bit in an integer. |
10777 class BooleanBit : public AllStatic { | 10690 class BooleanBit : public AllStatic { |
10778 public: | 10691 public: |
10779 static inline bool get(int value, int bit_position) { | 10692 static inline bool get(int value, int bit_position) { |
10780 return (value & (1 << bit_position)) != 0; | 10693 return (value & (1 << bit_position)) != 0; |
10781 } | 10694 } |
10782 | 10695 |
10783 static inline int set(int value, int bit_position, bool v) { | 10696 static inline int set(int value, int bit_position, bool v) { |
10784 if (v) { | 10697 if (v) { |
10785 value |= (1 << bit_position); | 10698 value |= (1 << bit_position); |
10786 } else { | 10699 } else { |
10787 value &= ~(1 << bit_position); | 10700 value &= ~(1 << bit_position); |
10788 } | 10701 } |
10789 return value; | 10702 return value; |
10790 } | 10703 } |
10791 }; | 10704 }; |
10792 | 10705 |
10793 | 10706 |
10794 } // NOLINT, false-positive due to second-order macros. | 10707 } // NOLINT, false-positive due to second-order macros. |
10795 } // NOLINT, false-positive due to second-order macros. | 10708 } // NOLINT, false-positive due to second-order macros. |
10796 | 10709 |
10797 #endif // V8_OBJECTS_H_ | 10710 #endif // V8_OBJECTS_H_ |
OLD | NEW |