| 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 var $getHash; | 5 var $getHash; |
| 6 var $getExistingHash; | 6 var $getExistingHash; |
| 7 | 7 |
| 8 (function(global, utils) { | 8 (function(global, utils) { |
| 9 "use strict"; | 9 "use strict"; |
| 10 | 10 |
| 11 %CheckIsBootstrapping(); | 11 %CheckIsBootstrapping(); |
| 12 | 12 |
| 13 // ------------------------------------------------------------------- | 13 // ------------------------------------------------------------------- |
| 14 // Imports | 14 // Imports |
| 15 | 15 |
| 16 var GlobalMap = global.Map; | 16 var GlobalMap = global.Map; |
| 17 var GlobalObject = global.Object; | 17 var GlobalObject = global.Object; |
| 18 var GlobalSet = global.Set; | 18 var GlobalSet = global.Set; |
| 19 var IntRandom; | |
| 20 | |
| 21 utils.Import(function(from) { | |
| 22 IntRandom = from.IntRandom; | |
| 23 }); | |
| 24 | 19 |
| 25 var NumberIsNaN; | 20 var NumberIsNaN; |
| 26 | 21 |
| 27 utils.Import(function(from) { | 22 utils.Import(function(from) { |
| 28 NumberIsNaN = from.NumberIsNaN; | 23 NumberIsNaN = from.NumberIsNaN; |
| 29 }); | 24 }); |
| 30 | 25 |
| 31 // ------------------------------------------------------------------- | 26 // ------------------------------------------------------------------- |
| 32 | 27 |
| 33 function HashToEntry(table, hash, numBuckets) { | 28 function HashToEntry(table, hash, numBuckets) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 98 } |
| 104 } else if (IS_SPEC_OBJECT(key) && !%_IsJSProxy(key) && !IS_GLOBAL(key)) { | 99 } else if (IS_SPEC_OBJECT(key) && !%_IsJSProxy(key) && !IS_GLOBAL(key)) { |
| 105 var hash = GET_PRIVATE(key, hashCodeSymbol); | 100 var hash = GET_PRIVATE(key, hashCodeSymbol); |
| 106 return hash; | 101 return hash; |
| 107 } | 102 } |
| 108 return %GenericHash(key); | 103 return %GenericHash(key); |
| 109 } | 104 } |
| 110 %SetForceInlineFlag(GetExistingHash); | 105 %SetForceInlineFlag(GetExistingHash); |
| 111 | 106 |
| 112 | 107 |
| 108 var hashCounter = 1; |
| 109 |
| 110 |
| 113 function GetHash(key) { | 111 function GetHash(key) { |
| 114 var hash = GetExistingHash(key); | 112 var hash = GetExistingHash(key); |
| 115 if (IS_UNDEFINED(hash)) { | 113 if (IS_UNDEFINED(hash)) { |
| 116 hash = IntRandom() | 0; | 114 hash = hashCounter; |
| 117 if (hash === 0) hash = 1; | 115 // Avoid a hash of zero, reserved for the hidden string. Also avoid |
| 116 // non-Smi hashes. |
| 117 hashCounter = hash == 0x3fffffff ? 1 : hash + 1; |
| 118 SET_PRIVATE(key, hashCodeSymbol, hash); | 118 SET_PRIVATE(key, hashCodeSymbol, hash); |
| 119 } | 119 } |
| 120 return hash; | 120 return hash; |
| 121 } | 121 } |
| 122 %SetForceInlineFlag(GetHash); | 122 %SetForceInlineFlag(GetHash); |
| 123 | 123 |
| 124 | 124 |
| 125 // ------------------------------------------------------------------- | 125 // ------------------------------------------------------------------- |
| 126 // Harmony Set | 126 // Harmony Set |
| 127 | 127 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 "delete", MapDelete, | 474 "delete", MapDelete, |
| 475 "clear", MapClearJS, | 475 "clear", MapClearJS, |
| 476 "forEach", MapForEach | 476 "forEach", MapForEach |
| 477 ]); | 477 ]); |
| 478 | 478 |
| 479 // Expose to the global scope. | 479 // Expose to the global scope. |
| 480 $getHash = GetHash; | 480 $getHash = GetHash; |
| 481 $getExistingHash = GetExistingHash; | 481 $getExistingHash = GetExistingHash; |
| 482 | 482 |
| 483 }) | 483 }) |
| OLD | NEW |