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

Side by Side Diff: src/collection.js

Issue 1067933002: Use NumberIsNaN in collections.js and make it inlined (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 | src/v8natives.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 "use strict"; 5 "use strict";
6 6
7 // This file relies on the fact that the following declaration has been made 7 // This file relies on the fact that the following declaration has been made
8 // in runtime.js: 8 // in runtime.js:
9 // var $Array = global.Array; 9 // var $Array = global.Array;
10 10
11 var $Set = global.Set; 11 var $Set = global.Set;
12 var $Map = global.Map; 12 var $Map = global.Map;
13 13
14 14
15 (function() { 15 (function() {
16 16
17 %CheckIsBootstrapping(); 17 %CheckIsBootstrapping();
18 18
19 19
20 function HashToEntry(table, hash, numBuckets) { 20 function HashToEntry(table, hash, numBuckets) {
21 var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets); 21 var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets);
22 return ORDERED_HASH_TABLE_BUCKET_AT(table, bucket); 22 return ORDERED_HASH_TABLE_BUCKET_AT(table, bucket);
23 } 23 }
24 %SetInlineBuiltinFlag(HashToEntry); 24 %SetInlineBuiltinFlag(HashToEntry);
25 25
26 26
27 function SetFindEntry(table, numBuckets, key, hash) { 27 function SetFindEntry(table, numBuckets, key, hash) {
28 var keyIsNaN = IS_NUMBER(key) && NUMBER_IS_NAN(key); 28 var keyIsNaN = NumberIsNaN(key);
29 for (var entry = HashToEntry(table, hash, numBuckets); 29 for (var entry = HashToEntry(table, hash, numBuckets);
30 entry !== NOT_FOUND; 30 entry !== NOT_FOUND;
31 entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets)) { 31 entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets)) {
32 var candidate = ORDERED_HASH_SET_KEY_AT(table, entry, numBuckets); 32 var candidate = ORDERED_HASH_SET_KEY_AT(table, entry, numBuckets);
33 if (key === candidate) { 33 if (key === candidate) {
34 return entry; 34 return entry;
35 } 35 }
36 if (keyIsNaN && IS_NUMBER(candidate) && NUMBER_IS_NAN(candidate)) { 36 if (keyIsNaN && NumberIsNaN(candidate)) {
37 return entry; 37 return entry;
38 } 38 }
39 } 39 }
40 return NOT_FOUND; 40 return NOT_FOUND;
41 } 41 }
42 %SetInlineBuiltinFlag(SetFindEntry); 42 %SetInlineBuiltinFlag(SetFindEntry);
43 43
44 44
45 function MapFindEntry(table, numBuckets, key, hash) { 45 function MapFindEntry(table, numBuckets, key, hash) {
46 var keyIsNaN = IS_NUMBER(key) && NUMBER_IS_NAN(key); 46 var keyIsNaN = NumberIsNaN(key);
47 for (var entry = HashToEntry(table, hash, numBuckets); 47 for (var entry = HashToEntry(table, hash, numBuckets);
48 entry !== NOT_FOUND; 48 entry !== NOT_FOUND;
49 entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets)) { 49 entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets)) {
50 var candidate = ORDERED_HASH_MAP_KEY_AT(table, entry, numBuckets); 50 var candidate = ORDERED_HASH_MAP_KEY_AT(table, entry, numBuckets);
51 if (key === candidate) { 51 if (key === candidate) {
52 return entry; 52 return entry;
53 } 53 }
54 if (keyIsNaN && IS_NUMBER(candidate) && NUMBER_IS_NAN(candidate)) { 54 if (keyIsNaN && NumberIsNaN(candidate)) {
55 return entry; 55 return entry;
56 } 56 }
57 } 57 }
58 return NOT_FOUND; 58 return NOT_FOUND;
59 } 59 }
60 %SetInlineBuiltinFlag(MapFindEntry); 60 %SetInlineBuiltinFlag(MapFindEntry);
61 61
62 62
63 function ComputeIntegerHash(key, seed) { 63 function ComputeIntegerHash(key, seed) {
64 var hash = key; 64 var hash = key;
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 InstallFunctions($Map.prototype, DONT_ENUM, $Array( 436 InstallFunctions($Map.prototype, DONT_ENUM, $Array(
437 "get", MapGet, 437 "get", MapGet,
438 "set", MapSet, 438 "set", MapSet,
439 "has", MapHas, 439 "has", MapHas,
440 "delete", MapDelete, 440 "delete", MapDelete,
441 "clear", MapClearJS, 441 "clear", MapClearJS,
442 "forEach", MapForEach 442 "forEach", MapForEach
443 )); 443 ));
444 444
445 })(); 445 })();
OLDNEW
« no previous file with comments | « no previous file | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698