| OLD | NEW |
| 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; | 17 var MathRandom; |
| 18 var MapIterator; | 18 var MapIterator; |
| 19 var NumberIsNaN; | |
| 20 var SetIterator; | 19 var SetIterator; |
| 21 var speciesSymbol = utils.ImportNow("species_symbol"); | 20 var speciesSymbol = utils.ImportNow("species_symbol"); |
| 22 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 21 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
| 23 | 22 |
| 24 utils.Import(function(from) { | 23 utils.Import(function(from) { |
| 25 MathRandom = from.MathRandom; | 24 MathRandom = from.MathRandom; |
| 26 MapIterator = from.MapIterator; | 25 MapIterator = from.MapIterator; |
| 27 NumberIsNaN = from.NumberIsNaN; | |
| 28 SetIterator = from.SetIterator; | 26 SetIterator = from.SetIterator; |
| 29 }); | 27 }); |
| 30 | 28 |
| 31 // ------------------------------------------------------------------- | 29 // ------------------------------------------------------------------- |
| 32 | 30 |
| 33 function HashToEntry(table, hash, numBuckets) { | 31 function HashToEntry(table, hash, numBuckets) { |
| 34 var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets); | 32 var bucket = ORDERED_HASH_TABLE_HASH_TO_BUCKET(hash, numBuckets); |
| 35 return ORDERED_HASH_TABLE_BUCKET_AT(table, bucket); | 33 return ORDERED_HASH_TABLE_BUCKET_AT(table, bucket); |
| 36 } | 34 } |
| 37 %SetForceInlineFlag(HashToEntry); | 35 %SetForceInlineFlag(HashToEntry); |
| 38 | 36 |
| 39 | 37 |
| 40 function SetFindEntry(table, numBuckets, key, hash) { | 38 function SetFindEntry(table, numBuckets, key, hash) { |
| 41 var entry = HashToEntry(table, hash, numBuckets); | 39 var entry = HashToEntry(table, hash, numBuckets); |
| 42 if (entry === NOT_FOUND) return entry; | 40 if (entry === NOT_FOUND) return entry; |
| 43 var candidate = ORDERED_HASH_SET_KEY_AT(table, entry, numBuckets); | 41 var candidate = ORDERED_HASH_SET_KEY_AT(table, entry, numBuckets); |
| 44 if (key === candidate) return entry; | 42 if (key === candidate) return entry; |
| 45 var keyIsNaN = NumberIsNaN(key); | 43 var keyIsNaN = NUMBER_IS_NAN(key); |
| 46 while (true) { | 44 while (true) { |
| 47 if (keyIsNaN && NumberIsNaN(candidate)) { | 45 if (keyIsNaN && NUMBER_IS_NAN(candidate)) { |
| 48 return entry; | 46 return entry; |
| 49 } | 47 } |
| 50 entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets); | 48 entry = ORDERED_HASH_SET_CHAIN_AT(table, entry, numBuckets); |
| 51 if (entry === NOT_FOUND) return entry; | 49 if (entry === NOT_FOUND) return entry; |
| 52 candidate = ORDERED_HASH_SET_KEY_AT(table, entry, numBuckets); | 50 candidate = ORDERED_HASH_SET_KEY_AT(table, entry, numBuckets); |
| 53 if (key === candidate) return entry; | 51 if (key === candidate) return entry; |
| 54 } | 52 } |
| 55 return NOT_FOUND; | 53 return NOT_FOUND; |
| 56 } | 54 } |
| 57 %SetForceInlineFlag(SetFindEntry); | 55 %SetForceInlineFlag(SetFindEntry); |
| 58 | 56 |
| 59 | 57 |
| 60 function MapFindEntry(table, numBuckets, key, hash) { | 58 function MapFindEntry(table, numBuckets, key, hash) { |
| 61 var entry = HashToEntry(table, hash, numBuckets); | 59 var entry = HashToEntry(table, hash, numBuckets); |
| 62 if (entry === NOT_FOUND) return entry; | 60 if (entry === NOT_FOUND) return entry; |
| 63 var candidate = ORDERED_HASH_MAP_KEY_AT(table, entry, numBuckets); | 61 var candidate = ORDERED_HASH_MAP_KEY_AT(table, entry, numBuckets); |
| 64 if (key === candidate) return entry; | 62 if (key === candidate) return entry; |
| 65 var keyIsNaN = NumberIsNaN(key); | 63 var keyIsNaN = NUMBER_IS_NAN(key); |
| 66 while (true) { | 64 while (true) { |
| 67 if (keyIsNaN && NumberIsNaN(candidate)) { | 65 if (keyIsNaN && NUMBER_IS_NAN(candidate)) { |
| 68 return entry; | 66 return entry; |
| 69 } | 67 } |
| 70 entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets); | 68 entry = ORDERED_HASH_MAP_CHAIN_AT(table, entry, numBuckets); |
| 71 if (entry === NOT_FOUND) return entry; | 69 if (entry === NOT_FOUND) return entry; |
| 72 candidate = ORDERED_HASH_MAP_KEY_AT(table, entry, numBuckets); | 70 candidate = ORDERED_HASH_MAP_KEY_AT(table, entry, numBuckets); |
| 73 if (key === candidate) return entry; | 71 if (key === candidate) return entry; |
| 74 } | 72 } |
| 75 return NOT_FOUND; | 73 return NOT_FOUND; |
| 76 } | 74 } |
| 77 %SetForceInlineFlag(MapFindEntry); | 75 %SetForceInlineFlag(MapFindEntry); |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 "set_has", SetHas, | 481 "set_has", SetHas, |
| 484 "set_delete", SetDelete, | 482 "set_delete", SetDelete, |
| 485 ]); | 483 ]); |
| 486 | 484 |
| 487 utils.Export(function(to) { | 485 utils.Export(function(to) { |
| 488 to.GetExistingHash = GetExistingHash; | 486 to.GetExistingHash = GetExistingHash; |
| 489 to.GetHash = GetHash; | 487 to.GetHash = GetHash; |
| 490 }); | 488 }); |
| 491 | 489 |
| 492 }) | 490 }) |
| OLD | NEW |