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

Unified Diff: src/runtime.js

Issue 6341: Improve the generated code for the instanceof operator. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 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
===================================================================
--- src/runtime.js (revision 469)
+++ src/runtime.js (working copy)
@@ -274,7 +274,10 @@
}
-// ECMA-262, section 11.8.6, page 54.
+// ECMA-262, section 11.8.6, page 54. To make the implementation more
+// efficient, the return value should be zero if the 'this' is an
+// instance of F, and non-zero if not. This makes it possible to avoid
+// an expensive ToBoolean conversion in the generated code.
function INSTANCE_OF(F) {
var V = this;
if (!IS_FUNCTION(F)) {
@@ -283,7 +286,7 @@
// If V is not an object, return false.
if (IS_NULL(V) || (!IS_OBJECT(V) && !IS_FUNCTION(V))) {
- return false;
+ return 1;
}
// Get the prototype of F; if it is not an object, throw an error.
@@ -293,7 +296,7 @@
}
// Return whether or not O is in the prototype chain of V.
- return %IsInPrototypeChain(O, V);
+ return %IsInPrototypeChain(O, V) ? 0 : 1;
}

Powered by Google App Engine
This is Rietveld 408576698