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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 V(TRANSITION_ARRAY_SUB_TYPE) | 793 V(TRANSITION_ARRAY_SUB_TYPE) |
794 | 794 |
795 enum FixedArraySubInstanceType { | 795 enum FixedArraySubInstanceType { |
796 #define DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE(name) name, | 796 #define DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE(name) name, |
797 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE) | 797 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE) |
798 #undef DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE | 798 #undef DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE |
799 LAST_FIXED_ARRAY_SUB_TYPE = TRANSITION_ARRAY_SUB_TYPE | 799 LAST_FIXED_ARRAY_SUB_TYPE = TRANSITION_ARRAY_SUB_TYPE |
800 }; | 800 }; |
801 | 801 |
802 | 802 |
| 803 // TODO(bmeurer): Remove this in favor of the ComparisonResult below. |
803 enum CompareResult { | 804 enum CompareResult { |
804 LESS = -1, | 805 LESS = -1, |
805 EQUAL = 0, | 806 EQUAL = 0, |
806 GREATER = 1, | 807 GREATER = 1, |
807 | 808 |
808 NOT_EQUAL = GREATER | 809 NOT_EQUAL = GREATER |
809 }; | 810 }; |
810 | 811 |
811 | 812 |
| 813 // Result of an abstract relational comparison of x and y, implemented according |
| 814 // to ES6 section 7.2.11 Abstract Relational Comparison. |
| 815 enum class ComparisonResult { |
| 816 kLessThan, // x < y |
| 817 kEqual, // x = y |
| 818 kGreaterThan, // x > x |
| 819 kUndefined // at least one of x or y was undefined or NaN |
| 820 }; |
| 821 |
| 822 |
812 #define DECL_BOOLEAN_ACCESSORS(name) \ | 823 #define DECL_BOOLEAN_ACCESSORS(name) \ |
813 inline bool name() const; \ | 824 inline bool name() const; \ |
814 inline void set_##name(bool value); \ | 825 inline void set_##name(bool value); \ |
815 | 826 |
816 | 827 |
817 #define DECL_ACCESSORS(name, type) \ | 828 #define DECL_ACCESSORS(name, type) \ |
818 inline type* name() const; \ | 829 inline type* name() const; \ |
819 inline void set_##name(type* value, \ | 830 inline void set_##name(type* value, \ |
820 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ | 831 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ |
821 | 832 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 Representation representation); | 1087 Representation representation); |
1077 | 1088 |
1078 // Returns true if the object is of the correct type to be used as a | 1089 // Returns true if the object is of the correct type to be used as a |
1079 // implementation of a JSObject's elements. | 1090 // implementation of a JSObject's elements. |
1080 inline bool HasValidElements(); | 1091 inline bool HasValidElements(); |
1081 | 1092 |
1082 inline bool HasSpecificClassOf(String* name); | 1093 inline bool HasSpecificClassOf(String* name); |
1083 | 1094 |
1084 bool BooleanValue(); // ECMA-262 9.2. | 1095 bool BooleanValue(); // ECMA-262 9.2. |
1085 | 1096 |
| 1097 // ES6 section 7.2.11 Abstract Relational Comparison |
| 1098 MUST_USE_RESULT static Maybe<ComparisonResult> Compare( |
| 1099 Handle<Object> x, Handle<Object> y, Strength strength = Strength::WEAK); |
| 1100 |
1086 // ES6 section 7.2.12 Abstract Equality Comparison | 1101 // ES6 section 7.2.12 Abstract Equality Comparison |
1087 MUST_USE_RESULT static Maybe<bool> Equals(Handle<Object> x, Handle<Object> y); | 1102 MUST_USE_RESULT static Maybe<bool> Equals(Handle<Object> x, Handle<Object> y); |
1088 | 1103 |
1089 // ES6 section 7.2.13 Strict Equality Comparison | 1104 // ES6 section 7.2.13 Strict Equality Comparison |
1090 bool StrictEquals(Object* that); | 1105 bool StrictEquals(Object* that); |
1091 | 1106 |
1092 // Convert to a JSObject if needed. | 1107 // Convert to a JSObject if needed. |
1093 // native_context is used when creating wrapper object. | 1108 // native_context is used when creating wrapper object. |
1094 static inline MaybeHandle<JSReceiver> ToObject(Isolate* isolate, | 1109 static inline MaybeHandle<JSReceiver> ToObject(Isolate* isolate, |
1095 Handle<Object> object); | 1110 Handle<Object> object); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 MUST_USE_RESULT static MaybeHandle<Object> ShiftLeft( | 1156 MUST_USE_RESULT static MaybeHandle<Object> ShiftLeft( |
1142 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, | 1157 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, |
1143 Strength strength = Strength::WEAK); | 1158 Strength strength = Strength::WEAK); |
1144 MUST_USE_RESULT static MaybeHandle<Object> ShiftRight( | 1159 MUST_USE_RESULT static MaybeHandle<Object> ShiftRight( |
1145 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, | 1160 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, |
1146 Strength strength = Strength::WEAK); | 1161 Strength strength = Strength::WEAK); |
1147 MUST_USE_RESULT static MaybeHandle<Object> ShiftRightLogical( | 1162 MUST_USE_RESULT static MaybeHandle<Object> ShiftRightLogical( |
1148 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, | 1163 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, |
1149 Strength strength = Strength::WEAK); | 1164 Strength strength = Strength::WEAK); |
1150 | 1165 |
| 1166 // ES6 section 12.9 Relational Operators |
| 1167 MUST_USE_RESULT static inline Maybe<bool> GreaterThan( |
| 1168 Handle<Object> x, Handle<Object> y, Strength strength = Strength::WEAK); |
| 1169 MUST_USE_RESULT static inline Maybe<bool> GreaterThanOrEqual( |
| 1170 Handle<Object> x, Handle<Object> y, Strength strength = Strength::WEAK); |
| 1171 MUST_USE_RESULT static inline Maybe<bool> LessThan( |
| 1172 Handle<Object> x, Handle<Object> y, Strength strength = Strength::WEAK); |
| 1173 MUST_USE_RESULT static inline Maybe<bool> LessThanOrEqual( |
| 1174 Handle<Object> x, Handle<Object> y, Strength strength = Strength::WEAK); |
| 1175 |
1151 // ES6 section 12.11 Binary Bitwise Operators | 1176 // ES6 section 12.11 Binary Bitwise Operators |
1152 MUST_USE_RESULT static MaybeHandle<Object> BitwiseAnd( | 1177 MUST_USE_RESULT static MaybeHandle<Object> BitwiseAnd( |
1153 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, | 1178 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, |
1154 Strength strength = Strength::WEAK); | 1179 Strength strength = Strength::WEAK); |
1155 MUST_USE_RESULT static MaybeHandle<Object> BitwiseOr( | 1180 MUST_USE_RESULT static MaybeHandle<Object> BitwiseOr( |
1156 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, | 1181 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, |
1157 Strength strength = Strength::WEAK); | 1182 Strength strength = Strength::WEAK); |
1158 MUST_USE_RESULT static MaybeHandle<Object> BitwiseXor( | 1183 MUST_USE_RESULT static MaybeHandle<Object> BitwiseXor( |
1159 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, | 1184 Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs, |
1160 Strength strength = Strength::WEAK); | 1185 Strength strength = Strength::WEAK); |
(...skipping 7321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8482 // a flat vector of char or of uc16. | 8507 // a flat vector of char or of uc16. |
8483 // If the string isn't flat, and therefore doesn't have flat content, the | 8508 // If the string isn't flat, and therefore doesn't have flat content, the |
8484 // returned structure will report so, and can't provide a vector of either | 8509 // returned structure will report so, and can't provide a vector of either |
8485 // kind. | 8510 // kind. |
8486 FlatContent GetFlatContent(); | 8511 FlatContent GetFlatContent(); |
8487 | 8512 |
8488 // Returns the parent of a sliced string or first part of a flat cons string. | 8513 // Returns the parent of a sliced string or first part of a flat cons string. |
8489 // Requires: StringShape(this).IsIndirect() && this->IsFlat() | 8514 // Requires: StringShape(this).IsIndirect() && this->IsFlat() |
8490 inline String* GetUnderlying(); | 8515 inline String* GetUnderlying(); |
8491 | 8516 |
| 8517 // String relational comparison, implemented according to ES6 section 7.2.11 |
| 8518 // Abstract Relational Comparison (step 5): The comparison of Strings uses a |
| 8519 // simple lexicographic ordering on sequences of code unit values. There is no |
| 8520 // attempt to use the more complex, semantically oriented definitions of |
| 8521 // character or string equality and collating order defined in the Unicode |
| 8522 // specification. Therefore String values that are canonically equal according |
| 8523 // to the Unicode standard could test as unequal. In effect this algorithm |
| 8524 // assumes that both Strings are already in normalized form. Also, note that |
| 8525 // for strings containing supplementary characters, lexicographic ordering on |
| 8526 // sequences of UTF-16 code unit values differs from that on sequences of code |
| 8527 // point values. |
| 8528 MUST_USE_RESULT static ComparisonResult Compare(Handle<String> x, |
| 8529 Handle<String> y); |
| 8530 |
8492 // String equality operations. | 8531 // String equality operations. |
8493 inline bool Equals(String* other); | 8532 inline bool Equals(String* other); |
8494 inline static bool Equals(Handle<String> one, Handle<String> two); | 8533 inline static bool Equals(Handle<String> one, Handle<String> two); |
8495 bool IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match = false); | 8534 bool IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match = false); |
8496 bool IsOneByteEqualTo(Vector<const uint8_t> str); | 8535 bool IsOneByteEqualTo(Vector<const uint8_t> str); |
8497 bool IsTwoByteEqualTo(Vector<const uc16> str); | 8536 bool IsTwoByteEqualTo(Vector<const uc16> str); |
8498 | 8537 |
8499 // Return a UTF8 representation of the string. The string is null | 8538 // Return a UTF8 representation of the string. The string is null |
8500 // terminated but may optionally contain nulls. Length is returned | 8539 // terminated but may optionally contain nulls. Length is returned |
8501 // in length_output if length_output is not a null pointer The string | 8540 // in length_output if length_output is not a null pointer The string |
(...skipping 2020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10522 | 10561 |
10523 Isolate* isolate_; | 10562 Isolate* isolate_; |
10524 Handle<FixedArray> keys_; | 10563 Handle<FixedArray> keys_; |
10525 Handle<OrderedHashSet> set_; | 10564 Handle<OrderedHashSet> set_; |
10526 int length_; | 10565 int length_; |
10527 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); | 10566 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); |
10528 }; | 10567 }; |
10529 } } // namespace v8::internal | 10568 } } // namespace v8::internal |
10530 | 10569 |
10531 #endif // V8_OBJECTS_H_ | 10570 #endif // V8_OBJECTS_H_ |
OLD | NEW |