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

Unified Diff: src/runtime/runtime-object.cc

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/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);

Powered by Google App Engine
This is Rietveld 408576698