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

Unified Diff: src/api.cc

Issue 100147: Make Object::GetIdentityHash() never return 0.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
===================================================================
--- src/api.cc (revision 1810)
+++ src/api.cc (working copy)
@@ -2072,7 +2072,12 @@
if (hash->IsSmi()) {
hash_value = i::Smi::cast(*hash)->value();
} else {
- hash_value = random() & i::Smi::kMaxValue; // Limit range to fit a smi.
+ int attempts = 0;
+ do {
+ 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
+ attempts++;
+ } while (hash_value == 0 && attempts < 30);
+ hash_value = hash_value != 0 ? hash_value : 1; // never return 0
i::SetProperty(hidden_props,
hash_symbol,
i::Handle<i::Object>(i::Smi::FromInt(hash_value)),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698