< prev index next >

src/hotspot/share/runtime/os.cpp

Print this page
rev 55555 : [mq]: nestegg


 778 #ifdef ASSERT
 779   if (memblock == NULL) return;
 780   if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) {
 781     log_warning(malloc, free)("os::free caught " PTR_FORMAT, p2i(memblock));
 782     breakpoint();
 783   }
 784   void* membase = MemTracker::record_free(memblock);
 785   verify_memory(membase);
 786 
 787   GuardedMemory guarded(membase);
 788   size_t size = guarded.get_user_size();
 789   inc_stat_counter(&free_bytes, size);
 790   membase = guarded.release_for_freeing();
 791   ::free(membase);
 792 #else
 793   void* membase = MemTracker::record_free(memblock);
 794   ::free(membase);
 795 #endif
 796 }
 797 











 798 void os::init_random(unsigned int initval) {
 799   _rand_seed = initval;
 800 }
 801 
 802 
 803 static int random_helper(unsigned int rand_seed) {
 804   /* standard, well-known linear congruential random generator with
 805    * next_rand = (16807*seed) mod (2**31-1)
 806    * see
 807    * (1) "Random Number Generators: Good Ones Are Hard to Find",
 808    *      S.K. Park and K.W. Miller, Communications of the ACM 31:10 (Oct 1988),
 809    * (2) "Two Fast Implementations of the 'Minimal Standard' Random
 810    *     Number Generator", David G. Carta, Comm. ACM 33, 1 (Jan 1990), pp. 87-88.
 811   */
 812   const unsigned int a = 16807;
 813   const unsigned int m = 2147483647;
 814   const int q = m / a;        assert(q == 127773, "weird math");
 815   const int r = m % a;        assert(r == 2836, "weird math");
 816 
 817   // compute az=2^31p+q




 778 #ifdef ASSERT
 779   if (memblock == NULL) return;
 780   if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) {
 781     log_warning(malloc, free)("os::free caught " PTR_FORMAT, p2i(memblock));
 782     breakpoint();
 783   }
 784   void* membase = MemTracker::record_free(memblock);
 785   verify_memory(membase);
 786 
 787   GuardedMemory guarded(membase);
 788   size_t size = guarded.get_user_size();
 789   inc_stat_counter(&free_bytes, size);
 790   membase = guarded.release_for_freeing();
 791   ::free(membase);
 792 #else
 793   void* membase = MemTracker::record_free(memblock);
 794   ::free(membase);
 795 #endif
 796 }
 797 
 798 static void* p_nestegg = NULL;
 799 bool os::init_nestegg(size_t size) {
 800   p_nestegg = os::malloc(size, mtInternal);
 801   return p_nestegg != NULL;
 802 }
 803 
 804 void os::release_nestegg() {
 805   os::free(p_nestegg);
 806   p_nestegg = NULL;
 807 }
 808 
 809 void os::init_random(unsigned int initval) {
 810   _rand_seed = initval;
 811 }
 812 
 813 
 814 static int random_helper(unsigned int rand_seed) {
 815   /* standard, well-known linear congruential random generator with
 816    * next_rand = (16807*seed) mod (2**31-1)
 817    * see
 818    * (1) "Random Number Generators: Good Ones Are Hard to Find",
 819    *      S.K. Park and K.W. Miller, Communications of the ACM 31:10 (Oct 1988),
 820    * (2) "Two Fast Implementations of the 'Minimal Standard' Random
 821    *     Number Generator", David G. Carta, Comm. ACM 33, 1 (Jan 1990), pp. 87-88.
 822   */
 823   const unsigned int a = 16807;
 824   const unsigned int m = 2147483647;
 825   const int q = m / a;        assert(q == 127773, "weird math");
 826   const int r = m % a;        assert(r == 2836, "weird math");
 827 
 828   // compute az=2^31p+q


< prev index next >