Chromium Code Reviews| Index: src/objects.h |
| diff --git a/src/objects.h b/src/objects.h |
| index 38104b89f4935eb20a5c61b630806d5a96df9d5b..ec3b54c7dd13459d8456f2308adcfb9233736e81 100644 |
| --- a/src/objects.h |
| +++ b/src/objects.h |
| @@ -136,6 +136,9 @@ namespace v8 { |
| namespace internal { |
| enum ElementsKind { |
| + // The "fast" kind for elements that only contain SMI values. |
| + FAST_SMI_ONLY_ELEMENTS, |
| + |
| // The "fast" kind for tagged values. Must be first to make it possible |
| // to efficiently check maps if they have fast elements. |
|
Yang
2011/09/19 14:00:15
Outdated comment. (Any consequences since the assu
danno
2011/09/21 14:32:04
Done.
|
| FAST_ELEMENTS, |
| @@ -160,7 +163,7 @@ enum ElementsKind { |
| // Derived constants from ElementsKind |
| FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_BYTE_ELEMENTS, |
| LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS, |
| - FIRST_ELEMENTS_KIND = FAST_ELEMENTS, |
| + FIRST_ELEMENTS_KIND = FAST_SMI_ONLY_ELEMENTS, |
| LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS |
| }; |
| @@ -1525,8 +1528,10 @@ class JSObject: public JSReceiver { |
| MUST_USE_RESULT inline MaybeObject* ResetElements(); |
| inline ElementsKind GetElementsKind(); |
| inline ElementsAccessor* GetElementsAccessor(); |
| + inline bool HasFastSmiOnlyElements(); |
|
Rico
2011/09/16 09:40:10
Do we want to include something like HasFastTypeEl
danno
2011/09/21 14:32:04
On 2011/09/16 09:40:10, Rico wrote:
> Do we want t
|
| inline bool HasFastElements(); |
| inline bool HasFastDoubleElements(); |
| + inline bool HasNonStrictArgumentsElements(); |
| inline bool HasDictionaryElements(); |
| inline bool HasExternalPixelElements(); |
| inline bool HasExternalArrayElements(); |
| @@ -1698,6 +1703,17 @@ class JSObject: public JSReceiver { |
| // Tests for the fast common case for property enumeration. |
| bool IsSimpleEnum(); |
| + // Makes sure the elements can contain non-smi Object. |
| + inline MaybeObject* EnsureCanContainNonSmiElements(); |
| + |
| + // Make sure that elements can contain the specified elements. |
|
Jakob Kummerow
2011/09/16 16:30:34
The comments for both these methods deserve better
danno
2011/09/21 14:32:04
Done.
|
| + inline MaybeObject* EnsureCanContainElements(Object** elements, |
| + uint32_t count); |
| + inline MaybeObject* EnsureCanContainElements(FixedArray* elements); |
| + MaybeObject* EnsureCanContainElements(Arguments* arguments, |
| + uint32_t first_arg, |
| + uint32_t arg_count); |
| + |
| // Do we want to keep the elements in fast case when increasing the |
| // capacity? |
| bool ShouldConvertToSlowElements(int new_capacity); |
| @@ -1747,6 +1763,7 @@ class JSObject: public JSReceiver { |
| Object* value, |
| StrictModeFlag strict_mode, |
| bool check_prototype); |
| + |
| MUST_USE_RESULT MaybeObject* SetDictionaryElement(uint32_t index, |
| Object* value, |
| StrictModeFlag strict_mode, |
| @@ -1769,11 +1786,18 @@ class JSObject: public JSReceiver { |
| // The undefined object if index is out of bounds. |
| MaybeObject* GetElementWithInterceptor(Object* receiver, uint32_t index); |
| + enum SetFastElementsCapacityMode { |
| + kAllowSmiOnlyElements, |
| + kDontAllowSmiOnlyElements |
| + }; |
| + |
| // Replace the elements' backing store with fast elements of the given |
| // capacity. Update the length for JSArrays. Returns the new backing |
| // store. |
| - MUST_USE_RESULT MaybeObject* SetFastElementsCapacityAndLength(int capacity, |
| - int length); |
| + MUST_USE_RESULT MaybeObject* SetFastElementsCapacityAndLength( |
| + int capacity, |
| + int length, |
| + SetFastElementsCapacityMode set_capacity_mode); |
| MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength( |
| int capacity, |
| int length); |
| @@ -4043,8 +4067,12 @@ class Map: public HeapObject { |
| (bit_field2() & kElementsKindMask) >> kElementsKindShift); |
| } |
| + // Tells whether the instance has fast elements that are only Smis. |
| + inline bool has_fast_smi_only_elements() { |
| + return elements_kind() == FAST_SMI_ONLY_ELEMENTS; |
| + } |
| + |
| // Tells whether the instance has fast elements. |
| - // Equivalent to instance->GetElementsKind() == FAST_ELEMENTS. |
| inline bool has_fast_elements() { |
| return elements_kind() == FAST_ELEMENTS; |
| } |
| @@ -4053,6 +4081,10 @@ class Map: public HeapObject { |
| return elements_kind() == FAST_DOUBLE_ELEMENTS; |
| } |
| + inline bool has_non_strict_arguments_elements() { |
| + return elements_kind() == NON_STRICT_ARGUMENTS_ELEMENTS; |
| + } |
| + |
| inline bool has_external_array_elements() { |
| ElementsKind kind(elements_kind()); |
| return kind >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && |
| @@ -4312,6 +4344,9 @@ class Map: public HeapObject { |
| ((1 << (kElementsKindShift + kElementsKindBitCount)) - 1); |
| static const int8_t kMaximumBitField2FastElementValue = static_cast<int8_t>( |
| (FAST_ELEMENTS + 1) << Map::kElementsKindShift) - 1; |
| + static const int8_t kMaximumBitField2FastSmiOnlyElementValue = |
| + static_cast<int8_t>((FAST_SMI_ONLY_ELEMENTS + 1) << |
| + Map::kElementsKindShift) - 1; |
| // Bit positions for bit field 3 |
| static const int kIsShared = 0; |
| @@ -6872,7 +6907,7 @@ class JSArray: public JSObject { |
| MUST_USE_RESULT MaybeObject* Initialize(int capacity); |
| // Set the content of the array to the content of storage. |
| - inline void SetContent(FixedArray* storage); |
| + inline MaybeObject* SetContent(FixedArray* storage); |
| // Casting. |
| static inline JSArray* cast(Object* obj); |