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

Side by Side Diff: src/harmony-array.js

Issue 1116003005: Remove GetDefaultReceiver, pass in undefined to sloppy-mode functions instead. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make sure it does TO_OBJECT Created 5 years, 7 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 | « src/collection.js ('k') | src/harmony-typedarray.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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() { 5 (function() {
6 6
7 'use strict'; 7 'use strict';
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 if (!IS_SPEC_FUNCTION(predicate)) { 76 if (!IS_SPEC_FUNCTION(predicate)) {
77 throw MakeTypeError(kCalledNonCallable, predicate); 77 throw MakeTypeError(kCalledNonCallable, predicate);
78 } 78 }
79 79
80 var thisArg; 80 var thisArg;
81 if (%_ArgumentsLength() > 1) { 81 if (%_ArgumentsLength() > 1) {
82 thisArg = %_Arguments(1); 82 thisArg = %_Arguments(1);
83 } 83 }
84 84
85 var needs_wrapper = false; 85 var needs_wrapper = false;
86 if (IS_NULL_OR_UNDEFINED(thisArg)) { 86 if (IS_NULL(thisArg)) {
87 thisArg = %GetDefaultReceiver(predicate) || thisArg; 87 if (%IsSloppyModeFunction(predicate)) thisArg = UNDEFINED;
88 } else { 88 } else if (!IS_UNDEFINED(thisArg)) {
89 needs_wrapper = SHOULD_CREATE_WRAPPER(predicate, thisArg); 89 needs_wrapper = SHOULD_CREATE_WRAPPER(predicate, thisArg);
90 } 90 }
91 91
92 for (var i = 0; i < length; i++) { 92 for (var i = 0; i < length; i++) {
93 if (i in array) { 93 if (i in array) {
94 var element = array[i]; 94 var element = array[i];
95 var newThisArg = needs_wrapper ? ToObject(thisArg) : thisArg; 95 var newThisArg = needs_wrapper ? ToObject(thisArg) : thisArg;
96 if (%_CallFunction(newThisArg, element, i, array, predicate)) { 96 if (%_CallFunction(newThisArg, element, i, array, predicate)) {
97 return element; 97 return element;
98 } 98 }
(...skipping 14 matching lines...) Expand all
113 if (!IS_SPEC_FUNCTION(predicate)) { 113 if (!IS_SPEC_FUNCTION(predicate)) {
114 throw MakeTypeError(kCalledNonCallable, predicate); 114 throw MakeTypeError(kCalledNonCallable, predicate);
115 } 115 }
116 116
117 var thisArg; 117 var thisArg;
118 if (%_ArgumentsLength() > 1) { 118 if (%_ArgumentsLength() > 1) {
119 thisArg = %_Arguments(1); 119 thisArg = %_Arguments(1);
120 } 120 }
121 121
122 var needs_wrapper = false; 122 var needs_wrapper = false;
123 if (IS_NULL_OR_UNDEFINED(thisArg)) { 123 if (IS_NULL(thisArg)) {
124 thisArg = %GetDefaultReceiver(predicate) || thisArg; 124 if (%IsSloppyModeFunction(predicate)) thisArg = UNDEFINED;
125 } else { 125 } else if (!IS_UNDEFINED(thisArg)) {
126 needs_wrapper = SHOULD_CREATE_WRAPPER(predicate, thisArg); 126 needs_wrapper = SHOULD_CREATE_WRAPPER(predicate, thisArg);
127 } 127 }
128 128
129 for (var i = 0; i < length; i++) { 129 for (var i = 0; i < length; i++) {
130 if (i in array) { 130 if (i in array) {
131 var element = array[i]; 131 var element = array[i];
132 var newThisArg = needs_wrapper ? ToObject(thisArg) : thisArg; 132 var newThisArg = needs_wrapper ? ToObject(thisArg) : thisArg;
133 if (%_CallFunction(newThisArg, element, i, array, predicate)) { 133 if (%_CallFunction(newThisArg, element, i, array, predicate)) {
134 return i; 134 return i;
135 } 135 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 183 }
184 184
185 // ES6, draft 10-14-14, section 22.1.2.1 185 // ES6, draft 10-14-14, section 22.1.2.1
186 function ArrayFrom(arrayLike, mapfn, receiver) { 186 function ArrayFrom(arrayLike, mapfn, receiver) {
187 var items = ToObject(arrayLike); 187 var items = ToObject(arrayLike);
188 var mapping = !IS_UNDEFINED(mapfn); 188 var mapping = !IS_UNDEFINED(mapfn);
189 189
190 if (mapping) { 190 if (mapping) {
191 if (!IS_SPEC_FUNCTION(mapfn)) { 191 if (!IS_SPEC_FUNCTION(mapfn)) {
192 throw MakeTypeError(kCalledNonCallable, mapfn); 192 throw MakeTypeError(kCalledNonCallable, mapfn);
193 } else if (IS_NULL_OR_UNDEFINED(receiver)) { 193 } else if (%IsSloppyModeFunction(mapfn)) {
194 receiver = %GetDefaultReceiver(mapfn) || receiver; 194 if (IS_NULL(receiver)) {
195 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(mapfn)) { 195 receiver = UNDEFINED;
196 receiver = ToObject(receiver); 196 } else if (!IS_UNDEFINED(receiver)) {
197 receiver = TO_OBJECT_INLINE(receiver);
198 }
197 } 199 }
198 } 200 }
199 201
200 var iterable = GetMethod(items, symbolIterator); 202 var iterable = GetMethod(items, symbolIterator);
201 var k; 203 var k;
202 var result; 204 var result;
203 var mappedValue; 205 var mappedValue;
204 var nextValue; 206 var nextValue;
205 207
206 if (!IS_UNDEFINED(iterable)) { 208 if (!IS_UNDEFINED(iterable)) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 281
280 // Set up the non-enumerable functions on the Array prototype object. 282 // Set up the non-enumerable functions on the Array prototype object.
281 InstallFunctions(GlobalArray.prototype, DONT_ENUM, [ 283 InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
282 "copyWithin", ArrayCopyWithin, 284 "copyWithin", ArrayCopyWithin,
283 "find", ArrayFind, 285 "find", ArrayFind,
284 "findIndex", ArrayFindIndex, 286 "findIndex", ArrayFindIndex,
285 "fill", ArrayFill 287 "fill", ArrayFill
286 ]); 288 ]);
287 289
288 })(); 290 })();
OLDNEW
« no previous file with comments | « src/collection.js ('k') | src/harmony-typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698