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

Side by Side Diff: src/string.js

Issue 1226143009: Fix limit calculation in String.prototype.split (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed test expectations Created 5 years, 5 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
« no previous file with comments | « no previous file | test/test262-es6/test262-es6.status » ('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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 // Imports 10 // Imports
11 11
12 var GlobalRegExp = global.RegExp; 12 var GlobalRegExp = global.RegExp;
13 var GlobalNumber = global.Number;
13 var GlobalString = global.String; 14 var GlobalString = global.String;
14 var InternalArray = utils.InternalArray; 15 var InternalArray = utils.InternalArray;
15 var InternalPackedArray = utils.InternalPackedArray; 16 var InternalPackedArray = utils.InternalPackedArray;
16 17
17 var ArrayIndexOf; 18 var ArrayIndexOf;
18 var ArrayJoin; 19 var ArrayJoin;
19 var MathMax; 20 var MathMax;
20 var MathMin; 21 var MathMin;
21 var RegExpExec; 22 var RegExpExec;
22 var RegExpExecNoTests; 23 var RegExpExecNoTests;
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 602
602 return %_SubString(s, start_i, end_i); 603 return %_SubString(s, start_i, end_i);
603 } 604 }
604 605
605 606
606 // ECMA-262 section 15.5.4.14 607 // ECMA-262 section 15.5.4.14
607 function StringSplitJS(separator, limit) { 608 function StringSplitJS(separator, limit) {
608 CHECK_OBJECT_COERCIBLE(this, "String.prototype.split"); 609 CHECK_OBJECT_COERCIBLE(this, "String.prototype.split");
609 610
610 var subject = TO_STRING_INLINE(this); 611 var subject = TO_STRING_INLINE(this);
611 limit = (IS_UNDEFINED(limit)) ? 0xffffffff : TO_UINT32(limit); 612 limit = IS_UNDEFINED(limit) ? GlobalNumber.MAX_SAFE_INTEGER
Dan Ehrenberg 2015/07/13 23:19:13 Defined this way, a user could modify Number.MAX_S
adamk 2015/07/14 00:16:48 MAX_SAFE_INTEGER is non-configurable, non-writable
613 : $toLength(limit);
612 614
613 var length = subject.length; 615 var length = subject.length;
614 if (!IS_REGEXP(separator)) { 616 if (!IS_REGEXP(separator)) {
615 var separator_string = TO_STRING_INLINE(separator); 617 var separator_string = TO_STRING_INLINE(separator);
616 618
617 if (limit === 0) return []; 619 if (limit === 0) return [];
618 620
619 // ECMA-262 says that if separator is undefined, the result should 621 // ECMA-262 says that if separator is undefined, the result should
620 // be an array of size 1 containing the entire string. 622 // be an array of size 1 containing the entire string.
621 if (IS_UNDEFINED(separator)) return [subject]; 623 if (IS_UNDEFINED(separator)) return [subject];
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 to.StringIndexOf = StringIndexOfJS; 1200 to.StringIndexOf = StringIndexOfJS;
1199 to.StringLastIndexOf = StringLastIndexOfJS; 1201 to.StringLastIndexOf = StringLastIndexOfJS;
1200 to.StringMatch = StringMatchJS; 1202 to.StringMatch = StringMatchJS;
1201 to.StringReplace = StringReplace; 1203 to.StringReplace = StringReplace;
1202 to.StringSplit = StringSplitJS; 1204 to.StringSplit = StringSplitJS;
1203 to.StringSubstr = StringSubstr; 1205 to.StringSubstr = StringSubstr;
1204 to.StringSubstring = StringSubstring; 1206 to.StringSubstring = StringSubstring;
1205 }); 1207 });
1206 1208
1207 }) 1209 })
OLDNEW
« no previous file with comments | « no previous file | test/test262-es6/test262-es6.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698