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

Side by Side Diff: src/objects.h

Issue 3066044: Generalize virtually dispatched scavenger to virtually dispatched specialized visitors. (Closed)
Patch Set: cleanup Created 10 years, 4 months 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/mark-compact.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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 1099
1100 // Computes the object size from the map. 1100 // Computes the object size from the map.
1101 // Should only be used from SizeFromMap. 1101 // Should only be used from SizeFromMap.
1102 int SlowSizeFromMap(Map* map); 1102 int SlowSizeFromMap(Map* map);
1103 1103
1104 private: 1104 private:
1105 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject); 1105 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObject);
1106 }; 1106 };
1107 1107
1108 1108
1109 #define SLOT_ADDR(obj, offset) \
1110 reinterpret_cast<Object**>((obj)->address() + offset)
1111
1112 // This class describes a body of an object of a fixed size
1113 // in which all pointer fields are located in the [start_offset, end_offset)
1114 // interval.
1115 template<int start_offset, int end_offset, int size>
1116 class FixedBodyDescriptor {
1117 public:
1118 static const int kStartOffset = start_offset;
1119 static const int kEndOffset = end_offset;
1120 static const int kSize = size;
1121
1122 static inline void IterateBody(HeapObject* obj, ObjectVisitor* v);
1123
1124 template<typename StaticVisitor>
1125 static inline void IterateBody(HeapObject* obj) {
1126 StaticVisitor::VisitPointers(SLOT_ADDR(obj, start_offset),
1127 SLOT_ADDR(obj, end_offset));
1128 }
1129 };
1130
1131
1132 // This class describes a body of an object of a variable size
1133 // in which all pointer fields are located in the [start_offset, object_size)
1134 // interval.
1135 template<int start_offset>
1136 class FlexibleBodyDescriptor {
1137 public:
1138 static const int kStartOffset = start_offset;
1139
1140 static inline void IterateBody(HeapObject* obj,
1141 int object_size,
1142 ObjectVisitor* v);
1143
1144 template<typename StaticVisitor>
1145 static inline void IterateBody(HeapObject* obj, int object_size) {
1146 StaticVisitor::VisitPointers(SLOT_ADDR(obj, start_offset),
1147 SLOT_ADDR(obj, object_size));
1148 }
1149 };
1150
1151 #undef SLOT_ADDR
1152
1153
1109 // The HeapNumber class describes heap allocated numbers that cannot be 1154 // The HeapNumber class describes heap allocated numbers that cannot be
1110 // represented in a Smi (small integer) 1155 // represented in a Smi (small integer)
1111 class HeapNumber: public HeapObject { 1156 class HeapNumber: public HeapObject {
1112 public: 1157 public:
1113 // [value]: number value. 1158 // [value]: number value.
1114 inline double value(); 1159 inline double value();
1115 inline void set_value(double value); 1160 inline void set_value(double value);
1116 1161
1117 // Casting. 1162 // Casting.
1118 static inline HeapNumber* cast(Object* obj); 1163 static inline HeapNumber* cast(Object* obj);
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 bool ReferencesObject(Object* obj); 1560 bool ReferencesObject(Object* obj);
1516 1561
1517 // Casting. 1562 // Casting.
1518 static inline JSObject* cast(Object* obj); 1563 static inline JSObject* cast(Object* obj);
1519 1564
1520 // Disalow further properties to be added to the object. 1565 // Disalow further properties to be added to the object.
1521 Object* PreventExtensions(); 1566 Object* PreventExtensions();
1522 1567
1523 1568
1524 // Dispatched behavior. 1569 // Dispatched behavior.
1525 void JSObjectIterateBody(int object_size, ObjectVisitor* v);
1526 void JSObjectShortPrint(StringStream* accumulator); 1570 void JSObjectShortPrint(StringStream* accumulator);
1527 #ifdef DEBUG 1571 #ifdef DEBUG
1528 void JSObjectPrint(); 1572 void JSObjectPrint();
1529 void JSObjectVerify(); 1573 void JSObjectVerify();
1530 void PrintProperties(); 1574 void PrintProperties();
1531 void PrintElements(); 1575 void PrintElements();
1532 1576
1533 // Structure for collecting spill information about JSObjects. 1577 // Structure for collecting spill information about JSObjects.
1534 class SpillInformation { 1578 class SpillInformation {
1535 public: 1579 public:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 // to the same object requires fewer allocations and copies. 1615 // to the same object requires fewer allocations and copies.
1572 static const int kFieldsAdded = 3; 1616 static const int kFieldsAdded = 3;
1573 1617
1574 // Layout description. 1618 // Layout description.
1575 static const int kPropertiesOffset = HeapObject::kHeaderSize; 1619 static const int kPropertiesOffset = HeapObject::kHeaderSize;
1576 static const int kElementsOffset = kPropertiesOffset + kPointerSize; 1620 static const int kElementsOffset = kPropertiesOffset + kPointerSize;
1577 static const int kHeaderSize = kElementsOffset + kPointerSize; 1621 static const int kHeaderSize = kElementsOffset + kPointerSize;
1578 1622
1579 STATIC_CHECK(kHeaderSize == Internals::kJSObjectHeaderSize); 1623 STATIC_CHECK(kHeaderSize == Internals::kJSObjectHeaderSize);
1580 1624
1625 class BodyDescriptor : public FlexibleBodyDescriptor<kPropertiesOffset> {
1626 public:
1627 static inline int SizeOf(Map* map, HeapObject* object);
1628 };
1629
1581 private: 1630 private:
1582 Object* GetElementWithCallback(Object* receiver, 1631 Object* GetElementWithCallback(Object* receiver,
1583 Object* structure, 1632 Object* structure,
1584 uint32_t index, 1633 uint32_t index,
1585 Object* holder); 1634 Object* holder);
1586 Object* SetElementWithCallback(Object* structure, 1635 Object* SetElementWithCallback(Object* structure,
1587 uint32_t index, 1636 uint32_t index,
1588 Object* value, 1637 Object* value,
1589 JSObject* holder); 1638 JSObject* holder);
1590 Object* SetElementWithInterceptor(uint32_t index, Object* value); 1639 Object* SetElementWithInterceptor(uint32_t index, Object* value);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 static const int kHeaderSize = kLengthOffset + kPointerSize; 1734 static const int kHeaderSize = kLengthOffset + kPointerSize;
1686 1735
1687 // Maximal allowed size, in bytes, of a single FixedArray. 1736 // Maximal allowed size, in bytes, of a single FixedArray.
1688 // Prevents overflowing size computations, as well as extreme memory 1737 // Prevents overflowing size computations, as well as extreme memory
1689 // consumption. 1738 // consumption.
1690 static const int kMaxSize = 512 * MB; 1739 static const int kMaxSize = 512 * MB;
1691 // Maximally allowed length of a FixedArray. 1740 // Maximally allowed length of a FixedArray.
1692 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize; 1741 static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize;
1693 1742
1694 // Dispatched behavior. 1743 // Dispatched behavior.
1695 int FixedArraySize() { return SizeFor(length()); }
1696 void FixedArrayIterateBody(ObjectVisitor* v);
1697 #ifdef DEBUG 1744 #ifdef DEBUG
1698 void FixedArrayPrint(); 1745 void FixedArrayPrint();
1699 void FixedArrayVerify(); 1746 void FixedArrayVerify();
1700 // Checks if two FixedArrays have identical contents. 1747 // Checks if two FixedArrays have identical contents.
1701 bool IsEqualTo(FixedArray* other); 1748 bool IsEqualTo(FixedArray* other);
1702 #endif 1749 #endif
1703 1750
1704 // Swap two elements in a pair of arrays. If this array and the 1751 // Swap two elements in a pair of arrays. If this array and the
1705 // numbers array are the same object, the elements are only swapped 1752 // numbers array are the same object, the elements are only swapped
1706 // once. 1753 // once.
1707 void SwapPairs(FixedArray* numbers, int i, int j); 1754 void SwapPairs(FixedArray* numbers, int i, int j);
1708 1755
1709 // Sort prefix of this array and the numbers array as pairs wrt. the 1756 // Sort prefix of this array and the numbers array as pairs wrt. the
1710 // numbers. If the numbers array and the this array are the same 1757 // numbers. If the numbers array and the this array are the same
1711 // object, the prefix of this array is sorted. 1758 // object, the prefix of this array is sorted.
1712 void SortPairs(FixedArray* numbers, uint32_t len); 1759 void SortPairs(FixedArray* numbers, uint32_t len);
1713 1760
1761 class BodyDescriptor : public FlexibleBodyDescriptor<kHeaderSize> {
1762 public:
1763 static inline int SizeOf(Map* map, HeapObject* object) {
1764 return SizeFor(reinterpret_cast<FixedArray*>(object)->length());
1765 }
1766 };
1767
1714 protected: 1768 protected:
1715 // Set operation on FixedArray without using write barriers. Can 1769 // Set operation on FixedArray without using write barriers. Can
1716 // only be used for storing old space objects or smis. 1770 // only be used for storing old space objects or smis.
1717 static inline void fast_set(FixedArray* array, int index, Object* value); 1771 static inline void fast_set(FixedArray* array, int index, Object* value);
1718 1772
1719 private: 1773 private:
1720 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray); 1774 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray);
1721 }; 1775 };
1722 1776
1723 1777
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
2419 // Returns data start address. 2473 // Returns data start address.
2420 inline Address GetDataStartAddress(); 2474 inline Address GetDataStartAddress();
2421 2475
2422 // Returns a pointer to the ByteArray object for a given data start address. 2476 // Returns a pointer to the ByteArray object for a given data start address.
2423 static inline ByteArray* FromDataStartAddress(Address address); 2477 static inline ByteArray* FromDataStartAddress(Address address);
2424 2478
2425 // Casting. 2479 // Casting.
2426 static inline ByteArray* cast(Object* obj); 2480 static inline ByteArray* cast(Object* obj);
2427 2481
2428 // Dispatched behavior. 2482 // Dispatched behavior.
2429 int ByteArraySize() { return SizeFor(length()); } 2483 inline int ByteArraySize() {
2484 return SizeFor(this->length());
2485 }
2430 #ifdef DEBUG 2486 #ifdef DEBUG
2431 void ByteArrayPrint(); 2487 void ByteArrayPrint();
2432 void ByteArrayVerify(); 2488 void ByteArrayVerify();
2433 #endif 2489 #endif
2434 2490
2435 // Layout description. 2491 // Layout description.
2436 // Length is smi tagged when it is stored. 2492 // Length is smi tagged when it is stored.
2437 static const int kLengthOffset = HeapObject::kHeaderSize; 2493 static const int kLengthOffset = HeapObject::kHeaderSize;
2438 static const int kHeaderSize = kLengthOffset + kPointerSize; 2494 static const int kHeaderSize = kLengthOffset + kPointerSize;
2439 2495
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
2840 2896
2841 // Locating source position. 2897 // Locating source position.
2842 int SourcePosition(Address pc); 2898 int SourcePosition(Address pc);
2843 int SourceStatementPosition(Address pc); 2899 int SourceStatementPosition(Address pc);
2844 2900
2845 // Casting. 2901 // Casting.
2846 static inline Code* cast(Object* obj); 2902 static inline Code* cast(Object* obj);
2847 2903
2848 // Dispatched behavior. 2904 // Dispatched behavior.
2849 int CodeSize() { return SizeFor(body_size()); } 2905 int CodeSize() { return SizeFor(body_size()); }
2850 void CodeIterateBody(ObjectVisitor* v); 2906 inline void CodeIterateBody(ObjectVisitor* v);
2907
2908 template<typename StaticVisitor>
2909 inline void CodeIterateBody();
2851 #ifdef DEBUG 2910 #ifdef DEBUG
2852 void CodePrint(); 2911 void CodePrint();
2853 void CodeVerify(); 2912 void CodeVerify();
2854 #endif 2913 #endif
2855 // Code entry points are aligned to 32 bytes. 2914 // Code entry points are aligned to 32 bytes.
2856 static const int kCodeAlignmentBits = 5; 2915 static const int kCodeAlignmentBits = 5;
2857 static const int kCodeAlignment = 1 << kCodeAlignmentBits; 2916 static const int kCodeAlignment = 1 << kCodeAlignmentBits;
2858 static const int kCodeAlignmentMask = kCodeAlignment - 1; 2917 static const int kCodeAlignmentMask = kCodeAlignment - 1;
2859 2918
2860 // Layout description. 2919 // Layout description.
(...skipping 25 matching lines...) Expand all
2886 static const int kFlagsCacheInPrototypeMapMask = 0x00000800; 2945 static const int kFlagsCacheInPrototypeMapMask = 0x00000800;
2887 static const int kFlagsArgumentsCountMask = 0xFFFFF000; 2946 static const int kFlagsArgumentsCountMask = 0xFFFFF000;
2888 2947
2889 static const int kFlagsNotUsedInLookup = 2948 static const int kFlagsNotUsedInLookup =
2890 (kFlagsICInLoopMask | kFlagsTypeMask | kFlagsCacheInPrototypeMapMask); 2949 (kFlagsICInLoopMask | kFlagsTypeMask | kFlagsCacheInPrototypeMapMask);
2891 2950
2892 private: 2951 private:
2893 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); 2952 DISALLOW_IMPLICIT_CONSTRUCTORS(Code);
2894 }; 2953 };
2895 2954
2896 typedef void (*Scavenger)(Map* map, HeapObject** slot, HeapObject* object);
2897 2955
2898 // All heap objects have a Map that describes their structure. 2956 // All heap objects have a Map that describes their structure.
2899 // A Map contains information about: 2957 // A Map contains information about:
2900 // - Size information about the object 2958 // - Size information about the object
2901 // - How to iterate over an object (for garbage collection) 2959 // - How to iterate over an object (for garbage collection)
2902 class Map: public HeapObject { 2960 class Map: public HeapObject {
2903 public: 2961 public:
2904 // Instance size. 2962 // Instance size.
2905 inline int instance_size(); 2963 inline int instance_size();
2906 inline void set_instance_size(int value); 2964 inline void set_instance_size(int value);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
3082 // This is undone in MarkCompactCollector::ClearNonLiveTransitions(). 3140 // This is undone in MarkCompactCollector::ClearNonLiveTransitions().
3083 void CreateBackPointers(); 3141 void CreateBackPointers();
3084 3142
3085 // Set all map transitions from this map to dead maps to null. 3143 // Set all map transitions from this map to dead maps to null.
3086 // Also, restore the original prototype on the targets of these 3144 // Also, restore the original prototype on the targets of these
3087 // transitions, so that we do not process this map again while 3145 // transitions, so that we do not process this map again while
3088 // following back pointers. 3146 // following back pointers.
3089 void ClearNonLiveTransitions(Object* real_prototype); 3147 void ClearNonLiveTransitions(Object* real_prototype);
3090 3148
3091 // Dispatched behavior. 3149 // Dispatched behavior.
3092 void MapIterateBody(ObjectVisitor* v);
3093 #ifdef DEBUG 3150 #ifdef DEBUG
3094 void MapPrint(); 3151 void MapPrint();
3095 void MapVerify(); 3152 void MapVerify();
3096 #endif 3153 #endif
3097 3154
3098 inline Scavenger scavenger(); 3155 inline int visitor_id();
3099 inline void set_scavenger(Scavenger callback); 3156 inline void set_visitor_id(int visitor_id);
3100
3101 inline void Scavenge(HeapObject** slot, HeapObject* obj) {
3102 scavenger()(this, slot, obj);
3103 }
3104 3157
3105 static const int kMaxPreAllocatedPropertyFields = 255; 3158 static const int kMaxPreAllocatedPropertyFields = 255;
3106 3159
3107 // Layout description. 3160 // Layout description.
3108 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; 3161 static const int kInstanceSizesOffset = HeapObject::kHeaderSize;
3109 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; 3162 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize;
3110 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; 3163 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize;
3111 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; 3164 static const int kConstructorOffset = kPrototypeOffset + kPointerSize;
3112 static const int kInstanceDescriptorsOffset = 3165 static const int kInstanceDescriptorsOffset =
3113 kConstructorOffset + kPointerSize; 3166 kConstructorOffset + kPointerSize;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3153 // Bit positions for bit field 2 3206 // Bit positions for bit field 2
3154 static const int kIsExtensible = 0; 3207 static const int kIsExtensible = 0;
3155 static const int kFunctionWithPrototype = 1; 3208 static const int kFunctionWithPrototype = 1;
3156 static const int kHasFastElements = 2; 3209 static const int kHasFastElements = 2;
3157 3210
3158 // Layout of the default cache. It holds alternating name and code objects. 3211 // Layout of the default cache. It holds alternating name and code objects.
3159 static const int kCodeCacheEntrySize = 2; 3212 static const int kCodeCacheEntrySize = 2;
3160 static const int kCodeCacheEntryNameOffset = 0; 3213 static const int kCodeCacheEntryNameOffset = 0;
3161 static const int kCodeCacheEntryCodeOffset = 1; 3214 static const int kCodeCacheEntryCodeOffset = 1;
3162 3215
3216 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset,
3217 kPointerFieldsEndOffset,
3218 kSize> BodyDescriptor;
3219
3163 private: 3220 private:
3164 DISALLOW_IMPLICIT_CONSTRUCTORS(Map); 3221 DISALLOW_IMPLICIT_CONSTRUCTORS(Map);
3165 }; 3222 };
3166 3223
3167 3224
3168 // An abstract superclass, a marker class really, for simple structure classes. 3225 // An abstract superclass, a marker class really, for simple structure classes.
3169 // It doesn't carry much functionality but allows struct classes to me 3226 // It doesn't carry much functionality but allows struct classes to me
3170 // identified in the type system. 3227 // identified in the type system.
3171 class Struct: public HeapObject { 3228 class Struct: public HeapObject {
3172 public: 3229 public:
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3407 bool HasSourceCode(); 3464 bool HasSourceCode();
3408 Object* GetSourceCode(); 3465 Object* GetSourceCode();
3409 3466
3410 // Calculate the instance size. 3467 // Calculate the instance size.
3411 int CalculateInstanceSize(); 3468 int CalculateInstanceSize();
3412 3469
3413 // Calculate the number of in-object properties. 3470 // Calculate the number of in-object properties.
3414 int CalculateInObjectProperties(); 3471 int CalculateInObjectProperties();
3415 3472
3416 // Dispatched behavior. 3473 // Dispatched behavior.
3417 void SharedFunctionInfoIterateBody(ObjectVisitor* v);
3418 // Set max_length to -1 for unlimited length. 3474 // Set max_length to -1 for unlimited length.
3419 void SourceCodePrint(StringStream* accumulator, int max_length); 3475 void SourceCodePrint(StringStream* accumulator, int max_length);
3420 #ifdef DEBUG 3476 #ifdef DEBUG
3421 void SharedFunctionInfoPrint(); 3477 void SharedFunctionInfoPrint();
3422 void SharedFunctionInfoVerify(); 3478 void SharedFunctionInfoVerify();
3423 #endif 3479 #endif
3424 3480
3425 // Casting. 3481 // Casting.
3426 static inline SharedFunctionInfo* cast(Object* obj); 3482 static inline SharedFunctionInfo* cast(Object* obj);
3427 3483
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3496 3552
3497 static const int kThisPropertyAssignmentsCountOffset = 3553 static const int kThisPropertyAssignmentsCountOffset =
3498 kCompilerHintsOffset + kIntSize; 3554 kCompilerHintsOffset + kIntSize;
3499 3555
3500 // Total size. 3556 // Total size.
3501 static const int kSize = kThisPropertyAssignmentsCountOffset + kIntSize; 3557 static const int kSize = kThisPropertyAssignmentsCountOffset + kIntSize;
3502 3558
3503 #endif 3559 #endif
3504 static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize); 3560 static const int kAlignedSize = POINTER_SIZE_ALIGN(kSize);
3505 3561
3562 typedef FixedBodyDescriptor<kNameOffset,
3563 kThisPropertyAssignmentsOffset + kPointerSize,
3564 kSize> BodyDescriptor;
3565
3506 private: 3566 private:
3507 // Bit positions in start_position_and_type. 3567 // Bit positions in start_position_and_type.
3508 // The source code start position is in the 30 most significant bits of 3568 // The source code start position is in the 30 most significant bits of
3509 // the start_position_and_type field. 3569 // the start_position_and_type field.
3510 static const int kIsExpressionBit = 0; 3570 static const int kIsExpressionBit = 0;
3511 static const int kIsTopLevelBit = 1; 3571 static const int kIsTopLevelBit = 1;
3512 static const int kStartPositionShift = 2; 3572 static const int kStartPositionShift = 2;
3513 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); 3573 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1);
3514 3574
3515 // Bit positions in compiler_hints. 3575 // Bit positions in compiler_hints.
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
4544 inline Object* unchecked_second(); 4604 inline Object* unchecked_second();
4545 inline void set_second(String* second, 4605 inline void set_second(String* second,
4546 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 4606 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
4547 4607
4548 // Dispatched behavior. 4608 // Dispatched behavior.
4549 uint16_t ConsStringGet(int index); 4609 uint16_t ConsStringGet(int index);
4550 4610
4551 // Casting. 4611 // Casting.
4552 static inline ConsString* cast(Object* obj); 4612 static inline ConsString* cast(Object* obj);
4553 4613
4554 // Garbage collection support. This method is called during garbage
4555 // collection to iterate through the heap pointers in the body of
4556 // the ConsString.
4557 void ConsStringIterateBody(ObjectVisitor* v);
4558
4559 // Layout description. 4614 // Layout description.
4560 static const int kFirstOffset = POINTER_SIZE_ALIGN(String::kSize); 4615 static const int kFirstOffset = POINTER_SIZE_ALIGN(String::kSize);
4561 static const int kSecondOffset = kFirstOffset + kPointerSize; 4616 static const int kSecondOffset = kFirstOffset + kPointerSize;
4562 static const int kSize = kSecondOffset + kPointerSize; 4617 static const int kSize = kSecondOffset + kPointerSize;
4563 4618
4564 // Support for StringInputBuffer. 4619 // Support for StringInputBuffer.
4565 inline const unibrow::byte* ConsStringReadBlock(ReadBlockBuffer* buffer, 4620 inline const unibrow::byte* ConsStringReadBlock(ReadBlockBuffer* buffer,
4566 unsigned* offset_ptr, 4621 unsigned* offset_ptr,
4567 unsigned chars); 4622 unsigned chars);
4568 inline void ConsStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, 4623 inline void ConsStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
4569 unsigned* offset_ptr, 4624 unsigned* offset_ptr,
4570 unsigned chars); 4625 unsigned chars);
4571 4626
4572 // Minimum length for a cons string. 4627 // Minimum length for a cons string.
4573 static const int kMinLength = 13; 4628 static const int kMinLength = 13;
4574 4629
4630 typedef FixedBodyDescriptor<kFirstOffset, kSecondOffset + kPointerSize, kSize>
4631 BodyDescriptor;
4632
4575 private: 4633 private:
4576 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); 4634 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString);
4577 }; 4635 };
4578 4636
4579 4637
4580 // The ExternalString class describes string values that are backed by 4638 // The ExternalString class describes string values that are backed by
4581 // a string resource that lies outside the V8 heap. ExternalStrings 4639 // a string resource that lies outside the V8 heap. ExternalStrings
4582 // consist of the length field common to all strings, a pointer to the 4640 // consist of the length field common to all strings, a pointer to the
4583 // external resource. It is important to ensure (externally) that the 4641 // external resource. It is important to ensure (externally) that the
4584 // resource is not deallocated while the ExternalString is live in the 4642 // resource is not deallocated while the ExternalString is live in the
(...skipping 29 matching lines...) Expand all
4614 inline Resource* resource(); 4672 inline Resource* resource();
4615 inline void set_resource(Resource* buffer); 4673 inline void set_resource(Resource* buffer);
4616 4674
4617 // Dispatched behavior. 4675 // Dispatched behavior.
4618 uint16_t ExternalAsciiStringGet(int index); 4676 uint16_t ExternalAsciiStringGet(int index);
4619 4677
4620 // Casting. 4678 // Casting.
4621 static inline ExternalAsciiString* cast(Object* obj); 4679 static inline ExternalAsciiString* cast(Object* obj);
4622 4680
4623 // Garbage collection support. 4681 // Garbage collection support.
4624 void ExternalAsciiStringIterateBody(ObjectVisitor* v); 4682 inline void ExternalAsciiStringIterateBody(ObjectVisitor* v);
4683
4684 template<typename StaticVisitor>
4685 inline void ExternalAsciiStringIterateBody();
4625 4686
4626 // Support for StringInputBuffer. 4687 // Support for StringInputBuffer.
4627 const unibrow::byte* ExternalAsciiStringReadBlock(unsigned* remaining, 4688 const unibrow::byte* ExternalAsciiStringReadBlock(unsigned* remaining,
4628 unsigned* offset, 4689 unsigned* offset,
4629 unsigned chars); 4690 unsigned chars);
4630 inline void ExternalAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, 4691 inline void ExternalAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
4631 unsigned* offset, 4692 unsigned* offset,
4632 unsigned chars); 4693 unsigned chars);
4633 4694
4634 private: 4695 private:
(...skipping 16 matching lines...) Expand all
4651 // Dispatched behavior. 4712 // Dispatched behavior.
4652 uint16_t ExternalTwoByteStringGet(int index); 4713 uint16_t ExternalTwoByteStringGet(int index);
4653 4714
4654 // For regexp code. 4715 // For regexp code.
4655 const uint16_t* ExternalTwoByteStringGetData(unsigned start); 4716 const uint16_t* ExternalTwoByteStringGetData(unsigned start);
4656 4717
4657 // Casting. 4718 // Casting.
4658 static inline ExternalTwoByteString* cast(Object* obj); 4719 static inline ExternalTwoByteString* cast(Object* obj);
4659 4720
4660 // Garbage collection support. 4721 // Garbage collection support.
4661 void ExternalTwoByteStringIterateBody(ObjectVisitor* v); 4722 inline void ExternalTwoByteStringIterateBody(ObjectVisitor* v);
4723
4724 template<typename StaticVisitor>
4725 inline void ExternalTwoByteStringIterateBody();
4726
4662 4727
4663 // Support for StringInputBuffer. 4728 // Support for StringInputBuffer.
4664 void ExternalTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, 4729 void ExternalTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
4665 unsigned* offset_ptr, 4730 unsigned* offset_ptr,
4666 unsigned chars); 4731 unsigned chars);
4667 4732
4668 private: 4733 private:
4669 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString); 4734 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString);
4670 }; 4735 };
4671 4736
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
4762 // [to_string]: Cached to_string computed at startup. 4827 // [to_string]: Cached to_string computed at startup.
4763 DECL_ACCESSORS(to_string, String) 4828 DECL_ACCESSORS(to_string, String)
4764 4829
4765 // [to_number]: Cached to_number computed at startup. 4830 // [to_number]: Cached to_number computed at startup.
4766 DECL_ACCESSORS(to_number, Object) 4831 DECL_ACCESSORS(to_number, Object)
4767 4832
4768 // Casting. 4833 // Casting.
4769 static inline Oddball* cast(Object* obj); 4834 static inline Oddball* cast(Object* obj);
4770 4835
4771 // Dispatched behavior. 4836 // Dispatched behavior.
4772 void OddballIterateBody(ObjectVisitor* v);
4773 #ifdef DEBUG 4837 #ifdef DEBUG
4774 void OddballVerify(); 4838 void OddballVerify();
4775 #endif 4839 #endif
4776 4840
4777 // Initialize the fields. 4841 // Initialize the fields.
4778 Object* Initialize(const char* to_string, Object* to_number); 4842 Object* Initialize(const char* to_string, Object* to_number);
4779 4843
4780 // Layout description. 4844 // Layout description.
4781 static const int kToStringOffset = HeapObject::kHeaderSize; 4845 static const int kToStringOffset = HeapObject::kHeaderSize;
4782 static const int kToNumberOffset = kToStringOffset + kPointerSize; 4846 static const int kToNumberOffset = kToStringOffset + kPointerSize;
4783 static const int kSize = kToNumberOffset + kPointerSize; 4847 static const int kSize = kToNumberOffset + kPointerSize;
4784 4848
4849 typedef FixedBodyDescriptor<kToStringOffset,
4850 kToNumberOffset + kPointerSize,
4851 kSize> BodyDescriptor;
4852
4785 private: 4853 private:
4786 DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball); 4854 DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball);
4787 }; 4855 };
4788 4856
4789 4857
4790 class JSGlobalPropertyCell: public HeapObject { 4858 class JSGlobalPropertyCell: public HeapObject {
4791 public: 4859 public:
4792 // [value]: value of the global property. 4860 // [value]: value of the global property.
4793 DECL_ACCESSORS(value, Object) 4861 DECL_ACCESSORS(value, Object)
4794 4862
4795 // Casting. 4863 // Casting.
4796 static inline JSGlobalPropertyCell* cast(Object* obj); 4864 static inline JSGlobalPropertyCell* cast(Object* obj);
4797 4865
4798 // Dispatched behavior.
4799 void JSGlobalPropertyCellIterateBody(ObjectVisitor* v);
4800 #ifdef DEBUG 4866 #ifdef DEBUG
4801 void JSGlobalPropertyCellVerify(); 4867 void JSGlobalPropertyCellVerify();
4802 void JSGlobalPropertyCellPrint(); 4868 void JSGlobalPropertyCellPrint();
4803 #endif 4869 #endif
4804 4870
4805 // Layout description. 4871 // Layout description.
4806 static const int kValueOffset = HeapObject::kHeaderSize; 4872 static const int kValueOffset = HeapObject::kHeaderSize;
4807 static const int kSize = kValueOffset + kPointerSize; 4873 static const int kSize = kValueOffset + kPointerSize;
4808 4874
4875 typedef FixedBodyDescriptor<kValueOffset,
4876 kValueOffset + kPointerSize,
4877 kSize> BodyDescriptor;
4878
4809 private: 4879 private:
4810 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell); 4880 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell);
4811 }; 4881 };
4812 4882
4813 4883
4814 4884
4815 // Proxy describes objects pointing from JavaScript to C structures. 4885 // Proxy describes objects pointing from JavaScript to C structures.
4816 // Since they cannot contain references to JS HeapObjects they can be 4886 // Since they cannot contain references to JS HeapObjects they can be
4817 // placed in old_data_space. 4887 // placed in old_data_space.
4818 class Proxy: public HeapObject { 4888 class Proxy: public HeapObject {
4819 public: 4889 public:
4820 // [proxy]: field containing the address. 4890 // [proxy]: field containing the address.
4821 inline Address proxy(); 4891 inline Address proxy();
4822 inline void set_proxy(Address value); 4892 inline void set_proxy(Address value);
4823 4893
4824 // Casting. 4894 // Casting.
4825 static inline Proxy* cast(Object* obj); 4895 static inline Proxy* cast(Object* obj);
4826 4896
4827 // Dispatched behavior. 4897 // Dispatched behavior.
4828 inline void ProxyIterateBody(ObjectVisitor* v); 4898 inline void ProxyIterateBody(ObjectVisitor* v);
4899
4900 template<typename StaticVisitor>
4901 inline void ProxyIterateBody();
4902
4829 #ifdef DEBUG 4903 #ifdef DEBUG
4830 void ProxyPrint(); 4904 void ProxyPrint();
4831 void ProxyVerify(); 4905 void ProxyVerify();
4832 #endif 4906 #endif
4833 4907
4834 // Layout description. 4908 // Layout description.
4835 4909
4836 static const int kProxyOffset = HeapObject::kHeaderSize; 4910 static const int kProxyOffset = HeapObject::kHeaderSize;
4837 static const int kSize = kProxyOffset + kPointerSize; 4911 static const int kSize = kProxyOffset + kPointerSize;
4838 4912
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
5336 #ifdef DEBUG 5410 #ifdef DEBUG
5337 // Intended for serialization/deserialization checking: insert, or 5411 // Intended for serialization/deserialization checking: insert, or
5338 // check for the presence of, a tag at this position in the stream. 5412 // check for the presence of, a tag at this position in the stream.
5339 virtual void Synchronize(const char* tag) {} 5413 virtual void Synchronize(const char* tag) {}
5340 #else 5414 #else
5341 inline void Synchronize(const char* tag) {} 5415 inline void Synchronize(const char* tag) {}
5342 #endif 5416 #endif
5343 }; 5417 };
5344 5418
5345 5419
5420 class StructBodyDescriptor : public
5421 FlexibleBodyDescriptor<HeapObject::kHeaderSize> {
5422 public:
5423 static inline int SizeOf(Map* map, HeapObject* object) {
5424 return map->instance_size();
5425 }
5426 };
5427
5428
5346 // BooleanBit is a helper class for setting and getting a bit in an 5429 // BooleanBit is a helper class for setting and getting a bit in an
5347 // integer or Smi. 5430 // integer or Smi.
5348 class BooleanBit : public AllStatic { 5431 class BooleanBit : public AllStatic {
5349 public: 5432 public:
5350 static inline bool get(Smi* smi, int bit_position) { 5433 static inline bool get(Smi* smi, int bit_position) {
5351 return get(smi->value(), bit_position); 5434 return get(smi->value(), bit_position);
5352 } 5435 }
5353 5436
5354 static inline bool get(int value, int bit_position) { 5437 static inline bool get(int value, int bit_position) {
5355 return (value & (1 << bit_position)) != 0; 5438 return (value & (1 << bit_position)) != 0;
5356 } 5439 }
5357 5440
5358 static inline Smi* set(Smi* smi, int bit_position, bool v) { 5441 static inline Smi* set(Smi* smi, int bit_position, bool v) {
5359 return Smi::FromInt(set(smi->value(), bit_position, v)); 5442 return Smi::FromInt(set(smi->value(), bit_position, v));
5360 } 5443 }
5361 5444
5362 static inline int set(int value, int bit_position, bool v) { 5445 static inline int set(int value, int bit_position, bool v) {
5363 if (v) { 5446 if (v) {
5364 value |= (1 << bit_position); 5447 value |= (1 << bit_position);
5365 } else { 5448 } else {
5366 value &= ~(1 << bit_position); 5449 value &= ~(1 << bit_position);
5367 } 5450 }
5368 return value; 5451 return value;
5369 } 5452 }
5370 }; 5453 };
5371 5454
5372 } } // namespace v8::internal 5455 } } // namespace v8::internal
5373 5456
5374 #endif // V8_OBJECTS_H_ 5457 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mark-compact.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698