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

Side by Side Diff: src/js/collection.js

Issue 2614623003: Move all Symbol.species setup for builtin constructors to bootstrapper (Closed)
Patch Set: Rebased Created 3 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
« no previous file with comments | « src/js/arraybuffer.js ('k') | src/js/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 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 "use strict"; 6 "use strict";
7 7
8 %CheckIsBootstrapping(); 8 %CheckIsBootstrapping();
9 9
10 // ------------------------------------------------------------------- 10 // -------------------------------------------------------------------
11 // Imports 11 // Imports
12 12
13 var GlobalMap = global.Map; 13 var GlobalMap = global.Map;
14 var GlobalObject = global.Object; 14 var GlobalObject = global.Object;
15 var GlobalSet = global.Set; 15 var GlobalSet = global.Set;
16 var hashCodeSymbol = utils.ImportNow("hash_code_symbol"); 16 var hashCodeSymbol = utils.ImportNow("hash_code_symbol");
17 var MathRandom = global.Math.random; 17 var MathRandom = global.Math.random;
18 var MapIterator; 18 var MapIterator;
19 var SetIterator; 19 var SetIterator;
20 var speciesSymbol = utils.ImportNow("species_symbol");
21 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); 20 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
22 21
23 utils.Import(function(from) { 22 utils.Import(function(from) {
24 MapIterator = from.MapIterator; 23 MapIterator = from.MapIterator;
25 SetIterator = from.SetIterator; 24 SetIterator = from.SetIterator;
26 }); 25 });
27 26
28 // ------------------------------------------------------------------- 27 // -------------------------------------------------------------------
29 28
30 function HashToEntry(table, hash, numBuckets) { 29 function HashToEntry(table, hash, numBuckets) {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 243
245 var iterator = new SetIterator(this, ITERATOR_KIND_VALUES); 244 var iterator = new SetIterator(this, ITERATOR_KIND_VALUES);
246 var key; 245 var key;
247 var value_array = [UNDEFINED]; 246 var value_array = [UNDEFINED];
248 while (%SetIteratorNext(iterator, value_array)) { 247 while (%SetIteratorNext(iterator, value_array)) {
249 key = value_array[0]; 248 key = value_array[0];
250 %_Call(f, receiver, key, key, this); 249 %_Call(f, receiver, key, key, this);
251 } 250 }
252 } 251 }
253 252
254
255 function SetSpecies() {
256 return this;
257 }
258
259
260 // ------------------------------------------------------------------- 253 // -------------------------------------------------------------------
261 254
262 %SetCode(GlobalSet, SetConstructor); 255 %SetCode(GlobalSet, SetConstructor);
263 %FunctionSetLength(GlobalSet, 0); 256 %FunctionSetLength(GlobalSet, 0);
264 %FunctionSetPrototype(GlobalSet, new GlobalObject()); 257 %FunctionSetPrototype(GlobalSet, new GlobalObject());
265 %AddNamedProperty(GlobalSet.prototype, "constructor", GlobalSet, DONT_ENUM); 258 %AddNamedProperty(GlobalSet.prototype, "constructor", GlobalSet, DONT_ENUM);
266 %AddNamedProperty(GlobalSet.prototype, toStringTagSymbol, "Set", 259 %AddNamedProperty(GlobalSet.prototype, toStringTagSymbol, "Set",
267 DONT_ENUM | READ_ONLY); 260 DONT_ENUM | READ_ONLY);
268 261
269 %FunctionSetLength(SetForEach, 1); 262 %FunctionSetLength(SetForEach, 1);
270 263
271 utils.InstallGetter(GlobalSet, speciesSymbol, SetSpecies);
272
273 // Set up the non-enumerable functions on the Set prototype object. 264 // Set up the non-enumerable functions on the Set prototype object.
274 utils.InstallGetter(GlobalSet.prototype, "size", SetGetSize); 265 utils.InstallGetter(GlobalSet.prototype, "size", SetGetSize);
275 utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [ 266 utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
276 "add", SetAdd, 267 "add", SetAdd,
277 "has", SetHas, 268 "has", SetHas,
278 "delete", SetDelete, 269 "delete", SetDelete,
279 "clear", SetClearJS, 270 "clear", SetClearJS,
280 "forEach", SetForEach 271 "forEach", SetForEach
281 ]); 272 ]);
282 273
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 423
433 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f); 424 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
434 425
435 var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES); 426 var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES);
436 var value_array = [UNDEFINED, UNDEFINED]; 427 var value_array = [UNDEFINED, UNDEFINED];
437 while (%MapIteratorNext(iterator, value_array)) { 428 while (%MapIteratorNext(iterator, value_array)) {
438 %_Call(f, receiver, value_array[1], value_array[0], this); 429 %_Call(f, receiver, value_array[1], value_array[0], this);
439 } 430 }
440 } 431 }
441 432
442
443 function MapSpecies() {
444 return this;
445 }
446
447 // ------------------------------------------------------------------- 433 // -------------------------------------------------------------------
448 434
449 %SetCode(GlobalMap, MapConstructor); 435 %SetCode(GlobalMap, MapConstructor);
450 %FunctionSetLength(GlobalMap, 0); 436 %FunctionSetLength(GlobalMap, 0);
451 %FunctionSetPrototype(GlobalMap, new GlobalObject()); 437 %FunctionSetPrototype(GlobalMap, new GlobalObject());
452 %AddNamedProperty(GlobalMap.prototype, "constructor", GlobalMap, DONT_ENUM); 438 %AddNamedProperty(GlobalMap.prototype, "constructor", GlobalMap, DONT_ENUM);
453 %AddNamedProperty( 439 %AddNamedProperty(
454 GlobalMap.prototype, toStringTagSymbol, "Map", DONT_ENUM | READ_ONLY); 440 GlobalMap.prototype, toStringTagSymbol, "Map", DONT_ENUM | READ_ONLY);
455 441
456 %FunctionSetLength(MapForEach, 1); 442 %FunctionSetLength(MapForEach, 1);
457 443
458 utils.InstallGetter(GlobalMap, speciesSymbol, MapSpecies);
459
460 // Set up the non-enumerable functions on the Map prototype object. 444 // Set up the non-enumerable functions on the Map prototype object.
461 utils.InstallGetter(GlobalMap.prototype, "size", MapGetSize); 445 utils.InstallGetter(GlobalMap.prototype, "size", MapGetSize);
462 utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [ 446 utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
463 "get", MapGet, 447 "get", MapGet,
464 "set", MapSet, 448 "set", MapSet,
465 "has", MapHas, 449 "has", MapHas,
466 "delete", MapDelete, 450 "delete", MapDelete,
467 "clear", MapClearJS, 451 "clear", MapClearJS,
468 "forEach", MapForEach 452 "forEach", MapForEach
469 ]); 453 ]);
(...skipping 10 matching lines...) Expand all
480 "set_has", SetHas, 464 "set_has", SetHas,
481 "set_delete", SetDelete, 465 "set_delete", SetDelete,
482 ]); 466 ]);
483 467
484 utils.Export(function(to) { 468 utils.Export(function(to) {
485 to.GetExistingHash = GetExistingHash; 469 to.GetExistingHash = GetExistingHash;
486 to.GetHash = GetHash; 470 to.GetHash = GetHash;
487 }); 471 });
488 472
489 }) 473 })
OLDNEW
« no previous file with comments | « src/js/arraybuffer.js ('k') | src/js/typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698