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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 length = (args == null) ? 0 : %ToUint32(args.length); | 451 length = (args == null) ? 0 : %ToUint32(args.length); |
452 | 452 |
453 // We can handle any number of apply arguments if the stack is | 453 // We can handle any number of apply arguments if the stack is |
454 // big enough, but sanity check the value to avoid overflow when | 454 // big enough, but sanity check the value to avoid overflow when |
455 // multiplying with pointer size. | 455 // multiplying with pointer size. |
456 if (length > 0x800000) { | 456 if (length > 0x800000) { |
457 throw %MakeRangeError('stack_overflow', []); | 457 throw %MakeRangeError('stack_overflow', []); |
458 } | 458 } |
459 | 459 |
460 if (!IS_SPEC_FUNCTION(this)) { | 460 if (!IS_SPEC_FUNCTION(this)) { |
461 throw %MakeTypeError('apply_non_function', [ %ToString(this), typeof this ])
; | 461 throw %MakeTypeError('apply_non_function', |
| 462 [ %ToString(this), typeof this ]); |
462 } | 463 } |
463 | 464 |
464 // Make sure the arguments list has the right type. | 465 // Make sure the arguments list has the right type. |
465 if (args != null && !IS_SPEC_OBJECT(args)) { | 466 if (args != null && !IS_SPEC_OBJECT(args)) { |
466 throw %MakeTypeError('apply_wrong_args', []); | 467 throw %MakeTypeError('apply_wrong_args', []); |
467 } | 468 } |
468 | 469 |
469 // Return the length which is the number of arguments to copy to the | 470 // Return the length which is the number of arguments to copy to the |
470 // stack. It is guaranteed to be a small integer at this point. | 471 // stack. It is guaranteed to be a small integer at this point. |
471 return length; | 472 return length; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 throw %MakeTypeError('cannot_convert_to_primitive', []); | 658 throw %MakeTypeError('cannot_convert_to_primitive', []); |
658 } | 659 } |
659 | 660 |
660 | 661 |
661 // NOTE: Setting the prototype for Array must take place as early as | 662 // NOTE: Setting the prototype for Array must take place as early as |
662 // possible due to code generation for array literals. When | 663 // possible due to code generation for array literals. When |
663 // generating code for a array literal a boilerplate array is created | 664 // generating code for a array literal a boilerplate array is created |
664 // that is cloned when running the code. It is essential that the | 665 // that is cloned when running the code. It is essential that the |
665 // boilerplate gets the right prototype. | 666 // boilerplate gets the right prototype. |
666 %FunctionSetPrototype($Array, new $Array(0)); | 667 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |