| 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 // First check whether length is a positive Smi and args is an | 423 // First check whether length is a positive Smi and args is an |
| 424 // array. This is the fast case. If this fails, we do the slow case | 424 // array. This is the fast case. If this fails, we do the slow case |
| 425 // that takes care of more eventualities. | 425 // that takes care of more eventualities. |
| 426 if (IS_ARRAY(args)) { | 426 if (IS_ARRAY(args)) { |
| 427 length = args.length; | 427 length = args.length; |
| 428 if (%_IsSmi(length) && length >= 0 && length < 0x800000 && IS_FUNCTION(this)
) { | 428 if (%_IsSmi(length) && length >= 0 && length < 0x800000 && IS_FUNCTION(this)
) { |
| 429 return length; | 429 return length; |
| 430 } | 430 } |
| 431 } | 431 } |
| 432 | 432 |
| 433 length = (args == null) ? 0 : TO_UINT32(args.length); | 433 length = (args == null) ? 0 : %ToUint32(args.length); |
| 434 | 434 |
| 435 // We can handle any number of apply arguments if the stack is | 435 // We can handle any number of apply arguments if the stack is |
| 436 // big enough, but sanity check the value to avoid overflow when | 436 // big enough, but sanity check the value to avoid overflow when |
| 437 // multiplying with pointer size. | 437 // multiplying with pointer size. |
| 438 if (length > 0x800000) { | 438 if (length > 0x800000) { |
| 439 throw %MakeRangeError('apply_overflow', [length]); | 439 throw %MakeRangeError('apply_overflow', [length]); |
| 440 } | 440 } |
| 441 | 441 |
| 442 if (!IS_FUNCTION(this)) { | 442 if (!IS_FUNCTION(this)) { |
| 443 throw %MakeTypeError('apply_non_function', [ %ToString(this), typeof this ])
; | 443 throw %MakeTypeError('apply_non_function', [ %ToString(this), typeof this ])
; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 throw %MakeTypeError('cannot_convert_to_primitive', []); | 617 throw %MakeTypeError('cannot_convert_to_primitive', []); |
| 618 } | 618 } |
| 619 | 619 |
| 620 | 620 |
| 621 // NOTE: Setting the prototype for Array must take place as early as | 621 // NOTE: Setting the prototype for Array must take place as early as |
| 622 // possible due to code generation for array literals. When | 622 // possible due to code generation for array literals. When |
| 623 // generating code for a array literal a boilerplate array is created | 623 // generating code for a array literal a boilerplate array is created |
| 624 // that is cloned when running the code. It is essiential that the | 624 // that is cloned when running the code. It is essiential that the |
| 625 // boilerplate gets the right prototype. | 625 // boilerplate gets the right prototype. |
| 626 %FunctionSetPrototype($Array, new $Array(0)); | 626 %FunctionSetPrototype($Array, new $Array(0)); |
| OLD | NEW |