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

Side by Side Diff: src/v8natives.js

Issue 335653002: Have one, long-lived map for bound functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 6 years, 6 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/runtime.cc ('k') | test/mjsunit/runtime-gen/functionbindarguments.js » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file relies on the fact that the following declarations have been made 5 // This file relies on the fact that the following declarations have been made
6 // in runtime.js: 6 // in runtime.js:
7 // var $Object = global.Object; 7 // var $Object = global.Object;
8 // var $Boolean = global.Boolean; 8 // var $Boolean = global.Boolean;
9 // var $Number = global.Number; 9 // var $Number = global.Number;
10 // var $Function = global.Function; 10 // var $Function = global.Function;
(...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 var argv = new InternalArray(bound_argc + argc); 1774 var argv = new InternalArray(bound_argc + argc);
1775 for (var i = 0; i < bound_argc; i++) { 1775 for (var i = 0; i < bound_argc; i++) {
1776 argv[i] = bindings[i + 2]; 1776 argv[i] = bindings[i + 2];
1777 } 1777 }
1778 for (var j = 0; j < argc; j++) { 1778 for (var j = 0; j < argc; j++) {
1779 argv[i++] = %_Arguments(j); 1779 argv[i++] = %_Arguments(j);
1780 } 1780 }
1781 return %Apply(bindings[0], bindings[1], argv, 0, bound_argc + argc); 1781 return %Apply(bindings[0], bindings[1], argv, 0, bound_argc + argc);
1782 }; 1782 };
1783 1783
1784 %FunctionRemovePrototype(boundFunction);
1785 var new_length = 0; 1784 var new_length = 0;
1786 if (%_ClassOf(this) == "Function") { 1785 var old_length = this.length;
1787 // Function or FunctionProxy. 1786 // FunctionProxies might provide a non-UInt32 value. If so, ignore it.
1788 var old_length = this.length; 1787 if ((typeof old_length === "number") &&
1789 // FunctionProxies might provide a non-UInt32 value. If so, ignore it. 1788 ((old_length >>> 0) === old_length)) {
1790 if ((typeof old_length === "number") && 1789 var argc = %_ArgumentsLength();
1791 ((old_length >>> 0) === old_length)) { 1790 if (argc > 0) argc--; // Don't count the thisArg as parameter.
1792 var argc = %_ArgumentsLength(); 1791 new_length = old_length - argc;
1793 if (argc > 0) argc--; // Don't count the thisArg as parameter. 1792 if (new_length < 0) new_length = 0;
1794 new_length = old_length - argc;
1795 if (new_length < 0) new_length = 0;
1796 }
1797 } 1793 }
1798 // This runtime function finds any remaining arguments on the stack, 1794 // This runtime function finds any remaining arguments on the stack,
1799 // so we don't pass the arguments object. 1795 // so we don't pass the arguments object.
1800 var result = %FunctionBindArguments(boundFunction, this, 1796 var result = %FunctionBindArguments(boundFunction, this,
1801 this_arg, new_length); 1797 this_arg, new_length);
1802 1798
1803 // We already have caller and arguments properties on functions, 1799 // We already have caller and arguments properties on functions,
1804 // which are non-configurable. It therefore makes no sence to 1800 // which are non-configurable. It therefore makes no sence to
1805 // try to redefine these as defined by the spec. The spec says 1801 // try to redefine these as defined by the spec. The spec says
1806 // that bind should make these throw a TypeError if get or set 1802 // that bind should make these throw a TypeError if get or set
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 %SetCode($Function, FunctionConstructor); 1852 %SetCode($Function, FunctionConstructor);
1857 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM); 1853 %SetProperty($Function.prototype, "constructor", $Function, DONT_ENUM);
1858 1854
1859 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1855 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1860 "bind", FunctionBind, 1856 "bind", FunctionBind,
1861 "toString", FunctionToString 1857 "toString", FunctionToString
1862 )); 1858 ));
1863 } 1859 }
1864 1860
1865 SetUpFunction(); 1861 SetUpFunction();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/runtime-gen/functionbindarguments.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698