< prev index next >

test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include <string.h>
  26 #include "utilities/globalDefinitions.hpp"
  27 #include <sstream>
  28 #include "gc/shared/memset_with_concurrent_readers.hpp"

  29 #include "unittest.hpp"
  30 
  31 #if INCLUDE_ALL_GCS

  32 
  33 static unsigned line_byte(const char* line, size_t i) {
  34   return unsigned(line[i]) & 0xFF;
  35 }
  36 
  37 TEST(gc, memset_with_concurrent_readers) {
  38   const size_t chunk_size = 8 * BytesPerWord;
  39   const unsigned chunk_count = 4;
  40   const size_t block_size = (chunk_count + 4) * chunk_size;
  41   char block[block_size];
  42   char clear_block[block_size];
  43   char set_block[block_size];
  44 
  45   // block format:
  46   // 0: unused leading chunk
  47   // 1: chunk written from start index to end of chunk
  48   // ... nchunks fully written chunks
  49   // N: chunk written from start of chunk to end index
  50   // N+1: unused trailing chunk
  51 


  79               err_stream << std::dec << chunk << "," << line << ": " << std::hex
  80                          << std::setw(2) << line_byte(lp, 0) << " "
  81                          << std::setw(2) << line_byte(lp, 1) << "  "
  82                          << std::setw(2) << line_byte(lp, 2) << " "
  83                          << std::setw(2) << line_byte(lp, 3) << "  "
  84                          << std::setw(2) << line_byte(lp, 4) << " "
  85                          << std::setw(2) << line_byte(lp, 5) << "  "
  86                          << std::setw(2) << line_byte(lp, 6) << " "
  87                          << std::setw(2) << line_byte(lp, 7) << std::endl;
  88             }
  89           }
  90           EXPECT_TRUE(head_clear) << "leading byte not clear";
  91           EXPECT_TRUE(middle_set) << "memset byte not set";
  92           EXPECT_TRUE(tail_clear) << "trailing bye not clear";
  93           ASSERT_TRUE(head_clear && middle_set && tail_clear) << err_stream.str();
  94         }
  95       }
  96     }
  97   }
  98 }
  99 #endif


   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"



  25 #include "gc/shared/memset_with_concurrent_readers.hpp"
  26 #include "utilities/globalDefinitions.hpp"
  27 #include "unittest.hpp"
  28 
  29 #include <string.h>
  30 #include <sstream>
  31 
  32 static unsigned line_byte(const char* line, size_t i) {
  33   return unsigned(line[i]) & 0xFF;
  34 }
  35 
  36 TEST(gc, memset_with_concurrent_readers) {
  37   const size_t chunk_size = 8 * BytesPerWord;
  38   const unsigned chunk_count = 4;
  39   const size_t block_size = (chunk_count + 4) * chunk_size;
  40   char block[block_size];
  41   char clear_block[block_size];
  42   char set_block[block_size];
  43 
  44   // block format:
  45   // 0: unused leading chunk
  46   // 1: chunk written from start index to end of chunk
  47   // ... nchunks fully written chunks
  48   // N: chunk written from start of chunk to end index
  49   // N+1: unused trailing chunk
  50 


  78               err_stream << std::dec << chunk << "," << line << ": " << std::hex
  79                          << std::setw(2) << line_byte(lp, 0) << " "
  80                          << std::setw(2) << line_byte(lp, 1) << "  "
  81                          << std::setw(2) << line_byte(lp, 2) << " "
  82                          << std::setw(2) << line_byte(lp, 3) << "  "
  83                          << std::setw(2) << line_byte(lp, 4) << " "
  84                          << std::setw(2) << line_byte(lp, 5) << "  "
  85                          << std::setw(2) << line_byte(lp, 6) << " "
  86                          << std::setw(2) << line_byte(lp, 7) << std::endl;
  87             }
  88           }
  89           EXPECT_TRUE(head_clear) << "leading byte not clear";
  90           EXPECT_TRUE(middle_set) << "memset byte not set";
  91           EXPECT_TRUE(tail_clear) << "trailing bye not clear";
  92           ASSERT_TRUE(head_clear && middle_set && tail_clear) << err_stream.str();
  93         }
  94       }
  95     }
  96   }
  97 }

< prev index next >