Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/objects.h

Issue 1440243002: Object's body descriptors refactoring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@new-visitor-base
Patch Set: New files added to the lists Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/store-buffer.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 static inline HeapObject* FromAddress(Address address) { 1548 static inline HeapObject* FromAddress(Address address) {
1549 DCHECK_TAG_ALIGNED(address); 1549 DCHECK_TAG_ALIGNED(address);
1550 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag); 1550 return reinterpret_cast<HeapObject*>(address + kHeapObjectTag);
1551 } 1551 }
1552 1552
1553 // Returns the address of this HeapObject. 1553 // Returns the address of this HeapObject.
1554 inline Address address() { 1554 inline Address address() {
1555 return reinterpret_cast<Address>(this) - kHeapObjectTag; 1555 return reinterpret_cast<Address>(this) - kHeapObjectTag;
1556 } 1556 }
1557 1557
1558 // Iterates over pointers contained in the object (including the Map) 1558 // Iterates over pointers contained in the object (including the Map).
1559 // If it's not performance critical iteration use the non-templatized
1560 // version.
1559 void Iterate(ObjectVisitor* v); 1561 void Iterate(ObjectVisitor* v);
1560 1562
1563 template <typename ObjectVisitor>
1564 inline void IterateFast(ObjectVisitor* v);
1565
1561 // Iterates over all pointers contained in the object except the 1566 // Iterates over all pointers contained in the object except the
1562 // first map pointer. The object type is given in the first 1567 // first map pointer. The object type is given in the first
1563 // parameter. This function does not access the map pointer in the 1568 // 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. 1569 // object, and so is safe to call while the map pointer is modified.
1570 // If it's not performance critical iteration use the non-templatized
1571 // version.
1572 void IterateBody(ObjectVisitor* v);
1565 void IterateBody(InstanceType type, int object_size, ObjectVisitor* v); 1573 void IterateBody(InstanceType type, int object_size, ObjectVisitor* v);
1566 1574
1575 template <typename ObjectVisitor>
1576 inline void IterateBodyFast(ObjectVisitor* v);
1577
1578 template <typename ObjectVisitor>
1579 inline void IterateBodyFast(InstanceType type, int object_size,
1580 ObjectVisitor* v);
1581
1582 // 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
1584 // of the object or to the map word, the result is UNDEFINED (!!!).
1585 bool IsValidSlot(int offset);
1586
1567 // Returns the heap object's size in bytes 1587 // Returns the heap object's size in bytes
1568 inline int Size(); 1588 inline int Size();
1569 1589
1570 // Indicates what type of values this heap object may contain. 1590 // Indicates what type of values this heap object may contain.
1571 inline HeapObjectContents ContentType(); 1591 inline HeapObjectContents ContentType();
1572 1592
1573 // Given a heap object's map pointer, returns the heap size in bytes 1593 // 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. 1594 // Useful when the map pointer field is used for other purposes.
1575 // GC internal. 1595 // GC internal.
1576 inline int SizeFromMap(Map* map); 1596 inline int SizeFromMap(Map* map);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 1636
1617 inline AllocationAlignment RequiredAlignment(); 1637 inline AllocationAlignment RequiredAlignment();
1618 1638
1619 // Layout description. 1639 // Layout description.
1620 // First field in a heap object is map. 1640 // First field in a heap object is map.
1621 static const int kMapOffset = Object::kHeaderSize; 1641 static const int kMapOffset = Object::kHeaderSize;
1622 static const int kHeaderSize = kMapOffset + kPointerSize; 1642 static const int kHeaderSize = kMapOffset + kPointerSize;
1623 1643
1624 STATIC_ASSERT(kMapOffset == Internals::kHeapObjectMapOffset); 1644 STATIC_ASSERT(kMapOffset == Internals::kHeapObjectMapOffset);
1625 1645
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: 1646 private:
1636 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject); 1647 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject);
1637 }; 1648 };
1638 1649
1639 1650
1640 // This is the base class for object's body descriptors. 1651 template <int start_offset, int end_offset, int size>
1641 class BodyDescriptorBase { 1652 class FixedBodyDescriptor;
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 1653
1658 1654
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> 1655 template <int start_offset>
1685 class FlexibleBodyDescriptorBase : public BodyDescriptorBase { 1656 class FlexibleBodyDescriptor;
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 1657
1711 1658
1712 // The HeapNumber class describes heap allocated numbers that cannot be 1659 // The HeapNumber class describes heap allocated numbers that cannot be
1713 // represented in a Smi (small integer) 1660 // represented in a Smi (small integer)
1714 class HeapNumber: public HeapObject { 1661 class HeapNumber: public HeapObject {
1715 public: 1662 public:
1716 // [value]: number value. 1663 // [value]: number value.
1717 inline double value() const; 1664 inline double value() const;
1718 inline void set_value(double value); 1665 inline void set_value(double value);
1719 1666
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 // Swap two elements in a pair of arrays. If this array and the 2628 // 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 2629 // numbers array are the same object, the elements are only swapped
2683 // once. 2630 // once.
2684 void SwapPairs(FixedArray* numbers, int i, int j); 2631 void SwapPairs(FixedArray* numbers, int i, int j);
2685 2632
2686 // Sort prefix of this array and the numbers array as pairs wrt. the 2633 // 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 2634 // numbers. If the numbers array and the this array are the same
2688 // object, the prefix of this array is sorted. 2635 // object, the prefix of this array is sorted.
2689 void SortPairs(FixedArray* numbers, uint32_t len); 2636 void SortPairs(FixedArray* numbers, uint32_t len);
2690 2637
2691 class BodyDescriptor : public FlexibleBodyDescriptorBase<kHeaderSize> { 2638 typedef FlexibleBodyDescriptor<kHeaderSize> BodyDescriptor;
2692 public:
2693 static inline int SizeOf(Map* map, HeapObject* object);
2694 };
2695 2639
2696 protected: 2640 protected:
2697 // Set operation on FixedArray without using write barriers. Can 2641 // Set operation on FixedArray without using write barriers. Can
2698 // only be used for storing old space objects or smis. 2642 // only be used for storing old space objects or smis.
2699 static inline void NoWriteBarrierSet(FixedArray* array, 2643 static inline void NoWriteBarrierSet(FixedArray* array,
2700 int index, 2644 int index,
2701 Object* value); 2645 Object* value);
2702 2646
2703 // Set operation on FixedArray without incremental write barrier. Can 2647 // Set operation on FixedArray without incremental write barrier. Can
2704 // only be used if the object is guaranteed to be white (whiteness witness 2648 // 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
4416 inline int parameter_count() const; 4360 inline int parameter_count() const;
4417 inline void set_parameter_count(int number_of_parameters); 4361 inline void set_parameter_count(int number_of_parameters);
4418 4362
4419 // Accessors for the constant pool. 4363 // Accessors for the constant pool.
4420 DECL_ACCESSORS(constant_pool, FixedArray) 4364 DECL_ACCESSORS(constant_pool, FixedArray)
4421 4365
4422 DECLARE_CAST(BytecodeArray) 4366 DECLARE_CAST(BytecodeArray)
4423 4367
4424 // Dispatched behavior. 4368 // Dispatched behavior.
4425 inline int BytecodeArraySize(); 4369 inline int BytecodeArraySize();
4426 inline void BytecodeArrayIterateBody(ObjectVisitor* v);
4427 4370
4428 DECLARE_PRINTER(BytecodeArray) 4371 DECLARE_PRINTER(BytecodeArray)
4429 DECLARE_VERIFIER(BytecodeArray) 4372 DECLARE_VERIFIER(BytecodeArray)
4430 4373
4431 void Disassemble(std::ostream& os); 4374 void Disassemble(std::ostream& os);
4432 4375
4433 // Layout description. 4376 // Layout description.
4434 static const int kFrameSizeOffset = FixedArrayBase::kHeaderSize; 4377 static const int kFrameSizeOffset = FixedArrayBase::kHeaderSize;
4435 static const int kParameterSizeOffset = kFrameSizeOffset + kIntSize; 4378 static const int kParameterSizeOffset = kFrameSizeOffset + kIntSize;
4436 static const int kConstantPoolOffset = kParameterSizeOffset + kIntSize; 4379 static const int kConstantPoolOffset = kParameterSizeOffset + kIntSize;
4437 static const int kHeaderSize = kConstantPoolOffset + kPointerSize; 4380 static const int kHeaderSize = kConstantPoolOffset + kPointerSize;
4438 4381
4439 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); 4382 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize);
4440 4383
4441 // Maximal memory consumption for a single BytecodeArray. 4384 // Maximal memory consumption for a single BytecodeArray.
4442 static const int kMaxSize = 512 * MB; 4385 static const int kMaxSize = 512 * MB;
4443 // Maximal length of a single BytecodeArray. 4386 // Maximal length of a single BytecodeArray.
4444 static const int kMaxLength = kMaxSize - kHeaderSize; 4387 static const int kMaxLength = kMaxSize - kHeaderSize;
4445 4388
4389 class BodyDescriptor;
4390
4446 private: 4391 private:
4447 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArray); 4392 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArray);
4448 }; 4393 };
4449 4394
4450 4395
4451 // FreeSpace are fixed-size free memory blocks used by the heap and GC. 4396 // 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 4397 // 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. 4398 // 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) 4399 // The next pointer is the raw address of the next FreeSpace object (or NULL)
4455 // in the free list. 4400 // in the free list.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4501 public: 4446 public:
4502 // [base_pointer]: Either points to the FixedTypedArrayBase itself or nullptr. 4447 // [base_pointer]: Either points to the FixedTypedArrayBase itself or nullptr.
4503 DECL_ACCESSORS(base_pointer, Object) 4448 DECL_ACCESSORS(base_pointer, Object)
4504 4449
4505 // [external_pointer]: Contains the offset between base_pointer and the start 4450 // [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 4451 // of the data. If the base_pointer is a nullptr, the external_pointer
4507 // therefore points to the actual backing store. 4452 // therefore points to the actual backing store.
4508 DECL_ACCESSORS(external_pointer, void) 4453 DECL_ACCESSORS(external_pointer, void)
4509 4454
4510 // Dispatched behavior. 4455 // Dispatched behavior.
4511 inline void FixedTypedArrayBaseIterateBody(ObjectVisitor* v);
4512
4513 template <typename StaticVisitor>
4514 inline void FixedTypedArrayBaseIterateBody();
4515
4516 DECLARE_CAST(FixedTypedArrayBase) 4456 DECLARE_CAST(FixedTypedArrayBase)
4517 4457
4518 static const int kBasePointerOffset = FixedArrayBase::kHeaderSize; 4458 static const int kBasePointerOffset = FixedArrayBase::kHeaderSize;
4519 static const int kExternalPointerOffset = kBasePointerOffset + kPointerSize; 4459 static const int kExternalPointerOffset = kBasePointerOffset + kPointerSize;
4520 static const int kHeaderSize = 4460 static const int kHeaderSize =
4521 DOUBLE_POINTER_ALIGN(kExternalPointerOffset + kPointerSize); 4461 DOUBLE_POINTER_ALIGN(kExternalPointerOffset + kPointerSize);
4522 4462
4523 static const int kDataOffset = kHeaderSize; 4463 static const int kDataOffset = kHeaderSize;
4524 4464
4465 class BodyDescriptor;
4466
4525 inline int size(); 4467 inline int size();
4526 4468
4527 static inline int TypedArraySize(InstanceType type, int length); 4469 static inline int TypedArraySize(InstanceType type, int length);
4528 inline int TypedArraySize(InstanceType type); 4470 inline int TypedArraySize(InstanceType type);
4529 4471
4530 // Use with care: returns raw pointer into heap. 4472 // Use with care: returns raw pointer into heap.
4531 inline void* DataPtr(); 4473 inline void* DataPtr();
4532 4474
4533 inline int DataSize(); 4475 inline int DataSize();
4534 4476
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
5185 inline int ExecutableSize(); 5127 inline int ExecutableSize();
5186 5128
5187 // Locating source position. 5129 // Locating source position.
5188 int SourcePosition(Address pc); 5130 int SourcePosition(Address pc);
5189 int SourceStatementPosition(Address pc); 5131 int SourceStatementPosition(Address pc);
5190 5132
5191 DECLARE_CAST(Code) 5133 DECLARE_CAST(Code)
5192 5134
5193 // Dispatched behavior. 5135 // Dispatched behavior.
5194 inline int CodeSize(); 5136 inline int CodeSize();
5195 inline void CodeIterateBody(ObjectVisitor* v);
5196
5197 template<typename StaticVisitor>
5198 inline void CodeIterateBody(Heap* heap);
5199 5137
5200 DECLARE_PRINTER(Code) 5138 DECLARE_PRINTER(Code)
5201 DECLARE_VERIFIER(Code) 5139 DECLARE_VERIFIER(Code)
5202 5140
5203 void ClearInlineCaches(); 5141 void ClearInlineCaches();
5204 void ClearInlineCaches(Kind kind); 5142 void ClearInlineCaches(Kind kind);
5205 5143
5206 BailoutId TranslatePcOffsetToAstId(uint32_t pc_offset); 5144 BailoutId TranslatePcOffsetToAstId(uint32_t pc_offset);
5207 uint32_t TranslateAstIdToPcOffset(BailoutId ast_id); 5145 uint32_t TranslateAstIdToPcOffset(BailoutId ast_id);
5208 5146
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
5287 static const int kPrologueOffset = kKindSpecificFlags2Offset + kIntSize; 5225 static const int kPrologueOffset = kKindSpecificFlags2Offset + kIntSize;
5288 static const int kConstantPoolOffset = kPrologueOffset + kIntSize; 5226 static const int kConstantPoolOffset = kPrologueOffset + kIntSize;
5289 static const int kHeaderPaddingStart = 5227 static const int kHeaderPaddingStart =
5290 kConstantPoolOffset + kConstantPoolSize; 5228 kConstantPoolOffset + kConstantPoolSize;
5291 5229
5292 // Add padding to align the instruction start following right after 5230 // Add padding to align the instruction start following right after
5293 // the Code object header. 5231 // the Code object header.
5294 static const int kHeaderSize = 5232 static const int kHeaderSize =
5295 (kHeaderPaddingStart + kCodeAlignmentMask) & ~kCodeAlignmentMask; 5233 (kHeaderPaddingStart + kCodeAlignmentMask) & ~kCodeAlignmentMask;
5296 5234
5235 class BodyDescriptor;
5236
5297 // Byte offsets within kKindSpecificFlags1Offset. 5237 // Byte offsets within kKindSpecificFlags1Offset.
5298 static const int kFullCodeFlags = kKindSpecificFlags1Offset; 5238 static const int kFullCodeFlags = kKindSpecificFlags1Offset;
5299 class FullCodeFlagsHasDeoptimizationSupportField: 5239 class FullCodeFlagsHasDeoptimizationSupportField:
5300 public BitField<bool, 0, 1> {}; // NOLINT 5240 public BitField<bool, 0, 1> {}; // NOLINT
5301 class FullCodeFlagsHasDebugBreakSlotsField: public BitField<bool, 1, 1> {}; 5241 class FullCodeFlagsHasDebugBreakSlotsField: public BitField<bool, 1, 1> {};
5302 class FullCodeFlagsHasRelocInfoForSerialization 5242 class FullCodeFlagsHasRelocInfoForSerialization
5303 : public BitField<bool, 2, 1> {}; 5243 : public BitField<bool, 2, 1> {};
5304 // Bit 3 in this bitfield is unused. 5244 // Bit 3 in this bitfield is unused.
5305 class ProfilerTicksField : public BitField<int, 4, 28> {}; 5245 class ProfilerTicksField : public BitField<int, 4, 28> {};
5306 5246
(...skipping 3890 matching lines...) Expand 10 before | Expand all | Expand 10 after
9197 // which the pointer cache has to be refreshed. 9137 // which the pointer cache has to be refreshed.
9198 inline void update_data_cache(); 9138 inline void update_data_cache();
9199 9139
9200 inline const uint8_t* GetChars(); 9140 inline const uint8_t* GetChars();
9201 9141
9202 // Dispatched behavior. 9142 // Dispatched behavior.
9203 inline uint16_t ExternalOneByteStringGet(int index); 9143 inline uint16_t ExternalOneByteStringGet(int index);
9204 9144
9205 DECLARE_CAST(ExternalOneByteString) 9145 DECLARE_CAST(ExternalOneByteString)
9206 9146
9207 // Garbage collection support. 9147 class BodyDescriptor;
9208 inline void ExternalOneByteStringIterateBody(ObjectVisitor* v);
9209
9210 template <typename StaticVisitor>
9211 inline void ExternalOneByteStringIterateBody();
9212 9148
9213 private: 9149 private:
9214 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalOneByteString); 9150 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalOneByteString);
9215 }; 9151 };
9216 9152
9217 9153
9218 // The ExternalTwoByteString class is an external string backed by a UTF-16 9154 // The ExternalTwoByteString class is an external string backed by a UTF-16
9219 // encoded string. 9155 // encoded string.
9220 class ExternalTwoByteString: public ExternalString { 9156 class ExternalTwoByteString: public ExternalString {
9221 public: 9157 public:
(...skipping 14 matching lines...) Expand all
9236 inline const uint16_t* GetChars(); 9172 inline const uint16_t* GetChars();
9237 9173
9238 // Dispatched behavior. 9174 // Dispatched behavior.
9239 inline uint16_t ExternalTwoByteStringGet(int index); 9175 inline uint16_t ExternalTwoByteStringGet(int index);
9240 9176
9241 // For regexp code. 9177 // For regexp code.
9242 inline const uint16_t* ExternalTwoByteStringGetData(unsigned start); 9178 inline const uint16_t* ExternalTwoByteStringGetData(unsigned start);
9243 9179
9244 DECLARE_CAST(ExternalTwoByteString) 9180 DECLARE_CAST(ExternalTwoByteString)
9245 9181
9246 // Garbage collection support. 9182 class BodyDescriptor;
9247 inline void ExternalTwoByteStringIterateBody(ObjectVisitor* v);
9248
9249 template<typename StaticVisitor>
9250 inline void ExternalTwoByteStringIterateBody();
9251 9183
9252 private: 9184 private:
9253 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString); 9185 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString);
9254 }; 9186 };
9255 9187
9256 9188
9257 // Utility superclass for stack-allocated objects that must be updated 9189 // Utility superclass for stack-allocated objects that must be updated
9258 // on gc. It provides two ways for the gc to update instances, either 9190 // on gc. It provides two ways for the gc to update instances, either
9259 // iterating or updating after gc. 9191 // iterating or updating after gc.
9260 class Relocatable BASE_EMBEDDED { 9192 class Relocatable BASE_EMBEDDED {
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
9879 static void Initialize(Handle<JSWeakCollection> collection, Isolate* isolate); 9811 static void Initialize(Handle<JSWeakCollection> collection, Isolate* isolate);
9880 static void Set(Handle<JSWeakCollection> collection, Handle<Object> key, 9812 static void Set(Handle<JSWeakCollection> collection, Handle<Object> key,
9881 Handle<Object> value, int32_t hash); 9813 Handle<Object> value, int32_t hash);
9882 static bool Delete(Handle<JSWeakCollection> collection, Handle<Object> key, 9814 static bool Delete(Handle<JSWeakCollection> collection, Handle<Object> key,
9883 int32_t hash); 9815 int32_t hash);
9884 9816
9885 static const int kTableOffset = JSObject::kHeaderSize; 9817 static const int kTableOffset = JSObject::kHeaderSize;
9886 static const int kNextOffset = kTableOffset + kPointerSize; 9818 static const int kNextOffset = kTableOffset + kPointerSize;
9887 static const int kSize = kNextOffset + kPointerSize; 9819 static const int kSize = kNextOffset + kPointerSize;
9888 9820
9821 class BodyDescriptor;
9822
9889 private: 9823 private:
9890 DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakCollection); 9824 DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakCollection);
9891 }; 9825 };
9892 9826
9893 9827
9894 // The JSWeakMap describes EcmaScript Harmony weak maps 9828 // The JSWeakMap describes EcmaScript Harmony weak maps
9895 class JSWeakMap: public JSWeakCollection { 9829 class JSWeakMap: public JSWeakCollection {
9896 public: 9830 public:
9897 DECLARE_CAST(JSWeakMap) 9831 DECLARE_CAST(JSWeakMap)
9898 9832
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
9957 static bool SetupAllocatingData(Handle<JSArrayBuffer> array_buffer, 9891 static bool SetupAllocatingData(Handle<JSArrayBuffer> array_buffer,
9958 Isolate* isolate, size_t allocated_length, 9892 Isolate* isolate, size_t allocated_length,
9959 bool initialize = true, 9893 bool initialize = true,
9960 SharedFlag shared = SharedFlag::kNotShared); 9894 SharedFlag shared = SharedFlag::kNotShared);
9961 9895
9962 // Dispatched behavior. 9896 // Dispatched behavior.
9963 DECLARE_PRINTER(JSArrayBuffer) 9897 DECLARE_PRINTER(JSArrayBuffer)
9964 DECLARE_VERIFIER(JSArrayBuffer) 9898 DECLARE_VERIFIER(JSArrayBuffer)
9965 9899
9966 static const int kByteLengthOffset = JSObject::kHeaderSize; 9900 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; 9901 static const int kBackingStoreOffset = kByteLengthOffset + kPointerSize;
9973 static const int kBitFieldSlot = kBackingStoreOffset + kPointerSize; 9902 static const int kBitFieldSlot = kBackingStoreOffset + kPointerSize;
9974 #if V8_TARGET_LITTLE_ENDIAN || !V8_HOST_ARCH_64_BIT 9903 #if V8_TARGET_LITTLE_ENDIAN || !V8_HOST_ARCH_64_BIT
9975 static const int kBitFieldOffset = kBitFieldSlot; 9904 static const int kBitFieldOffset = kBitFieldSlot;
9976 #else 9905 #else
9977 static const int kBitFieldOffset = kBitFieldSlot + kIntSize; 9906 static const int kBitFieldOffset = kBitFieldSlot + kIntSize;
9978 #endif 9907 #endif
9979 static const int kSize = kBitFieldSlot + kPointerSize; 9908 static const int kSize = kBitFieldSlot + kPointerSize;
9980 9909
9981 static const int kSizeWithInternalFields = 9910 static const int kSizeWithInternalFields =
9982 kSize + v8::ArrayBuffer::kInternalFieldCount * kPointerSize; 9911 kSize + v8::ArrayBuffer::kInternalFieldCount * kPointerSize;
9983 9912
9984 template <typename StaticVisitor> 9913 // Iterates all fields in the object including internal ones except
9985 static inline void JSArrayBufferIterateBody(Heap* heap, HeapObject* obj); 9914 // kBackingStoreOffset and kBitFieldSlot.
9986 9915 class BodyDescriptor;
9987 static inline void JSArrayBufferIterateBody(HeapObject* obj,
9988 ObjectVisitor* v);
9989 9916
9990 class IsExternal : public BitField<bool, 1, 1> {}; 9917 class IsExternal : public BitField<bool, 1, 1> {};
9991 class IsNeuterable : public BitField<bool, 2, 1> {}; 9918 class IsNeuterable : public BitField<bool, 2, 1> {};
9992 class WasNeutered : public BitField<bool, 3, 1> {}; 9919 class WasNeutered : public BitField<bool, 3, 1> {};
9993 class IsShared : public BitField<bool, 4, 1> {}; 9920 class IsShared : public BitField<bool, 4, 1> {};
9994 9921
9995 private: 9922 private:
9996 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBuffer); 9923 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBuffer);
9997 }; 9924 };
9998 9925
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
10084 // Foreign describes objects pointing from JavaScript to C structures. 10011 // Foreign describes objects pointing from JavaScript to C structures.
10085 class Foreign: public HeapObject { 10012 class Foreign: public HeapObject {
10086 public: 10013 public:
10087 // [address]: field containing the address. 10014 // [address]: field containing the address.
10088 inline Address foreign_address(); 10015 inline Address foreign_address();
10089 inline void set_foreign_address(Address value); 10016 inline void set_foreign_address(Address value);
10090 10017
10091 DECLARE_CAST(Foreign) 10018 DECLARE_CAST(Foreign)
10092 10019
10093 // Dispatched behavior. 10020 // 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) 10021 DECLARE_PRINTER(Foreign)
10101 DECLARE_VERIFIER(Foreign) 10022 DECLARE_VERIFIER(Foreign)
10102 10023
10103 // Layout description. 10024 // Layout description.
10104 10025
10105 static const int kForeignAddressOffset = HeapObject::kHeaderSize; 10026 static const int kForeignAddressOffset = HeapObject::kHeaderSize;
10106 static const int kSize = kForeignAddressOffset + kPointerSize; 10027 static const int kSize = kForeignAddressOffset + kPointerSize;
10107 10028
10108 STATIC_ASSERT(kForeignAddressOffset == Internals::kForeignAddressOffset); 10029 STATIC_ASSERT(kForeignAddressOffset == Internals::kForeignAddressOffset);
10109 10030
10031 class BodyDescriptor;
10032
10110 private: 10033 private:
10111 DISALLOW_IMPLICIT_CONSTRUCTORS(Foreign); 10034 DISALLOW_IMPLICIT_CONSTRUCTORS(Foreign);
10112 }; 10035 };
10113 10036
10114 10037
10115 // The JSArray describes JavaScript Arrays 10038 // The JSArray describes JavaScript Arrays
10116 // Such an array can be in one of two modes: 10039 // Such an array can be in one of two modes:
10117 // - fast, backing storage is a FixedArray and length <= elements.length(); 10040 // - 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. 10041 // 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. 10042 // - slow, backing storage is a HashTable with numbers as keys.
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
10763 // Visits a handle that has an embedder-assigned class ID. 10686 // Visits a handle that has an embedder-assigned class ID.
10764 virtual void VisitEmbedderReference(Object** p, uint16_t class_id) {} 10687 virtual void VisitEmbedderReference(Object** p, uint16_t class_id) {}
10765 10688
10766 // Intended for serialization/deserialization checking: insert, or 10689 // Intended for serialization/deserialization checking: insert, or
10767 // check for the presence of, a tag at this position in the stream. 10690 // check for the presence of, a tag at this position in the stream.
10768 // Also used for marking up GC roots in heap snapshots. 10691 // Also used for marking up GC roots in heap snapshots.
10769 virtual void Synchronize(VisitorSynchronization::SyncTag tag) {} 10692 virtual void Synchronize(VisitorSynchronization::SyncTag tag) {}
10770 }; 10693 };
10771 10694
10772 10695
10773 typedef FlexibleBodyDescriptor<HeapObject::kHeaderSize> StructBodyDescriptor;
10774
10775
10776 // BooleanBit is a helper class for setting and getting a bit in an integer. 10696 // BooleanBit is a helper class for setting and getting a bit in an integer.
10777 class BooleanBit : public AllStatic { 10697 class BooleanBit : public AllStatic {
10778 public: 10698 public:
10779 static inline bool get(int value, int bit_position) { 10699 static inline bool get(int value, int bit_position) {
10780 return (value & (1 << bit_position)) != 0; 10700 return (value & (1 << bit_position)) != 0;
10781 } 10701 }
10782 10702
10783 static inline int set(int value, int bit_position, bool v) { 10703 static inline int set(int value, int bit_position, bool v) {
10784 if (v) { 10704 if (v) {
10785 value |= (1 << bit_position); 10705 value |= (1 << bit_position);
10786 } else { 10706 } else {
10787 value &= ~(1 << bit_position); 10707 value &= ~(1 << bit_position);
10788 } 10708 }
10789 return value; 10709 return value;
10790 } 10710 }
10791 }; 10711 };
10792 10712
10793 10713
10794 } // NOLINT, false-positive due to second-order macros. 10714 } // NOLINT, false-positive due to second-order macros.
10795 } // NOLINT, false-positive due to second-order macros. 10715 } // NOLINT, false-positive due to second-order macros.
10796 10716
10797 #endif // V8_OBJECTS_H_ 10717 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/heap/store-buffer.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698