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

Unified Diff: src/runtime.js

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.js
diff --git a/src/runtime.js b/src/runtime.js
index a49a3bdfa991279df019c6d944cb6d3e2c08bf82..9ace6ff821db13e977c9c1d387ef433f787805c3 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -38,57 +38,6 @@ var isConcatSpreadableSymbol =
// ----------------------------------------------------------------------------
-/* -----------------------------------
-- - - C o m p a r i s o n - - -
------------------------------------
-*/
-
-// ECMA-262, section 11.8.5, page 53. The 'ncr' parameter is used as
-// the result when either (or both) the operands are NaN.
-function COMPARE(x, ncr) {
- var left;
- var right;
- // Fast cases for string, numbers and undefined compares.
- if (IS_STRING(this)) {
- if (IS_STRING(x)) return %_StringCompare(this, x);
- if (IS_UNDEFINED(x)) return ncr;
- left = this;
- } else if (IS_NUMBER(this)) {
- if (IS_NUMBER(x)) return %NumberCompare(this, x, ncr);
- if (IS_UNDEFINED(x)) return ncr;
- left = this;
- } else if (IS_UNDEFINED(this)) {
- if (!IS_UNDEFINED(x)) {
- %to_primitive(x, NUMBER_HINT);
- }
- return ncr;
- } else if (IS_UNDEFINED(x)) {
- %to_primitive(this, NUMBER_HINT);
- return ncr;
- } else {
- left = %to_primitive(this, NUMBER_HINT);
- }
-
- right = %to_primitive(x, NUMBER_HINT);
- if (IS_STRING(left) && IS_STRING(right)) {
- return %_StringCompare(left, right);
- } else {
- var left_number = %to_number_fun(left);
- var right_number = %to_number_fun(right);
- if (NUMBER_IS_NAN(left_number) || NUMBER_IS_NAN(right_number)) return ncr;
- return %NumberCompare(left_number, right_number, ncr);
- }
-}
-
-// Strong mode COMPARE throws if an implicit conversion would be performed
-function COMPARE_STRONG(x, ncr) {
- if (IS_STRING(this) && IS_STRING(x)) return %_StringCompare(this, x);
- if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberCompare(this, x, ncr);
-
- throw %make_type_error(kStrongImplicitConversion);
-}
-
-
/* -----------------------------
- - - H e l p e r s - - -
-----------------------------
@@ -433,8 +382,6 @@ $toString = ToString;
%InstallToContext([
"apply_prepare_builtin", APPLY_PREPARE,
- "compare_builtin", COMPARE,
- "compare_strong_builtin", COMPARE_STRONG,
"concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY,
"reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE,
"reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE,
« src/objects.cc ('K') | « src/objects-inl.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698