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

Side by Side Diff: src/objects.cc

Issue 23548024: Introduce a RandonNumberGenerator class. Refactor the random/private_random uses in Isolate/Context. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/isolate-inl.h ('k') | src/platform.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 4701 matching lines...) Expand 10 before | Expand all | Expand 10 after
4712 4712
4713 4713
4714 Smi* JSReceiver::GenerateIdentityHash() { 4714 Smi* JSReceiver::GenerateIdentityHash() {
4715 Isolate* isolate = GetIsolate(); 4715 Isolate* isolate = GetIsolate();
4716 4716
4717 int hash_value; 4717 int hash_value;
4718 int attempts = 0; 4718 int attempts = 0;
4719 do { 4719 do {
4720 // Generate a random 32-bit hash value but limit range to fit 4720 // Generate a random 32-bit hash value but limit range to fit
4721 // within a smi. 4721 // within a smi.
4722 hash_value = V8::RandomPrivate(isolate) & Smi::kMaxValue; 4722 hash_value = isolate->random_number_generator()->NextInt() & Smi::kMaxValue;
4723 attempts++; 4723 attempts++;
4724 } while (hash_value == 0 && attempts < 30); 4724 } while (hash_value == 0 && attempts < 30);
4725 hash_value = hash_value != 0 ? hash_value : 1; // never return 0 4725 hash_value = hash_value != 0 ? hash_value : 1; // never return 0
4726 4726
4727 return Smi::FromInt(hash_value); 4727 return Smi::FromInt(hash_value);
4728 } 4728 }
4729 4729
4730 4730
4731 void JSObject::SetIdentityHash(Handle<JSObject> object, Smi* hash) { 4731 void JSObject::SetIdentityHash(Handle<JSObject> object, Smi* hash) {
4732 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), 4732 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
(...skipping 11320 matching lines...) Expand 10 before | Expand all | Expand 10 after
16053 #define ERROR_MESSAGES_TEXTS(C, T) T, 16053 #define ERROR_MESSAGES_TEXTS(C, T) T,
16054 static const char* error_messages_[] = { 16054 static const char* error_messages_[] = {
16055 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16055 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16056 }; 16056 };
16057 #undef ERROR_MESSAGES_TEXTS 16057 #undef ERROR_MESSAGES_TEXTS
16058 return error_messages_[reason]; 16058 return error_messages_[reason];
16059 } 16059 }
16060 16060
16061 16061
16062 } } // namespace v8::internal 16062 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate-inl.h ('k') | src/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698