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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 return length; | 424 return length; |
425 } | 425 } |
426 } | 426 } |
427 | 427 |
428 length = (args == null) ? 0 : %ToUint32(args.length); | 428 length = (args == null) ? 0 : %ToUint32(args.length); |
429 | 429 |
430 // We can handle any number of apply arguments if the stack is | 430 // We can handle any number of apply arguments if the stack is |
431 // big enough, but sanity check the value to avoid overflow when | 431 // big enough, but sanity check the value to avoid overflow when |
432 // multiplying with pointer size. | 432 // multiplying with pointer size. |
433 if (length > 0x800000) { | 433 if (length > 0x800000) { |
434 throw %MakeRangeError('apply_overflow', [length]); | 434 throw %MakeRangeError('stack_overflow', []); |
435 } | 435 } |
436 | 436 |
437 if (!IS_FUNCTION(this)) { | 437 if (!IS_FUNCTION(this)) { |
438 throw %MakeTypeError('apply_non_function', [ %ToString(this), typeof this ])
; | 438 throw %MakeTypeError('apply_non_function', [ %ToString(this), typeof this ])
; |
439 } | 439 } |
440 | 440 |
441 // Make sure the arguments list has the right type. | 441 // Make sure the arguments list has the right type. |
442 if (args != null && !IS_ARRAY(args) && !IS_ARGUMENTS(args)) { | 442 if (args != null && !IS_ARRAY(args) && !IS_ARGUMENTS(args)) { |
443 throw %MakeTypeError('apply_wrong_args', []); | 443 throw %MakeTypeError('apply_wrong_args', []); |
444 } | 444 } |
445 | 445 |
446 // Return the length which is the number of arguments to copy to the | 446 // Return the length which is the number of arguments to copy to the |
447 // stack. It is guaranteed to be a small integer at this point. | 447 // stack. It is guaranteed to be a small integer at this point. |
448 return length; | 448 return length; |
449 } | 449 } |
450 | 450 |
451 | 451 |
452 function APPLY_OVERFLOW(length) { | 452 function APPLY_OVERFLOW(length) { |
453 throw %MakeRangeError('apply_overflow', [length]); | 453 throw %MakeRangeError('stack_overflow', []); |
454 } | 454 } |
455 | 455 |
456 | 456 |
457 // Convert the receiver to an object - forward to ToObject. | 457 // Convert the receiver to an object - forward to ToObject. |
458 function TO_OBJECT() { | 458 function TO_OBJECT() { |
459 return %ToObject(this); | 459 return %ToObject(this); |
460 } | 460 } |
461 | 461 |
462 | 462 |
463 // Convert the receiver to a number - forward to ToNumber. | 463 // Convert the receiver to a number - forward to ToNumber. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 throw %MakeTypeError('cannot_convert_to_primitive', []); | 624 throw %MakeTypeError('cannot_convert_to_primitive', []); |
625 } | 625 } |
626 | 626 |
627 | 627 |
628 // NOTE: Setting the prototype for Array must take place as early as | 628 // NOTE: Setting the prototype for Array must take place as early as |
629 // possible due to code generation for array literals. When | 629 // possible due to code generation for array literals. When |
630 // generating code for a array literal a boilerplate array is created | 630 // generating code for a array literal a boilerplate array is created |
631 // that is cloned when running the code. It is essiential that the | 631 // that is cloned when running the code. It is essiential that the |
632 // boilerplate gets the right prototype. | 632 // boilerplate gets the right prototype. |
633 %FunctionSetPrototype($Array, new $Array(0)); | 633 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |