OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2117 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2117 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2118 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); | 2118 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); |
2119 i::Handle<i::Object> hash_symbol = i::Factory::identity_hash_symbol(); | 2119 i::Handle<i::Object> hash_symbol = i::Factory::identity_hash_symbol(); |
2120 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol); | 2120 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol); |
2121 int hash_value; | 2121 int hash_value; |
2122 if (hash->IsSmi()) { | 2122 if (hash->IsSmi()) { |
2123 hash_value = i::Smi::cast(*hash)->value(); | 2123 hash_value = i::Smi::cast(*hash)->value(); |
2124 } else { | 2124 } else { |
2125 int attempts = 0; | 2125 int attempts = 0; |
2126 do { | 2126 do { |
2127 hash_value = random() & i::Smi::kMaxValue; // Limit range to fit a smi. | 2127 // Generate a random 32-bit hash value but limit range to fit |
| 2128 // within a smi. |
| 2129 hash_value = i::V8::Random() & i::Smi::kMaxValue; |
2128 attempts++; | 2130 attempts++; |
2129 } while (hash_value == 0 && attempts < 30); | 2131 } while (hash_value == 0 && attempts < 30); |
2130 hash_value = hash_value != 0 ? hash_value : 1; // never return 0 | 2132 hash_value = hash_value != 0 ? hash_value : 1; // never return 0 |
2131 i::SetProperty(hidden_props, | 2133 i::SetProperty(hidden_props, |
2132 hash_symbol, | 2134 hash_symbol, |
2133 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), | 2135 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), |
2134 static_cast<PropertyAttributes>(None)); | 2136 static_cast<PropertyAttributes>(None)); |
2135 } | 2137 } |
2136 return hash_value; | 2138 return hash_value; |
2137 } | 2139 } |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3502 reinterpret_cast<HandleScopeImplementer*>(storage); | 3504 reinterpret_cast<HandleScopeImplementer*>(storage); |
3503 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3505 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
3504 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3506 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
3505 &thread_local->handle_scope_data_; | 3507 &thread_local->handle_scope_data_; |
3506 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3508 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
3507 | 3509 |
3508 return storage + ArchiveSpacePerThread(); | 3510 return storage + ArchiveSpacePerThread(); |
3509 } | 3511 } |
3510 | 3512 |
3511 } } // namespace v8::internal | 3513 } } // namespace v8::internal |
OLD | NEW |