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

Side by Side Diff: src/objects.h

Issue 10697015: Separating transitions from descriptors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 V(ExternalDoubleArray) \ 773 V(ExternalDoubleArray) \
774 V(ExternalPixelArray) \ 774 V(ExternalPixelArray) \
775 V(ByteArray) \ 775 V(ByteArray) \
776 V(FreeSpace) \ 776 V(FreeSpace) \
777 V(JSReceiver) \ 777 V(JSReceiver) \
778 V(JSObject) \ 778 V(JSObject) \
779 V(JSContextExtensionObject) \ 779 V(JSContextExtensionObject) \
780 V(JSModule) \ 780 V(JSModule) \
781 V(Map) \ 781 V(Map) \
782 V(DescriptorArray) \ 782 V(DescriptorArray) \
783 V(TransitionArray) \
783 V(DeoptimizationInputData) \ 784 V(DeoptimizationInputData) \
784 V(DeoptimizationOutputData) \ 785 V(DeoptimizationOutputData) \
785 V(TypeFeedbackCells) \ 786 V(TypeFeedbackCells) \
786 V(FixedArray) \ 787 V(FixedArray) \
787 V(FixedDoubleArray) \ 788 V(FixedDoubleArray) \
788 V(Context) \ 789 V(Context) \
789 V(GlobalContext) \ 790 V(GlobalContext) \
790 V(ModuleContext) \ 791 V(ModuleContext) \
791 V(ScopeInfo) \ 792 V(ScopeInfo) \
792 V(JSFunction) \ 793 V(JSFunction) \
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 // Casting. 1188 // Casting.
1188 static inline HeapObject* cast(Object* obj); 1189 static inline HeapObject* cast(Object* obj);
1189 1190
1190 // Return the write barrier mode for this. Callers of this function 1191 // Return the write barrier mode for this. Callers of this function
1191 // must be able to present a reference to an AssertNoAllocation 1192 // must be able to present a reference to an AssertNoAllocation
1192 // object as a sign that they are not going to use this function 1193 // object as a sign that they are not going to use this function
1193 // from code that allocates and thus invalidates the returned write 1194 // from code that allocates and thus invalidates the returned write
1194 // barrier mode. 1195 // barrier mode.
1195 inline WriteBarrierMode GetWriteBarrierMode(const AssertNoAllocation&); 1196 inline WriteBarrierMode GetWriteBarrierMode(const AssertNoAllocation&);
1196 1197
1198 inline Address FieldAddress(int offset);
Jakob Kummerow 2012/06/29 16:31:36 I guess you forgot to remove these declarations?
Toon Verwaest 2012/07/05 12:56:11 Done.
1199 inline Object* ReadField(int offset);
1200 inline void WriteField(int offset, Object* value);
1201 inline void ConditionalWriteBarrier(Heap* heap,
1202 uint32_t offset,
1203 Object* value,
1204 WriteBarrierMode mode);
1205
1197 // Dispatched behavior. 1206 // Dispatched behavior.
1198 void HeapObjectShortPrint(StringStream* accumulator); 1207 void HeapObjectShortPrint(StringStream* accumulator);
1199 #ifdef OBJECT_PRINT 1208 #ifdef OBJECT_PRINT
1200 inline void HeapObjectPrint() { 1209 inline void HeapObjectPrint() {
1201 HeapObjectPrint(stdout); 1210 HeapObjectPrint(stdout);
1202 } 1211 }
1203 void HeapObjectPrint(FILE* out); 1212 void HeapObjectPrint(FILE* out);
1204 void PrintHeader(FILE* out, const char* id); 1213 void PrintHeader(FILE* out, const char* id);
1205 #endif 1214 #endif
1206 1215
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 // (storage->length() == NumberOfEnumElements()). 1900 // (storage->length() == NumberOfEnumElements()).
1892 // If storage is NULL, will count the elements without adding 1901 // If storage is NULL, will count the elements without adding
1893 // them to any storage. 1902 // them to any storage.
1894 // Returns the number of enumerable elements. 1903 // Returns the number of enumerable elements.
1895 int GetEnumElementKeys(FixedArray* storage); 1904 int GetEnumElementKeys(FixedArray* storage);
1896 1905
1897 // Add a property to a fast-case object using a map transition to 1906 // Add a property to a fast-case object using a map transition to
1898 // new_map. 1907 // new_map.
1899 MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap(Map* new_map, 1908 MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap(Map* new_map,
1900 String* name, 1909 String* name,
1901 Object* value); 1910 Object* value,
1911 int field_index);
1902 1912
1903 // Add a constant function property to a fast-case object. 1913 // Add a constant function property to a fast-case object.
1904 // This leaves a CONSTANT_TRANSITION in the old map, and 1914 // This leaves a CONSTANT_TRANSITION in the old map, and
1905 // if it is called on a second object with this map, a 1915 // if it is called on a second object with this map, a
1906 // normal property is added instead, with a map transition. 1916 // normal property is added instead, with a map transition.
1907 // This avoids the creation of many maps with the same constant 1917 // This avoids the creation of many maps with the same constant
1908 // function, all orphaned. 1918 // function, all orphaned.
1909 MUST_USE_RESULT MaybeObject* AddConstantFunctionProperty( 1919 MUST_USE_RESULT MaybeObject* AddConstantFunctionProperty(
1910 String* name, 1920 String* name,
1911 JSFunction* function, 1921 JSFunction* function,
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2049 #ifdef OBJECT_PRINT 2059 #ifdef OBJECT_PRINT
2050 inline void PrintProperties() { 2060 inline void PrintProperties() {
2051 PrintProperties(stdout); 2061 PrintProperties(stdout);
2052 } 2062 }
2053 void PrintProperties(FILE* out); 2063 void PrintProperties(FILE* out);
2054 2064
2055 inline void PrintElements() { 2065 inline void PrintElements() {
2056 PrintElements(stdout); 2066 PrintElements(stdout);
2057 } 2067 }
2058 void PrintElements(FILE* out); 2068 void PrintElements(FILE* out);
2069 inline void PrintTransitions() {
2070 PrintElements(stdout);
Jakob Kummerow 2012/06/29 16:31:36 Don't you mean PrintTransitions(stdout) here?
Toon Verwaest 2012/07/05 12:56:11 Done.
2071 }
2072 void PrintTransitions(FILE* out);
2059 #endif 2073 #endif
2060 2074
2061 void PrintElementsTransition( 2075 void PrintElementsTransition(
2062 FILE* file, ElementsKind from_kind, FixedArrayBase* from_elements, 2076 FILE* file, ElementsKind from_kind, FixedArrayBase* from_elements,
2063 ElementsKind to_kind, FixedArrayBase* to_elements); 2077 ElementsKind to_kind, FixedArrayBase* to_elements);
2064 2078
2065 #ifdef DEBUG 2079 #ifdef DEBUG
2066 // Structure for collecting spill information about JSObjects. 2080 // Structure for collecting spill information about JSObjects.
2067 class SpillInformation { 2081 class SpillInformation {
2068 public: 2082 public:
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 uint32_t index, 2216 uint32_t index,
2203 Object* getter, 2217 Object* getter,
2204 Object* setter, 2218 Object* setter,
2205 PropertyAttributes attributes); 2219 PropertyAttributes attributes);
2206 MUST_USE_RESULT MaybeObject* CreateAccessorPairFor(String* name); 2220 MUST_USE_RESULT MaybeObject* CreateAccessorPairFor(String* name);
2207 MUST_USE_RESULT MaybeObject* DefinePropertyAccessor( 2221 MUST_USE_RESULT MaybeObject* DefinePropertyAccessor(
2208 String* name, 2222 String* name,
2209 Object* getter, 2223 Object* getter,
2210 Object* setter, 2224 Object* setter,
2211 PropertyAttributes attributes); 2225 PropertyAttributes attributes);
2212 void LookupInDescriptor(String* name, LookupResult* result);
2213 2226
2214 // Returns the hidden properties backing store object, currently 2227 // Returns the hidden properties backing store object, currently
2215 // a StringDictionary, stored on this object. 2228 // a StringDictionary, stored on this object.
2216 // If no hidden properties object has been put on this object, 2229 // If no hidden properties object has been put on this object,
2217 // return undefined, unless create_if_absent is true, in which case 2230 // return undefined, unless create_if_absent is true, in which case
2218 // a new dictionary is created, added to this object, and returned. 2231 // a new dictionary is created, added to this object, and returned.
2219 MUST_USE_RESULT MaybeObject* GetHiddenPropertiesDictionary( 2232 MUST_USE_RESULT MaybeObject* GetHiddenPropertiesDictionary(
2220 bool create_if_absent); 2233 bool create_if_absent);
2221 // Updates the existing hidden properties dictionary. 2234 // Updates the existing hidden properties dictionary.
2222 MUST_USE_RESULT MaybeObject* SetHiddenPropertiesDictionary( 2235 MUST_USE_RESULT MaybeObject* SetHiddenPropertiesDictionary(
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2429 // [3]: first key 2442 // [3]: first key
2430 // [length() - 1]: last key 2443 // [length() - 1]: last key
2431 // 2444 //
2432 class DescriptorArray: public FixedArray { 2445 class DescriptorArray: public FixedArray {
2433 public: 2446 public:
2434 // Returns true for both shared empty_descriptor_array and for smis, which the 2447 // Returns true for both shared empty_descriptor_array and for smis, which the
2435 // map uses to encode additional bit fields when the descriptor array is not 2448 // map uses to encode additional bit fields when the descriptor array is not
2436 // yet used. 2449 // yet used.
2437 inline bool IsEmpty(); 2450 inline bool IsEmpty();
2438 inline bool MayContainTransitions(); 2451 inline bool MayContainTransitions();
2452 inline bool HasTransitionArray();
2439 2453
2440 DECL_ACCESSORS(elements_transition_map, Map) 2454 DECL_ACCESSORS(transitions, TransitionArray)
2441 inline void ClearElementsTransition(); 2455 inline void ClearTransitions();
2442 2456
2443 // Returns the number of descriptors in the array. 2457 // Returns the number of descriptors in the array.
2444 int number_of_descriptors() { 2458 int number_of_descriptors() {
2445 ASSERT(length() >= kFirstIndex || IsEmpty()); 2459 ASSERT(MayContainTransitions() || IsEmpty());
2446 int len = length(); 2460 int len = length();
2447 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kDescriptorSize; 2461 return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kDescriptorSize;
2448 } 2462 }
2449 2463
2464 inline int number_of_entries() { return number_of_descriptors(); }
2465
2450 int NextEnumerationIndex() { 2466 int NextEnumerationIndex() {
2451 if (IsEmpty()) return PropertyDetails::kInitialIndex; 2467 if (IsEmpty()) return PropertyDetails::kInitialIndex;
2452 Object* obj = get(kEnumerationIndexIndex); 2468 Object* obj = get(kEnumerationIndexIndex);
2453 if (obj->IsSmi()) { 2469 if (obj->IsSmi()) {
2454 return Smi::cast(obj)->value(); 2470 return Smi::cast(obj)->value();
2455 } else { 2471 } else {
2456 Object* index = FixedArray::cast(obj)->get(kEnumCacheBridgeEnumIndex); 2472 Object* index = FixedArray::cast(obj)->get(kEnumCacheBridgeEnumIndex);
2457 return Smi::cast(index)->value(); 2473 return Smi::cast(index)->value();
2458 } 2474 }
2459 } 2475 }
(...skipping 14 matching lines...) Expand all
2474 return bridge->get(kEnumCacheBridgeCacheIndex); 2490 return bridge->get(kEnumCacheBridgeCacheIndex);
2475 } 2491 }
2476 2492
2477 Object** GetEnumCacheSlot() { 2493 Object** GetEnumCacheSlot() {
2478 ASSERT(HasEnumCache()); 2494 ASSERT(HasEnumCache());
2479 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this), 2495 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this),
2480 kEnumerationIndexOffset); 2496 kEnumerationIndexOffset);
2481 } 2497 }
2482 2498
2483 Object** GetTransitionsSlot() { 2499 Object** GetTransitionsSlot() {
2484 ASSERT(elements_transition_map() != NULL);
2485 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this), 2500 return HeapObject::RawField(reinterpret_cast<HeapObject*>(this),
2486 kTransitionsOffset); 2501 kTransitionsOffset);
2487 } 2502 }
2488 2503
2489 // TODO(1399): It should be possible to make room for bit_field3 in the map 2504 // TODO(1399): It should be possible to make room for bit_field3 in the map
2490 // without overloading the instance descriptors field in the map 2505 // without overloading the instance descriptors field in the map
2491 // (and storing it in the DescriptorArray when the map has one). 2506 // (and storing it in the DescriptorArray when the map has one).
2492 inline int bit_field3_storage(); 2507 inline int bit_field3_storage();
2493 inline void set_bit_field3_storage(int value); 2508 inline void set_bit_field3_storage(int value);
2494 2509
2495 // Initialize or change the enum cache, 2510 // Initialize or change the enum cache,
2496 // using the supplied storage for the small "bridge". 2511 // using the supplied storage for the small "bridge".
2497 void SetEnumCache(FixedArray* bridge_storage, 2512 void SetEnumCache(FixedArray* bridge_storage,
2498 FixedArray* new_cache, 2513 FixedArray* new_cache,
2499 Object* new_index_cache); 2514 Object* new_index_cache);
2500 2515
2501 // Accessors for fetching instance descriptor at descriptor number. 2516 // Accessors for fetching instance descriptor at descriptor number.
2502 inline String* GetKey(int descriptor_number); 2517 inline String* GetKey(int descriptor_number);
2503 inline Object** GetKeySlot(int descriptor_number); 2518 inline Object** GetKeySlot(int descriptor_number);
2504 inline void SetKeyUnchecked(Heap* heap, int descriptor_number, String* value);
2505 inline Object* GetValue(int descriptor_number); 2519 inline Object* GetValue(int descriptor_number);
2506 inline Object** GetValueSlot(int descriptor_number); 2520 inline Object** GetValueSlot(int descriptor_number);
2507 inline void SetNullValueUnchecked(Heap* heap, int descriptor_number);
2508 inline void SetValueUnchecked(Heap* heap,
2509 int descriptor_number,
2510 Object* value);
2511 inline PropertyDetails GetDetails(int descriptor_number); 2521 inline PropertyDetails GetDetails(int descriptor_number);
2512 inline void SetDetailsUnchecked(int descriptor_number, Smi* value);
2513 inline PropertyType GetType(int descriptor_number); 2522 inline PropertyType GetType(int descriptor_number);
2514 inline int GetFieldIndex(int descriptor_number); 2523 inline int GetFieldIndex(int descriptor_number);
2515 inline JSFunction* GetConstantFunction(int descriptor_number); 2524 inline JSFunction* GetConstantFunction(int descriptor_number);
2516 inline Object* GetCallbacksObject(int descriptor_number); 2525 inline Object* GetCallbacksObject(int descriptor_number);
2517 inline AccessorDescriptor* GetCallbacks(int descriptor_number); 2526 inline AccessorDescriptor* GetCallbacks(int descriptor_number);
2518 inline bool IsProperty(int descriptor_number);
2519 inline bool IsTransitionOnly(int descriptor_number);
2520 2527
2521 // WhitenessWitness is used to prove that a specific descriptor array is white 2528 // WhitenessWitness is used to prove that a specific descriptor array is white
2522 // (unmarked), so incremental write barriers can be skipped because the 2529 // (unmarked), so incremental write barriers can be skipped because the
2523 // marking invariant cannot be broken and slots pointing into evacuation 2530 // marking invariant cannot be broken and slots pointing into evacuation
2524 // candidates will be discovered when the object is scanned. A witness is 2531 // candidates will be discovered when the object is scanned. A witness is
2525 // always stack-allocated right after creating a descriptor array. By 2532 // always stack-allocated right after creating a descriptor array. By
2526 // allocating a witness, incremental marking is globally disabled. The witness 2533 // allocating a witness, incremental marking is globally disabled. The witness
2527 // is then passed along wherever needed to statically prove that the 2534 // is then passed along wherever needed to statically prove that the
2528 // descriptor array is known to be white. 2535 // descriptor array is known to be white.
2529 class WhitenessWitness { 2536 class WhitenessWitness {
(...skipping 25 matching lines...) Expand all
2555 DescriptorArray* src, 2562 DescriptorArray* src,
2556 int src_index, 2563 int src_index,
2557 const WhitenessWitness&); 2564 const WhitenessWitness&);
2558 2565
2559 // Copy the descriptor array, insert a new descriptor and optionally 2566 // Copy the descriptor array, insert a new descriptor and optionally
2560 // remove map transitions. If the descriptor is already present, it is 2567 // remove map transitions. If the descriptor is already present, it is
2561 // replaced. If a replaced descriptor is a real property (not a transition 2568 // replaced. If a replaced descriptor is a real property (not a transition
2562 // or null), its enumeration index is kept as is. 2569 // or null), its enumeration index is kept as is.
2563 // If adding a real property, map transitions must be removed. If adding 2570 // If adding a real property, map transitions must be removed. If adding
2564 // a transition, they must not be removed. All null descriptors are removed. 2571 // a transition, they must not be removed. All null descriptors are removed.
2565 MUST_USE_RESULT MaybeObject* CopyInsert(Descriptor* descriptor, 2572 MUST_USE_RESULT MaybeObject* CopyInsert(Descriptor* descriptor);
2566 TransitionFlag transition_flag);
2567 2573
2568 // Indicates whether the search function should expect a sorted or an unsorted 2574 // Indicates whether the search function should expect a sorted or an unsorted
2569 // descriptor array as input. 2575 // descriptor array as input.
2570 enum SharedMode { 2576 enum SharedMode {
2571 MAY_BE_SHARED, 2577 MAY_BE_SHARED,
2572 CANNOT_BE_SHARED 2578 CANNOT_BE_SHARED
2573 }; 2579 };
2574 2580
2575 // Return a copy of the array with all transitions and null descriptors 2581 // Return a copy of the array with all transitions and null descriptors
2576 // removed. Return a Failure object in case of an allocation failure. 2582 // removed. Return a Failure object in case of an allocation failure.
2577 MUST_USE_RESULT MaybeObject* RemoveTransitions(SharedMode shared_mode); 2583 MUST_USE_RESULT MaybeObject* Copy(SharedMode shared_mode);
2578 2584
2579 // Sort the instance descriptors by the hash codes of their keys. 2585 // Sort the instance descriptors by the hash codes of their keys.
2580 // Does not check for duplicates. 2586 // Does not check for duplicates.
2581 void SortUnchecked(const WhitenessWitness&); 2587 void SortUnchecked(const WhitenessWitness&);
2582 2588
2583 // Sort the instance descriptors by the hash codes of their keys. 2589 // Sort the instance descriptors by the hash codes of their keys.
2584 // Checks the result for duplicates. 2590 // Checks the result for duplicates.
2585 void Sort(const WhitenessWitness&); 2591 void Sort(const WhitenessWitness&);
2586 2592
2587 // Search the instance descriptors for given name. 2593 // Search the instance descriptors for given name.
2588 INLINE(int Search(String* name)); 2594 INLINE(int Search(String* name));
2589 2595
2590 // As the above, but uses DescriptorLookupCache and updates it when 2596 // As the above, but uses DescriptorLookupCache and updates it when
2591 // necessary. 2597 // necessary.
2592 INLINE(int SearchWithCache(String* name)); 2598 INLINE(int SearchWithCache(String* name));
2593 2599
2594 // Tells whether the name is present int the array. 2600 // Tells whether the name is present int the array.
2595 bool Contains(String* name) { return kNotFound != Search(name); } 2601 bool Contains(String* name) { return kNotFound != Search(name); }
2596 2602
2597 // Perform a binary search in the instance descriptors represented
2598 // by this fixed array. low and high are descriptor indices. If there
2599 // are three instance descriptors in this array it should be called
2600 // with low=0 and high=2.
2601 int BinarySearch(String* name, int low, int high);
2602
2603 // Perform a linear search in the instance descriptors represented
2604 // by this fixed array. len is the number of descriptor indices that are
2605 // valid.
2606 int LinearSearch(SearchMode mode, String* name, int len);
2607
2608 // Allocates a DescriptorArray, but returns the singleton 2603 // Allocates a DescriptorArray, but returns the singleton
2609 // empty descriptor array object if number_of_descriptors is 0. 2604 // empty descriptor array object if number_of_descriptors is 0.
2610 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_descriptors, 2605 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_descriptors,
2611 SharedMode shared_mode); 2606 SharedMode shared_mode);
2612 2607
2613 // Casting. 2608 // Casting.
2614 static inline DescriptorArray* cast(Object* obj); 2609 static inline DescriptorArray* cast(Object* obj);
2615 2610
2616 // Constant for denoting key was not found. 2611 // Constant for denoting key was not found.
2617 static const int kNotFound = -1; 2612 static const int kNotFound = -1;
2618 2613
2619 static const int kBitField3StorageIndex = 0; 2614 static const int kBitField3StorageIndex = 0;
2620 static const int kEnumerationIndexIndex = 1; 2615 static const int kEnumerationIndexIndex = 1;
2621 static const int kTransitionsIndex = 2; 2616 static const int kTransitionsIndex = 2;
2622 static const int kFirstIndex = 3; 2617 static const int kFirstIndex = 3;
2623 2618
2624 // The length of the "bridge" to the enum cache. 2619 // The length of the "bridge" to the enum cache.
2625 static const int kEnumCacheBridgeLength = 3; 2620 static const int kEnumCacheBridgeLength = 3;
2626 static const int kEnumCacheBridgeEnumIndex = 0; 2621 static const int kEnumCacheBridgeEnumIndex = 0;
2627 static const int kEnumCacheBridgeCacheIndex = 1; 2622 static const int kEnumCacheBridgeCacheIndex = 1;
2628 static const int kEnumCacheBridgeIndicesCacheIndex = 2; 2623 static const int kEnumCacheBridgeIndicesCacheIndex = 2;
2629 2624
2630 // Layout description. 2625 // Layout description.
2631 static const int kBitField3StorageOffset = FixedArray::kHeaderSize; 2626 static const int kBitField3StorageOffset = FixedArray::kHeaderSize;
2632 static const int kEnumerationIndexOffset = 2627 static const int kEnumerationIndexOffset = kBitField3StorageOffset +
2633 kBitField3StorageOffset + kPointerSize; 2628 kPointerSize;
2634 static const int kTransitionsOffset = kEnumerationIndexOffset + kPointerSize; 2629 static const int kTransitionsOffset = kEnumerationIndexOffset + kPointerSize;
2635 static const int kFirstOffset = kTransitionsOffset + kPointerSize; 2630 static const int kFirstOffset = kTransitionsOffset + kPointerSize;
2636 2631
2637 // Layout description for the bridge array. 2632 // Layout description for the bridge array.
2638 static const int kEnumCacheBridgeEnumOffset = FixedArray::kHeaderSize; 2633 static const int kEnumCacheBridgeEnumOffset = FixedArray::kHeaderSize;
2639 static const int kEnumCacheBridgeCacheOffset = 2634 static const int kEnumCacheBridgeCacheOffset =
2640 kEnumCacheBridgeEnumOffset + kPointerSize; 2635 kEnumCacheBridgeEnumOffset + kPointerSize;
2641 2636
2642 // Layout of descriptor. 2637 // Layout of descriptor.
2643 static const int kDescriptorKey = 0; 2638 static const int kDescriptorKey = 0;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2699 static int ToValueIndex(int descriptor_number) { 2694 static int ToValueIndex(int descriptor_number) {
2700 return kFirstIndex + 2695 return kFirstIndex +
2701 (descriptor_number * kDescriptorSize) + 2696 (descriptor_number * kDescriptorSize) +
2702 kDescriptorValue; 2697 kDescriptorValue;
2703 } 2698 }
2704 2699
2705 // Swap operation on FixedArray without using write barriers. 2700 // Swap operation on FixedArray without using write barriers.
2706 static inline void NoIncrementalWriteBarrierSwap( 2701 static inline void NoIncrementalWriteBarrierSwap(
2707 FixedArray* array, int first, int second); 2702 FixedArray* array, int first, int second);
2708 2703
2709 // Swap descriptor first and second. 2704 // Swap first and second descriptor.
2710 inline void NoIncrementalWriteBarrierSwapDescriptors( 2705 inline void NoIncrementalWriteBarrierSwapDescriptors(
2711 int first, int second); 2706 int first, int second);
2712 2707
2713 DISALLOW_IMPLICIT_CONSTRUCTORS(DescriptorArray); 2708 DISALLOW_IMPLICIT_CONSTRUCTORS(DescriptorArray);
2714 }; 2709 };
2715 2710
2716 2711
2712 template<typename T>
2713 inline int LinearSearch(T* array, SearchMode mode, String* name, int len);
2714
2715
2716 template<typename T>
2717 inline int Search(T* array, String* name);
2718
2719
2717 // HashTable is a subclass of FixedArray that implements a hash table 2720 // HashTable is a subclass of FixedArray that implements a hash table
2718 // that uses open addressing and quadratic probing. 2721 // that uses open addressing and quadratic probing.
2719 // 2722 //
2720 // In order for the quadratic probing to work, elements that have not 2723 // In order for the quadratic probing to work, elements that have not
2721 // yet been used and elements that have been deleted are 2724 // yet been used and elements that have been deleted are
2722 // distinguished. Probing continues when deleted elements are 2725 // distinguished. Probing continues when deleted elements are
2723 // encountered and stops when unused elements are encountered. 2726 // encountered and stops when unused elements are encountered.
2724 // 2727 //
2725 // - Elements with key == undefined have not been used yet. 2728 // - Elements with key == undefined have not been used yet.
2726 // - Elements with key == the_hole have been deleted. 2729 // - Elements with key == the_hole have been deleted.
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
3171 void CopyEnumKeysTo(FixedArray* storage, FixedArray* sort_array); 3174 void CopyEnumKeysTo(FixedArray* storage, FixedArray* sort_array);
3172 3175
3173 // For transforming properties of a JSObject. 3176 // For transforming properties of a JSObject.
3174 MUST_USE_RESULT MaybeObject* TransformPropertiesToFastFor( 3177 MUST_USE_RESULT MaybeObject* TransformPropertiesToFastFor(
3175 JSObject* obj, 3178 JSObject* obj,
3176 int unused_property_fields); 3179 int unused_property_fields);
3177 3180
3178 // Find entry for key, otherwise return kNotFound. Optimized version of 3181 // Find entry for key, otherwise return kNotFound. Optimized version of
3179 // HashTable::FindEntry. 3182 // HashTable::FindEntry.
3180 int FindEntry(String* key); 3183 int FindEntry(String* key);
3181
3182 bool ContainsTransition(int entry);
3183 }; 3184 };
3184 3185
3185 3186
3186 class NumberDictionaryShape : public BaseShape<uint32_t> { 3187 class NumberDictionaryShape : public BaseShape<uint32_t> {
3187 public: 3188 public:
3188 static inline bool IsMatch(uint32_t key, Object* other); 3189 static inline bool IsMatch(uint32_t key, Object* other);
3189 MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key); 3190 MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key);
3190 static const int kEntrySize = 3; 3191 static const int kEntrySize = 3;
3191 static const bool kIsEnumerable = false; 3192 static const bool kIsEnumerable = false;
3192 }; 3193 };
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after
4621 // Bit field 2. 4622 // Bit field 2.
4622 inline byte bit_field2(); 4623 inline byte bit_field2();
4623 inline void set_bit_field2(byte value); 4624 inline void set_bit_field2(byte value);
4624 4625
4625 // Bit field 3. 4626 // Bit field 3.
4626 // TODO(1399): It should be possible to make room for bit_field3 in the map 4627 // TODO(1399): It should be possible to make room for bit_field3 in the map
4627 // without overloading the instance descriptors field (and storing it in the 4628 // without overloading the instance descriptors field (and storing it in the
4628 // DescriptorArray when the map has one). 4629 // DescriptorArray when the map has one).
4629 inline int bit_field3(); 4630 inline int bit_field3();
4630 inline void set_bit_field3(int value); 4631 inline void set_bit_field3(int value);
4632 inline void SetOwnBitField3(int value);
4631 4633
4632 // Tells whether the object in the prototype property will be used 4634 // Tells whether the object in the prototype property will be used
4633 // for instances created from this function. If the prototype 4635 // for instances created from this function. If the prototype
4634 // property is set to a value that is not a JSObject, the prototype 4636 // property is set to a value that is not a JSObject, the prototype
4635 // property will not be used to create instances of the function. 4637 // property will not be used to create instances of the function.
4636 // See ECMA-262, 13.2.2. 4638 // See ECMA-262, 13.2.2.
4637 inline void set_non_instance_prototype(bool value); 4639 inline void set_non_instance_prototype(bool value);
4638 inline bool has_non_instance_prototype(); 4640 inline bool has_non_instance_prototype();
4639 4641
4640 // Tells whether function has special prototype property. If not, prototype 4642 // Tells whether function has special prototype property. If not, prototype
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
4741 } 4743 }
4742 4744
4743 inline bool has_slow_elements_kind() { 4745 inline bool has_slow_elements_kind() {
4744 return elements_kind() == DICTIONARY_ELEMENTS 4746 return elements_kind() == DICTIONARY_ELEMENTS
4745 || elements_kind() == NON_STRICT_ARGUMENTS_ELEMENTS; 4747 || elements_kind() == NON_STRICT_ARGUMENTS_ELEMENTS;
4746 } 4748 }
4747 4749
4748 static bool IsValidElementsTransition(ElementsKind from_kind, 4750 static bool IsValidElementsTransition(ElementsKind from_kind,
4749 ElementsKind to_kind); 4751 ElementsKind to_kind);
4750 4752
4753 inline bool HasTransitionArray();
4754 inline bool HasElementsTransition();
4751 inline Map* elements_transition_map(); 4755 inline Map* elements_transition_map();
4752 inline void set_elements_transition_map(Map* transitioned_map); 4756 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map(
4757 Map* transitioned_map);
4758 inline TransitionArray* transitions();
4759 MUST_USE_RESULT inline MaybeObject* set_transitions(
4760 TransitionArray* transitions);
4761 inline void ClearTransitions();
4753 4762
4754 // Tells whether the map is attached to SharedFunctionInfo 4763 // Tells whether the map is attached to SharedFunctionInfo
4755 // (for inobject slack tracking). 4764 // (for inobject slack tracking).
4756 inline void set_attached_to_shared_function_info(bool value); 4765 inline void set_attached_to_shared_function_info(bool value);
4757 4766
4758 inline bool attached_to_shared_function_info(); 4767 inline bool attached_to_shared_function_info();
4759 4768
4760 // Tells whether the map is shared between objects that may have different 4769 // Tells whether the map is shared between objects that may have different
4761 // behavior. If true, the map should never be modified, instead a clone 4770 // behavior. If true, the map should never be modified, instead a clone
4762 // should be created and modified. 4771 // should be created and modified.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
4832 inline void SetNumberOfProtoTransitions(int value) { 4841 inline void SetNumberOfProtoTransitions(int value) {
4833 FixedArray* cache = prototype_transitions(); 4842 FixedArray* cache = prototype_transitions();
4834 ASSERT(cache->length() != 0); 4843 ASSERT(cache->length() != 0);
4835 cache->set_unchecked(kProtoTransitionNumberOfEntriesOffset, 4844 cache->set_unchecked(kProtoTransitionNumberOfEntriesOffset,
4836 Smi::FromInt(value)); 4845 Smi::FromInt(value));
4837 } 4846 }
4838 4847
4839 // Lookup in the map's instance descriptors and fill out the result 4848 // Lookup in the map's instance descriptors and fill out the result
4840 // with the given holder if the name is found. The holder may be 4849 // with the given holder if the name is found. The holder may be
4841 // NULL when this function is used from the compiler. 4850 // NULL when this function is used from the compiler.
4842 void LookupInDescriptors(JSObject* holder, 4851 void LookupDescriptor(JSObject* holder,
4843 String* name, 4852 String* name,
4844 LookupResult* result); 4853 LookupResult* result);
4854
4855 void LookupTransitionOrDescriptor(JSObject* holder,
4856 String* name,
4857 LookupResult* result);
4845 4858
4846 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); 4859 MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
4847 4860
4848 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, 4861 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode,
4849 NormalizedMapSharingMode sharing); 4862 NormalizedMapSharingMode sharing);
4850 4863
4851 // Returns a copy of the map, with all transitions dropped from the 4864 // Returns a copy of the map, with all transitions dropped from the
4852 // instance descriptors. 4865 // instance descriptors.
4853 MUST_USE_RESULT MaybeObject* CopyDropTransitions( 4866 MUST_USE_RESULT MaybeObject* CopyDropTransitions(
4854 DescriptorArray::SharedMode shared_mode); 4867 DescriptorArray::SharedMode shared_mode);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
4918 // elements_kind that's found in |candidates|, or null handle if no match is 4931 // elements_kind that's found in |candidates|, or null handle if no match is
4919 // found at all. 4932 // found at all.
4920 Handle<Map> FindTransitionedMap(MapHandleList* candidates); 4933 Handle<Map> FindTransitionedMap(MapHandleList* candidates);
4921 Map* FindTransitionedMap(MapList* candidates); 4934 Map* FindTransitionedMap(MapList* candidates);
4922 4935
4923 // Zaps the contents of backing data structures in debug mode. Note that the 4936 // Zaps the contents of backing data structures in debug mode. Note that the
4924 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects 4937 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects
4925 // holding weak references when incremental marking is used, because it also 4938 // holding weak references when incremental marking is used, because it also
4926 // iterates over objects that are otherwise unreachable. 4939 // iterates over objects that are otherwise unreachable.
4927 #ifdef DEBUG 4940 #ifdef DEBUG
4928 void ZapInstanceDescriptors();
4929 void ZapPrototypeTransitions(); 4941 void ZapPrototypeTransitions();
4942 void ZapTransitions();
4930 #endif 4943 #endif
4931 4944
4932 // Dispatched behavior. 4945 // Dispatched behavior.
4933 #ifdef OBJECT_PRINT 4946 #ifdef OBJECT_PRINT
4934 inline void MapPrint() { 4947 inline void MapPrint() {
4935 MapPrint(stdout); 4948 MapPrint(stdout);
4936 } 4949 }
4937 void MapPrint(FILE* out); 4950 void MapPrint(FILE* out);
4938 #endif 4951 #endif
4939 #ifdef DEBUG 4952 #ifdef DEBUG
(...skipping 3871 matching lines...) Expand 10 before | Expand all | Expand 10 after
8811 } else { 8824 } else {
8812 value &= ~(1 << bit_position); 8825 value &= ~(1 << bit_position);
8813 } 8826 }
8814 return value; 8827 return value;
8815 } 8828 }
8816 }; 8829 };
8817 8830
8818 } } // namespace v8::internal 8831 } } // namespace v8::internal
8819 8832
8820 #endif // V8_OBJECTS_H_ 8833 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698