OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assert-scope.h" | 9 #include "src/assert-scope.h" |
10 #include "src/builtins.h" | 10 #include "src/builtins.h" |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1345 | 1345 |
1346 // Object is the abstract superclass for all classes in the | 1346 // Object is the abstract superclass for all classes in the |
1347 // object hierarchy. | 1347 // object hierarchy. |
1348 // Object does not use any virtual functions to avoid the | 1348 // Object does not use any virtual functions to avoid the |
1349 // allocation of the C++ vtable. | 1349 // allocation of the C++ vtable. |
1350 // Since both Smi and HeapObject are subclasses of Object no | 1350 // Since both Smi and HeapObject are subclasses of Object no |
1351 // data members can be present in Object. | 1351 // data members can be present in Object. |
1352 class Object { | 1352 class Object { |
1353 public: | 1353 public: |
1354 // Type testing. | 1354 // Type testing. |
1355 bool IsObject() { return true; } | 1355 bool IsObject() const { return true; } |
1356 | 1356 |
1357 #define IS_TYPE_FUNCTION_DECL(type_) inline bool Is##type_(); | 1357 #define IS_TYPE_FUNCTION_DECL(type_) INLINE(bool Is##type_() const); |
1358 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) | 1358 OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) |
1359 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) | 1359 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) |
1360 #undef IS_TYPE_FUNCTION_DECL | 1360 #undef IS_TYPE_FUNCTION_DECL |
1361 | 1361 |
1362 inline bool IsFixedArrayBase(); | 1362 INLINE(bool IsFixedArrayBase() const); |
1363 inline bool IsExternal(); | 1363 INLINE(bool IsExternal() const); |
1364 inline bool IsAccessorInfo(); | 1364 INLINE(bool IsAccessorInfo() const); |
1365 | 1365 |
1366 inline bool IsStruct(); | 1366 INLINE(bool IsStruct() const); |
1367 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name(); | 1367 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) \ |
1368 INLINE(bool Is##Name() const); | |
1368 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) | 1369 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) |
1369 #undef DECLARE_STRUCT_PREDICATE | 1370 #undef DECLARE_STRUCT_PREDICATE |
1370 | 1371 |
1371 INLINE(bool IsSpecObject()); | 1372 INLINE(bool IsSpecObject()) const; |
1372 INLINE(bool IsSpecFunction()); | 1373 INLINE(bool IsSpecFunction()) const; |
1373 INLINE(bool IsTemplateInfo()); | 1374 INLINE(bool IsTemplateInfo()) const; |
1374 INLINE(bool IsNameDictionary()); | 1375 INLINE(bool IsNameDictionary() const); |
1375 INLINE(bool IsSeededNumberDictionary()); | 1376 INLINE(bool IsSeededNumberDictionary() const); |
1376 INLINE(bool IsUnseededNumberDictionary()); | 1377 INLINE(bool IsUnseededNumberDictionary() const); |
1377 INLINE(bool IsOrderedHashSet()); | 1378 INLINE(bool IsOrderedHashSet() const); |
1378 INLINE(bool IsOrderedHashMap()); | 1379 INLINE(bool IsOrderedHashMap() const); |
1379 bool IsCallable(); | 1380 bool IsCallable() const; |
1380 | 1381 |
1381 // Oddball testing. | 1382 // Oddball testing. |
1382 INLINE(bool IsUndefined()); | 1383 INLINE(bool IsUndefined() const); |
1383 INLINE(bool IsNull()); | 1384 INLINE(bool IsNull() const); |
1384 INLINE(bool IsTheHole()); | 1385 INLINE(bool IsTheHole() const); |
1385 INLINE(bool IsException()); | 1386 INLINE(bool IsException() const); |
1386 INLINE(bool IsUninitialized()); | 1387 INLINE(bool IsUninitialized() const); |
1387 INLINE(bool IsTrue()); | 1388 INLINE(bool IsTrue() const); |
1388 INLINE(bool IsFalse()); | 1389 INLINE(bool IsFalse() const); |
1389 inline bool IsArgumentsMarker(); | 1390 INLINE(bool IsArgumentsMarker() const); |
1390 | 1391 |
1391 // Filler objects (fillers and free space objects). | 1392 // Filler objects (fillers and free space objects). |
1392 inline bool IsFiller(); | 1393 INLINE(bool IsFiller() const); |
1393 | 1394 |
1394 // Extract the number. | 1395 // Extract the number. |
1395 inline double Number(); | 1396 inline double Number(); |
1396 inline bool IsNaN(); | 1397 INLINE(bool IsNaN() const); |
1397 bool ToInt32(int32_t* value); | 1398 bool ToInt32(int32_t* value); |
1398 bool ToUint32(uint32_t* value); | 1399 bool ToUint32(uint32_t* value); |
1399 | 1400 |
1400 // Indicates whether OptimalRepresentation can do its work, or whether it | 1401 // Indicates whether OptimalRepresentation can do its work, or whether it |
1401 // always has to return Representation::Tagged(). | 1402 // always has to return Representation::Tagged(). |
1402 enum ValueType { | 1403 enum ValueType { |
1403 OPTIMAL_REPRESENTATION, | 1404 OPTIMAL_REPRESENTATION, |
1404 FORCE_TAGGED | 1405 FORCE_TAGGED |
1405 }; | 1406 }; |
1406 | 1407 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1675 inline void synchronized_set_map(Map* value); | 1676 inline void synchronized_set_map(Map* value); |
1676 inline void synchronized_set_map_no_write_barrier(Map* value); | 1677 inline void synchronized_set_map_no_write_barrier(Map* value); |
1677 inline void synchronized_set_map_word(MapWord map_word); | 1678 inline void synchronized_set_map_word(MapWord map_word); |
1678 | 1679 |
1679 // During garbage collection, the map word of a heap object does not | 1680 // During garbage collection, the map word of a heap object does not |
1680 // necessarily contain a map pointer. | 1681 // necessarily contain a map pointer. |
1681 inline MapWord map_word() const; | 1682 inline MapWord map_word() const; |
1682 inline void set_map_word(MapWord map_word); | 1683 inline void set_map_word(MapWord map_word); |
1683 | 1684 |
1684 // The Heap the object was allocated in. Used also to access Isolate. | 1685 // The Heap the object was allocated in. Used also to access Isolate. |
1685 inline Heap* GetHeap() const; | 1686 INLINE(Heap* GetHeap() const); |
Michael Starzinger
2014/06/23 20:10:27
Is there a particular system or reason behind whic
Sven Panne
2014/06/24 06:10:23
The system was simply: Change every signature wher
| |
1686 | 1687 |
1687 // Convenience method to get current isolate. | 1688 // Convenience method to get current isolate. |
1688 inline Isolate* GetIsolate(); | 1689 INLINE(Isolate* GetIsolate() const); |
1689 | 1690 |
1690 // Converts an address to a HeapObject pointer. | 1691 // Converts an address to a HeapObject pointer. |
1691 static inline HeapObject* FromAddress(Address address); | 1692 static inline HeapObject* FromAddress(Address address); |
1692 | 1693 |
1693 // Returns the address of this HeapObject. | 1694 // Returns the address of this HeapObject. |
1694 inline Address address(); | 1695 inline Address address(); |
1695 | 1696 |
1696 // Iterates over pointers contained in the object (including the Map) | 1697 // Iterates over pointers contained in the object (including the Map) |
1697 void Iterate(ObjectVisitor* v); | 1698 void Iterate(ObjectVisitor* v); |
1698 | 1699 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1808 HeapObject::RawField(obj, object_size)); | 1809 HeapObject::RawField(obj, object_size)); |
1809 } | 1810 } |
1810 }; | 1811 }; |
1811 | 1812 |
1812 | 1813 |
1813 // The HeapNumber class describes heap allocated numbers that cannot be | 1814 // The HeapNumber class describes heap allocated numbers that cannot be |
1814 // represented in a Smi (small integer) | 1815 // represented in a Smi (small integer) |
1815 class HeapNumber: public HeapObject { | 1816 class HeapNumber: public HeapObject { |
1816 public: | 1817 public: |
1817 // [value]: number value. | 1818 // [value]: number value. |
1818 inline double value(); | 1819 INLINE(double value() const); |
Michael Starzinger
2014/06/23 20:10:27
Especially this one looks pretty random at first g
Sven Panne
2014/06/24 06:10:23
Rationale: See above.
| |
1819 inline void set_value(double value); | 1820 inline void set_value(double value); |
1820 | 1821 |
1821 DECLARE_CAST(HeapNumber) | 1822 DECLARE_CAST(HeapNumber) |
1822 | 1823 |
1823 // Dispatched behavior. | 1824 // Dispatched behavior. |
1824 bool HeapNumberBooleanValue(); | 1825 bool HeapNumberBooleanValue(); |
1825 | 1826 |
1826 void HeapNumberPrint(FILE* out = stdout); | 1827 void HeapNumberPrint(FILE* out = stdout); |
1827 void HeapNumberPrint(StringStream* accumulator); | 1828 void HeapNumberPrint(StringStream* accumulator); |
1828 DECLARE_VERIFIER(HeapNumber) | 1829 DECLARE_VERIFIER(HeapNumber) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1964 Handle<Name> name); | 1965 Handle<Name> name); |
1965 | 1966 |
1966 static inline PropertyAttributes GetElementAttribute( | 1967 static inline PropertyAttributes GetElementAttribute( |
1967 Handle<JSReceiver> object, | 1968 Handle<JSReceiver> object, |
1968 uint32_t index); | 1969 uint32_t index); |
1969 static inline PropertyAttributes GetOwnElementAttribute( | 1970 static inline PropertyAttributes GetOwnElementAttribute( |
1970 Handle<JSReceiver> object, | 1971 Handle<JSReceiver> object, |
1971 uint32_t index); | 1972 uint32_t index); |
1972 | 1973 |
1973 // Return the object's prototype (might be Heap::null_value()). | 1974 // Return the object's prototype (might be Heap::null_value()). |
1974 inline Object* GetPrototype(); | 1975 INLINE(Object* GetPrototype() const); |
1975 | 1976 |
1976 // Return the constructor function (may be Heap::null_value()). | 1977 // Return the constructor function (may be Heap::null_value()). |
1977 inline Object* GetConstructor(); | 1978 inline Object* GetConstructor(); |
1978 | 1979 |
1979 // Retrieves a permanent object identity hash code. The undefined value might | 1980 // Retrieves a permanent object identity hash code. The undefined value might |
1980 // be returned in case no hash was created yet. | 1981 // be returned in case no hash was created yet. |
1981 inline Object* GetIdentityHash(); | 1982 inline Object* GetIdentityHash(); |
1982 | 1983 |
1983 // Retrieves a permanent object identity hash code. May create and store a | 1984 // Retrieves a permanent object identity hash code. May create and store a |
1984 // hash code if needed and none exists. | 1985 // hash code if needed and none exists. |
(...skipping 2788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4773 static Handle<NormalizedMapCache> New(Isolate* isolate); | 4774 static Handle<NormalizedMapCache> New(Isolate* isolate); |
4774 | 4775 |
4775 MUST_USE_RESULT MaybeHandle<Map> Get(Handle<Map> fast_map, | 4776 MUST_USE_RESULT MaybeHandle<Map> Get(Handle<Map> fast_map, |
4776 PropertyNormalizationMode mode); | 4777 PropertyNormalizationMode mode); |
4777 void Set(Handle<Map> fast_map, Handle<Map> normalized_map); | 4778 void Set(Handle<Map> fast_map, Handle<Map> normalized_map); |
4778 | 4779 |
4779 void Clear(); | 4780 void Clear(); |
4780 | 4781 |
4781 DECLARE_CAST(NormalizedMapCache) | 4782 DECLARE_CAST(NormalizedMapCache) |
4782 | 4783 |
4783 static inline bool IsNormalizedMapCache(Object* obj); | 4784 INLINE(static bool IsNormalizedMapCache(const Object* obj)); |
4784 | 4785 |
4785 DECLARE_VERIFIER(NormalizedMapCache) | 4786 DECLARE_VERIFIER(NormalizedMapCache) |
4786 private: | 4787 private: |
4787 static const int kEntries = 64; | 4788 static const int kEntries = 64; |
4788 | 4789 |
4789 static inline int GetIndex(Handle<Map> map); | 4790 static inline int GetIndex(Handle<Map> map); |
4790 | 4791 |
4791 // The following declarations hide base class methods. | 4792 // The following declarations hide base class methods. |
4792 Object* get(int index); | 4793 Object* get(int index); |
4793 void set(int index, Object* value); | 4794 void set(int index, Object* value); |
(...skipping 3007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7801 public: | 7802 public: |
7802 // [native_context]: the owner native context of this global proxy object. | 7803 // [native_context]: the owner native context of this global proxy object. |
7803 // It is null value if this object is not used by any context. | 7804 // It is null value if this object is not used by any context. |
7804 DECL_ACCESSORS(native_context, Object) | 7805 DECL_ACCESSORS(native_context, Object) |
7805 | 7806 |
7806 // [hash]: The hash code property (undefined if not initialized yet). | 7807 // [hash]: The hash code property (undefined if not initialized yet). |
7807 DECL_ACCESSORS(hash, Object) | 7808 DECL_ACCESSORS(hash, Object) |
7808 | 7809 |
7809 DECLARE_CAST(JSGlobalProxy) | 7810 DECLARE_CAST(JSGlobalProxy) |
7810 | 7811 |
7811 inline bool IsDetachedFrom(GlobalObject* global); | 7812 INLINE(bool IsDetachedFrom(GlobalObject* global) const); |
7812 | 7813 |
7813 // Dispatched behavior. | 7814 // Dispatched behavior. |
7814 DECLARE_PRINTER(JSGlobalProxy) | 7815 DECLARE_PRINTER(JSGlobalProxy) |
7815 DECLARE_VERIFIER(JSGlobalProxy) | 7816 DECLARE_VERIFIER(JSGlobalProxy) |
7816 | 7817 |
7817 // Layout description. | 7818 // Layout description. |
7818 static const int kNativeContextOffset = JSObject::kHeaderSize; | 7819 static const int kNativeContextOffset = JSObject::kHeaderSize; |
7819 static const int kHashOffset = kNativeContextOffset + kPointerSize; | 7820 static const int kHashOffset = kNativeContextOffset + kPointerSize; |
7820 static const int kSize = kHashOffset + kPointerSize; | 7821 static const int kSize = kHashOffset + kPointerSize; |
7821 | 7822 |
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8797 // the shape of the string is given its own class so that it can be retrieved | 8798 // the shape of the string is given its own class so that it can be retrieved |
8798 // once and used for several string operations. A StringShape is small enough | 8799 // once and used for several string operations. A StringShape is small enough |
8799 // to be passed by value and is immutable, but be aware that flattening a | 8800 // to be passed by value and is immutable, but be aware that flattening a |
8800 // string can potentially alter its shape. Also be aware that a GC caused by | 8801 // string can potentially alter its shape. Also be aware that a GC caused by |
8801 // something else can alter the shape of a string due to ConsString | 8802 // something else can alter the shape of a string due to ConsString |
8802 // shortcutting. Keeping these restrictions in mind has proven to be error- | 8803 // shortcutting. Keeping these restrictions in mind has proven to be error- |
8803 // prone and so we no longer put StringShapes in variables unless there is a | 8804 // prone and so we no longer put StringShapes in variables unless there is a |
8804 // concrete performance benefit at that particular point in the code. | 8805 // concrete performance benefit at that particular point in the code. |
8805 class StringShape BASE_EMBEDDED { | 8806 class StringShape BASE_EMBEDDED { |
8806 public: | 8807 public: |
8807 inline explicit StringShape(String* s); | 8808 INLINE(explicit StringShape(const String* s)); |
8808 inline explicit StringShape(Map* s); | 8809 inline explicit StringShape(Map* s); |
8809 inline explicit StringShape(InstanceType t); | 8810 inline explicit StringShape(InstanceType t); |
8810 inline bool IsSequential(); | 8811 inline bool IsSequential(); |
8811 inline bool IsExternal(); | 8812 inline bool IsExternal(); |
8812 inline bool IsCons(); | 8813 inline bool IsCons(); |
8813 inline bool IsSliced(); | 8814 inline bool IsSliced(); |
8814 inline bool IsIndirect(); | 8815 inline bool IsIndirect(); |
8815 inline bool IsExternalAscii(); | 8816 inline bool IsExternalAscii(); |
8816 inline bool IsExternalTwoByte(); | 8817 inline bool IsExternalTwoByte(); |
8817 inline bool IsSequentialAscii(); | 8818 inline bool IsSequentialAscii(); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9056 | 9057 |
9057 // Get and set the length of the string using acquire loads and release | 9058 // Get and set the length of the string using acquire loads and release |
9058 // stores. | 9059 // stores. |
9059 inline int synchronized_length() const; | 9060 inline int synchronized_length() const; |
9060 inline void synchronized_set_length(int value); | 9061 inline void synchronized_set_length(int value); |
9061 | 9062 |
9062 // Returns whether this string has only ASCII chars, i.e. all of them can | 9063 // Returns whether this string has only ASCII chars, i.e. all of them can |
9063 // be ASCII encoded. This might be the case even if the string is | 9064 // be ASCII encoded. This might be the case even if the string is |
9064 // two-byte. Such strings may appear when the embedder prefers | 9065 // two-byte. Such strings may appear when the embedder prefers |
9065 // two-byte external representations even for ASCII data. | 9066 // two-byte external representations even for ASCII data. |
9066 inline bool IsOneByteRepresentation(); | 9067 INLINE(bool IsOneByteRepresentation() const); |
9067 inline bool IsTwoByteRepresentation(); | 9068 INLINE(bool IsTwoByteRepresentation() const); |
9068 | 9069 |
9069 // Cons and slices have an encoding flag that may not represent the actual | 9070 // Cons and slices have an encoding flag that may not represent the actual |
9070 // encoding of the underlying string. This is taken into account here. | 9071 // encoding of the underlying string. This is taken into account here. |
9071 // Requires: this->IsFlat() | 9072 // Requires: this->IsFlat() |
9072 inline bool IsOneByteRepresentationUnderneath(); | 9073 inline bool IsOneByteRepresentationUnderneath(); |
9073 inline bool IsTwoByteRepresentationUnderneath(); | 9074 inline bool IsTwoByteRepresentationUnderneath(); |
9074 | 9075 |
9075 // NOTE: this should be considered only a hint. False negatives are | 9076 // NOTE: this should be considered only a hint. False negatives are |
9076 // possible. | 9077 // possible. |
9077 inline bool HasOnlyOneByteChars(); | 9078 inline bool HasOnlyOneByteChars(); |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9725 | 9726 |
9726 // The Oddball describes objects null, undefined, true, and false. | 9727 // The Oddball describes objects null, undefined, true, and false. |
9727 class Oddball: public HeapObject { | 9728 class Oddball: public HeapObject { |
9728 public: | 9729 public: |
9729 // [to_string]: Cached to_string computed at startup. | 9730 // [to_string]: Cached to_string computed at startup. |
9730 DECL_ACCESSORS(to_string, String) | 9731 DECL_ACCESSORS(to_string, String) |
9731 | 9732 |
9732 // [to_number]: Cached to_number computed at startup. | 9733 // [to_number]: Cached to_number computed at startup. |
9733 DECL_ACCESSORS(to_number, Object) | 9734 DECL_ACCESSORS(to_number, Object) |
9734 | 9735 |
9735 inline byte kind(); | 9736 INLINE(byte kind() const); |
9736 inline void set_kind(byte kind); | 9737 inline void set_kind(byte kind); |
9737 | 9738 |
9738 DECLARE_CAST(Oddball) | 9739 DECLARE_CAST(Oddball) |
9739 | 9740 |
9740 // Dispatched behavior. | 9741 // Dispatched behavior. |
9741 DECLARE_VERIFIER(Oddball) | 9742 DECLARE_VERIFIER(Oddball) |
9742 | 9743 |
9743 // Initialize the fields. | 9744 // Initialize the fields. |
9744 static void Initialize(Isolate* isolate, | 9745 static void Initialize(Isolate* isolate, |
9745 Handle<Oddball> oddball, | 9746 Handle<Oddball> oddball, |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11146 } else { | 11147 } else { |
11147 value &= ~(1 << bit_position); | 11148 value &= ~(1 << bit_position); |
11148 } | 11149 } |
11149 return value; | 11150 return value; |
11150 } | 11151 } |
11151 }; | 11152 }; |
11152 | 11153 |
11153 } } // namespace v8::internal | 11154 } } // namespace v8::internal |
11154 | 11155 |
11155 #endif // V8_OBJECTS_H_ | 11156 #endif // V8_OBJECTS_H_ |
OLD | NEW |