Author: [email protected]
Date: Tue Jun 16 01:29:31 2009
New Revision: 2179
Modified:
branches/bleeding_edge/src/runtime.js
Log:
Make sure to invoke valueOf methods on both operands of & and >> -- even
when the left operand lets us shortcut the computation.
Review URL: http://codereview.chromium.org/125176
Modified: branches/bleeding_edge/src/runtime.js
==============================================================================
--- branches/bleeding_edge/src/runtime.js (original)
+++ branches/bleeding_edge/src/runtime.js Tue Jun 16 01:29:31 2009
@@ -224,14 +224,19 @@
var x;
if (IS_NUMBER(this)) {
x = this;
+ if (!IS_NUMBER(y)) y = %ToNumber(y);
} else {
x = %ToNumber(this);
+ // Make sure to convert the right operand to a number before
+ // bailing out in the fast case, but after converting the
+ // left operand. This ensures that valueOf methods on the right
+ // operand are always executed.
+ if (!IS_NUMBER(y)) y = %ToNumber(y);
// Optimize for the case where we end up AND'ing a value
// that doesn't convert to a number. This is common in
// certain benchmarks.
if (NUMBER_IS_NAN(x)) return 0;
}
- if (!IS_NUMBER(y)) y = %ToNumber(y);
return %NumberAnd(x, y);
}
@@ -271,14 +276,19 @@
var x;
if (IS_NUMBER(this)) {
x = this;
+ if (!IS_NUMBER(y)) y = %ToNumber(y);
} else {
x = %ToNumber(this);
+ // Make sure to convert the right operand to a number before
+ // bailing out in the fast case, but after converting the
+ // left operand. This ensures that valueOf methods on the right
+ // operand are always executed.
+ if (!IS_NUMBER(y)) y = %ToNumber(y);
// Optimize for the case where we end up shifting a value
// that doesn't convert to a number. This is common in
// certain benchmarks.
if (NUMBER_IS_NAN(x)) return 0;
}
- if (!IS_NUMBER(y)) y = %ToNumber(y);
return %NumberSar(x, y);
}
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---