Index: src/objects.h |
diff --git a/src/objects.h b/src/objects.h |
index 514d4a42e53afda47ae5a7d463f07608cc0bd733..421a5314b017294188aaa836293f7e36c9d3e020 100644 |
--- a/src/objects.h |
+++ b/src/objects.h |
@@ -30,7 +30,6 @@ |
#include "allocation.h" |
#include "builtins.h" |
-#include "elements-kind.h" |
#include "list.h" |
#include "property-details.h" |
#include "smart-array-pointer.h" |
@@ -132,6 +131,40 @@ |
namespace v8 { |
namespace internal { |
+enum ElementsKind { |
+ // 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. |
+ FAST_DOUBLE_ELEMENTS, |
+ |
+ // The "slow" kind. |
+ DICTIONARY_ELEMENTS, |
+ NON_STRICT_ARGUMENTS_ELEMENTS, |
+ // The "fast" kind for external arrays |
+ EXTERNAL_BYTE_ELEMENTS, |
+ EXTERNAL_UNSIGNED_BYTE_ELEMENTS, |
+ EXTERNAL_SHORT_ELEMENTS, |
+ EXTERNAL_UNSIGNED_SHORT_ELEMENTS, |
+ EXTERNAL_INT_ELEMENTS, |
+ EXTERNAL_UNSIGNED_INT_ELEMENTS, |
+ EXTERNAL_FLOAT_ELEMENTS, |
+ EXTERNAL_DOUBLE_ELEMENTS, |
+ EXTERNAL_PIXEL_ELEMENTS, |
+ |
+ // Derived constants from ElementsKind |
+ FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_BYTE_ELEMENTS, |
+ LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS, |
+ FIRST_ELEMENTS_KIND = FAST_SMI_ONLY_ELEMENTS, |
+ LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS |
+}; |
+ |
enum CompareMapMode { |
REQUIRE_EXACT_MAP, |
ALLOW_ELEMENT_TRANSITION_MAPS |
@@ -142,6 +175,13 @@ enum KeyedAccessGrowMode { |
ALLOW_JSARRAY_GROWTH |
}; |
+const int kElementsKindCount = LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; |
+ |
+void PrintElementsKind(FILE* out, ElementsKind kind); |
+ |
+inline bool IsMoreGeneralElementsKindTransition(ElementsKind from_kind, |
+ ElementsKind to_kind); |
+ |
// Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER. |
enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER }; |
@@ -1469,19 +1509,13 @@ class JSObject: public JSReceiver { |
MUST_USE_RESULT inline MaybeObject* ResetElements(); |
inline ElementsKind GetElementsKind(); |
inline ElementsAccessor* GetElementsAccessor(); |
- // Returns true if an object has elements of FAST_SMI_ELEMENTS ElementsKind. |
- inline bool HasFastSmiElements(); |
- // Returns true if an object has elements of FAST_ELEMENTS ElementsKind. |
- inline bool HasFastObjectElements(); |
- // Returns true if an object has elements of FAST_ELEMENTS or |
- // FAST_SMI_ONLY_ELEMENTS. |
- inline bool HasFastSmiOrObjectElements(); |
- // Returns true if an object has elements of FAST_DOUBLE_ELEMENTS |
- // ElementsKind. |
+ 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(); |
- // Returns true if an object has elements of FAST_HOLEY_*_ELEMENTS |
- // ElementsKind. |
- inline bool HasFastHoleyElements(); |
inline bool HasNonStrictArgumentsElements(); |
inline bool HasDictionaryElements(); |
inline bool HasExternalPixelElements(); |
@@ -1676,7 +1710,7 @@ class JSObject: public JSReceiver { |
static Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index); |
MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); |
- inline void ValidateElements(); |
+ inline void ValidateSmiOnlyElements(); |
// Makes sure that this object can contain HeapObject as elements. |
MUST_USE_RESULT inline MaybeObject* EnsureCanContainHeapObjectElements(); |
@@ -1688,7 +1722,6 @@ class JSObject: public JSReceiver { |
EnsureElementsMode mode); |
MUST_USE_RESULT inline MaybeObject* EnsureCanContainElements( |
FixedArrayBase* elements, |
- uint32_t length, |
EnsureElementsMode mode); |
MUST_USE_RESULT MaybeObject* EnsureCanContainElements( |
Arguments* arguments, |
@@ -1787,10 +1820,10 @@ class JSObject: public JSReceiver { |
MUST_USE_RESULT MaybeObject* GetElementWithInterceptor(Object* receiver, |
uint32_t index); |
- enum SetFastElementsCapacitySmiMode { |
- kAllowSmiElements, |
- kForceSmiElements, |
- kDontAllowSmiElements |
+ enum SetFastElementsCapacityMode { |
+ kAllowSmiOnlyElements, |
+ kForceSmiOnlyElements, |
+ kDontAllowSmiOnlyElements |
}; |
// Replace the elements' backing store with fast elements of the given |
@@ -1799,7 +1832,7 @@ class JSObject: public JSReceiver { |
MUST_USE_RESULT MaybeObject* SetFastElementsCapacityAndLength( |
int capacity, |
int length, |
- SetFastElementsCapacitySmiMode smi_mode); |
+ SetFastElementsCapacityMode set_capacity_mode); |
MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength( |
int capacity, |
int length); |
@@ -4605,21 +4638,17 @@ class Map: public HeapObject { |
} |
// Tells whether the instance has fast elements that are only Smis. |
- inline bool has_fast_smi_elements() { |
- return IsFastSmiElementsKind(elements_kind()); |
+ inline bool has_fast_smi_only_elements() { |
+ return elements_kind() == FAST_SMI_ONLY_ELEMENTS; |
} |
// Tells whether the instance has fast elements. |
- inline bool has_fast_object_elements() { |
- return IsFastObjectElementsKind(elements_kind()); |
- } |
- |
- inline bool has_fast_smi_or_object_elements() { |
- return IsFastSmiOrObjectElementsKind(elements_kind()); |
+ inline bool has_fast_elements() { |
+ return elements_kind() == FAST_ELEMENTS; |
} |
inline bool has_fast_double_elements() { |
- return IsFastDoubleElementsKind(elements_kind()); |
+ return elements_kind() == FAST_DOUBLE_ELEMENTS; |
} |
inline bool has_non_strict_arguments_elements() { |
@@ -4915,31 +4944,25 @@ class Map: public HeapObject { |
// Bit positions for bit field 2 |
static const int kIsExtensible = 0; |
- static const int kStringWrapperSafeForDefaultValueOf = 1; |
- static const int kAttachedToSharedFunctionInfo = 2; |
+ static const int kFunctionWithPrototype = 1; |
+ static const int kStringWrapperSafeForDefaultValueOf = 2; |
+ static const int kAttachedToSharedFunctionInfo = 3; |
// No bits can be used after kElementsKindFirstBit, they are all reserved for |
// storing ElementKind. |
- static const int kElementsKindShift = 3; |
- static const int kElementsKindBitCount = 5; |
+ static const int kElementsKindShift = 4; |
+ static const int kElementsKindBitCount = 4; |
// Derived values from bit field 2 |
static const int kElementsKindMask = (-1 << kElementsKindShift) & |
((1 << (kElementsKindShift + kElementsKindBitCount)) - 1); |
static const int8_t kMaximumBitField2FastElementValue = static_cast<int8_t>( |
(FAST_ELEMENTS + 1) << Map::kElementsKindShift) - 1; |
- static const int8_t kMaximumBitField2FastSmiElementValue = |
- static_cast<int8_t>((FAST_SMI_ELEMENTS + 1) << |
- Map::kElementsKindShift) - 1; |
- static const int8_t kMaximumBitField2FastHoleyElementValue = |
- static_cast<int8_t>((FAST_HOLEY_ELEMENTS + 1) << |
- Map::kElementsKindShift) - 1; |
- static const int8_t kMaximumBitField2FastHoleySmiElementValue = |
- static_cast<int8_t>((FAST_HOLEY_SMI_ELEMENTS + 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; |
- static const int kFunctionWithPrototype = 1; |
// Layout of the default cache. It holds alternating name and code objects. |
static const int kCodeCacheEntrySize = 2; |