| Index: src/objects.h
|
| diff --git a/src/objects.h b/src/objects.h
|
| index 3be92184c8fb58568afb7ed722a6d89df63b08ca..a7336d9143876afa8da092798f198e00e3f627a0 100644
|
| --- a/src/objects.h
|
| +++ b/src/objects.h
|
| @@ -137,8 +137,13 @@ namespace v8 {
|
| namespace internal {
|
|
|
| enum ElementsKind {
|
| - // The "fast" kind for tagged values. Must be first to make it possible
|
| - // to efficiently check maps if they have fast elements.
|
| + // The "fast" kind for elements that only contain SMI values. Must be first
|
| + // to make it possible to efficiently check maps for this kind.
|
| + FAST_SMI_ONLY_ELEMENTS,
|
| +
|
| + // The "fast" kind for tagged values. Must be second to make it possible to
|
| + // efficiently check maps for this and the FAST_SMI_ONLY_ELEMENTS kind
|
| + // together at once.
|
| FAST_ELEMENTS,
|
|
|
| // The "fast" kind for unwrapped, non-tagged double values.
|
| @@ -161,7 +166,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
|
| };
|
|
|
| @@ -1415,8 +1420,14 @@ class JSObject: public JSReceiver {
|
| MUST_USE_RESULT inline MaybeObject* ResetElements();
|
| inline ElementsKind GetElementsKind();
|
| inline ElementsAccessor* GetElementsAccessor();
|
| + inline bool HasFastSmiOnlyElements();
|
| inline bool HasFastElements();
|
| + // Returns if an object has either FAST_ELEMENT or FAST_SMI_ONLY_ELEMENT
|
| + // elements. TODO(danno): Rename HasFastTypeElements to HasFastElements() and
|
| + // HasFastElements to HasFastObjectElements.
|
| + inline bool HasFastTypeElements();
|
| inline bool HasFastDoubleElements();
|
| + inline bool HasNonStrictArgumentsElements();
|
| inline bool HasDictionaryElements();
|
| inline bool HasExternalPixelElements();
|
| inline bool HasExternalArrayElements();
|
| @@ -1587,6 +1598,19 @@ class JSObject: public JSReceiver {
|
| // Tests for the fast common case for property enumeration.
|
| bool IsSimpleEnum();
|
|
|
| + inline void ValidateSmiOnlyElements();
|
| +
|
| + // Makes sure that this object can contain non-smi Object as elements.
|
| + inline MaybeObject* EnsureCanContainNonSmiElements();
|
| +
|
| + // Makes sure that this object can contain the specified elements.
|
| + 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);
|
| @@ -1636,6 +1660,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,
|
| @@ -1658,11 +1683,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);
|
| @@ -3960,8 +3992,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;
|
| }
|
| @@ -3970,6 +4006,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 &&
|
| @@ -4217,7 +4257,7 @@ class Map: public HeapObject {
|
| static const int kStringWrapperSafeForDefaultValueOf = 2;
|
| static const int kAttachedToSharedFunctionInfo = 3;
|
| // No bits can be used after kElementsKindFirstBit, they are all reserved for
|
| - // storing ElementKind. for anything other than storing the ElementKind.
|
| + // storing ElementKind.
|
| static const int kElementsKindShift = 4;
|
| static const int kElementsKindBitCount = 4;
|
|
|
| @@ -4226,6 +4266,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;
|
| @@ -6818,7 +6861,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);
|
|
|