OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 V(MapCache) \ | 1037 V(MapCache) \ |
1038 V(Primitive) \ | 1038 V(Primitive) \ |
1039 V(GlobalObject) \ | 1039 V(GlobalObject) \ |
1040 V(JSGlobalObject) \ | 1040 V(JSGlobalObject) \ |
1041 V(JSBuiltinsObject) \ | 1041 V(JSBuiltinsObject) \ |
1042 V(JSGlobalProxy) \ | 1042 V(JSGlobalProxy) \ |
1043 V(UndetectableObject) \ | 1043 V(UndetectableObject) \ |
1044 V(AccessCheckNeeded) \ | 1044 V(AccessCheckNeeded) \ |
1045 V(Cell) \ | 1045 V(Cell) \ |
1046 V(PropertyCell) \ | 1046 V(PropertyCell) \ |
1047 V(ObjectHashTable) | 1047 V(ObjectHashTable) \ |
| 1048 V(WeakHashTable) |
1048 | 1049 |
1049 | 1050 |
1050 #define ERROR_MESSAGES_LIST(V) \ | 1051 #define ERROR_MESSAGES_LIST(V) \ |
1051 V(kNoReason, "no reason") \ | 1052 V(kNoReason, "no reason") \ |
1052 \ | 1053 \ |
1053 V(k32BitValueInRegisterIsNotZeroExtended, \ | 1054 V(k32BitValueInRegisterIsNotZeroExtended, \ |
1054 "32 bit value in register is not zero-extended") \ | 1055 "32 bit value in register is not zero-extended") \ |
1055 V(kAlignmentMarkerExpected, "alignment marker expected") \ | 1056 V(kAlignmentMarkerExpected, "alignment marker expected") \ |
1056 V(kAllocationIsNotDoubleAligned, "Allocation is not double aligned") \ | 1057 V(kAllocationIsNotDoubleAligned, "Allocation is not double aligned") \ |
1057 V(kAPICallReturnedInvalidObject, "API call returned invalid object") \ | 1058 V(kAPICallReturnedInvalidObject, "API call returned invalid object") \ |
(...skipping 1826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2884 inline void set_the_hole(int index); | 2885 inline void set_the_hole(int index); |
2885 | 2886 |
2886 inline Object** GetFirstElementAddress(); | 2887 inline Object** GetFirstElementAddress(); |
2887 inline bool ContainsOnlySmisOrHoles(); | 2888 inline bool ContainsOnlySmisOrHoles(); |
2888 | 2889 |
2889 // Gives access to raw memory which stores the array's data. | 2890 // Gives access to raw memory which stores the array's data. |
2890 inline Object** data_start(); | 2891 inline Object** data_start(); |
2891 | 2892 |
2892 // Copy operations. | 2893 // Copy operations. |
2893 MUST_USE_RESULT inline MaybeObject* Copy(); | 2894 MUST_USE_RESULT inline MaybeObject* Copy(); |
2894 MUST_USE_RESULT MaybeObject* CopySize(int new_length); | 2895 MUST_USE_RESULT MaybeObject* CopySize(int new_length, |
| 2896 PretenureFlag pretenure = NOT_TENURED); |
2895 | 2897 |
2896 // Add the elements of a JSArray to this FixedArray. | 2898 // Add the elements of a JSArray to this FixedArray. |
2897 MUST_USE_RESULT MaybeObject* AddKeysFromJSArray(JSArray* array); | 2899 MUST_USE_RESULT MaybeObject* AddKeysFromJSArray(JSArray* array); |
2898 | 2900 |
2899 // Compute the union of this and other. | 2901 // Compute the union of this and other. |
2900 MUST_USE_RESULT MaybeObject* UnionOfKeys(FixedArray* other); | 2902 MUST_USE_RESULT MaybeObject* UnionOfKeys(FixedArray* other); |
2901 | 2903 |
2902 // Copy a sub array from the receiver to dest. | 2904 // Copy a sub array from the receiver to dest. |
2903 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len); | 2905 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len); |
2904 | 2906 |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3519 | 3521 |
3520 void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode); | 3522 void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode); |
3521 | 3523 |
3522 // Rehashes this hash-table into the new table. | 3524 // Rehashes this hash-table into the new table. |
3523 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key); | 3525 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key); |
3524 | 3526 |
3525 // Attempt to shrink hash table after removal of key. | 3527 // Attempt to shrink hash table after removal of key. |
3526 MUST_USE_RESULT MaybeObject* Shrink(Key key); | 3528 MUST_USE_RESULT MaybeObject* Shrink(Key key); |
3527 | 3529 |
3528 // Ensure enough space for n additional elements. | 3530 // Ensure enough space for n additional elements. |
3529 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key); | 3531 MUST_USE_RESULT MaybeObject* EnsureCapacity( |
| 3532 int n, |
| 3533 Key key, |
| 3534 PretenureFlag pretenure = NOT_TENURED); |
3530 }; | 3535 }; |
3531 | 3536 |
3532 | 3537 |
3533 // HashTableKey is an abstract superclass for virtual key behavior. | 3538 // HashTableKey is an abstract superclass for virtual key behavior. |
3534 class HashTableKey { | 3539 class HashTableKey { |
3535 public: | 3540 public: |
3536 // Returns whether the other object matches this key. | 3541 // Returns whether the other object matches this key. |
3537 virtual bool IsMatch(Object* other) = 0; | 3542 virtual bool IsMatch(Object* other) = 0; |
3538 // Returns the hash value for this key. | 3543 // Returns the hash value for this key. |
3539 virtual uint32_t Hash() = 0; | 3544 virtual uint32_t Hash() = 0; |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3958 void AddEntry(int entry, Object* key, Object* value); | 3963 void AddEntry(int entry, Object* key, Object* value); |
3959 void RemoveEntry(int entry); | 3964 void RemoveEntry(int entry); |
3960 | 3965 |
3961 // Returns the index to the value of an entry. | 3966 // Returns the index to the value of an entry. |
3962 static inline int EntryToValueIndex(int entry) { | 3967 static inline int EntryToValueIndex(int entry) { |
3963 return EntryToIndex(entry) + 1; | 3968 return EntryToIndex(entry) + 1; |
3964 } | 3969 } |
3965 }; | 3970 }; |
3966 | 3971 |
3967 | 3972 |
| 3973 template <int entrysize> |
| 3974 class WeakHashTableShape : public BaseShape<Object*> { |
| 3975 public: |
| 3976 static inline bool IsMatch(Object* key, Object* other); |
| 3977 static inline uint32_t Hash(Object* key); |
| 3978 static inline uint32_t HashForObject(Object* key, Object* object); |
| 3979 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, |
| 3980 Object* key); |
| 3981 static const int kPrefixSize = 0; |
| 3982 static const int kEntrySize = entrysize; |
| 3983 }; |
| 3984 |
| 3985 |
| 3986 // WeakHashTable maps keys that are arbitrary objects to object values. |
| 3987 // It is used for the global weak hash table that maps objects |
| 3988 // embedded in optimized code to dependent code lists. |
| 3989 class WeakHashTable: public HashTable<WeakHashTableShape<2>, Object*> { |
| 3990 public: |
| 3991 static inline WeakHashTable* cast(Object* obj) { |
| 3992 ASSERT(obj->IsHashTable()); |
| 3993 return reinterpret_cast<WeakHashTable*>(obj); |
| 3994 } |
| 3995 |
| 3996 // Looks up the value associated with the given key. The hole value is |
| 3997 // returned in case the key is not present. |
| 3998 Object* Lookup(Object* key); |
| 3999 |
| 4000 // Adds (or overwrites) the value associated with the given key. Mapping a |
| 4001 // key to the hole value causes removal of the whole entry. |
| 4002 MUST_USE_RESULT MaybeObject* Put(Object* key, Object* value); |
| 4003 |
| 4004 private: |
| 4005 friend class MarkCompactCollector; |
| 4006 |
| 4007 void AddEntry(int entry, Object* key, Object* value); |
| 4008 |
| 4009 // Returns the index to the value of an entry. |
| 4010 static inline int EntryToValueIndex(int entry) { |
| 4011 return EntryToIndex(entry) + 1; |
| 4012 } |
| 4013 }; |
| 4014 |
| 4015 |
3968 // JSFunctionResultCache caches results of some JSFunction invocation. | 4016 // JSFunctionResultCache caches results of some JSFunction invocation. |
3969 // It is a fixed array with fixed structure: | 4017 // It is a fixed array with fixed structure: |
3970 // [0]: factory function | 4018 // [0]: factory function |
3971 // [1]: finger index | 4019 // [1]: finger index |
3972 // [2]: current cache size | 4020 // [2]: current cache size |
3973 // [3]: dummy field. | 4021 // [3]: dummy field. |
3974 // The rest of array are key/value pairs. | 4022 // The rest of array are key/value pairs. |
3975 class JSFunctionResultCache: public FixedArray { | 4023 class JSFunctionResultCache: public FixedArray { |
3976 public: | 4024 public: |
3977 static const int kFactoryIndex = 0; | 4025 static const int kFactoryIndex = 0; |
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5137 static void MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate); | 5185 static void MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate); |
5138 void MakeOlder(MarkingParity); | 5186 void MakeOlder(MarkingParity); |
5139 static bool IsYoungSequence(byte* sequence); | 5187 static bool IsYoungSequence(byte* sequence); |
5140 bool IsOld(); | 5188 bool IsOld(); |
5141 int GetAge(); | 5189 int GetAge(); |
5142 | 5190 |
5143 void PrintDeoptLocation(int bailout_id); | 5191 void PrintDeoptLocation(int bailout_id); |
5144 bool CanDeoptAt(Address pc); | 5192 bool CanDeoptAt(Address pc); |
5145 | 5193 |
5146 #ifdef VERIFY_HEAP | 5194 #ifdef VERIFY_HEAP |
5147 void VerifyEmbeddedMapsDependency(); | 5195 void VerifyEmbeddedObjectsDependency(); |
5148 #endif | 5196 #endif |
5149 | 5197 |
| 5198 static bool IsWeakEmbeddedObject(Kind kind, Object* object); |
| 5199 |
5150 // Max loop nesting marker used to postpose OSR. We don't take loop | 5200 // Max loop nesting marker used to postpose OSR. We don't take loop |
5151 // nesting that is deeper than 5 levels into account. | 5201 // nesting that is deeper than 5 levels into account. |
5152 static const int kMaxLoopNestingMarker = 6; | 5202 static const int kMaxLoopNestingMarker = 6; |
5153 | 5203 |
5154 // Layout description. | 5204 // Layout description. |
5155 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; | 5205 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; |
5156 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; | 5206 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; |
5157 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; | 5207 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; |
5158 static const int kDeoptimizationDataOffset = | 5208 static const int kDeoptimizationDataOffset = |
5159 kHandlerTableOffset + kPointerSize; | 5209 kHandlerTableOffset + kPointerSize; |
(...skipping 5073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10233 } else { | 10283 } else { |
10234 value &= ~(1 << bit_position); | 10284 value &= ~(1 << bit_position); |
10235 } | 10285 } |
10236 return value; | 10286 return value; |
10237 } | 10287 } |
10238 }; | 10288 }; |
10239 | 10289 |
10240 } } // namespace v8::internal | 10290 } } // namespace v8::internal |
10241 | 10291 |
10242 #endif // V8_OBJECTS_H_ | 10292 #endif // V8_OBJECTS_H_ |
OLD | NEW |