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

Side by Side Diff: src/v8natives.js

Issue 8333019: Make bound functions have poisoned .caller and .arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 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/ic.cc ('k') | test/mjsunit/function-bind.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 return FunctionSourceString(this); 1513 return FunctionSourceString(this);
1514 } 1514 }
1515 1515
1516 1516
1517 // ES5 15.3.4.5 1517 // ES5 15.3.4.5
1518 function FunctionBind(this_arg) { // Length is 1. 1518 function FunctionBind(this_arg) { // Length is 1.
1519 if (!IS_SPEC_FUNCTION(this)) { 1519 if (!IS_SPEC_FUNCTION(this)) {
1520 throw new $TypeError('Bind must be called on a function'); 1520 throw new $TypeError('Bind must be called on a function');
1521 } 1521 }
1522 var boundFunction = function () { 1522 var boundFunction = function () {
1523 // Poison .arguments and .caller, but is otherwise not detectable.
1524 "use strict";
1523 // This function must not use any object literals (Object, Array, RegExp), 1525 // This function must not use any object literals (Object, Array, RegExp),
1524 // since the literals-array is being used to store the bound data. 1526 // since the literals-array is being used to store the bound data.
1525 if (%_IsConstructCall()) { 1527 if (%_IsConstructCall()) {
1526 return %NewObjectFromBound(boundFunction); 1528 return %NewObjectFromBound(boundFunction);
1527 } 1529 }
1528 var bindings = %BoundFunctionGetBindings(boundFunction); 1530 var bindings = %BoundFunctionGetBindings(boundFunction);
1529 1531
1530 var argc = %_ArgumentsLength(); 1532 var argc = %_ArgumentsLength();
1531 if (argc == 0) { 1533 if (argc == 0) {
1532 return %Apply(bindings[0], bindings[1], bindings, 2, bindings.length - 2); 1534 return %Apply(bindings[0], bindings[1], bindings, 2, bindings.length - 2);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1604
1603 function SetUpFunction() { 1605 function SetUpFunction() {
1604 %CheckIsBootstrapping(); 1606 %CheckIsBootstrapping();
1605 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1607 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1606 "bind", FunctionBind, 1608 "bind", FunctionBind,
1607 "toString", FunctionToString 1609 "toString", FunctionToString
1608 )); 1610 ));
1609 } 1611 }
1610 1612
1611 SetUpFunction(); 1613 SetUpFunction();
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | test/mjsunit/function-bind.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698