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

Side by Side Diff: src/v8natives.js

Issue 141363005: A64: Synchronize with r15204. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/v8globals.h ('k') | src/version.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 // which are non-configurable. It therefore makes no sence to 1779 // which are non-configurable. It therefore makes no sence to
1780 // try to redefine these as defined by the spec. The spec says 1780 // try to redefine these as defined by the spec. The spec says
1781 // that bind should make these throw a TypeError if get or set 1781 // that bind should make these throw a TypeError if get or set
1782 // is called and make them non-enumerable and non-configurable. 1782 // is called and make them non-enumerable and non-configurable.
1783 // To be consistent with our normal functions we leave this as it is. 1783 // To be consistent with our normal functions we leave this as it is.
1784 // TODO(lrn): Do set these to be thrower. 1784 // TODO(lrn): Do set these to be thrower.
1785 return result; 1785 return result;
1786 } 1786 }
1787 1787
1788 1788
1789 function NewFunction(arg1) { // length == 1 1789 function NewFunctionString(arguments, function_token) {
1790 var n = %_ArgumentsLength(); 1790 var n = arguments.length;
1791 var p = ''; 1791 var p = '';
1792 if (n > 1) { 1792 if (n > 1) {
1793 p = new InternalArray(n - 1); 1793 p = ToString(arguments[0]);
1794 for (var i = 0; i < n - 1; i++) p[i] = %_Arguments(i); 1794 for (var i = 1; i < n - 1; i++) {
1795 p = Join(p, n - 1, ',', NonStringToString); 1795 p += ',' + ToString(arguments[i]);
1796 }
1796 // If the formal parameters string include ) - an illegal 1797 // If the formal parameters string include ) - an illegal
1797 // character - it may make the combined function expression 1798 // character - it may make the combined function expression
1798 // compile. We avoid this problem by checking for this early on. 1799 // compile. We avoid this problem by checking for this early on.
1799 if (%_CallFunction(p, ')', StringIndexOf) != -1) { 1800 if (%_CallFunction(p, ')', StringIndexOf) != -1) {
1800 throw MakeSyntaxError('paren_in_arg_string',[]); 1801 throw MakeSyntaxError('paren_in_arg_string', []);
1801 } 1802 }
1802 // If the formal parameters include an unbalanced block comment, the 1803 // If the formal parameters include an unbalanced block comment, the
1803 // function must be rejected. Since JavaScript does not allow nested 1804 // function must be rejected. Since JavaScript does not allow nested
1804 // comments we can include a trailing block comment to catch this. 1805 // comments we can include a trailing block comment to catch this.
1805 p += '\n/' + '**/'; 1806 p += '\n/' + '**/';
1806 } 1807 }
1807 var body = (n > 0) ? ToString(%_Arguments(n - 1)) : ''; 1808 var body = (n > 0) ? ToString(arguments[n - 1]) : '';
1808 var source = '(function(' + p + ') {\n' + body + '\n})'; 1809 return '(' + function_token + '(' + p + ') {\n' + body + '\n})';
1810 }
1809 1811
1812
1813 function FunctionConstructor(arg1) { // length == 1
1814 var source = NewFunctionString(arguments, 'function');
1810 var global_receiver = %GlobalReceiver(global); 1815 var global_receiver = %GlobalReceiver(global);
1816 // Compile the string in the constructor and not a helper so that errors
1817 // appear to come from here.
1811 var f = %_CallFunction(global_receiver, %CompileString(source, true)); 1818 var f = %_CallFunction(global_receiver, %CompileString(source, true));
1812
1813 %FunctionMarkNameShouldPrintAsAnonymous(f); 1819 %FunctionMarkNameShouldPrintAsAnonymous(f);
1814 return f; 1820 return f;
1815 } 1821 }
1816 1822
1817 1823
1818 // ---------------------------------------------------------------------------- 1824 // ----------------------------------------------------------------------------
1819 1825
1820 function SetUpFunction() { 1826 function SetUpFunction() {
1821 %CheckIsBootstrapping(); 1827 %CheckIsBootstrapping();
1822 1828
1823 %SetCode($Function, NewFunction); 1829 %SetCode($Function, FunctionConstructor);
1824 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM); 1830 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
1825 1831
1826 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1832 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1827 "bind", FunctionBind, 1833 "bind", FunctionBind,
1828 "toString", FunctionToString 1834 "toString", FunctionToString
1829 )); 1835 ));
1830 } 1836 }
1831 1837
1832 SetUpFunction(); 1838 SetUpFunction();
OLDNEW
« no previous file with comments | « src/v8globals.h ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698