Chromium Code Reviews| Index: src/objects.h |
| diff --git a/src/objects.h b/src/objects.h |
| index 15f22757e63b1e844b8dacb861629c15168e246c..6039f95d6daed28c159ea29ff5b747a138a6004f 100644 |
| --- a/src/objects.h |
| +++ b/src/objects.h |
| @@ -531,6 +531,7 @@ enum InstanceType { |
| EXTERNAL_FLOAT_ARRAY_TYPE, |
| EXTERNAL_DOUBLE_ARRAY_TYPE, |
| EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE |
| + FIXED_DOUBLE_ARRAY_TYPE, |
| FILLER_TYPE, // LAST_DATA_TYPE |
| // Structs. |
| @@ -729,6 +730,7 @@ class MaybeObject BASE_EMBEDDED { |
| V(DeoptimizationInputData) \ |
| V(DeoptimizationOutputData) \ |
| V(FixedArray) \ |
| + V(FixedDoubleArray) \ |
| V(Context) \ |
| V(CatchContext) \ |
| V(GlobalContext) \ |
| @@ -796,6 +798,10 @@ class Object : public MaybeObject { |
| // Extract the number. |
| inline double Number(); |
| + // Returns true if the object is of the correct type to be used as a |
| + // implementation of a JSObject's elements. |
| + inline bool HasValidElements(); |
| + |
| inline bool HasSpecificClassOf(String* name); |
| MUST_USE_RESULT MaybeObject* ToObject(); // ECMA-262 9.9. |
| @@ -1423,6 +1429,10 @@ class JSObject: public JSReceiver { |
| // The "fast" kind for tagged values. Must be first to make it possible |
| // to efficiently check maps if they have fast elements. |
| FAST_ELEMENTS, |
| + |
| + // The "fast" kind for unwrapped, non-tagged double values. |
| + FAST_DOUBLE_ELEMENTS, |
| + |
| // The "slow" kind. |
| DICTIONARY_ELEMENTS, |
| // The "fast" kind for external arrays |
| @@ -1474,6 +1484,7 @@ class JSObject: public JSReceiver { |
| MUST_USE_RESULT inline MaybeObject* ResetElements(); |
| inline ElementsKind GetElementsKind(); |
| inline bool HasFastElements(); |
| + inline bool HasFastDoubleElements(); |
| inline bool HasDictionaryElements(); |
| inline bool HasExternalPixelElements(); |
| inline bool HasExternalArrayElements(); |
| @@ -1633,6 +1644,9 @@ class JSObject: public JSReceiver { |
| // storage would. In that case the JSObject should have fast |
| // elements. |
| bool ShouldConvertToFastElements(); |
| + // Returns true if the elements of JSObject contains exclusively values |
| + // that can be represented in a FixedDoubleArray. |
| + bool ShouldConvertToFastDoubleElements(); |
| // Tells whether the index'th element is present. |
| inline bool HasElement(uint32_t index); |
| @@ -1672,6 +1686,12 @@ class JSObject: public JSReceiver { |
| StrictModeFlag strict_mode, |
| bool check_prototype = true); |
| + MUST_USE_RESULT MaybeObject* SetFastDoubleElement( |
| + uint32_t index, |
| + Object* value, |
| + StrictModeFlag strict_mode, |
| + bool check_prototype = true); |
| + |
| // Set the index'th array element. |
| // A Failure object is returned if GC is needed. |
| MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, |
| @@ -1691,6 +1711,9 @@ class JSObject: public JSReceiver { |
| MUST_USE_RESULT MaybeObject* SetFastElementsCapacityAndLength(int capacity, |
| int length); |
| + MUST_USE_RESULT MaybeObject* SetFastDoubleElementsCapacityAndLength( |
| + int capacity, |
| + int length); |
| MUST_USE_RESULT MaybeObject* SetSlowElements(Object* length); |
| // Lookup interceptors are used for handling properties controlled by host |
| @@ -2091,6 +2114,76 @@ class FixedArray: public HeapObject { |
| }; |
| +// FixedDoubleArray describes fixed-sized arrays with element type double |
|
Mads Ager (chromium)
2011/06/06 07:58:23
Period at end of comment.
danno
2011/06/08 12:09:43
Done.
|
| +class FixedDoubleArray: public HeapObject { |
| + public: |
| + inline void Initialize(FixedArray* from); |
| + inline void Initialize(FixedDoubleArray* from); |
| + inline void Initialize(NumberDictionary* from); |
| + |
| + // [length]: length of the array. |
| + inline int length(); |
| + inline void set_length(int value); |
| + |
| + // Setter and getter for elements. |
| + inline double get(int index); |
| + inline void set(int index, double value); |
| + inline void set_the_hole(int index); |
| + |
| + // Checking for the hole. |
| + inline bool is_the_hole(int index); |
| + |
| + // Garbage collection support. |
| + inline static int SizeFor(int length) { |
| + return kHeaderSize + length * kDoubleSize; |
| + } |
| + |
| + // The folllwing can't be declared inline as const static |
|
Mads Ager (chromium)
2011/06/06 07:58:23
following
danno
2011/06/08 12:09:43
Done.
|
| + // because they're 64-bit. |
| + static uint64_t kCanonoicalNonHoleNanLower32; |
|
Mads Ager (chromium)
2011/06/06 07:58:23
Canonical.
danno
2011/06/08 12:09:43
Done.
|
| + static uint64_t kCanonoicalNonHoleNanInt64; |
|
Mads Ager (chromium)
2011/06/06 07:58:23
Canonical.
danno
2011/06/08 12:09:43
Done.
|
| + static uint64_t kHoleNanInt64; |
| + |
| + inline static bool is_the_hole_nan(double value) { |
| + return BitCast<uint64_t, double>(value) == kHoleNanInt64; |
| + } |
| + |
| + inline static double hole_nan_as_double() { |
| + return BitCast<double, uint64_t>(kHoleNanInt64); |
| + } |
| + |
| + inline static double canonical_not_the_hole_nan_as_double() { |
| + return BitCast<double, uint64_t>(kCanonoicalNonHoleNanInt64); |
| + } |
| + |
| + // Casting. |
| + static inline FixedDoubleArray* cast(Object* obj); |
| + |
| + // Layout description. |
| + // Length is smi tagged when it is stored. |
|
Mads Ager (chromium)
2011/06/06 07:58:23
Is it? Didn't we just use INT_ACCESSOR?
You could
danno
2011/06/08 12:09:43
Done.
|
| + static const int kLengthOffset = HeapObject::kHeaderSize; |
| + static const int kHeaderSize = kLengthOffset + kPointerSize; |
| + |
| + // Maximal allowed size, in bytes, of a single FixedDoubleArray. |
| + // Prevents overflowing size computations, as well as extreme memory |
| + // consumption. |
| + static const int kMaxSize = 512 * MB; |
| + // Maximally allowed length of a FixedArray. |
| + static const int kMaxLength = (kMaxSize - kHeaderSize) / kDoubleSize; |
| + |
| + // Dispatched behavior. |
| +#ifdef OBJECT_PRINT |
| + inline void FixedDoubleArrayPrint() { |
| + FixedDoubleArrayPrint(stdout); |
| + } |
| + void FixedDoubleArrayPrint(FILE* out); |
| +#endif |
| + |
| + private: |
| + DISALLOW_IMPLICIT_CONSTRUCTORS(FixedDoubleArray); |
| +}; |
| + |
| + |
| // DescriptorArrays are fixed arrays used to hold instance descriptors. |
| // The format of the these objects is: |
| // TODO(1399): It should be possible to make room for bit_field3 in the map |
| @@ -3812,6 +3905,10 @@ class Map: public HeapObject { |
| return elements_kind() == JSObject::FAST_ELEMENTS; |
| } |
| + inline bool has_fast_double_elements() { |
| + return elements_kind() == JSObject::FAST_DOUBLE_ELEMENTS; |
| + } |
| + |
| inline bool has_external_array_elements() { |
| JSObject::ElementsKind kind(elements_kind()); |
| return kind >= JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && |
| @@ -3884,14 +3981,19 @@ class Map: public HeapObject { |
| // instance descriptors. |
| MUST_USE_RESULT MaybeObject* CopyDropTransitions(); |
| - // Returns this map if it has the fast elements bit set, otherwise |
| + // Returns this map if it already has elements that are fast, otherwise |
| // returns a copy of the map, with all transitions dropped from the |
| // descriptors and the fast elements bit set. |
| MUST_USE_RESULT inline MaybeObject* GetFastElementsMap(); |
| - // Returns this map if it has the fast elements bit cleared, |
| - // otherwise returns a copy of the map, with all transitions dropped |
| - // from the descriptors and the fast elements bit cleared. |
| + // Returns this map if it already has fast elements that are doubles, |
| + // otherwise returns a copy of the map, with all transitions dropped from the |
| + // descriptors and the fast elements bit set. |
|
Mads Ager (chromium)
2011/06/06 07:58:23
These comments should be updated? The fast element
danno
2011/06/08 12:09:43
Done.
|
| + MUST_USE_RESULT inline MaybeObject* GetFastDoubleElementsMap(); |
| + |
| + // Returns this map if already has dictionary elements, otherwise returns a |
| + // copy of the map, with all transitions dropped from the descriptors and the |
| + // fast elements bit cleared. |
| MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); |
| // Returns a new map with all transitions dropped from the descriptors and the |