Index: src/runtime/runtime-object.cc |
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc |
index a1d9dfa94d636cb622f6600f7d9dfcf866ce52f7..d2f1ee88e784c28230df03fac664dbdf8ded6151 100644 |
--- a/src/runtime/runtime-object.cc |
+++ b/src/runtime/runtime-object.cc |
@@ -1491,6 +1491,58 @@ RUNTIME_FUNCTION(Runtime_StrictEquals) { |
} |
+// TODO(bmeurer): Kill this special wrapper and use TF compatible LessThan, |
+// GreaterThan, etc. which return true or false. |
+RUNTIME_FUNCTION(Runtime_Compare) { |
+ HandleScope scope(isolate); |
+ DCHECK_EQ(3, args.length()); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, ncr, 2); |
+ Maybe<ComparisonResult> result = Object::Compare(x, y); |
+ if (result.IsJust()) { |
+ switch (result.FromJust()) { |
+ case ComparisonResult::kLessThan: |
+ return Smi::FromInt(LESS); |
+ case ComparisonResult::kEqual: |
+ return Smi::FromInt(EQUAL); |
+ case ComparisonResult::kGreaterThan: |
+ return Smi::FromInt(GREATER); |
+ case ComparisonResult::kUndefined: |
+ return *ncr; |
+ } |
+ UNREACHABLE(); |
+ } |
+ return isolate->heap()->exception(); |
+} |
+ |
+ |
+// TODO(bmeurer): Kill this special wrapper and use TF compatible LessThan, |
+// GreaterThan, etc. which return true or false. |
+RUNTIME_FUNCTION(Runtime_Compare_Strong) { |
+ HandleScope scope(isolate); |
+ DCHECK_EQ(3, args.length()); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, ncr, 2); |
+ Maybe<ComparisonResult> result = Object::Compare(x, y, Strength::STRONG); |
+ if (result.IsJust()) { |
+ switch (result.FromJust()) { |
+ case ComparisonResult::kLessThan: |
+ return Smi::FromInt(LESS); |
+ case ComparisonResult::kEqual: |
+ return Smi::FromInt(EQUAL); |
+ case ComparisonResult::kGreaterThan: |
+ return Smi::FromInt(GREATER); |
+ case ComparisonResult::kUndefined: |
+ return *ncr; |
+ } |
+ UNREACHABLE(); |
+ } |
+ return isolate->heap()->exception(); |
+} |
+ |
+ |
RUNTIME_FUNCTION(Runtime_InstanceOf) { |
// ECMA-262, section 11.8.6, page 54. |
HandleScope shs(isolate); |