< prev index next >

src/share/vm/utilities/globalDefinitions.cpp

Print this page




 339 size_t lcm(size_t a, size_t b) {
 340     size_t cur, div, next;
 341 
 342     cur = MAX2(a, b);
 343     div = MIN2(a, b);
 344 
 345     assert(div != 0, "lcm requires positive arguments");
 346 
 347 
 348     while ((next = cur % div) != 0) {
 349         cur = div; div = next;
 350     }
 351 
 352 
 353     julong result = julong(a) * b / div;
 354     assert(result <= (size_t)max_uintx, "Integer overflow in lcm");
 355 
 356     return size_t(result);
 357 }
 358 






 359 #ifndef PRODUCT
 360 
 361 void GlobalDefinitions::test_globals() {
 362   intptr_t page_sizes[] = { os::vm_page_size(), 4096, 8192, 65536, 2*1024*1024 };
 363   const int num_page_sizes = sizeof(page_sizes) / sizeof(page_sizes[0]);
 364 
 365   for (int i = 0; i < num_page_sizes; i++) {
 366     intptr_t page_size = page_sizes[i];
 367 
 368     address a_page = (address)(10*page_size);
 369 
 370     // Check that address within page is returned as is
 371     assert(clamp_address_in_page(a_page, a_page, page_size) == a_page, "incorrect");
 372     assert(clamp_address_in_page(a_page + 128, a_page, page_size) == a_page + 128, "incorrect");
 373     assert(clamp_address_in_page(a_page + page_size - 1, a_page, page_size) == a_page + page_size - 1, "incorrect");
 374 
 375     // Check that address above page returns start of next page
 376     assert(clamp_address_in_page(a_page + page_size, a_page, page_size) == a_page + page_size, "incorrect");
 377     assert(clamp_address_in_page(a_page + page_size + 1, a_page, page_size) == a_page + page_size, "incorrect");
 378     assert(clamp_address_in_page(a_page + page_size*5 + 1, a_page, page_size) == a_page + page_size, "incorrect");


 339 size_t lcm(size_t a, size_t b) {
 340     size_t cur, div, next;
 341 
 342     cur = MAX2(a, b);
 343     div = MIN2(a, b);
 344 
 345     assert(div != 0, "lcm requires positive arguments");
 346 
 347 
 348     while ((next = cur % div) != 0) {
 349         cur = div; div = next;
 350     }
 351 
 352 
 353     julong result = julong(a) * b / div;
 354     assert(result <= (size_t)max_uintx, "Integer overflow in lcm");
 355 
 356     return size_t(result);
 357 }
 358 
 359 void noreturn_function() {
 360   while (true) {
 361     os::naked_short_sleep(10);
 362   }
 363 }
 364 
 365 #ifndef PRODUCT
 366 
 367 void GlobalDefinitions::test_globals() {
 368   intptr_t page_sizes[] = { os::vm_page_size(), 4096, 8192, 65536, 2*1024*1024 };
 369   const int num_page_sizes = sizeof(page_sizes) / sizeof(page_sizes[0]);
 370 
 371   for (int i = 0; i < num_page_sizes; i++) {
 372     intptr_t page_size = page_sizes[i];
 373 
 374     address a_page = (address)(10*page_size);
 375 
 376     // Check that address within page is returned as is
 377     assert(clamp_address_in_page(a_page, a_page, page_size) == a_page, "incorrect");
 378     assert(clamp_address_in_page(a_page + 128, a_page, page_size) == a_page + 128, "incorrect");
 379     assert(clamp_address_in_page(a_page + page_size - 1, a_page, page_size) == a_page + page_size - 1, "incorrect");
 380 
 381     // Check that address above page returns start of next page
 382     assert(clamp_address_in_page(a_page + page_size, a_page, page_size) == a_page + page_size, "incorrect");
 383     assert(clamp_address_in_page(a_page + page_size + 1, a_page, page_size) == a_page + page_size, "incorrect");
 384     assert(clamp_address_in_page(a_page + page_size*5 + 1, a_page, page_size) == a_page + page_size, "incorrect");
< prev index next >