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 2457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2468 inline void ClearTransitions(); | 2468 inline void ClearTransitions(); |
2469 | 2469 |
2470 // Returns the number of descriptors in the array. | 2470 // Returns the number of descriptors in the array. |
2471 int number_of_descriptors() { | 2471 int number_of_descriptors() { |
2472 ASSERT(MayContainTransitions() || IsEmpty()); | 2472 ASSERT(MayContainTransitions() || IsEmpty()); |
2473 int len = length(); | 2473 int len = length(); |
2474 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kDescriptorSize; | 2474 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kDescriptorSize; |
2475 } | 2475 } |
2476 | 2476 |
2477 inline int number_of_entries() { return number_of_descriptors(); } | 2477 inline int number_of_entries() { return number_of_descriptors(); } |
2478 int NextEnumerationIndex() { return number_of_descriptors() + 1; } | |
2478 | 2479 |
2479 int LastAdded() { | 2480 int LastAdded() { |
2480 ASSERT(!IsEmpty()); | 2481 ASSERT(!IsEmpty()); |
2481 Object* obj = get(kLastAddedIndex); | 2482 Object* obj = get(kLastAddedIndex); |
2482 if (obj->IsSmi()) { | 2483 if (obj->IsSmi()) { |
2483 return Smi::cast(obj)->value(); | 2484 return Smi::cast(obj)->value(); |
2484 } else { | 2485 } else { |
2485 Object* index = FixedArray::cast(obj)->get(kEnumCacheBridgeLastAdded); | 2486 Object* index = FixedArray::cast(obj)->get(kEnumCacheBridgeLastAdded); |
2486 return Smi::cast(index)->value(); | 2487 return Smi::cast(index)->value(); |
2487 } | 2488 } |
2488 } | 2489 } |
2489 | 2490 |
2490 int NextEnumerationIndex() { | |
2491 if (number_of_descriptors() == 0) { | |
2492 return PropertyDetails::kInitialIndex; | |
2493 } | |
2494 return GetDetails(LastAdded()).index() + 1; | |
2495 } | |
2496 | |
2497 // Set index of the last added descriptor and flush any enum cache. | 2491 // Set index of the last added descriptor and flush any enum cache. |
2498 void SetLastAdded(int index) { | 2492 void SetLastAdded(int index) { |
2499 ASSERT(!IsEmpty() || index > 0); | 2493 ASSERT(!IsEmpty() || index > 0); |
2500 set(kLastAddedIndex, Smi::FromInt(index)); | 2494 set(kLastAddedIndex, Smi::FromInt(index)); |
2501 } | 2495 } |
2502 | 2496 |
2503 bool HasEnumCache() { | 2497 bool HasEnumCache() { |
2504 return !IsEmpty() && !get(kLastAddedIndex)->IsSmi(); | 2498 return !IsEmpty() && !get(kLastAddedIndex)->IsSmi(); |
2505 } | 2499 } |
2506 | 2500 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2539 inline int GetFieldIndex(int descriptor_number); | 2533 inline int GetFieldIndex(int descriptor_number); |
2540 inline JSFunction* GetConstantFunction(int descriptor_number); | 2534 inline JSFunction* GetConstantFunction(int descriptor_number); |
2541 inline Object* GetCallbacksObject(int descriptor_number); | 2535 inline Object* GetCallbacksObject(int descriptor_number); |
2542 inline AccessorDescriptor* GetCallbacks(int descriptor_number); | 2536 inline AccessorDescriptor* GetCallbacks(int descriptor_number); |
2543 | 2537 |
2544 // Accessor for complete descriptor. | 2538 // Accessor for complete descriptor. |
2545 inline void Get(int descriptor_number, Descriptor* desc); | 2539 inline void Get(int descriptor_number, Descriptor* desc); |
2546 inline void Set(int descriptor_number, | 2540 inline void Set(int descriptor_number, |
2547 Descriptor* desc, | 2541 Descriptor* desc, |
2548 const WhitenessWitness&); | 2542 const WhitenessWitness&); |
2543 // Append automatically sets the enumeration index. This should only be used | |
2544 // to add descriptors in bulk at the end, followed by sorting the descriptor | |
2545 // array. | |
2546 inline void Append(int descriptor_number, | |
2547 Descriptor* desc, | |
2548 const WhitenessWitness&); | |
danno
2012/07/12 11:26:08
Remove the need for descriptor_number as discussed
| |
2549 | 2549 |
2550 // Transfer a complete descriptor from the src descriptor array to the dst | 2550 // Transfer a complete descriptor from the src descriptor array to the dst |
2551 // one, dropping map transitions in CALLBACKS. | 2551 // one, dropping map transitions in CALLBACKS. |
2552 static void CopyFrom(Handle<DescriptorArray> dst, | 2552 static void CopyFrom(Handle<DescriptorArray> dst, |
2553 int dst_index, | 2553 int dst_index, |
2554 Handle<DescriptorArray> src, | 2554 Handle<DescriptorArray> src, |
2555 int src_index, | 2555 int src_index, |
2556 const WhitenessWitness& witness); | 2556 const WhitenessWitness& witness); |
2557 | 2557 |
2558 // Transfer a complete descriptor from the src descriptor array to this | 2558 // Transfer a complete descriptor from the src descriptor array to this |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2606 // empty descriptor array object if number_of_descriptors is 0. | 2606 // empty descriptor array object if number_of_descriptors is 0. |
2607 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_descriptors, | 2607 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_descriptors, |
2608 SharedMode shared_mode); | 2608 SharedMode shared_mode); |
2609 | 2609 |
2610 // Casting. | 2610 // Casting. |
2611 static inline DescriptorArray* cast(Object* obj); | 2611 static inline DescriptorArray* cast(Object* obj); |
2612 | 2612 |
2613 // Constant for denoting key was not found. | 2613 // Constant for denoting key was not found. |
2614 static const int kNotFound = -1; | 2614 static const int kNotFound = -1; |
2615 | 2615 |
2616 // Constant for denoting that the LastAdded field was not yet set. | |
2617 static const int kNoneAdded = -1; | |
2618 | |
2616 static const int kBackPointerStorageIndex = 0; | 2619 static const int kBackPointerStorageIndex = 0; |
2617 static const int kLastAddedIndex = 1; | 2620 static const int kLastAddedIndex = 1; |
2618 static const int kTransitionsIndex = 2; | 2621 static const int kTransitionsIndex = 2; |
2619 static const int kFirstIndex = 3; | 2622 static const int kFirstIndex = 3; |
2620 | 2623 |
2621 // The length of the "bridge" to the enum cache. | 2624 // The length of the "bridge" to the enum cache. |
2622 static const int kEnumCacheBridgeLength = 3; | 2625 static const int kEnumCacheBridgeLength = 3; |
2623 static const int kEnumCacheBridgeLastAdded = 0; | 2626 static const int kEnumCacheBridgeLastAdded = 0; |
2624 static const int kEnumCacheBridgeCacheIndex = 1; | 2627 static const int kEnumCacheBridgeCacheIndex = 1; |
2625 static const int kEnumCacheBridgeIndicesCacheIndex = 2; | 2628 static const int kEnumCacheBridgeIndicesCacheIndex = 2; |
(...skipping 6259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8885 } else { | 8888 } else { |
8886 value &= ~(1 << bit_position); | 8889 value &= ~(1 << bit_position); |
8887 } | 8890 } |
8888 return value; | 8891 return value; |
8889 } | 8892 } |
8890 }; | 8893 }; |
8891 | 8894 |
8892 } } // namespace v8::internal | 8895 } } // namespace v8::internal |
8893 | 8896 |
8894 #endif // V8_OBJECTS_H_ | 8897 #endif // V8_OBJECTS_H_ |
OLD | NEW |