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 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2065 ON_BAILOUT("v8::Object::GetIdentityHash()", return 0); | 2065 ON_BAILOUT("v8::Object::GetIdentityHash()", return 0); |
2066 ENTER_V8; | 2066 ENTER_V8; |
2067 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2067 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
2068 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); | 2068 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); |
2069 i::Handle<i::Object> hash_symbol = i::Factory::identity_hash_symbol(); | 2069 i::Handle<i::Object> hash_symbol = i::Factory::identity_hash_symbol(); |
2070 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol); | 2070 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol); |
2071 int hash_value; | 2071 int hash_value; |
2072 if (hash->IsSmi()) { | 2072 if (hash->IsSmi()) { |
2073 hash_value = i::Smi::cast(*hash)->value(); | 2073 hash_value = i::Smi::cast(*hash)->value(); |
2074 } else { | 2074 } else { |
2075 hash_value = random() & i::Smi::kMaxValue; // Limit range to fit a smi. | 2075 int attempts = 0; |
2076 do { | |
2077 hash_value = random() & i::Smi::kMaxValue; // Limit range to fit a smi. | |
Dean McNamee
2009/04/29 09:14:52
Just to be annoying, we probably shouldn't be usin
| |
2078 attempts++; | |
2079 } while (hash_value == 0 && attempts < 30); | |
2080 hash_value = hash_value != 0 ? hash_value : 1; // never return 0 | |
2076 i::SetProperty(hidden_props, | 2081 i::SetProperty(hidden_props, |
2077 hash_symbol, | 2082 hash_symbol, |
2078 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), | 2083 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), |
2079 static_cast<PropertyAttributes>(None)); | 2084 static_cast<PropertyAttributes>(None)); |
2080 } | 2085 } |
2081 return hash_value; | 2086 return hash_value; |
2082 } | 2087 } |
2083 | 2088 |
2084 | 2089 |
2085 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, | 2090 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3387 reinterpret_cast<HandleScopeImplementer*>(storage); | 3392 reinterpret_cast<HandleScopeImplementer*>(storage); |
3388 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); | 3393 List<void**>* blocks_of_archived_thread = thread_local->Blocks(); |
3389 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = | 3394 v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread = |
3390 &thread_local->handle_scope_data_; | 3395 &thread_local->handle_scope_data_; |
3391 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); | 3396 Iterate(v, blocks_of_archived_thread, handle_data_of_archived_thread); |
3392 | 3397 |
3393 return storage + ArchiveSpacePerThread(); | 3398 return storage + ArchiveSpacePerThread(); |
3394 } | 3399 } |
3395 | 3400 |
3396 } } // namespace v8::internal | 3401 } } // namespace v8::internal |
OLD | NEW |