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 <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 STORE_TRANSITION_TO_OBJECT, | 161 STORE_TRANSITION_TO_OBJECT, |
162 STORE_TRANSITION_TO_DOUBLE, | 162 STORE_TRANSITION_TO_DOUBLE, |
163 STORE_AND_GROW_NO_TRANSITION, | 163 STORE_AND_GROW_NO_TRANSITION, |
164 STORE_AND_GROW_TRANSITION_TO_OBJECT, | 164 STORE_AND_GROW_TRANSITION_TO_OBJECT, |
165 STORE_AND_GROW_TRANSITION_TO_DOUBLE, | 165 STORE_AND_GROW_TRANSITION_TO_DOUBLE, |
166 STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS, | 166 STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS, |
167 STORE_NO_TRANSITION_HANDLE_COW | 167 STORE_NO_TRANSITION_HANDLE_COW |
168 }; | 168 }; |
169 | 169 |
170 | 170 |
| 171 // Valid hints for the abstract operation ToPrimitive, |
| 172 // implemented according to ES6, section 7.1.1. |
| 173 enum class ToPrimitiveHint { kDefault, kNumber, kString }; |
| 174 |
| 175 |
171 enum TypeofMode { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF }; | 176 enum TypeofMode { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF }; |
172 | 177 |
173 | 178 |
174 enum MutableMode { | 179 enum MutableMode { |
175 MUTABLE, | 180 MUTABLE, |
176 IMMUTABLE | 181 IMMUTABLE |
177 }; | 182 }; |
178 | 183 |
179 | 184 |
180 enum ExternalArrayType { | 185 enum ExternalArrayType { |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 // ES6 section 7.2.13 Strict Equality Comparison | 1075 // ES6 section 7.2.13 Strict Equality Comparison |
1071 bool StrictEquals(Object* that); | 1076 bool StrictEquals(Object* that); |
1072 | 1077 |
1073 // Convert to a JSObject if needed. | 1078 // Convert to a JSObject if needed. |
1074 // native_context is used when creating wrapper object. | 1079 // native_context is used when creating wrapper object. |
1075 static inline MaybeHandle<JSReceiver> ToObject(Isolate* isolate, | 1080 static inline MaybeHandle<JSReceiver> ToObject(Isolate* isolate, |
1076 Handle<Object> object); | 1081 Handle<Object> object); |
1077 MUST_USE_RESULT static MaybeHandle<JSReceiver> ToObject( | 1082 MUST_USE_RESULT static MaybeHandle<JSReceiver> ToObject( |
1078 Isolate* isolate, Handle<Object> object, Handle<Context> context); | 1083 Isolate* isolate, Handle<Object> object, Handle<Context> context); |
1079 | 1084 |
1080 // Convert to a Name if needed. | 1085 // ES6 section 7.1.14 ToPropertyKey |
1081 MUST_USE_RESULT static MaybeHandle<Name> ToName(Isolate* isolate, | 1086 MUST_USE_RESULT static inline MaybeHandle<Name> ToName(Isolate* isolate, |
1082 Handle<Object> object); | 1087 Handle<Object> input); |
| 1088 |
| 1089 // ES6 section 7.1.1 ToPrimitive |
| 1090 MUST_USE_RESULT static inline MaybeHandle<Object> ToPrimitive( |
| 1091 Handle<Object> input, ToPrimitiveHint hint = ToPrimitiveHint::kDefault); |
| 1092 |
| 1093 // ES6 section 7.1.3 ToNumber |
| 1094 MUST_USE_RESULT static MaybeHandle<Object> ToNumber(Isolate* isolate, |
| 1095 Handle<Object> input); |
| 1096 |
| 1097 // ES6 section 7.1.12 ToString |
| 1098 MUST_USE_RESULT static MaybeHandle<String> ToString(Isolate* isolate, |
| 1099 Handle<Object> input); |
| 1100 |
| 1101 // ES6 section 7.3.9 GetMethod |
| 1102 MUST_USE_RESULT static MaybeHandle<Object> GetMethod( |
| 1103 Handle<JSReceiver> receiver, Handle<Name> name); |
1083 | 1104 |
1084 MUST_USE_RESULT static MaybeHandle<Object> GetProperty( | 1105 MUST_USE_RESULT static MaybeHandle<Object> GetProperty( |
1085 LookupIterator* it, LanguageMode language_mode = SLOPPY); | 1106 LookupIterator* it, LanguageMode language_mode = SLOPPY); |
1086 | 1107 |
1087 // Implementation of [[Put]], ECMA-262 5th edition, section 8.12.5. | 1108 // Implementation of [[Put]], ECMA-262 5th edition, section 8.12.5. |
1088 MUST_USE_RESULT static MaybeHandle<Object> SetProperty( | 1109 MUST_USE_RESULT static MaybeHandle<Object> SetProperty( |
1089 Handle<Object> object, Handle<Name> name, Handle<Object> value, | 1110 Handle<Object> object, Handle<Name> name, Handle<Object> value, |
1090 LanguageMode language_mode, | 1111 LanguageMode language_mode, |
1091 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); | 1112 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); |
1092 | 1113 |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1571 | 1592 |
1572 | 1593 |
1573 // The Simd128Value class describes heap allocated 128 bit SIMD values. | 1594 // The Simd128Value class describes heap allocated 128 bit SIMD values. |
1574 class Simd128Value : public HeapObject { | 1595 class Simd128Value : public HeapObject { |
1575 public: | 1596 public: |
1576 DECLARE_CAST(Simd128Value) | 1597 DECLARE_CAST(Simd128Value) |
1577 | 1598 |
1578 DECLARE_PRINTER(Simd128Value) | 1599 DECLARE_PRINTER(Simd128Value) |
1579 DECLARE_VERIFIER(Simd128Value) | 1600 DECLARE_VERIFIER(Simd128Value) |
1580 | 1601 |
| 1602 static Handle<String> ToString(Handle<Simd128Value> input); |
| 1603 |
1581 // Equality operations. | 1604 // Equality operations. |
1582 inline bool Equals(Simd128Value* that); | 1605 inline bool Equals(Simd128Value* that); |
1583 | 1606 |
1584 // Checks that another instance is bit-wise equal. | 1607 // Checks that another instance is bit-wise equal. |
1585 bool BitwiseEquals(const Simd128Value* other) const; | 1608 bool BitwiseEquals(const Simd128Value* other) const; |
1586 // Computes a hash from the 128 bit value, viewed as 4 32-bit integers. | 1609 // Computes a hash from the 128 bit value, viewed as 4 32-bit integers. |
1587 uint32_t Hash() const; | 1610 uint32_t Hash() const; |
1588 // Copies the 16 bytes of SIMD data to the destination address. | 1611 // Copies the 16 bytes of SIMD data to the destination address. |
1589 void CopyBits(void* destination) const; | 1612 void CopyBits(void* destination) const; |
1590 | 1613 |
(...skipping 22 matching lines...) Expand all Loading... |
1613 #define SIMD128_VALUE_CLASS(TYPE, Type, type, lane_count, lane_type) \ | 1636 #define SIMD128_VALUE_CLASS(TYPE, Type, type, lane_count, lane_type) \ |
1614 class Type final : public Simd128Value { \ | 1637 class Type final : public Simd128Value { \ |
1615 public: \ | 1638 public: \ |
1616 inline lane_type get_lane(int lane) const; \ | 1639 inline lane_type get_lane(int lane) const; \ |
1617 inline void set_lane(int lane, lane_type value); \ | 1640 inline void set_lane(int lane, lane_type value); \ |
1618 \ | 1641 \ |
1619 DECLARE_CAST(Type) \ | 1642 DECLARE_CAST(Type) \ |
1620 \ | 1643 \ |
1621 DECLARE_PRINTER(Type) \ | 1644 DECLARE_PRINTER(Type) \ |
1622 \ | 1645 \ |
| 1646 static Handle<String> ToString(Handle<Type> input); \ |
| 1647 \ |
1623 inline bool Equals(Type* that); \ | 1648 inline bool Equals(Type* that); \ |
1624 \ | 1649 \ |
1625 private: \ | 1650 private: \ |
1626 DISALLOW_IMPLICIT_CONSTRUCTORS(Type); \ | 1651 DISALLOW_IMPLICIT_CONSTRUCTORS(Type); \ |
1627 }; | 1652 }; |
1628 SIMD128_TYPES(SIMD128_VALUE_CLASS) | 1653 SIMD128_TYPES(SIMD128_VALUE_CLASS) |
1629 #undef SIMD128_VALUE_CLASS | 1654 #undef SIMD128_VALUE_CLASS |
1630 | 1655 |
1631 | 1656 |
1632 enum EnsureElementsMode { | 1657 enum EnsureElementsMode { |
1633 DONT_ALLOW_DOUBLE_ELEMENTS, | 1658 DONT_ALLOW_DOUBLE_ELEMENTS, |
1634 ALLOW_COPIED_DOUBLE_ELEMENTS, | 1659 ALLOW_COPIED_DOUBLE_ELEMENTS, |
1635 ALLOW_CONVERTED_DOUBLE_ELEMENTS | 1660 ALLOW_CONVERTED_DOUBLE_ELEMENTS |
1636 }; | 1661 }; |
1637 | 1662 |
1638 | 1663 |
1639 // Indicator for one component of an AccessorPair. | 1664 // Indicator for one component of an AccessorPair. |
1640 enum AccessorComponent { | 1665 enum AccessorComponent { |
1641 ACCESSOR_GETTER, | 1666 ACCESSOR_GETTER, |
1642 ACCESSOR_SETTER | 1667 ACCESSOR_SETTER |
1643 }; | 1668 }; |
1644 | 1669 |
1645 | 1670 |
1646 // JSReceiver includes types on which properties can be defined, i.e., | 1671 // JSReceiver includes types on which properties can be defined, i.e., |
1647 // JSObject and JSProxy. | 1672 // JSObject and JSProxy. |
1648 class JSReceiver: public HeapObject { | 1673 class JSReceiver: public HeapObject { |
1649 public: | 1674 public: |
1650 DECLARE_CAST(JSReceiver) | 1675 DECLARE_CAST(JSReceiver) |
1651 | 1676 |
| 1677 // ES6 section 7.1.1 ToPrimitive |
| 1678 MUST_USE_RESULT static MaybeHandle<Object> ToPrimitive( |
| 1679 Handle<JSReceiver> receiver, |
| 1680 ToPrimitiveHint hint = ToPrimitiveHint::kDefault); |
| 1681 MUST_USE_RESULT static MaybeHandle<Object> OrdinaryToPrimitive( |
| 1682 Handle<JSReceiver> receiver, Handle<String> hint); |
| 1683 |
1652 // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6. | 1684 // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6. |
1653 MUST_USE_RESULT static inline Maybe<bool> HasProperty( | 1685 MUST_USE_RESULT static inline Maybe<bool> HasProperty( |
1654 Handle<JSReceiver> object, Handle<Name> name); | 1686 Handle<JSReceiver> object, Handle<Name> name); |
1655 MUST_USE_RESULT static inline Maybe<bool> HasOwnProperty(Handle<JSReceiver>, | 1687 MUST_USE_RESULT static inline Maybe<bool> HasOwnProperty(Handle<JSReceiver>, |
1656 Handle<Name> name); | 1688 Handle<Name> name); |
1657 MUST_USE_RESULT static inline Maybe<bool> HasElement( | 1689 MUST_USE_RESULT static inline Maybe<bool> HasElement( |
1658 Handle<JSReceiver> object, uint32_t index); | 1690 Handle<JSReceiver> object, uint32_t index); |
1659 MUST_USE_RESULT static inline Maybe<bool> HasOwnElement( | 1691 MUST_USE_RESULT static inline Maybe<bool> HasOwnElement( |
1660 Handle<JSReceiver> object, uint32_t index); | 1692 Handle<JSReceiver> object, uint32_t index); |
1661 | 1693 |
(...skipping 6677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8339 // NOTE: this should be considered only a hint. False negatives are | 8371 // NOTE: this should be considered only a hint. False negatives are |
8340 // possible. | 8372 // possible. |
8341 inline bool HasOnlyOneByteChars(); | 8373 inline bool HasOnlyOneByteChars(); |
8342 | 8374 |
8343 // Get and set individual two byte chars in the string. | 8375 // Get and set individual two byte chars in the string. |
8344 inline void Set(int index, uint16_t value); | 8376 inline void Set(int index, uint16_t value); |
8345 // Get individual two byte char in the string. Repeated calls | 8377 // Get individual two byte char in the string. Repeated calls |
8346 // to this method are not efficient unless the string is flat. | 8378 // to this method are not efficient unless the string is flat. |
8347 INLINE(uint16_t Get(int index)); | 8379 INLINE(uint16_t Get(int index)); |
8348 | 8380 |
| 8381 // ES6 section 7.1.3.1 ToNumber Applied to the String Type |
| 8382 static Handle<Object> ToNumber(Handle<String> subject); |
| 8383 |
8349 // Flattens the string. Checks first inline to see if it is | 8384 // Flattens the string. Checks first inline to see if it is |
8350 // necessary. Does nothing if the string is not a cons string. | 8385 // necessary. Does nothing if the string is not a cons string. |
8351 // Flattening allocates a sequential string with the same data as | 8386 // Flattening allocates a sequential string with the same data as |
8352 // the given string and mutates the cons string to a degenerate | 8387 // the given string and mutates the cons string to a degenerate |
8353 // form, where the first component is the new sequential string and | 8388 // form, where the first component is the new sequential string and |
8354 // the second component is the empty string. If allocation fails, | 8389 // the second component is the empty string. If allocation fails, |
8355 // this function returns a failure. If flattening succeeds, this | 8390 // this function returns a failure. If flattening succeeds, this |
8356 // function returns the sequential string that is now the first | 8391 // function returns the sequential string that is now the first |
8357 // component of the cons string. | 8392 // component of the cons string. |
8358 // | 8393 // |
(...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10335 } else { | 10370 } else { |
10336 value &= ~(1 << bit_position); | 10371 value &= ~(1 << bit_position); |
10337 } | 10372 } |
10338 return value; | 10373 return value; |
10339 } | 10374 } |
10340 }; | 10375 }; |
10341 | 10376 |
10342 } } // namespace v8::internal | 10377 } } // namespace v8::internal |
10343 | 10378 |
10344 #endif // V8_OBJECTS_H_ | 10379 #endif // V8_OBJECTS_H_ |
OLD | NEW |