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

Side by Side Diff: src/collection.js

Issue 1154793003: Revert of Hook up more import/exports in natives. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/bootstrapper.cc ('k') | src/collection-iterator.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 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // -------------------------------------------------------------------
12 // Imports
13
14 var GlobalMap = global.Map; 11 var GlobalMap = global.Map;
15 var GlobalObject = global.Object; 12 var GlobalObject = global.Object;
16 var GlobalSet = global.Set; 13 var GlobalSet = global.Set;
17 14
18 var NumberIsNaN;
19
20 utils.Import(function(from) {
21 NumberIsNaN = from.NumberIsNaN;
22 });
23
24 // ------------------------------------------------------------------- 15 // -------------------------------------------------------------------
25 16
26 function HashToEntry(table, hash, numBuckets) { 17 function HashToEntry(table, hash, numBuckets) {
27 var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets); 18 var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets);
28 return ORDERED_HASH_TABLE_BUCKET_AT(table, bucket); 19 return ORDERED_HASH_TABLE_BUCKET_AT(table, bucket);
29 } 20 }
30 %SetForceInlineFlag(HashToEntry); 21 %SetForceInlineFlag(HashToEntry);
31 22
32 23
33 function SetFindEntry(table, numBuckets, key, hash) { 24 function SetFindEntry(table, numBuckets, key, hash) {
34 var keyIsNaN = NumberIsNaN(key); 25 var keyIsNaN = $numberIsNaN(key);
35 for (var entry = HashToEntry(table, hash, numBuckets); 26 for (var entry = HashToEntry(table, hash, numBuckets);
36 entry !== NOT_FOUND; 27 entry !== NOT_FOUND;
37 entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets)) { 28 entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets)) {
38 var candidate = ORDERED_HASH_SET_KEY_AT(table, entry, numBuckets); 29 var candidate = ORDERED_HASH_SET_KEY_AT(table, entry, numBuckets);
39 if (key === candidate) { 30 if (key === candidate) {
40 return entry; 31 return entry;
41 } 32 }
42 if (keyIsNaN && NumberIsNaN(candidate)) { 33 if (keyIsNaN && $numberIsNaN(candidate)) {
43 return entry; 34 return entry;
44 } 35 }
45 } 36 }
46 return NOT_FOUND; 37 return NOT_FOUND;
47 } 38 }
48 %SetForceInlineFlag(SetFindEntry); 39 %SetForceInlineFlag(SetFindEntry);
49 40
50 41
51 function MapFindEntry(table, numBuckets, key, hash) { 42 function MapFindEntry(table, numBuckets, key, hash) {
52 var keyIsNaN = NumberIsNaN(key); 43 var keyIsNaN = $numberIsNaN(key);
53 for (var entry = HashToEntry(table, hash, numBuckets); 44 for (var entry = HashToEntry(table, hash, numBuckets);
54 entry !== NOT_FOUND; 45 entry !== NOT_FOUND;
55 entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets)) { 46 entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets)) {
56 var candidate = ORDERED_HASH_MAP_KEY_AT(table, entry, numBuckets); 47 var candidate = ORDERED_HASH_MAP_KEY_AT(table, entry, numBuckets);
57 if (key === candidate) { 48 if (key === candidate) {
58 return entry; 49 return entry;
59 } 50 }
60 if (keyIsNaN && NumberIsNaN(candidate)) { 51 if (keyIsNaN && $numberIsNaN(candidate)) {
61 return entry; 52 return entry;
62 } 53 }
63 } 54 }
64 return NOT_FOUND; 55 return NOT_FOUND;
65 } 56 }
66 %SetForceInlineFlag(MapFindEntry); 57 %SetForceInlineFlag(MapFindEntry);
67 58
68 59
69 function ComputeIntegerHash(key, seed) { 60 function ComputeIntegerHash(key, seed) {
70 var hash = key; 61 var hash = key;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 %SetCode(GlobalSet, SetConstructor); 232 %SetCode(GlobalSet, SetConstructor);
242 %FunctionSetLength(GlobalSet, 0); 233 %FunctionSetLength(GlobalSet, 0);
243 %FunctionSetPrototype(GlobalSet, new GlobalObject()); 234 %FunctionSetPrototype(GlobalSet, new GlobalObject());
244 %AddNamedProperty(GlobalSet.prototype, "constructor", GlobalSet, DONT_ENUM); 235 %AddNamedProperty(GlobalSet.prototype, "constructor", GlobalSet, DONT_ENUM);
245 %AddNamedProperty(GlobalSet.prototype, symbolToStringTag, "Set", 236 %AddNamedProperty(GlobalSet.prototype, symbolToStringTag, "Set",
246 DONT_ENUM | READ_ONLY); 237 DONT_ENUM | READ_ONLY);
247 238
248 %FunctionSetLength(SetForEach, 1); 239 %FunctionSetLength(SetForEach, 1);
249 240
250 // Set up the non-enumerable functions on the Set prototype object. 241 // Set up the non-enumerable functions on the Set prototype object.
251 utils.InstallGetter(GlobalSet.prototype, "size", SetGetSize); 242 $installGetter(GlobalSet.prototype, "size", SetGetSize);
252 utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [ 243 $installFunctions(GlobalSet.prototype, DONT_ENUM, [
253 "add", SetAdd, 244 "add", SetAdd,
254 "has", SetHas, 245 "has", SetHas,
255 "delete", SetDelete, 246 "delete", SetDelete,
256 "clear", SetClearJS, 247 "clear", SetClearJS,
257 "forEach", SetForEach 248 "forEach", SetForEach
258 ]); 249 ]);
259 250
260 251
261 // ------------------------------------------------------------------- 252 // -------------------------------------------------------------------
262 // Harmony Map 253 // Harmony Map
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 %SetCode(GlobalMap, MapConstructor); 420 %SetCode(GlobalMap, MapConstructor);
430 %FunctionSetLength(GlobalMap, 0); 421 %FunctionSetLength(GlobalMap, 0);
431 %FunctionSetPrototype(GlobalMap, new GlobalObject()); 422 %FunctionSetPrototype(GlobalMap, new GlobalObject());
432 %AddNamedProperty(GlobalMap.prototype, "constructor", GlobalMap, DONT_ENUM); 423 %AddNamedProperty(GlobalMap.prototype, "constructor", GlobalMap, DONT_ENUM);
433 %AddNamedProperty( 424 %AddNamedProperty(
434 GlobalMap.prototype, symbolToStringTag, "Map", DONT_ENUM | READ_ONLY); 425 GlobalMap.prototype, symbolToStringTag, "Map", DONT_ENUM | READ_ONLY);
435 426
436 %FunctionSetLength(MapForEach, 1); 427 %FunctionSetLength(MapForEach, 1);
437 428
438 // Set up the non-enumerable functions on the Map prototype object. 429 // Set up the non-enumerable functions on the Map prototype object.
439 utils.InstallGetter(GlobalMap.prototype, "size", MapGetSize); 430 $installGetter(GlobalMap.prototype, "size", MapGetSize);
440 utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [ 431 $installFunctions(GlobalMap.prototype, DONT_ENUM, [
441 "get", MapGet, 432 "get", MapGet,
442 "set", MapSet, 433 "set", MapSet,
443 "has", MapHas, 434 "has", MapHas,
444 "delete", MapDelete, 435 "delete", MapDelete,
445 "clear", MapClearJS, 436 "clear", MapClearJS,
446 "forEach", MapForEach 437 "forEach", MapForEach
447 ]); 438 ]);
448 439
449 }) 440 })
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/collection-iterator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698