OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 var V = this; | 368 var V = this; |
369 if (!IS_SPEC_FUNCTION(F)) { | 369 if (!IS_SPEC_FUNCTION(F)) { |
370 throw %MakeTypeError('instanceof_function_expected', [V]); | 370 throw %MakeTypeError('instanceof_function_expected', [V]); |
371 } | 371 } |
372 | 372 |
373 // If V is not an object, return false. | 373 // If V is not an object, return false. |
374 if (!IS_SPEC_OBJECT(V)) { | 374 if (!IS_SPEC_OBJECT(V)) { |
375 return 1; | 375 return 1; |
376 } | 376 } |
377 | 377 |
| 378 // Check if function is bound, if so, get [[BoundFunction]] from it |
| 379 // and use that instead of F. |
| 380 var bindings = %BoundFunctionGetBindings(F); |
| 381 if (bindings) { |
| 382 F = bindings[kBoundFunctionIndex]; // Always a non-bound function. |
| 383 } |
378 // Get the prototype of F; if it is not an object, throw an error. | 384 // Get the prototype of F; if it is not an object, throw an error. |
379 var O = F.prototype; | 385 var O = F.prototype; |
380 if (!IS_SPEC_OBJECT(O)) { | 386 if (!IS_SPEC_OBJECT(O)) { |
381 throw %MakeTypeError('instanceof_nonobject_proto', [O]); | 387 throw %MakeTypeError('instanceof_nonobject_proto', [O]); |
382 } | 388 } |
383 | 389 |
384 // Return whether or not O is in the prototype chain of V. | 390 // Return whether or not O is in the prototype chain of V. |
385 return %IsInPrototypeChain(O, V) ? 0 : 1; | 391 return %IsInPrototypeChain(O, V) ? 0 : 1; |
386 } | 392 } |
387 | 393 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 throw %MakeTypeError('cannot_convert_to_primitive', []); | 664 throw %MakeTypeError('cannot_convert_to_primitive', []); |
659 } | 665 } |
660 | 666 |
661 | 667 |
662 // NOTE: Setting the prototype for Array must take place as early as | 668 // NOTE: Setting the prototype for Array must take place as early as |
663 // possible due to code generation for array literals. When | 669 // possible due to code generation for array literals. When |
664 // generating code for a array literal a boilerplate array is created | 670 // generating code for a array literal a boilerplate array is created |
665 // that is cloned when running the code. It is essential that the | 671 // that is cloned when running the code. It is essential that the |
666 // boilerplate gets the right prototype. | 672 // boilerplate gets the right prototype. |
667 %FunctionSetPrototype($Array, new $Array(0)); | 673 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |