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

Unified Diff: src/runtime.js

Issue 661369: Builtin function EQULAS partially rewritten in C++. Control branches that cal... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 10 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
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/equals.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.js
===================================================================
--- src/runtime.js (revision 4001)
+++ src/runtime.js (working copy)
@@ -52,43 +52,28 @@
// ECMA-262, section 11.9.1, page 55.
function EQUALS(y) {
- if (IS_STRING(this) && IS_STRING(y)) return %StringEquals(this, y);
+ var r = %FastEquals(this, y);
+ if (r <= 1) return r;
var x = this;
// NOTE: We use iteration instead of recursion, because it is
// difficult to call EQUALS with the correct setting of 'this' in
// an efficient way.
while (true) {
- if (IS_NUMBER(x)) {
- if (y == null) return 1; // not equal
- return %NumberEquals(x, %ToNumber(y));
- } else if (IS_STRING(x)) {
- if (IS_STRING(y)) return %StringEquals(x, y);
- if (IS_NUMBER(y)) return %NumberEquals(%ToNumber(x), y);
- if (IS_BOOLEAN(y)) return %NumberEquals(%ToNumber(x), %ToNumber(y));
- if (y == null) return 1; // not equal
+ if (r == EQUALS_SECOND_ARG_TO_DEFAULT_VALUE) {
+ x = %ToNumber(x);
+ y = %ToNumber(%DefaultNumber(y));
+ return %NumberEquals(x, y);
+ } else if (r == EQUALS_SECOND_ARG_TO_PRIMITIVE) {
y = %ToPrimitive(y, NO_HINT);
- } else if (IS_BOOLEAN(x)) {
- if (IS_BOOLEAN(y)) {
- return %_ObjectEquals(x, y) ? 0 : 1;
- }
- if (y == null) return 1; // not equal
- return %NumberEquals(%ToNumber(x), %ToNumber(y));
- } else if (x == null) {
- // NOTE: This checks for both null and undefined.
- return (y == null) ? 0 : 1;
- } else {
- // x is not a number, boolean, null or undefined.
- if (y == null) return 1; // not equal
- if (IS_OBJECT(y)) {
- return %_ObjectEquals(x, y) ? 0 : 1;
- }
- if (IS_FUNCTION(y)) {
- return %_ObjectEquals(x, y) ? 0 : 1;
- }
-
+ // retry
+ } else if (r == EQUALS_FIRST_ARG_TO_PRIMITIVE) {
x = %ToPrimitive(x, NO_HINT);
+ // retry
}
+
+ var r = %FastEquals(x, y);
+ if (r <= 1) return r;
}
}
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/equals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698