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

Side by Side Diff: src/collection.js

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