OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1345 | 1345 |
1346 // Tries to convert an object to an array length. Returns true and sets the | 1346 // Tries to convert an object to an array length. Returns true and sets the |
1347 // output parameter if it succeeds. | 1347 // output parameter if it succeeds. |
1348 inline bool ToArrayLength(uint32_t* index); | 1348 inline bool ToArrayLength(uint32_t* index); |
1349 | 1349 |
1350 // Tries to convert an object to an array index. Returns true and sets the | 1350 // Tries to convert an object to an array index. Returns true and sets the |
1351 // output parameter if it succeeds. Equivalent to ToArrayLength, but does not | 1351 // output parameter if it succeeds. Equivalent to ToArrayLength, but does not |
1352 // allow kMaxUInt32. | 1352 // allow kMaxUInt32. |
1353 inline bool ToArrayIndex(uint32_t* index); | 1353 inline bool ToArrayIndex(uint32_t* index); |
1354 | 1354 |
1355 // Returns true if this is a JSValue containing a string and the index is | |
1356 // < the length of the string. Used to implement [] on strings. | |
1357 inline bool IsStringObjectWithCharacterAt(uint32_t index); | |
1358 | |
1359 DECLARE_VERIFIER(Object) | 1355 DECLARE_VERIFIER(Object) |
1360 #ifdef VERIFY_HEAP | 1356 #ifdef VERIFY_HEAP |
1361 // Verify a pointer is a valid object pointer. | 1357 // Verify a pointer is a valid object pointer. |
1362 static void VerifyPointer(Object* p); | 1358 static void VerifyPointer(Object* p); |
1363 #endif | 1359 #endif |
1364 | 1360 |
1365 inline void VerifyApiCallResultType(); | 1361 inline void VerifyApiCallResultType(); |
1366 | 1362 |
1367 // ES6 19.1.3.6 Object.prototype.toString | 1363 // ES6 19.1.3.6 Object.prototype.toString |
1368 MUST_USE_RESULT static MaybeHandle<String> ObjectProtoToString( | 1364 MUST_USE_RESULT static MaybeHandle<String> ObjectProtoToString( |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2024 inline bool HasFastSmiOrObjectElements(); | 2020 inline bool HasFastSmiOrObjectElements(); |
2025 // Returns true if an object has any of the fast elements kinds. | 2021 // Returns true if an object has any of the fast elements kinds. |
2026 inline bool HasFastElements(); | 2022 inline bool HasFastElements(); |
2027 // Returns true if an object has elements of FAST_DOUBLE_ELEMENTS | 2023 // Returns true if an object has elements of FAST_DOUBLE_ELEMENTS |
2028 // ElementsKind. | 2024 // ElementsKind. |
2029 inline bool HasFastDoubleElements(); | 2025 inline bool HasFastDoubleElements(); |
2030 // Returns true if an object has elements of FAST_HOLEY_*_ELEMENTS | 2026 // Returns true if an object has elements of FAST_HOLEY_*_ELEMENTS |
2031 // ElementsKind. | 2027 // ElementsKind. |
2032 inline bool HasFastHoleyElements(); | 2028 inline bool HasFastHoleyElements(); |
2033 inline bool HasSloppyArgumentsElements(); | 2029 inline bool HasSloppyArgumentsElements(); |
2030 inline bool HasStringWrapperElements(); | |
2034 inline bool HasDictionaryElements(); | 2031 inline bool HasDictionaryElements(); |
2035 | 2032 |
2036 inline bool HasFixedTypedArrayElements(); | 2033 inline bool HasFixedTypedArrayElements(); |
2037 | 2034 |
2038 inline bool HasFixedUint8ClampedElements(); | 2035 inline bool HasFixedUint8ClampedElements(); |
2039 inline bool HasFixedArrayElements(); | 2036 inline bool HasFixedArrayElements(); |
2040 inline bool HasFixedInt8Elements(); | 2037 inline bool HasFixedInt8Elements(); |
2041 inline bool HasFixedUint8Elements(); | 2038 inline bool HasFixedUint8Elements(); |
2042 inline bool HasFixedInt16Elements(); | 2039 inline bool HasFixedInt16Elements(); |
2043 inline bool HasFixedUint16Elements(); | 2040 inline bool HasFixedUint16Elements(); |
2044 inline bool HasFixedInt32Elements(); | 2041 inline bool HasFixedInt32Elements(); |
2045 inline bool HasFixedUint32Elements(); | 2042 inline bool HasFixedUint32Elements(); |
2046 inline bool HasFixedFloat32Elements(); | 2043 inline bool HasFixedFloat32Elements(); |
2047 inline bool HasFixedFloat64Elements(); | 2044 inline bool HasFixedFloat64Elements(); |
2048 | 2045 |
2049 inline bool HasFastArgumentsElements(); | 2046 inline bool HasFastArgumentsElements(); |
2050 inline bool HasSlowArgumentsElements(); | 2047 inline bool HasSlowArgumentsElements(); |
2048 inline bool HasFastStringWrapperElements(); | |
2049 inline bool HasSlowStringWrapperElements(); | |
2051 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements. | 2050 inline SeededNumberDictionary* element_dictionary(); // Gets slow elements. |
2052 | 2051 |
2053 // Requires: HasFastElements(). | 2052 // Requires: HasFastElements(). |
2054 static Handle<FixedArray> EnsureWritableFastElements( | 2053 static Handle<FixedArray> EnsureWritableFastElements( |
2055 Handle<JSObject> object); | 2054 Handle<JSObject> object); |
2056 | 2055 |
2057 // Collects elements starting at index 0. | 2056 // Collects elements starting at index 0. |
2058 // Undefined values are placed after non-undefined values. | 2057 // Undefined values are placed after non-undefined values. |
2059 // Returns the number of non-undefined values. | 2058 // Returns the number of non-undefined values. |
2060 static Handle<Object> PrepareElementsForSort(Handle<JSObject> object, | 2059 static Handle<Object> PrepareElementsForSort(Handle<JSObject> object, |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2628 | 2627 |
2629 class FixedDoubleArray; | 2628 class FixedDoubleArray; |
2630 class IncrementalMarking; | 2629 class IncrementalMarking; |
2631 | 2630 |
2632 | 2631 |
2633 // FixedArray describes fixed-sized arrays with element type Object*. | 2632 // FixedArray describes fixed-sized arrays with element type Object*. |
2634 class FixedArray: public FixedArrayBase { | 2633 class FixedArray: public FixedArrayBase { |
2635 public: | 2634 public: |
2636 // Setter and getter for elements. | 2635 // Setter and getter for elements. |
2637 inline Object* get(int index) const; | 2636 inline Object* get(int index) const; |
2638 static inline Handle<Object> get(Handle<FixedArray> array, int index); | 2637 static inline Handle<Object> get(FixedArray* array, int index, |
Jakob Kummerow
2016/01/26 14:21:24
Taking a raw pointer allows some callers to skip c
| |
2638 Isolate* isolate); | |
2639 // Setter that uses write barrier. | 2639 // Setter that uses write barrier. |
2640 inline void set(int index, Object* value); | 2640 inline void set(int index, Object* value); |
2641 inline bool is_the_hole(int index); | 2641 inline bool is_the_hole(int index); |
2642 | 2642 |
2643 // Setter that doesn't need write barrier. | 2643 // Setter that doesn't need write barrier. |
2644 inline void set(int index, Smi* value); | 2644 inline void set(int index, Smi* value); |
2645 // Setter with explicit barrier mode. | 2645 // Setter with explicit barrier mode. |
2646 inline void set(int index, Object* value, WriteBarrierMode mode); | 2646 inline void set(int index, Object* value, WriteBarrierMode mode); |
2647 | 2647 |
2648 // Setters for frequently used oddballs located in old space. | 2648 // Setters for frequently used oddballs located in old space. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2715 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray); | 2715 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedArray); |
2716 }; | 2716 }; |
2717 | 2717 |
2718 | 2718 |
2719 // FixedDoubleArray describes fixed-sized arrays with element type double. | 2719 // FixedDoubleArray describes fixed-sized arrays with element type double. |
2720 class FixedDoubleArray: public FixedArrayBase { | 2720 class FixedDoubleArray: public FixedArrayBase { |
2721 public: | 2721 public: |
2722 // Setter and getter for elements. | 2722 // Setter and getter for elements. |
2723 inline double get_scalar(int index); | 2723 inline double get_scalar(int index); |
2724 inline uint64_t get_representation(int index); | 2724 inline uint64_t get_representation(int index); |
2725 static inline Handle<Object> get(Handle<FixedDoubleArray> array, int index); | 2725 static inline Handle<Object> get(FixedDoubleArray* array, int index, |
2726 Isolate* isolate); | |
2726 inline void set(int index, double value); | 2727 inline void set(int index, double value); |
2727 inline void set_the_hole(int index); | 2728 inline void set_the_hole(int index); |
2728 | 2729 |
2729 // Checking for the hole. | 2730 // Checking for the hole. |
2730 inline bool is_the_hole(int index); | 2731 inline bool is_the_hole(int index); |
2731 | 2732 |
2732 // Garbage collection support. | 2733 // Garbage collection support. |
2733 inline static int SizeFor(int length) { | 2734 inline static int SizeFor(int length) { |
2734 return kHeaderSize + length * kDoubleSize; | 2735 return kHeaderSize + length * kDoubleSize; |
2735 } | 2736 } |
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4551 | 4552 |
4552 template <class Traits> | 4553 template <class Traits> |
4553 class FixedTypedArray: public FixedTypedArrayBase { | 4554 class FixedTypedArray: public FixedTypedArrayBase { |
4554 public: | 4555 public: |
4555 typedef typename Traits::ElementType ElementType; | 4556 typedef typename Traits::ElementType ElementType; |
4556 static const InstanceType kInstanceType = Traits::kInstanceType; | 4557 static const InstanceType kInstanceType = Traits::kInstanceType; |
4557 | 4558 |
4558 DECLARE_CAST(FixedTypedArray<Traits>) | 4559 DECLARE_CAST(FixedTypedArray<Traits>) |
4559 | 4560 |
4560 inline ElementType get_scalar(int index); | 4561 inline ElementType get_scalar(int index); |
4561 static inline Handle<Object> get(Handle<FixedTypedArray> array, int index); | 4562 static inline Handle<Object> get(FixedTypedArray* array, int index); |
4562 inline void set(int index, ElementType value); | 4563 inline void set(int index, ElementType value); |
4563 | 4564 |
4564 static inline ElementType from_int(int value); | 4565 static inline ElementType from_int(int value); |
4565 static inline ElementType from_double(double value); | 4566 static inline ElementType from_double(double value); |
4566 | 4567 |
4567 // This accessor applies the correct conversion from Smi, HeapNumber | 4568 // This accessor applies the correct conversion from Smi, HeapNumber |
4568 // and undefined. | 4569 // and undefined. |
4569 inline void SetValue(uint32_t index, Object* value); | 4570 inline void SetValue(uint32_t index, Object* value); |
4570 | 4571 |
4571 DECLARE_PRINTER(FixedTypedArray) | 4572 DECLARE_PRINTER(FixedTypedArray) |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5648 | 5649 |
5649 // Tells whether the instance has fast elements that are only Smis. | 5650 // Tells whether the instance has fast elements that are only Smis. |
5650 inline bool has_fast_smi_elements(); | 5651 inline bool has_fast_smi_elements(); |
5651 | 5652 |
5652 // Tells whether the instance has fast elements. | 5653 // Tells whether the instance has fast elements. |
5653 inline bool has_fast_object_elements(); | 5654 inline bool has_fast_object_elements(); |
5654 inline bool has_fast_smi_or_object_elements(); | 5655 inline bool has_fast_smi_or_object_elements(); |
5655 inline bool has_fast_double_elements(); | 5656 inline bool has_fast_double_elements(); |
5656 inline bool has_fast_elements(); | 5657 inline bool has_fast_elements(); |
5657 inline bool has_sloppy_arguments_elements(); | 5658 inline bool has_sloppy_arguments_elements(); |
5659 inline bool has_fast_string_wrapper_elements(); | |
5658 inline bool has_fixed_typed_array_elements(); | 5660 inline bool has_fixed_typed_array_elements(); |
5659 inline bool has_dictionary_elements(); | 5661 inline bool has_dictionary_elements(); |
5660 | 5662 |
5661 static bool IsValidElementsTransition(ElementsKind from_kind, | 5663 static bool IsValidElementsTransition(ElementsKind from_kind, |
5662 ElementsKind to_kind); | 5664 ElementsKind to_kind); |
5663 | 5665 |
5664 // Returns true if the current map doesn't have DICTIONARY_ELEMENTS but if a | 5666 // Returns true if the current map doesn't have DICTIONARY_ELEMENTS but if a |
5665 // map with DICTIONARY_ELEMENTS was found in the prototype chain. | 5667 // map with DICTIONARY_ELEMENTS was found in the prototype chain. |
5666 bool DictionaryElementsInPrototypeChainOnly(); | 5668 bool DictionaryElementsInPrototypeChainOnly(); |
5667 | 5669 |
(...skipping 5115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10783 } | 10785 } |
10784 return value; | 10786 return value; |
10785 } | 10787 } |
10786 }; | 10788 }; |
10787 | 10789 |
10788 | 10790 |
10789 } // NOLINT, false-positive due to second-order macros. | 10791 } // NOLINT, false-positive due to second-order macros. |
10790 } // NOLINT, false-positive due to second-order macros. | 10792 } // NOLINT, false-positive due to second-order macros. |
10791 | 10793 |
10792 #endif // V8_OBJECTS_H_ | 10794 #endif // V8_OBJECTS_H_ |
OLD | NEW |