Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(593)

Unified Diff: src/objects.h

Issue 1350113002: [runtime] Replace COMPARE/COMPARE_STRONG with proper Object::Compare. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 74ed139080df8238601f931fc5b38910635d868c..e28081c33f4cd8bb48dfee82dbfb9aa9e86dfbd4 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -800,6 +800,7 @@ enum FixedArraySubInstanceType {
};
+// TODO(bmeurer): Remove this in favor of the ComparisonResult below.
enum CompareResult {
LESS = -1,
EQUAL = 0,
@@ -809,6 +810,16 @@ enum CompareResult {
};
+// Result of an abstract relational comparison of x and y, implemented according
+// to ES6 section 7.2.11 Abstract Relational Comparison.
+enum class ComparisonResult {
+ kLessThan, // x < y
+ kEqual, // x = y
+ kGreaterThan, // x > x
+ kUndefined // at least one of x or y was undefined or NaN
+};
+
+
#define DECL_BOOLEAN_ACCESSORS(name) \
inline bool name() const; \
inline void set_##name(bool value); \
@@ -1083,6 +1094,10 @@ class Object {
bool BooleanValue(); // ECMA-262 9.2.
+ // ES6 section 7.2.11 Abstract Relational Comparison
+ MUST_USE_RESULT static Maybe<ComparisonResult> Compare(
+ Handle<Object> x, Handle<Object> y, Strength strength = Strength::WEAK);
+
// ES6 section 7.2.12 Abstract Equality Comparison
MUST_USE_RESULT static Maybe<bool> Equals(Handle<Object> x, Handle<Object> y);
@@ -1148,6 +1163,16 @@ class Object {
Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs,
Strength strength = Strength::WEAK);
+ // ES6 section 12.9 Relational Operators
+ MUST_USE_RESULT static inline Maybe<bool> GreaterThan(
+ Handle<Object> x, Handle<Object> y, Strength strength = Strength::WEAK);
+ MUST_USE_RESULT static inline Maybe<bool> GreaterThanOrEqual(
+ Handle<Object> x, Handle<Object> y, Strength strength = Strength::WEAK);
+ MUST_USE_RESULT static inline Maybe<bool> LessThan(
+ Handle<Object> x, Handle<Object> y, Strength strength = Strength::WEAK);
+ MUST_USE_RESULT static inline Maybe<bool> LessThanOrEqual(
+ Handle<Object> x, Handle<Object> y, Strength strength = Strength::WEAK);
+
// ES6 section 12.11 Binary Bitwise Operators
MUST_USE_RESULT static MaybeHandle<Object> BitwiseAnd(
Isolate* isolate, Handle<Object> lhs, Handle<Object> rhs,
@@ -8489,6 +8514,20 @@ class String: public Name {
// Requires: StringShape(this).IsIndirect() && this->IsFlat()
inline String* GetUnderlying();
+ // String relational comparison, implemented according to ES6 section 7.2.11
+ // Abstract Relational Comparison (step 5): The comparison of Strings uses a
+ // simple lexicographic ordering on sequences of code unit values. There is no
+ // attempt to use the more complex, semantically oriented definitions of
+ // character or string equality and collating order defined in the Unicode
+ // specification. Therefore String values that are canonically equal according
+ // to the Unicode standard could test as unequal. In effect this algorithm
+ // assumes that both Strings are already in normalized form. Also, note that
+ // for strings containing supplementary characters, lexicographic ordering on
+ // sequences of UTF-16 code unit values differs from that on sequences of code
+ // point values.
+ MUST_USE_RESULT static ComparisonResult Compare(Handle<String> x,
+ Handle<String> y);
+
// String equality operations.
inline bool Equals(String* other);
inline static bool Equals(Handle<String> one, Handle<String> two);
« no previous file with comments | « src/mips64/code-stubs-mips64.cc ('k') | src/objects.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698